Wrapper for GetResponse API. Class interfaces from version 0.2 has changed breaking backward compatibility. Be sure to check changes before update.
Just add to you Gemfile
gem "getresponse", :require => "get_response"
Test connection to GetResponse API.
gr_connection = GetResponse::Connection.new("my_secret_api") gr_connection.ping
Get info about account:
gr_connection.account
Get your active campaigns.
gr_connection.campaigns.all
You can operate on your contacts quite the same way as on ActiveRecord objects. Before any operation on contacts you must connect to API.
Get all contacts:
gr_connection.contacts.all
Create new contact:
# with connection gr_connection.contacts.create("name" => "John Doe", "email" => "john.d@somewhere.com", "campaign" => "campaignId", "customs" => { "source" => "mainpage" })
Update your contact:
# with connection # contact - existing contact contact.update("name" => "John Thenewname") # or contact.name = "John Thenewname" contact.save
Delete contact:
# with connection # contact - existing contact contact.destroy
Move contact between campaigns:
# with connection # contact - existing contact # zXy - existing campaign contact.move("zXy")
Get geoip location
# with connection # contact - existing contact contact.geoip
Set contact cycle
# with connection # contact - existing contact contact.set_cycle(5)
Get custom attributes
# with connection # contact - existing contact contact.customs => { "attr_name" => "attr_value" }
Get account from fields
# with account # account - existing account account.from_fields.all => [<FromField: xcv>]
Add account from field
# with account # account = existing account account.from_fields.create("name" => "My new name", "email" => "my_new_email@foo.bar") => #<GetResponse::FromField:0xb7727010 ... >
Get account domains
# with account # account - existing account account.domains.all
Get campaign domain
# with campaign # campaign - existing campaign campaign.domain
Set campaign domain
domain = account.domains.first campaign.domain = domain
Get campaign messages
# with campaign # campaign - existing campaign messages = campaign.messages newsletters = campaign.messages(:type => "newsletter")
Get all messages
# with connection connection.messages.all
Get message contents
# with message # message - existing messsage message.contents["plain"] message.contents["html"]
Get stats of message
# message - existing message message.stats
Delete message
# message - existing message message.destroy
Get/set campaign’s postal address
# campaign_one - existing campaign # campaign_two - existing campaign postal_address = campaign_one.postal_address campaign_two.postal_address = postal_address
To get contact openned message list with dates
# contact - existing contact @contact.opens
Get subscriptions statistics
# campaign - existing campaign campaign.subscription_statistics campaign.subscription_statistics(:created_on => {:at => Date.today}) campaign.subscription_statistics(:created_on => {:from => "2011-01-01", :to => "2011-12-30"})
Get confirmation message bodies
# connection - existing connection connection.confirmation_bodies.all connection.confirmation_bodies.all(:language_code => {:equals => "en"})
Get confirmation message subjects
# connection - existing connection connection.confirmation_subjects.all connection.confirmation_subjects.all(:language_code => {:equals => "en"})
Get deleted contacts
contact_proxy.deleted contact_proxy.deleted(:reason => "bounce") campaign.deleted
Get single field form by id
from_field_proxy.find("from_field_id")
Get single confirmation body by id
confirmation_body_proxy.find("confirmation_body_id")
Get single confirmation subject by id
confirmation_subject_proxy.find("confirmation_subject_id")
Create new campaign
connection.campaigns.create(new_campaign_attributes)
Fetching links embedded in messages
connection.links.all message.links
Fetching blacklisted addresses for account
account.blacklist
Fetching blacklisted addresses for campaign
campaign.blacklist