Class: CreateSend::Person
- Inherits:
-
Object
- Object
- CreateSend::Person
- Defined in:
- lib/createsend/person.rb
Overview
Represents a person and associated functionality.
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#email_address ⇒ Object
readonly
Returns the value of attribute email_address.
Class Method Summary collapse
-
.add(client_id, email_address, name, access_level, password) ⇒ Object
Adds a person to the client.
-
.get(client_id, email_address) ⇒ Object
Gets a person by client ID and email address.
Instance Method Summary collapse
-
#delete ⇒ Object
deletes this person from the client.
-
#initialize(client_id, email_address) ⇒ Person
constructor
A new instance of Person.
-
#update(new_email_address, name, access_level, password) ⇒ Object
Updates the person details.
- #uri_for(client_id) ⇒ Object
Constructor Details
#initialize(client_id, email_address) ⇒ Person
Returns a new instance of Person.
10 11 12 13 |
# File 'lib/createsend/person.rb', line 10 def initialize(client_id, email_address) @client_id = client_id @email_address = email_address end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
7 8 9 |
# File 'lib/createsend/person.rb', line 7 def client_id @client_id end |
#email_address ⇒ Object (readonly)
Returns the value of attribute email_address.
8 9 10 |
# File 'lib/createsend/person.rb', line 8 def email_address @email_address end |
Class Method Details
.add(client_id, email_address, name, access_level, password) ⇒ Object
Adds a person to the client. password is optional. if ommitted, an email invitation will be sent to the person
24 25 26 27 28 29 30 31 32 |
# File 'lib/createsend/person.rb', line 24 def self.add(client_id, email_address, name, access_level, password) = { :body => { :EmailAddress => email_address, :Name => name, :AccessLevel => access_level, :Password => password }.to_json } response = CreateSend.post "/clients/#{client_id}/people.json", Hashie::Mash.new(response) end |
.get(client_id, email_address) ⇒ Object
Gets a person by client ID and email address.
16 17 18 19 20 |
# File 'lib/createsend/person.rb', line 16 def self.get(client_id, email_address) = { :query => { :email => email_address } } response = CreateSend.get "/clients/#{client_id}/people.json", Hashie::Mash.new(response) end |
Instance Method Details
#delete ⇒ Object
deletes this person from the client
50 51 52 53 |
# File 'lib/createsend/person.rb', line 50 def delete = { :query => { :email => @email_address } } CreateSend.delete uri_for(client_id), end |
#update(new_email_address, name, access_level, password) ⇒ Object
Updates the person details. password is optional and will only be updated if supplied
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/createsend/person.rb', line 36 def update(new_email_address, name, access_level, password) = { :query => { :email => @email_address }, :body => { :EmailAddress => new_email_address, :Name => name, :AccessLevel => access_level, :Password => password }.to_json } CreateSend.put uri_for(client_id), # Update @email_address, so this object can continue to be used reliably @email_address = new_email_address end |
#uri_for(client_id) ⇒ Object
55 56 57 |
# File 'lib/createsend/person.rb', line 55 def uri_for(client_id) "/clients/#{client_id}/people.json" end |