Class: Starling::Services::ContactsService
- Inherits:
-
BaseService
- Object
- BaseService
- Starling::Services::ContactsService
- Defined in:
- lib/starling/services/contacts_service.rb
Overview
A service for accessing the Contact’s API’s Get Contacts, Get Contact, Delete Contact and Create Contact and Account endpoints
Instance Method Summary collapse
-
#create(params:, headers: {}) ⇒ Resources::ContactResource
The created contact.
-
#delete(id, params: {}, headers: {}) ⇒ Faraday::Response
The raw response from the Starling Bank API.
- #get(id, params: {}, headers: {}) ⇒ Resources::ContactResource
- #list(params: {}, headers: {}) ⇒ Array<Resources::ContactResource>
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from Starling::Services::BaseService
Instance Method Details
#create(params:, headers: {}) ⇒ Resources::ContactResource
Returns the created contact.
53 54 55 56 57 58 59 60 61 62 63 64 |
# 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 |
#delete(id, params: {}, headers: {}) ⇒ Faraday::Response
Returns the raw response from the Starling Bank API.
28 29 30 31 |
# 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 |
#get(id, params: {}, headers: {}) ⇒ Resources::ContactResource
14 15 16 17 18 |
# 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 |
#list(params: {}, headers: {}) ⇒ Array<Resources::ContactResource>
40 41 42 43 44 |
# File 'lib/starling/services/contacts_service.rb', line 40 def list(params: {}, headers: {}) response = api_service.make_request(:get, '/contacts', params: params, headers: headers) (response, key: 'contacts', resource: resource) end |