Module: Resend::Broadcasts

Defined in:
lib/resend/broadcasts.rb

Overview

broadcasts api wrapper

Class Method Summary collapse

Class Method Details

.create(params = {}) ⇒ Object

Note:

Supports both segment_id and audience_id. At least one is required. audience_id is deprecated - use segment_id instead.

Note:

When send: true is passed, the broadcast is sent immediately instead of creating a draft. When using send: true, you can also include scheduled_at to schedule the broadcast. Passing scheduled_at without send: true is an error.

resend.com/docs/api-reference/broadcasts/create-broadcast



13
14
15
16
17
18
19
# File 'lib/resend/broadcasts.rb', line 13

def create(params = {})
  if params[:audience_id] && !params[:segment_id]
    warn "[DEPRECATION] Using audience_id in broadcasts is deprecated. Use segment_id instead."
  end
  path = "broadcasts"
  Resend::Request.new(path, params, "post").perform
end

.get(broadcast_id = "") ⇒ Object



51
52
53
54
# File 'lib/resend/broadcasts.rb', line 51

def get(broadcast_id = "")
  path = "broadcasts/#{broadcast_id}"
  Resend::Request.new(path, {}, "get").perform
end

.list(params = {}) ⇒ Object



39
40
41
42
# File 'lib/resend/broadcasts.rb', line 39

def list(params = {})
  path = Resend::PaginationHelper.build_paginated_path("broadcasts", params)
  Resend::Request.new(path, {}, "get").perform
end

.remove(broadcast_id = "") ⇒ Object



45
46
47
48
# File 'lib/resend/broadcasts.rb', line 45

def remove(broadcast_id = "")
  path = "broadcasts/#{broadcast_id}"
  Resend::Request.new(path, {}, "delete").perform
end

.send(params = {}) ⇒ Object



33
34
35
36
# File 'lib/resend/broadcasts.rb', line 33

def send(params = {})
  path = "broadcasts/#{params[:broadcast_id]}/send"
  Resend::Request.new(path, params, "post").perform
end

.update(params = {}) ⇒ Object

Note:

Supports both segment_id and audience_id. At least one may be required. audience_id is deprecated - use segment_id instead.

resend.com/docs/api-reference/broadcasts/update-broadcast



24
25
26
27
28
29
30
# File 'lib/resend/broadcasts.rb', line 24

def update(params = {})
  if params[:audience_id] && !params[:segment_id]
    warn "[DEPRECATION] Using audience_id in broadcasts is deprecated. Use segment_id instead."
  end
  path = "broadcasts/#{params[:broadcast_id]}"
  Resend::Request.new(path, params, "patch").perform
end