Class: Lists
- Inherits:
-
Object
- Object
- Lists
- Defined in:
- lib/unisender_api/lists.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
Instance Method Summary collapse
- #createList(title, before_subscribe_url = '', after_subscribe_url = '') ⇒ Object
- #deleteList(list_id) ⇒ Object
- #exportContacts(list_id, field_names = ['email'], offset = 0, tag = '', email = '', email_status = '', phone = '', phone_status = '', limit = 1000) ⇒ Object
- #getLists ⇒ Object
- #importContacts(field_names = 'email', data = '[email protected]', double_optin = 0, overwrite_tags = 0, overwrite_lists = 0, force_import = 0) ⇒ Object
-
#initialize(api) ⇒ Lists
constructor
A new instance of Lists.
- #subscribe(list_ids, fields, tags = '', request_ip = '', request_time = '', double_optin = '', confirm_ip = '', confirm_time = '', overwrite = '') ⇒ Object
- #updateList(list_id, title, before_subscribe_url = '', after_subscribe_url = '') ⇒ Object
Constructor Details
#initialize(api) ⇒ Lists
Returns a new instance of Lists.
4 5 6 |
# File 'lib/unisender_api/lists.rb', line 4 def initialize(api) self.api = api end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
2 3 4 |
# File 'lib/unisender_api/lists.rb', line 2 def api @api end |
Instance Method Details
#createList(title, before_subscribe_url = '', after_subscribe_url = '') ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/unisender_api/lists.rb', line 12 def createList(title, before_subscribe_url = '', after_subscribe_url = '') param = Hash.new param.merge!(self.api.gen_hash(title, 'title')) param.merge!(self.api.gen_hash(before_subscribe_url,'before_subscribe_url')) if before_subscribe_url != '' peram.merge!(self.api.gen_hash(after_subscribe_url, 'after_subscribe_url')) if after_subscribe_url != '' self.api.api_call('createList', param) end |
#deleteList(list_id) ⇒ Object
29 30 31 32 33 |
# File 'lib/unisender_api/lists.rb', line 29 def deleteList(list_id) param = Hash.new param.merge!(self.api.gen_hash(list_id, 'list_id')) self.api.api_call('deleteList', param) end |
#exportContacts(list_id, field_names = ['email'], offset = 0, tag = '', email = '', email_status = '', phone = '', phone_status = '', limit = 1000) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/unisender_api/lists.rb', line 60 def exportContacts(list_id, field_names = ['email'], offset = 0, tag = '', email = '', email_status = '', phone = '', phone_status = '', limit = 1000) param = Hash.new param.merge!(self.api.gen_hash(list_id, 'list_id')) param.merge!(self.api.gen_hash(field_names, 'field_names')) param.merge!(self.api.gen_hash(offset, 'offset')) param.merge!(self.api.gen_hash(tag, 'tag')) if tag != '' param.merge!(self.api.gen_hash(email, 'email')) if email != '' param.merge!(self.api.gen_hash(email_status, 'email_status')) if email_status != '' param.merge!(self.api.gen_hash(phone, 'phone')) if phone != '' param.merge!(self.api.gen_hash(phone_status, 'phone_status')) if phone_status != '' param.merge!(self.api.gen_hash(limit, 'limit')) self.api.api_call('exportContacts', param) end |
#getLists ⇒ Object
8 9 10 |
# File 'lib/unisender_api/lists.rb', line 8 def getLists self.api.api_call('getLists', {}) end |
#importContacts(field_names = 'email', data = '[email protected]', double_optin = 0, overwrite_tags = 0, overwrite_lists = 0, force_import = 0) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/unisender_api/lists.rb', line 49 def importContacts(field_names = 'email', data = '[email protected]', double_optin = 0, = 0, overwrite_lists = 0, force_import = 0) param = Hash.new param.merge!(self.api.gen_hash(field_names, 'field_names')) param.merge!(self.api.gen_hash(data, 'data')) param.merge!(self.api.gen_hash(double_optin, 'double_optin')) param.merge!(self.api.gen_hash(, 'overwrite_tags')) param.merge!(self.api.gen_hash(overwrite_lists, 'overwrite_lists')) param.merge!(self.api.gen_hash(force_import, 'force_import')) self.api.api_call('importContacts', param) end |
#subscribe(list_ids, fields, tags = '', request_ip = '', request_time = '', double_optin = '', confirm_ip = '', confirm_time = '', overwrite = '') ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/unisender_api/lists.rb', line 35 def subscribe(list_ids, fields, = '', request_ip = '', request_time = '', double_optin = '', confirm_ip = '', confirm_time = '', overwrite = '') param = Hash.new param.merge!(self.api.gen_hash(list_ids, 'list_ids')) param.merge!(self.api.gen_hash(fields, 'fields')) param.merge!(self.api.gen_hash(, 'tags')) if != '' param.merge!(self.api.gen_hash(request_ip, 'request_ip')) if request_ip != '' param.merge!(self.api.gen_hash(request_time, 'request_time')) if request_time != '' param.merge!(self.api.gen_hash(double_optin, 'double_optin')) if double_optin != '' param.merge!(self.api.gen_hash(confirm_ip, 'confirm_ip')) if confirm_ip != '' param.merge!(self.api.gen_hash(confirm_time, 'confirm_time')) if confirm_time != '' param.merge!(self.api.gen_hash(overwrite, 'overwrite')) if overwrite != '' self.api.api_call('subscribe', param) end |
#updateList(list_id, title, before_subscribe_url = '', after_subscribe_url = '') ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/unisender_api/lists.rb', line 20 def updateList(list_id, title, before_subscribe_url = '', after_subscribe_url = '') param = Hash.new param.merge!(self.api.gen_hash(list_id, 'list_id')) param.merge!(self.api.gen_hash(title, 'title')) param.merge!(self.api.gen_hash(before_subscirbe_url, 'before_subscribe_url')) if before_subscribe_url != '' param.merge!(self.api.gen_hash(after_subscribe_url, 'after_subscribe_url')) if after_subscribe_url != '' self.api.api_call('updateList', param) end |