class CreateSend::Person
Represents a person and associated functionality.
Attributes
client_id[R]
email_address[R]
Public Class Methods
add(auth, client_id, email_address, name, access_level, password)
click to toggle source
Adds a person to the client. Password is optional. If ommitted, an email invitation will be sent to the person
# File lib/createsend/person.rb, line 23 def self.add(auth, client_id, email_address, name, access_level, password) options = { :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", options Hashie::Mash.new(response) end
get(auth, client_id, email_address)
click to toggle source
Gets a person by client ID and email address.
# File lib/createsend/person.rb, line 14 def self.get(auth, client_id, email_address) options = { :query => { :email => email_address } } cs = CreateSend.new auth response = cs.get "/clients/#{client_id}/people.json", options Hashie::Mash.new(response) end
new(auth, client_id, email_address)
click to toggle source
Calls superclass method
# File lib/createsend/person.rb, line 7 def initialize(auth, client_id, email_address) @client_id = client_id @email_address = email_address super end
Public Instance Methods
delete()
click to toggle source
deletes this person from the client
Calls superclass method
# File lib/createsend/person.rb, line 50 def delete options = { :query => { :email => @email_address } } super uri_for(client_id), options end
update(new_email_address, name, access_level, password)
click to toggle source
Updates the person details. password is optional and will only be updated if supplied
# File lib/createsend/person.rb, line 36 def update(new_email_address, name, access_level, password) options = { :query => { :email => @email_address }, :body => { :EmailAddress => new_email_address, :Name => name, :AccessLevel => access_level, :Password => password }.to_json } put uri_for(client_id), options # Update @email_address, so this object can continue to be used reliably @email_address = new_email_address end
uri_for(client_id)
click to toggle source
# File lib/createsend/person.rb, line 55 def uri_for(client_id) "/clients/#{client_id}/people.json" end