Class: ZohoTools::ListManagement
- Inherits:
-
Object
- Object
- ZohoTools::ListManagement
- Defined in:
- lib/zoho_tools/list_management.rb
Constant Summary collapse
- SUBSCRIBE_URL =
'/api/v1.1/json/listsubscribe'.freeze
- UNSUBSCRIBE_URL =
'/api/v1.1/json/listunsubscribe'.freeze
Class Method Summary collapse
- .subscribe(access_token:, list_key:, contact_info:, topic_id: nil, source: nil) ⇒ Object
- .unsubscribe(access_token:, list_key:, contact_info:, topic_id: nil) ⇒ Object
Class Method Details
.subscribe(access_token:, list_key:, contact_info:, topic_id: nil, source: nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/zoho_tools/list_management.rb', line 6 def self.subscribe(access_token:, list_key:, contact_info:, topic_id: nil, source: nil) params = { listkey: list_key, resfmt: 'JSON', contactinfo: contact_info.to_json } params = params.merge(source: source) if source params = params.merge(topic_id: topic_id) if topic_id response = RestClient.post(URI.join(ZohoTools.config.campaigns_api_url, SUBSCRIBE_URL).to_s, params, { 'Authorization': "Zoho-oauthtoken #{access_token}" }) ZohoTools::Response.new(response) end |
.unsubscribe(access_token:, list_key:, contact_info:, topic_id: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/zoho_tools/list_management.rb', line 18 def self.unsubscribe(access_token:, list_key:, contact_info:, topic_id: nil) params = { listkey: list_key, resfmt: 'JSON', contactinfo: contact_info.to_json } params = params.merge(topic_id: topic_id) if topic_id response = RestClient.post(URI.join(ZohoTools.config.campaigns_api_url, UNSUBSCRIBE_URL).to_s, params, { 'Authorization': "Zoho-oauthtoken #{access_token}" }) ZohoTools::Response.new(response) end |