Class: CreateSend::Person
- Inherits:
-
CreateSend
- Object
- CreateSend
- CreateSend::Person
- Defined in:
- lib/createsend/person.rb
Overview
Represents a person and associated functionality.
Constant Summary
Constants included from CreateSend
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(auth, client_id, email_address, name, access_level, password) ⇒ Object
Adds a person to the client.
-
.get(auth, 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(auth, 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(auth, client_id, email_address) ⇒ Person
Returns a new instance of Person.
7 8 9 10 11 |
# File 'lib/createsend/person.rb', line 7 def initialize(auth, client_id, email_address) @client_id = client_id @email_address = email_address super end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
4 5 6 |
# File 'lib/createsend/person.rb', line 4 def client_id @client_id end |
#email_address ⇒ Object (readonly)
Returns the value of attribute email_address.
5 6 7 |
# File 'lib/createsend/person.rb', line 5 def email_address @email_address end |
Class Method Details
.add(auth, 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
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/createsend/person.rb', line 23 def self.add(auth, client_id, email_address, name, access_level, password) = { :body => { :EmailAddress => email_address, :Name => name, :AccessLevel => access_level, :Password => password }.to_json } cs = CreateSend.new auth response = cs.post "/clients/#{client_id}/people.json", Hashie::Mash.new(response) end |
.get(auth, client_id, email_address) ⇒ Object
Gets a person by client ID and email address.
14 15 16 17 18 19 |
# File 'lib/createsend/person.rb', line 14 def self.get(auth, client_id, email_address) = { :query => { :email => email_address } } cs = CreateSend.new auth response = cs.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 } } super 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 } 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 |