class SimpleSpark::Endpoints::RecipientLists

Provides access to the /recipient-lists endpoint @note See: developers.sparkpost.com/api/recipient-lists

Attributes

client[RW]

Public Class Methods

new(client) click to toggle source
# File lib/simple_spark/endpoints/recipient_lists.rb, line 8
def initialize(client)
  @client = client
end

Public Instance Methods

create(values, num_rcpt_errors = nil) click to toggle source

Create a recipient list @param values [Hash] the values to create the recipient list with, valid keys: [:id, :name, :description, :attributes, :recipients] @param num_rcpt_errors [Integer] max number of recipient errors that this call can return @return [Hash] details about created list @note See: developers.sparkpost.com/api/recipient-lists#recipient-lists-post-create-a-recipient-list

# File lib/simple_spark/endpoints/recipient_lists.rb, line 24
def create(values, num_rcpt_errors = nil)
  query_params = num_rcpt_errors.nil? ? '' : "?num_rcpt_errors=#{num_rcpt_errors.to_i}"
  @client.call(method: :post, path: "recipient-lists#{query_params}", body_values: values)
end
delete(id) click to toggle source

Delete a recipient list @param id [String] the ID @note See: developers.sparkpost.com/api/recipient-lists#recipient-lists-delete-delete-a-recipient-list

# File lib/simple_spark/endpoints/recipient_lists.rb, line 51
def delete(id)
  @client.call(method: :delete, path: "recipient-lists/#{id}")
end
list() click to toggle source

List all recipient lists @return [Array] an array of abbreviated recipient list objects @note See: developers.sparkpost.com/api/recipient-lists/#recipient-lists-get-list-all-recipient-lists

# File lib/simple_spark/endpoints/recipient_lists.rb, line 15
def list
  @client.call(method: :get, path: 'recipient-lists')
end
retrieve(id, show_recipients = false) click to toggle source

Retrieve recipient list details @param id [Integer] the recipient list ID to retrieve @param show_recipients [Boolean] if true, return all the recipients contained in the list @return [Hash] details about a specified recipient list @note See: developers.sparkpost.com/api/recipient-lists/#recipient-lists-get-retrieve-a-recipient-list

# File lib/simple_spark/endpoints/recipient_lists.rb, line 34
def retrieve(id, show_recipients = false)
  params = { show_recipients: show_recipients }.compact
  @client.call(method: :get, path: "recipient-lists/#{id}", query_values: params)
end
update(id, values) click to toggle source

Update a recipient list @param id [Integer] the recipient list ID to update @param values [Hash] hash of values to update, valid keys: [:name, :description, :attributes, :recipients] @return [Hash] details on update operation @note See: developers.sparkpost.com/api/recipient-lists/#recipient-lists-put-update-a-recipient-list

# File lib/simple_spark/endpoints/recipient_lists.rb, line 44
def update(id, values)
  @client.call(method: :put, path: "recipient-lists/#{id}", body_values: values)
end