Class: Responder
- Inherits:
-
Object
- Object
- Responder
- Defined in:
- lib/responder-api.rb
Overview
gem class name Responder
Instance Method Summary collapse
-
#create_list(args = {}) ⇒ Object
create new list.
-
#create_personal_fields(id, args = {}) ⇒ Object
create new personal fields in specific list.
-
#create_subscribers(id, args = {}) ⇒ Object
create new subscribers in specific list.
-
#delete_list(id) ⇒ Object
delete list by id.
-
#delete_personal_fields(id, args) ⇒ Object
delete personal fields of specific list.
-
#delete_subscribers(id, args) ⇒ Object
delete subscribers of specific list.
-
#edit_list(id, args = {}) ⇒ Object
edit list by id.
-
#edit_personal_fields(id, args) ⇒ Object
edit personal fields of specific list.
-
#edit_subscribers(id, args) ⇒ Object
edit subscribers of specific list.
-
#get_list(id) ⇒ Object
get list by id.
-
#get_lists ⇒ Object
get all the lists.
-
#get_personal_fields(id) ⇒ Object
get personal fields from specific list.
-
#get_subscribers(id) ⇒ Object
get subscribers from specific list.
-
#initialize(client_key, client_secret, user_key, user_secret) ⇒ Responder
constructor
initialize new Responder Object.
Constructor Details
#initialize(client_key, client_secret, user_key, user_secret) ⇒ Responder
initialize new Responder Object
Example:
>> Responder.new(MNFDKRHUI2398RJ2O3R, NF932URH29837RY923JN, NF2983HFOIMNW2983H32, NFG8927RH238RH2)
Arguments:
client_key: (String) Client Key
client_secret: (String) Client Secret
user_key: (String) User Key
user_secret: (String) User Secret
20 21 22 23 |
# File 'lib/responder-api.rb', line 20 def initialize(client_key, client_secret, user_key, user_secret) consumer = OAuth::Consumer.new(client_key, client_secret, site: 'http://api.responder.co.il') @access_token = OAuth::AccessToken.new(consumer, user_key, user_secret) end |
Instance Method Details
#create_list(args = {}) ⇒ Object
create new list
Example:
>> Responder.create_list( {"DESCRIPTION": "Test List", "NAME": "try", ... } )
=> {"ERRORS"=>[], "LIST_ID"=>123456, "INVALID_EMAIL_NOTIFY"=>[], "INVALID_LIST_IDS"=>[]}
Arguments:
args: (Hash)
57 58 59 |
# File 'lib/responder-api.rb', line 57 def create_list(args = {}) send_request(:post, 'info', '', [], args) end |
#create_personal_fields(id, args = {}) ⇒ Object
create new personal fields in specific list
Example:
>> Responder.create_personal_fields(123456, {0 => {"NAME": "City", "DEFAULT_VALUE": "Tel Aviv", "DIR": "rtl", "TYPE": 0}, 1 => {"NAME": "Date of birth", "TYPE": 1}} )
=> {"LIST_ID": 123456, "CREATED_PERSONAL_FIELDS": [], "EXISTING_PERSONAL_FIELD_NAMES": []}
Arguments:
id: (int)
args: (Hash)
162 163 164 |
# File 'lib/responder-api.rb', line 162 def create_personal_fields(id, args = {}) send_request(:post, 'personal_fields', '/' + id.to_s + '/personal_fields', [], args) end |
#create_subscribers(id, args = {}) ⇒ Object
create new subscribers in specific list
Example:
>> Responder.create_subscribers(123456, {0 => {'EMAIL': "[email protected]", 'NAME': "sub1"}, 1 => {'EMAIL': "[email protected]", 'NAME': "sub2"}} )
=> {"SUBSCRIBERS_CREATED": [], "EMAILS_INVALID": [], "EMAILS_EXISTING": ["[email protected]"], "EMAILS_BANNED": [], "PHONES_INVALID": [], "PHONES_EXISTING": [], "BAD_PERSONAL_FIELDS": {}, "ERRORS" : [] }
Arguments:
id: (int)
args: (Hash)
109 110 111 |
# File 'lib/responder-api.rb', line 109 def create_subscribers(id, args = {}) send_request(:post, 'subscribers', '/' + id.to_s + '/subscribers', [], args) end |
#delete_list(id) ⇒ Object
delete list by id
Example:
>> Responder.delete_list(123456)
=> {"DELETED_LIST_ID"=>123456}
Arguments:
id: (int)
82 83 84 |
# File 'lib/responder-api.rb', line 82 def delete_list(id) send_request(:delete, 'info', '/' + id.to_s, [], {}) end |
#delete_personal_fields(id, args) ⇒ Object
delete personal fields of specific list
Example:
>> Responder.delete_personal_fields(123456, {0 => { 'ID': 1234 }, 1 => { 'ID': 5678 }} )
=> {"DELETED_FIELDS": [], "INVALID_FIELD_IDS" : [] }
Arguments:
id: (int)
args: (Hash)
188 189 190 |
# File 'lib/responder-api.rb', line 188 def delete_personal_fields(id, args) send_request(:post, 'personal_fields', '/' + id.to_s + '/personal_fields?', %w[method delete], args) end |
#delete_subscribers(id, args) ⇒ Object
delete subscribers of specific list
Example:
>> Responder.delete_subscribers(123456, {0 => { 'EMAIL': "[email protected]" }, 1 => { 'ID': 323715811 }} )
=> {"INVALID_SUBSCRIBER_IDS": [], "INVALID_SUBSCRIBER_EMAILS": [], "DELETED_SUBSCRIBERS": {} }
Arguments:
id: (int)
args: (Hash)
135 136 137 |
# File 'lib/responder-api.rb', line 135 def delete_subscribers(id, args) send_request(:post, 'subscribers', '/' + id.to_s + '/subscribers?', %w[method delete], args) end |
#edit_list(id, args = {}) ⇒ Object
edit list by id
Example:
>> Responder.edit_list(123456, {"DESCRIPTION": "Test List Edited", "NAME": "try Edited", ... } )
=> {"ERRORS"=>[], "INVALID_EMAIL_NOTIFY"=>[], "INVALID_LIST_IDS"=>[], "SUCCESS"=>true}
Arguments:
id: (int)
args: (Hash)
70 71 72 |
# File 'lib/responder-api.rb', line 70 def edit_list(id, args = {}) send_request(:put, 'info', '/' + id.to_s, [], args) end |
#edit_personal_fields(id, args) ⇒ Object
edit personal fields of specific list
Example:
>> Responder.edit_personal_fields(123456, {0 => {"ID": "1234", "DEFAULT_VALUE": "Tel Aviv-Jaffa"}, 1 => {"ID": "5678", "DIR": "rtl"}})
=> {"LIST_ID" : 123456, "UPDATED_PERSONAL_FIELDS": [], "INVALID_PERSONAL_FIELD_IDS": [], "EXISTING_PERSONAL_FIELD_NAMES": []}
Arguments:
id: (int)
args: (Hash)
175 176 177 |
# File 'lib/responder-api.rb', line 175 def edit_personal_fields(id, args) send_request(:put, 'personal_fields', '/' + id.to_s + '/personal_fields', [], args) end |
#edit_subscribers(id, args) ⇒ Object
edit subscribers of specific list
Example:
>> Responder.edit_subscribers(123456, {0 => {'IDENTIFIER': "[email protected]", 'NAME': "sub1NewName"}, 1 => {'IDENTIFIER': "sub2", 'NAME': "sub2"}} )
=> {"SUBSCRIBERS_UPDATED": [], "INVALID_SUBSCRIBER_IDENTIFIERS": [], "EMAILS_INVALID": [], "EMAILS_EXISTED": ["[email protected]"], "EMAILS_BANNED": [], "PHONES_INVALID": [], "PHONES_EXISTING": [], "BAD_PERSONAL_FIELDS": {} }}
Arguments:
id: (int)
args: (Hash)
122 123 124 |
# File 'lib/responder-api.rb', line 122 def edit_subscribers(id, args) send_request(:put, 'subscribers', '/' + id.to_s + '/subscribers', [], args) end |
#get_list(id) ⇒ Object
get list by id
Example:
>> Responder.get_list(123456)
=> { "LISTS" => [{}, {}, ... ] }
Arguments:
id: (int)
45 46 47 |
# File 'lib/responder-api.rb', line 45 def get_list(id) send_request(:get, '', '?', ['list_ids', id.to_s], {}) end |
#get_lists ⇒ Object
get all the lists
Example:
>> Responder.get_lists()
=> { "LISTS" => [{}, {}, ... ] }
33 34 35 |
# File 'lib/responder-api.rb', line 33 def get_lists send_request(:get, '', '', [], {}) end |
#get_personal_fields(id) ⇒ Object
get personal fields from specific list
Example:
>> Responder.get_personal_fields(123456)
=> {"LIST_ID": 123456, "PERSONAL_FIELDS": [{"ID": 1234, "NAME": "City", "DEFAULT_VALUE": "Tel Aviv", "DIR": "rtl", "TYPE": 0}, {"ID": 5678, "NAME": "Birth Date", "DEFAULT_VALUE" : "", "DIR": "ltr", "TYPE": 1}] }
Arguments:
id: (int)
149 150 151 |
# File 'lib/responder-api.rb', line 149 def get_personal_fields(id) send_request(:get, '', '/' + id.to_s + '/personal_fields', [], {}) end |
#get_subscribers(id) ⇒ Object
get subscribers from specific list
Example:
>> Responder.get_subscribers(123456)
=> [{}, {}, ... ]
Arguments:
id: (int)
96 97 98 |
# File 'lib/responder-api.rb', line 96 def get_subscribers(id) send_request(:get, '', '/' + id.to_s + '/subscribers', [], {}) end |