class Starling::Services::ContactAccountsService

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

Public Instance Methods

get(contact_id, contact_account_id, params: {}, headers: {}) click to toggle source

@param contact_id [String] The Starling internal ID of the contact the contact

account belongs to

@param contact_account_id [String] The Starling internal ID of the contact

account

@param params [Hash] Parameters which will be included in the HTTP request,

included in the URL as a query string

@param headers [Hash] Headers which be included in the HTTP request, merged on

top of the headers set at the {Client} level

@return [Resources::ContactAccountResource] @raise [Errors::ApiError] if the HTTP request returns a status indicating that it

was unsuccessful
# File lib/starling/services/contact_accounts_service.rb, line 17
def get(contact_id, contact_account_id, params: {}, headers: {})
  response = api_service.make_request(
    :get,
    "/contacts/#{contact_id}/accounts/#{contact_account_id}",
    params: params,
    headers: headers
  )

  resource.new(response: response)
end
list(contact_id, params: {}, headers: {}) click to toggle source

@param contact_id [String] The Starling internal ID of the contact @param params [Hash] Parameters which will be included in the HTTP request,

included in the URL as a query string

@param headers [Hash] Headers which be included in the HTTP request, merged on

top of the headers set at the {Client} level

@return [Array<Resources::ContactAccountResource>] @raise [Errors::ApiError] if the HTTP request returns a status indicating that it

was unsuccessful
# 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

Private Instance Methods

resource() click to toggle source
# File lib/starling/services/contact_accounts_service.rb, line 49
def resource
  Resources::ContactAccountResource
end