Class: SendGrid4r::Factory::CampaignFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/sendgrid4r/factory/campaign_factory.rb

Overview

SendGrid Web API v3 Campaign Factory Class implementation

Instance Method Summary collapse

Instance Method Details

#create(title: nil, subject: nil, sender_id: nil, list_ids: nil, segment_ids: nil, categories: nil, suppression_group_id: nil, custom_unsubscribe_url: nil, ip_pool: nil, html_content: nil, plain_content: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sendgrid4r/factory/campaign_factory.rb', line 9

def create(title: nil, subject: nil, sender_id: nil, list_ids: nil,
  segment_ids: nil, categories: nil, suppression_group_id: nil,
  custom_unsubscribe_url: nil, ip_pool: nil, html_content: nil,
  plain_content: nil)
  campaign = REST::MarketingCampaigns::Campaign.new(
    nil, title, subject, sender_id, list_ids, segment_ids, categories,
    suppression_group_id, custom_unsubscribe_url, ip_pool, html_content,
    plain_content, nil, nil
  )
  campaign.to_h.reject { |_key, value| value.nil? }
end

#create_address(email:, name:) ⇒ Object



34
35
36
# File 'lib/sendgrid4r/factory/campaign_factory.rb', line 34

def create_address(email:, name:)
  REST::MarketingCampaigns::Address.new(email, name).to_h
end

#create_sender(nickname:, from:, reply_to:, address:, address_2:, city:, state:, zip:, country:) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sendgrid4r/factory/campaign_factory.rb', line 21

def create_sender(
  nickname:, from:, reply_to:, address:, address_2:, city:, state:,
  zip:, country:
)
  REST::MarketingCampaigns::Sender.new(
    nil, nickname, nil, nil, address, address_2,
    city, state, zip, country, nil, nil, nil, nil
  ).tap do |sender|
    sender.from = from
    sender.reply_to = reply_to
  end
end