Class: ADSMedia::Client
- Inherits:
-
Object
- Object
- ADSMedia::Client
- Defined in:
- lib/adsmedia.rb
Constant Summary collapse
- BASE_URL =
'https://api.adsmedia.live/v1'.freeze
Instance Method Summary collapse
-
#add_contacts(list_id:, contacts:) ⇒ Object
Add contacts to list.
-
#check_suppression(email) ⇒ Object
Check suppression.
-
#create_campaign(name:, subject:, html:, text: nil, preheader: nil, type: 1) ⇒ Object
Create campaign.
-
#create_list(name:, type: 1) ⇒ Object
Create list.
-
#create_schedule(campaign_id:, list_id:, server_id:, sender_name: nil, schedule: nil) ⇒ Object
Create schedule.
-
#get_account ⇒ Object
Get account info.
-
#get_campaign(id) ⇒ Object
Get campaign.
-
#get_campaigns(limit: 50, offset: 0) ⇒ Object
List campaigns.
-
#get_lists ⇒ Object
List contact lists.
-
#get_schedules(status: 'queue') ⇒ Object
List schedules.
-
#get_servers ⇒ Object
List servers.
-
#get_status(message_id) ⇒ Object
Check email status.
-
#get_usage ⇒ Object
Get usage.
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
-
#ping ⇒ Object
Test connection.
-
#send_batch(recipients:, subject:, html:, text: nil, preheader: nil, from_name: nil) ⇒ Object
Send batch emails.
-
#send_email(to:, subject:, html:, to_name: nil, from_name: nil, text: nil, reply_to: nil) ⇒ Object
Send single email.
-
#verify_domain(server_id) ⇒ Object
Verify domain.
Constructor Details
Instance Method Details
#add_contacts(list_id:, contacts:) ⇒ Object
Add contacts to list
78 79 80 |
# File 'lib/adsmedia.rb', line 78 def add_contacts(list_id:, contacts:) post("/lists/contacts/add?id=#{list_id}", contacts: contacts) end |
#check_suppression(email) ⇒ Object
Check suppression
107 108 109 |
# File 'lib/adsmedia.rb', line 107 def check_suppression(email) get('/suppressions/check', email: email) end |
#create_campaign(name:, subject:, html:, text: nil, preheader: nil, type: 1) ⇒ Object
Create campaign
59 60 61 62 63 64 65 |
# File 'lib/adsmedia.rb', line 59 def create_campaign(name:, subject:, html:, text: nil, preheader: nil, type: 1) payload = { name: name, subject: subject, html: html, type: type } payload[:text] = text if text payload[:preheader] = preheader if preheader post('/campaigns/create', payload) end |
#create_list(name:, type: 1) ⇒ Object
Create list
73 74 75 |
# File 'lib/adsmedia.rb', line 73 def create_list(name:, type: 1) post('/lists/create', name: name, type: type) end |
#create_schedule(campaign_id:, list_id:, server_id:, sender_name: nil, schedule: nil) ⇒ Object
Create schedule
88 89 90 91 92 93 94 |
# File 'lib/adsmedia.rb', line 88 def create_schedule(campaign_id:, list_id:, server_id:, sender_name: nil, schedule: nil) payload = { campaign_id: campaign_id, list_id: list_id, server_id: server_id } payload[:sender_name] = sender_name if sender_name payload[:schedule] = schedule if schedule post('/schedules/create', payload) end |
#get_account ⇒ Object
Get account info
112 113 114 |
# File 'lib/adsmedia.rb', line 112 def get_account get('/account') end |
#get_campaign(id) ⇒ Object
Get campaign
54 55 56 |
# File 'lib/adsmedia.rb', line 54 def get_campaign(id) get('/campaigns/get', id: id) end |
#get_campaigns(limit: 50, offset: 0) ⇒ Object
List campaigns
49 50 51 |
# File 'lib/adsmedia.rb', line 49 def get_campaigns(limit: 50, offset: 0) get('/campaigns', limit: limit, offset: offset) end |
#get_lists ⇒ Object
List contact lists
68 69 70 |
# File 'lib/adsmedia.rb', line 68 def get_lists get('/lists') end |
#get_schedules(status: 'queue') ⇒ Object
List schedules
83 84 85 |
# File 'lib/adsmedia.rb', line 83 def get_schedules(status: 'queue') get('/schedules', status: status) end |
#get_servers ⇒ Object
List servers
97 98 99 |
# File 'lib/adsmedia.rb', line 97 def get_servers get('/servers') end |
#get_status(message_id) ⇒ Object
Check email status
44 45 46 |
# File 'lib/adsmedia.rb', line 44 def get_status() get('/send/status', message_id: ) end |
#get_usage ⇒ Object
Get usage
117 118 119 |
# File 'lib/adsmedia.rb', line 117 def get_usage get('/account/usage') end |
#ping ⇒ Object
Test connection
18 19 20 |
# File 'lib/adsmedia.rb', line 18 def ping get('/ping') end |
#send_batch(recipients:, subject:, html:, text: nil, preheader: nil, from_name: nil) ⇒ Object
Send batch emails
34 35 36 37 38 39 40 41 |
# File 'lib/adsmedia.rb', line 34 def send_batch(recipients:, subject:, html:, text: nil, preheader: nil, from_name: nil) payload = { recipients: recipients, subject: subject, html: html } payload[:text] = text if text payload[:preheader] = preheader if preheader payload[:from_name] = from_name if from_name post('/send/batch', payload) end |
#send_email(to:, subject:, html:, to_name: nil, from_name: nil, text: nil, reply_to: nil) ⇒ Object
Send single email
23 24 25 26 27 28 29 30 31 |
# File 'lib/adsmedia.rb', line 23 def send_email(to:, subject:, html:, to_name: nil, from_name: nil, text: nil, reply_to: nil) payload = { to: to, subject: subject, html: html } payload[:to_name] = to_name if to_name payload[:from_name] = from_name if from_name payload[:text] = text if text payload[:reply_to] = reply_to if reply_to post('/send', payload) end |
#verify_domain(server_id) ⇒ Object
Verify domain
102 103 104 |
# File 'lib/adsmedia.rb', line 102 def verify_domain(server_id) get('/domains/verify', server_id: server_id) end |