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, recipients: nil, scheduled_at: nil, send_now: nil) ⇒ Object



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

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,
              recipients: nil, scheduled_at: nil, send_now: 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, recipients: recipients,
    scheduled_at: scheduled_at, send_now: send_now
  )) || {}
end

#cancel(id) ⇒ Object



32
33
34
# File 'lib/sendara/resources/broadcasts.rb', line 32

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, recipients: nil, scheduled_at: nil, send_now: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# 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,
           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, recipients: recipients,
    scheduled_at: scheduled_at, send_now: send_now
  )) || {}
end

#delete(id) ⇒ Object



36
37
38
39
# File 'lib/sendara/resources/broadcasts.rb', line 36

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



28
29
30
# File 'lib/sendara/resources/broadcasts.rb', line 28

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