Class: Starling::Services::ContactAccountsService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/starling/services/contact_accounts_service.rb

Overview

A service for accessing the Contact API’s Get Contact Accounts and Get Contact endpoints

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Starling::Services::BaseService

Instance Method Details

#get(contact_id, contact_account_id, params: {}, headers: {}) ⇒ Resources::ContactAccountResource

Parameters:

  • contact_id (String)

    The Starling internal ID of the contact the contact account belongs to

  • contact_account_id (String)

    The Starling internal ID of the contact account

  • params (Hash) (defaults to: {})

    Parameters which will be included in the HTTP request, included in the URL as a query string

  • headers (Hash) (defaults to: {})

    Headers which be included in the HTTP request, merged on top of the headers set at the Client level

Returns:

Raises:

  • (Errors::ApiError)

    if the HTTP request returns a status indicating that it was unsuccessful



17
18
19
20
21
22
23
24
25
26
# File 'lib/starling/services/contact_accounts_service.rb', line 17

def get(contact_id, , params: {}, headers: {})
  response = api_service.make_request(
    :get,
    "/contacts/#{contact_id}/accounts/#{}",
    params: params,
    headers: headers
  )

  resource.new(response: response)
end

#list(contact_id, params: {}, headers: {}) ⇒ Array<Resources::ContactAccountResource>

Parameters:

  • contact_id (String)

    The Starling internal ID of the contact

  • params (Hash) (defaults to: {})

    Parameters which will be included in the HTTP request, included in the URL as a query string

  • headers (Hash) (defaults to: {})

    Headers which be included in the HTTP request, merged on top of the headers set at the Client level

Returns:

Raises:

  • (Errors::ApiError)

    if the HTTP request returns a status indicating that it was unsuccessful



36
37
38
39
40
41
42
43
44
45
# File 'lib/starling/services/contact_accounts_service.rb', line 36

def list(contact_id, params: {}, headers: {})
  response = api_service.make_request(
    :get,
    "/contacts/#{contact_id}/accounts",
    params: params,
    headers: headers
  )

  build_collection_from_key(response, key: 'contactAccounts', resource: resource)
end