Module: Hashblue::API

Extended by:
Request
Includes:
HTTParty
Defined in:
lib/hashblue/api.rb,
lib/hashblue/api/error.rb

Overview

It’s the Hashblue API gem

Connecting

Hashblue API requires ActiveSupport; if this isn’t already loaded, you’ll need to ensure that it is available - either by requiring rubygems, or ensuring it is in the LOAD_PATH already.

To connect to the Hashblue API, you need to set the base URL, and provide your credentials (you can find these in your hashblue.com account). For example:

require 'active_support/all' # unless you have already loaded it
require 'hashblue/api'

Hashblue::API.base_uri "https://api.hashblue.apigee.com"
Hashblue::API.basic_auth "[email protected]", "yourapikey"

Using the API

Everything is loaded via your subscriber:

subscriber = Hashblue::API::Subscriber.find("yourapikey")

Once you have this, you can load all messages, all contacts, or all messages for a specific contact:

all_messages = subscriber.messages
all_contacts = subscriber.contacts
messages_between_me_and_a_contact = all_contacts.first.messages

Interacting with messages

It’s simple to delete a message:

all_messages.first.delete

This message is now deleted. You can see a list of all deleted messages via the subscriber:

subscriber.deleted_messages

Defined Under Namespace

Modules: Request, TestHelper Classes: AccessDeniedError, BadRequestError, BadResponseError, Contact, Error, Message, Model, NotFoundError, NotRespondingError, RateLimitError, ServiceUnavailableError, Subscriber

Class Method Summary collapse

Methods included from Request

_request, _with_timeout, delete, get, post

Class Method Details

.timeout(value) ⇒ Object

Sets the timeout used before raising an error.



67
68
69
# File 'lib/hashblue/api.rb', line 67

def self.timeout(value)
  default_options[:timeout] = value
end