Class: SimpleSpark::Endpoints::RecipientLists

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_spark/endpoints/recipient_lists.rb

Overview

Provides access to the /recipient-lists endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ RecipientLists

Returns a new instance of RecipientLists.



8
9
10
# File 'lib/simple_spark/endpoints/recipient_lists.rb', line 8

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/simple_spark/endpoints/recipient_lists.rb', line 6

def client
  @client
end

Instance Method Details

#create(values, num_rcpt_errors = nil) ⇒ Hash

Parameters:

  • values (Hash)

    the values to create the recipient list with, valid keys: [:id, :name, :description, :attributes, :recipients]

  • num_rcpt_errors (Integer) (defaults to: nil)

    max number of recipient errors that this call can return

Returns:

  • (Hash)

    details about created list



24
25
26
27
# 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) ⇒ Object

Parameters:

  • id (String)

    the ID



51
52
53
# File 'lib/simple_spark/endpoints/recipient_lists.rb', line 51

def delete(id)
  @client.call(method: :delete, path: "recipient-lists/#{id}")
end

#listArray

Returns:

  • (Array)

    an array of abbreviated recipient list objects



15
16
17
# 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) ⇒ Hash

Parameters:

  • id (Integer)

    the recipient list ID to retrieve

  • show_recipients (Boolean) (defaults to: false)

    if true, return all the recipients contained in the list

Returns:

  • (Hash)

    details about a specified recipient list



34
35
36
37
# 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) ⇒ Hash

Parameters:

  • id (Integer)

    the recipient list ID to update

  • values (Hash)

    hash of values to update, valid keys: [:name, :description, :attributes, :recipients]

Returns:

  • (Hash)

    details on update operation



44
45
46
# 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