Class: SimpleSpark::Endpoints::Subaccounts

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

Overview

Note:

Example subaccount

Provides access to the /subaccounts endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Subaccounts

Returns a new instance of Subaccounts.



9
10
11
# File 'lib/simple_spark/endpoints/subaccounts.rb', line 9

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/simple_spark/endpoints/subaccounts.rb', line 7

def client
  @client
end

Instance Method Details

#create(values) ⇒ Object

Note:

Example: values =

"name": "Sparkle Ponies",
"key_label": "API Key for Sparkle Ponies Subaccount",
"key_grants": ["smtp/inject", "sending_domains/manage", "message_events/view", "suppression_lists/manage"]

Create a subaccount

Parameters:

  • values (Hash)

    the values to create the subaccount with



29
30
31
# File 'lib/simple_spark/endpoints/subaccounts.rb', line 29

def create(values)
  @client.call(method: :post, path: 'subaccounts', body_values: values)
end

#listArray

Returns:

  • (Array)

    a list of Subaccount hash objects



16
17
18
# File 'lib/simple_spark/endpoints/subaccounts.rb', line 16

def list
  @client.call(method: :get, path: 'subaccounts')
end

#retrieve(id) ⇒ Hash

Retrieve details about a subaccount by specifying its id

Parameters:

  • id (Integer)

    the ID of the subaccount

Returns:

  • (Hash)

    an Subaccount hash object



37
38
39
# File 'lib/simple_spark/endpoints/subaccounts.rb', line 37

def retrieve(id)
  @client.call(method: :get, path: "subaccounts/#{id}")
end

#update(id, values) ⇒ Object

Parameters:

  • id (Integer)

    the ID of the subaccount

  • values (Hash)

    the values to update the subaccount with



45
46
47
# File 'lib/simple_spark/endpoints/subaccounts.rb', line 45

def update(id, values)
  @client.call(method: :put, path: "subaccounts/#{id}", body_values: values)
end