class Starling::Services::ContactsService
A service for accessing the Contact's API's Get Contacts, Get Contact, Delete Contact and Create Contact and Account endpoints
Public Instance Methods
@param params [Hash] Parameters which will be included in the HTTP request,
included in the body
@param headers [Hash] Headers which be included in the HTTP request, merged on
top of the headers set at the {Client} level
@return [Resources::ContactResource] the created contact @raise [Errors::ApiError] if the HTTP request returns a status indicating that it
was unsuccessful
# File lib/starling/services/contacts_service.rb, line 53 def create(params:, headers: {}) post_response = api_service.make_request(:post, '/contacts', params: params, headers: headers) get_response = api_service.make_request( :get, convert_location_header_to_relative_path(post_response.headers['Location']), headers: headers ) resource.new(response: get_response) end
@param id [String] The Starling
internal ID of the contact @param params [Hash] Parameters which will be included in the HTTP request,
included in the body
@param headers [Hash] Headers which be included in the HTTP request, merged on
top of the headers set at the {Client} level
@return [Faraday::Response] the raw response from the Starling
Bank API @raise [Errors::ApiError] if the HTTP request returns a status indicating that it
was unsuccessful
# File lib/starling/services/contacts_service.rb, line 28 def delete(id, params: {}, headers: {}) api_service.make_request(:delete, "/contacts/#{id}", params: params, headers: headers) end
@param 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 [Resources::ContactResource] @raise [Errors::ApiError] if the HTTP request returns a status indicating that it
was unsuccessful
# File lib/starling/services/contacts_service.rb, line 14 def get(id, params: {}, headers: {}) response = api_service.make_request(:get, "/contacts/#{id}", params: params, headers: headers) resource.new(response: response) end
@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::ContactResource>] @raise [Errors::ApiError] if the HTTP request returns a status indicating that it
was unsuccessful
# File lib/starling/services/contacts_service.rb, line 40 def list(params: {}, headers: {}) response = api_service.make_request(:get, '/contacts', params: params, headers: headers) build_collection_from_embedded_key(response, key: 'contacts', resource: resource) end
Private Instance Methods
# File lib/starling/services/contacts_service.rb, line 68 def resource Resources::ContactResource end