GithubHelp home page GithubHelp logo

deliverhq's Introduction

DeliverHQ

Rubygem wrapper for deliverHQ API.

Build Status Coverage Status Code Climate

Installing

gem install deliverhq

or

(in Gemfile or .gemspec)

gem 'deliverhq'

then

require 'deliverhq'

Usage

Authentication

Set your API ID and key using the two environment variables, DELIVERHQ_ID and DELIVERHQ_KEY. This can be found in the "Setup" section of your DeliverHQ account.

Sending E-Mail

Deliverhq::send(from: '[email protected]', to: '[email protected]', subject: 'Hello!', plain_body: 'This is a test.')
#=> #<Deliverhq::Message:0x007fc79...

Domains

# Retrieve all domains associated with your account
Deliverhq::Domain.all
#=> [#<Deliverhq::Domain:0x007fc79c1..]

# Create a new domain
domain = Deliverhq::Domain.create(name: 'test.com')
#=> #<Deliverhq::Domain:0x007fc79c134a78 @id=7970, @account_id=506, @name="test.com", @verification_token="punqv7acjm", @verified_at=nil>

# And remove it
domain.destroy
#=> true

Mailboxes

# Retrieve all mailboxes associated with your account
Deliverhq::Mailbox.all
#=> [#<Deliverhq::Mailbox:0x007fc79c2...

# Create a new mailbox
mailbox = Deliverhq::Mailbox.create(name: 'Incoming Support',
        check_spam: 0,
        destination_address: 'http://app.sirportly.com/modules/deliver2/accept',
        destination_type: 'http',
        domain_id: 6707,
        encoding:'post',
        format: 'full',
        reply_stripping: false,
        partial_address: 'support')

# And remove it
mailbox.destroy
#=> true

Messages

# Retrieve messages by page
page = 1
Deliverhq::Message.all(page)
#=> [#<Deliverhq::Message:0x007f88e29...
page = 2
Deliverhq::Message.all(page)
#=> [#<Deliverhq::Message:0x008ef62a9...
page = 999
Deliverhq::Message.all(page)
#=> []

# Show individual message
Deliverhq::Message.find(226945)
#=> #<Deliverhq::Message:0x007f88e2998a28 @id=222697445, @envelope_to ...

Handling Errors

If the API reports an error, the gem will raise the message as an exception of type Deliverhq::RequestError. e.g.

domain = Deliverhq::Domain.create(name: 'test.com')
#=> #<Deliverhq::Domain:0x007fc79c134a78 @id=7970, @account_id=506, @name="test.com", @verification_token="punqv7acjm", @verified_at=nil>

domain.destroy
#=> true

# Try to remove it after it's been removed
domain.destroy
#=> Deliverhq::RequestError: Server responded with 404: {"error":"Not Found"}

Further Reading

You can learn more about the DeliverHQ API here: http://deliver.apidoc.io/.

deliverhq's People

Contributors

seanhandley avatar

Stargazers

Eugenia Grieff avatar

Watchers

 avatar Rob Greenwood avatar Joel Merrick avatar James Cloos avatar Matt Illingworth avatar Dominic Lindsay avatar  avatar Bartosz Miklaszewski avatar Katherine Jenkins avatar Frazer Watson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.