Class: Sendara::Resources::Broadcasts

Inherits:
Sendara::Resource show all
Defined in:
lib/sendara/resources/broadcasts.rb

Instance Method Summary collapse

Methods inherited from Sendara::Resource

#initialize

Constructor Details

This class inherits a constructor from Sendara::Resource

Instance Method Details

#bulk_send(from_email:, name: nil, subject: nil, body_html: nil, body_text: nil, template_id: nil, message_type: nil, audience_list_id: nil, list_ids: nil, exclude_list_ids: nil, recipients: nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/sendara/resources/broadcasts.rb', line 43

def bulk_send(from_email:, name: nil, subject: nil, body_html: nil, body_text: nil,
              template_id: nil, message_type: nil, audience_list_id: nil,
              list_ids: nil, exclude_list_ids: nil, recipients: nil)
  request(:post, "/v1/send/bulk", body: broadcast_body(
    from_email: from_email, name: name, subject: subject, body_html: body_html,
    body_text: body_text, template_id: template_id, message_type: message_type,
    audience_list_id: audience_list_id, list_ids: list_ids,
    exclude_list_ids: exclude_list_ids, recipients: recipients,
    scheduled_at: nil, send_now: nil
  )) || {}
end

#cancel(id) ⇒ Object



34
35
36
# File 'lib/sendara/resources/broadcasts.rb', line 34

def cancel(id)
  request(:post, "/v1/broadcasts/#{encode(id)}/cancel") || {}
end

#create(from_email:, name: nil, subject: nil, body_html: nil, body_text: nil, template_id: nil, message_type: nil, audience_list_id: nil, list_ids: nil, exclude_list_ids: nil, recipients: nil, scheduled_at: nil, send_now: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sendara/resources/broadcasts.rb', line 17

def create(from_email:, name: nil, subject: nil, body_html: nil, body_text: nil,
           template_id: nil, message_type: nil, audience_list_id: nil,
           list_ids: nil, exclude_list_ids: nil,
           recipients: nil, scheduled_at: nil, send_now: nil)
  request(:post, "/v1/broadcasts", body: broadcast_body(
    from_email: from_email, name: name, subject: subject, body_html: body_html,
    body_text: body_text, template_id: template_id, message_type: message_type,
    audience_list_id: audience_list_id, list_ids: list_ids,
    exclude_list_ids: exclude_list_ids, recipients: recipients,
    scheduled_at: scheduled_at, send_now: send_now
  )) || {}
end

#delete(id) ⇒ Object



38
39
40
41
# File 'lib/sendara/resources/broadcasts.rb', line 38

def delete(id)
  request(:delete, "/v1/broadcasts/#{encode(id)}")
  nil
end

#get(id) ⇒ Object



13
14
15
# File 'lib/sendara/resources/broadcasts.rb', line 13

def get(id)
  request(:get, "/v1/broadcasts/#{encode(id)}") || {}
end

#list(limit: nil, offset: nil) ⇒ Object



6
7
8
9
10
11
# File 'lib/sendara/resources/broadcasts.rb', line 6

def list(limit: nil, offset: nil)
  query = compact_params("limit" => limit, "offset" => offset)
  response = request(:get, "/v1/broadcasts", query: query) || {}
  broadcasts = response["broadcasts"]
  broadcasts.is_a?(Array) ? broadcasts : []
end

#send(id) ⇒ Object



30
31
32
# File 'lib/sendara/resources/broadcasts.rb', line 30

def send(id)
  request(:post, "/v1/broadcasts/#{encode(id)}/send") || {}
end