Class: Sendgrid::API::Newsletter::Lists::Services

Inherits:
Service
  • Object
show all
Includes:
Utils
Defined in:
lib/sendgrid/api/newsletter/lists.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) ⇒ Entities::Response

Create a new Recipient List.

Parameters:

  • list (String, Entities::List)

    A new list name or Entities::List object.

Returns:

See Also:



23
24
25
26
# File 'lib/sendgrid/api/newsletter/lists.rb', line 23

def add(list)
  params = { :list => extract_listname(list) }
  perform_request(Entities::Response, 'newsletter/lists/add.json', params)
end

#delete(list) ⇒ Entities::Response

Remove a Recipient List from your account.

Parameters:

  • list (String, Entities::List)

    An existing list name or Entities::List object.

Returns:

See Also:



54
55
56
57
# File 'lib/sendgrid/api/newsletter/lists.rb', line 54

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

#edit(list, newlist) ⇒ Entities::Response

Rename a Recipient List.

Parameters:

  • list (String, Entities::List)

    An existing list name or Entities::List object.

  • newlist (String, Entities::List)

    A new list name or Entities::List object.

Returns:

See Also:



34
35
36
37
# File 'lib/sendgrid/api/newsletter/lists.rb', line 34

def edit(list, newlist)
  params = { :list => extract_listname(list), :newlist => extract_listname(newlist) }
  perform_request(Entities::Response, 'newsletter/lists/edit.json', params)
end

#get(list = nil) ⇒ Array<Entities::List>

List all Recipient Lists on your account, or check if a particular List exists.

Parameters:

  • list (String, Entities::List) (defaults to: nil)

    An existing list name or Entities::List object. Optional.

Returns:

See Also:



44
45
46
47
# File 'lib/sendgrid/api/newsletter/lists.rb', line 44

def get(list = nil)
  params = { :list => extract_listname(list) } if list
  perform_request(Entities::List, 'newsletter/lists/get.json', params || {})
end