Class: CreateSend::Administrator

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

Overview

Represents an administrator and associated functionality.

Instance Attribute Summary collapse

Attributes inherited from CreateSend

#auth_details

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CreateSend

#add_auth_details_to_options, #administrators, #auth, authorize_url, #billing_details, #clients, #countries, exchange_token, #external_session_url, #get, #get_primary_contact, #handle_response, #post, #put, refresh_access_token, #refresh_token, #set_primary_contact, #systemdate, #timezones, user_agent

Constructor Details

#initialize(auth, email_address) ⇒ Administrator

Returns a new instance of Administrator.



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

def initialize(auth, email_address)
  @email_address = email_address
  super
end

Instance Attribute Details

#email_addressObject (readonly)

Returns the value of attribute email_address.



4
5
6
# File 'lib/createsend/administrator.rb', line 4

def email_address
  @email_address
end

Class Method Details

.add(auth, email_address, name) ⇒ Object

Adds an administrator to the account.



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

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

.get(auth, email_address) ⇒ Object

Gets an administrator by email address.



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

def self.get(auth, email_address)
  options = { :query => { :email => email_address } }
  cs = CreateSend.new auth
  response = cs.cs_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 } }
  super '/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 }
  put '/admins.json', options
  # Update @email_address, so this object can continue to be used reliably
  @email_address = new_email_address
end