Class: Sendgrid::API::Newsletter::Emails::Services

Inherits:
Service
  • Object
show all
Includes:
Utils
Defined in:
lib/sendgrid/api/newsletter/emails.rb

Instance Attribute Summary

Attributes inherited from Service

#resource

Instance Method Summary collapse

Methods inherited from Service

#initialize, #perform_request

Constructor Details

This class inherits a constructor from Sendgrid::API::Service

Instance Method Details

#add(list, emails) ⇒ Entities::ResponseInsert

Add one or more emails to a Recipient List.

Parameters:

  • list (String, Entities::List)

    A list name or Entities::List object.

  • emails (Array<Entities::Email>)

    A list of emails to be added. Limited to a 1000 entries maximum.

Returns:

See Also:



25
26
27
28
# File 'lib/sendgrid/api/newsletter/emails.rb', line 25

def add(list, emails)
  params = { :list => extract_listname(list), :data => map_emails(emails, :to_json) }
  perform_request(Entities::ResponseInsert, 'newsletter/lists/email/add.json', params)
end

#delete(list, emails) ⇒ Entities::ResponseRemove

Remove one or more emails from a Recipient List.

Parameters:

Returns:

See Also:



48
49
50
51
# File 'lib/sendgrid/api/newsletter/emails.rb', line 48

def delete(list, emails)
  params = { :list => extract_listname(list), :email => map_emails(emails, :email) }
  perform_request(Entities::ResponseRemove, 'newsletter/lists/email/delete.json', params)
end

#get(list, emails = nil) ⇒ Array<Entities::Email>

Get the email addresses and associated fields for a Recipient List.

Parameters:

Returns:

See Also:



36
37
38
39
40
# File 'lib/sendgrid/api/newsletter/emails.rb', line 36

def get(list, emails = nil)
  params = { :list => extract_listname(list) }
  params[:email] = map_emails(emails, :email) if emails
  perform_request(Entities::Email, 'newsletter/lists/email/get.json', params)
end