class Iterable::Lists
Interact with /lists API endpoints
@example Creating list endpoint object
# With default config lists = Iterable::Lists.new lists.all # With custom config conf = Iterable::Config.new(token: 'new-token') lists = Iterable::Lists.new(config)
Public Instance Methods
Get all lists
@return [Iterable::Response] A response object
# File lib/iterable/lists.rb, line 20 def all Iterable.request(conf, '/lists').get end
Create a new list with a name
@param name [String] The name of the list to create
@return [Iterable::Response] A response object
# File lib/iterable/lists.rb, line 31 def create(name) Iterable.request(conf, '/lists').post(name: name) end
Delete an existing list given a list id
@param name [String|Integer] The id of the list to delete
@return [Iterable::Response] A response object
# File lib/iterable/lists.rb, line 42 def delete(list_id) Iterable.request(conf, "/lists/#{list_id}").delete end
Subscribe users to a list
@param list_id [String|Integer] The id of the list @param subscribes [Array] An array of hashes of user emails and data fields
@return [Iterable::Response] A response object
# File lib/iterable/lists.rb, line 65 def subscribe(list_id, subscribers = []) attrs = { listId: list_id, subscribers: subscribers } Iterable.request(conf, '/lists/subscribe').post(attrs) end
Subscribe users to a list
@param list_id [String|Integer] The id of the list @param subscribes [Array] An array of hashes with an email
@return [Iterable::Response] A response object
# File lib/iterable/lists.rb, line 81 def unsubscribe(list_id, subscribers = []) attrs = { listId: list_id, subscribers: subscribers } Iterable.request(conf, '/lists/unsubscribe').post(attrs) end
Get users for a list
@param list_id [String|Integer] The id of the list
@return [Iterable::Response] A response object
# File lib/iterable/lists.rb, line 53 def users(list_id) Iterable.request(conf, '/lists/getUsers', listId: list_id).get end