Class: CreateSend::Administrator

Inherits:
Object
  • Object
show all
Defined in:
lib/createsend/administrator.rb

Overview

Represents an administrator and associated functionality.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email_address) ⇒ Administrator

Returns a new instance of Administrator.



9
10
11
# File 'lib/createsend/administrator.rb', line 9

def initialize(email_address)
  @email_address = email_address
end

Instance Attribute Details

#email_addressObject (readonly)

Returns the value of attribute email_address.



7
8
9
# File 'lib/createsend/administrator.rb', line 7

def email_address
  @email_address
end

Class Method Details

.add(email_address, name) ⇒ Object

Adds an adminstrator to the account



21
22
23
24
25
26
27
28
# File 'lib/createsend/administrator.rb', line 21

def self.add(email_address, name)
  options = { :body => {
    :EmailAddress => email_address,
    :Name => name
  }.to_json }
  response = CreateSend.post "/admins.json", options
  Hashie::Mash.new(response)
end

.get(email_address) ⇒ Object

Gets an adminsitrator by email address.



14
15
16
17
18
# File 'lib/createsend/administrator.rb', line 14

def self.get(email_address)
  options = { :query => { :email => email_address } }
  response = CreateSend.get "/admins.json", options
  Hashie::Mash.new(response)
end

Instance Method Details

#deleteObject

deletes this administrator from the account



44
45
46
47
# File 'lib/createsend/administrator.rb', line 44

def delete
  options = { :query => { :email => @email_address } }
  CreateSend.delete '/admins.json', options
end

#update(new_email_address, name) ⇒ Object

Updates the administator details



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/createsend/administrator.rb', line 31

def update(new_email_address, name)
  options = {
    :query => { :email => @email_address },
    :body => {
      :EmailAddress => new_email_address,
      :Name => name
    }.to_json }
  CreateSend.put '/admins.json', options
  # Update @email_address, so this object can continue to be used reliably
  @email_address = new_email_address
end