module SendGrid4r::REST::MarketingCampaigns::Contacts::Lists

SendGrid Web API v3 Contacts - Lists

Constants

List
Lists

Public Class Methods

create_list(resp) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 26
def self.create_list(resp)
  return resp if resp.nil?
  List.new(resp['id'], resp['name'], resp['recipient_count'])
end
create_lists(resp) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 31
def self.create_lists(resp)
  return resp if resp.nil?
  lists = resp['lists'].map { |list| Contacts::Lists.create_list(list) }
  Lists.new(lists)
end
recipients_url(list_id, recipient_id = nil) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 20
def self.recipients_url(list_id, recipient_id = nil)
  url = "#{Contacts::Lists.url(list_id)}/recipients"
  url = "#{url}/#{recipient_id}" unless recipient_id.nil?
  url
end
url(list_id = nil) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 14
def self.url(list_id = nil)
  url = "#{BASE_URL}/contactdb/lists"
  url = "#{url}/#{list_id}" unless list_id.nil?
  url
end

Public Instance Methods

delete_list(list_id:, &block) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 61
def delete_list(list_id:, &block)
  delete(@auth, Contacts::Lists.url(list_id), &block)
end
delete_lists(list_ids:, &block) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 94
def delete_lists(list_ids:, &block)
  delete(@auth, "#{BASE_URL}/contactdb/lists", nil, list_ids, &block)
end
delete_recipient_from_list(list_id:, recipient_id:, &block) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 89
def delete_recipient_from_list(list_id:, recipient_id:, &block)
  endpoint = Contacts::Lists.recipients_url(list_id, recipient_id)
  delete(@auth, endpoint, &block)
end
get_list(list_id:, &block) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 49
def get_list(list_id:, &block)
  resp = get(@auth, Contacts::Lists.url(list_id), &block)
  finish(resp, @raw_resp) { |r| Contacts::Lists.create_list(r) }
end
get_lists(&block) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 44
def get_lists(&block)
  resp = get(@auth, Contacts::Lists.url, &block)
  finish(resp, @raw_resp) { |r| Contacts::Lists.create_lists(r) }
end
get_recipients_from_list( list_id:, page: nil, page_size: nil, &block ) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 71
def get_recipients_from_list(
  list_id:, page: nil, page_size: nil, &block
)
  params = {}
  params['page'] = page unless page.nil?
  params['page_size'] = page_size unless page_size.nil?
  endpoint = Contacts::Lists.recipients_url(list_id)
  resp = get(@auth, endpoint, params, &block)
  finish(resp, @raw_resp) do |r|
    Contacts::Recipients.create_recipients(r)
  end
end
patch_list(list_id:, name:, &block) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 54
def patch_list(list_id:, name:, &block)
  params = {}
  params['name'] = name
  resp = patch(@auth, Contacts::Lists.url(list_id), params, &block)
  finish(resp, @raw_resp) { |r| Contacts::Lists.create_list(r) }
end
post_list(name:, &block) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 37
def post_list(name:, &block)
  params = {}
  params['name'] = name
  resp = post(@auth, Contacts::Lists.url, params, &block)
  finish(resp, @raw_resp) { |r| Contacts::Lists.create_list(r) }
end
post_recipient_to_list(list_id:, recipient_id:, &block) click to toggle source
# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 84
def post_recipient_to_list(list_id:, recipient_id:, &block)
  endpoint = Contacts::Lists.recipients_url(list_id, recipient_id)
  post(@auth, endpoint, &block)
end
post_recipients_to_list(list_id:, recipients:, &block) click to toggle source

no bodies returned

# File lib/sendgrid4r/rest/marketing_campaigns/contacts/lists.rb, line 66
def post_recipients_to_list(list_id:, recipients:, &block)
  endpoint = "#{Contacts::Lists.url(list_id)}/recipients"
  post(@auth, endpoint, recipients, &block)
end