Module: Contactology

Defined in:
lib/contactology.rb,
lib/contactology/list.rb,
lib/contactology/issue.rb,
lib/contactology/stash.rb,
lib/contactology/errors.rb,
lib/contactology/issues.rb,
lib/contactology/parser.rb,
lib/contactology/contact.rb,
lib/contactology/version.rb,
lib/contactology/campaign.rb,
lib/contactology/list_proxy.rb,
lib/contactology/send_result.rb,
lib/contactology/basic_object.rb,
lib/contactology/campaign/preview.rb,
lib/contactology/transactional_message.rb

Overview

This library provides an interface to the Contactology v2, “REST-based” email marketing API.

Example usage:

require 'contactology'

Contactology.configuration do |config|
  config.key = 'aBcDeFg12345'
end

list = Contactology::List.find(4)
# => #<Contactology::List:0x000... @list_id="4" @name="test list" ...>

list.subscribe('[email protected]')
# => true

contact = Contactology::Contact.find('[email protected]')
# => #<Contactology::Contact:0x000... @email="[email protected]" ...>

contact.lists
# => [#<Contactology::List:0x000... @list_id="4" ...>]

Defined Under Namespace

Modules: API, Campaigns Classes: BasicObject, Campaign, Configuration, Contact, Issue, Issues, List, ListProxy, Parser, SendResult, Stash, TransactionalMessage

Constant Summary collapse

Error =
Class.new(StandardError)
InvalidObjectError =
Class.new(Error)
VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.configuration {|@@_configuration| ... } ⇒ Object

Public: Primary accessor for reading or manipulating the default configuration.

Examples

Contactology.configuration do |config|
  config.key = 'newkey'
end

Contactology.configuration
# => #<Contactology::Configuration:0x000...>

Returns the default Contactology::Configuration instance.

Yields:

  • (@@_configuration)


55
56
57
58
59
# File 'lib/contactology.rb', line 55

def self.configuration
  @@_configuration ||= Contactology::Configuration.new
  yield @@_configuration if block_given?
  @@_configuration
end

.configuration=(configuration) ⇒ Object

Public: Explicitly sets the default configuration by replacing it with the instance given.

configuration - A Contactology::Configuration instance.

Examples

Contactology.configuration = Contactology::Configuration.new
# => #<Contactology::Configuration:0x000...>

Returns nothing. Raises ArgumentError unless given a Contactology::Configuration instance.

Raises:

  • (ArgumentError)


75
76
77
78
# File 'lib/contactology.rb', line 75

def self.configuration=(configuration)
  raise ArgumentError, 'Expected a Contactology::Configuration instance' unless configuration.kind_of?(Configuration)
  @@_configuration = configuration
end

.configure(&block) ⇒ Object

Public: Alias to Contactology.configuration.

Returns the default Contactology::Configuration instance.



85
86
87
# File 'lib/contactology.rb', line 85

def self.configure(&block)
  configuration(&block)
end

.endpointObject

Public: Shorthand reader of the default configuration’s endpoint.

Returns the String endpoint from the default configuration.



94
95
96
# File 'lib/contactology.rb', line 94

def self.endpoint
  configuration.endpoint
end

.endpoint=(endpoint) ⇒ Object

Public: Shorthand writer to the default configuration’s endpoint.

endpoint = The String to use for the API endpoint.

Returns nothing.



105
106
107
# File 'lib/contactology.rb', line 105

def self.endpoint=(endpoint)
  configuration.endpoint = endpoint
end

.keyObject

Public: Shorthand reader of the default configuration’s key.

Returns the String key from the default configuration.



114
115
116
# File 'lib/contactology.rb', line 114

def self.key
  configuration.key
end

.key=(key) ⇒ Object

Public: Shortand writer to the default configuration’s key.

key - The String to use for the API key.

Returns nothing.



125
126
127
# File 'lib/contactology.rb', line 125

def self.key=(key)
  configuration.key = key
end