Class: GetResponse::ContactProxy
- Inherits:
-
Object
- Object
- GetResponse::ContactProxy
- Includes:
- Conditions
- Defined in:
- lib/get_response/contact_proxy.rb
Overview
Proxy class for contact related operations.
Instance Method Summary collapse
-
#all(conditions = {}) ⇒ Object
Get all contacts from account.
-
#create(attrs) ⇒ Object
Create new contact.
-
#deleted(conditions = {}) ⇒ Array
Get deleted contacts.
-
#initialize(connection) ⇒ ContactProxy
constructor
A new instance of ContactProxy.
-
#statistics(conditions = {}) ⇒ Hash
Get contacts subscription stats aggregated by date, campaign and contact’s origin.
Constructor Details
#initialize(connection) ⇒ ContactProxy
Returns a new instance of ContactProxy.
8 9 10 |
# File 'lib/get_response/contact_proxy.rb', line 8 def initialize(connection) @connection = connection end |
Instance Method Details
#all(conditions = {}) ⇒ Object
Get all contacts from account. Conditions could be passed to method. Returned contacts will be limited to passed conditions eg. to certain campaign. For more examples of conditions visit: dev.getresponse.com/api-doc/#get_contacts Example:
@contact_proxy.all(:campaigns => ["my_campaign_id"])
- returns
-
Array of GetResponse::Contact
20 21 22 23 |
# File 'lib/get_response/contact_proxy.rb', line 20 def all(conditions = {}) response = @connection.send_request("get_contacts", conditions) build_contacts(response["result"]) end |
#create(attrs) ⇒ Object
Create new contact. Method can raise GetResponseError
.
- returns
-
GetResponse::Contact
29 30 31 32 33 |
# File 'lib/get_response/contact_proxy.rb', line 29 def create(attrs) contact = GetResponse::Contact.new(attrs, @connection) contact.save contact end |
#deleted(conditions = {}) ⇒ Array
Get deleted contacts. Example:
# get all deleted contacts
@contact_proxy.deleted
# get contacts deleted through api
@contact_proxy.deleted(:reason => "api")
# get deleted contacts from campaign
@contact_proxy.deleted(:campaigns => ["campaign_id"])
72 73 74 75 76 |
# File 'lib/get_response/contact_proxy.rb', line 72 def deleted(conditions = {}) conditions = parse_conditions(conditions) response = @connection.send_request("get_contacts_deleted", conditions) build_contacts(response["result"]) end |
#statistics(conditions = {}) ⇒ Hash
Get contacts subscription stats aggregated by date, campaign and contact’s origin. Example:
# get stats for any camapign, any time period
@contact_proxy.statistics
# get stats for selected camapigns, any time period
@contact_proxy.statistics(:campaigns => ["cmp1", "cmp2"])
# get stats for specified date
@contact_proxy.statistics(:created_on => {:at => Date.today})
@contact_proxy.statistics(:created_on => {:from => "2011-01-01", :to => "2011-12-30"})
51 52 53 54 55 |
# File 'lib/get_response/contact_proxy.rb', line 51 def statistics(conditions = {}) conditions = parse_conditions(conditions) @connection.send_request("get_contacts_subscription_stats", conditions)["result"] end |