Class: Unit::Resource::CustomerResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- Unit::Resource::CustomerResource
- Defined in:
- lib/unit/api_resources/customer_resource.rb
Class Method Summary collapse
-
.add_authorized_users(request) ⇒ UnitResponse, UnitError
Add authorized users to a customer by calling Unit’s API.
-
.archive(request) ⇒ UnitResponse, UnitError
Archive customers by calling Unit’s API.
-
.get(customer_id) ⇒ UnitResponse, UnitError
Get a customer by calling Unit’s API.
-
.list(params = nil) ⇒ UnitResponse, UnitError
Get customers by calling Unit’s API.
-
.remove_authorized_users(request) ⇒ UnitResponse, UnitError
Remove authorized users from a customer by calling Unit’s API.
-
.update(request) ⇒ UnitResponse, UnitError
Update a customer by calling Unit’s API.
Methods inherited from BaseResource
file_response_handler, response_handler
Class Method Details
.add_authorized_users(request) ⇒ UnitResponse, UnitError
Add authorized users to a customer by calling Unit’s API
51 52 53 54 55 56 57 58 59 |
# File 'lib/unit/api_resources/customer_resource.rb', line 51 def (request) payload = request.to_json_api response = HttpHelper.post( "#{api_url}/customers/#{request.customer_id}/authorized-users", body: payload, headers: headers ) response_handler(response) end |
.archive(request) ⇒ UnitResponse, UnitError
Archive customers by calling Unit’s API
42 43 44 45 46 |
# File 'lib/unit/api_resources/customer_resource.rb', line 42 def archive(request) payload = request.to_json_api response = HttpHelper.post("#{api_url}/customers/#{request.customer_id}/archive", body: payload, headers: headers) response_handler(response) end |
.get(customer_id) ⇒ UnitResponse, UnitError
Get a customer by calling Unit’s API
26 27 28 29 |
# File 'lib/unit/api_resources/customer_resource.rb', line 26 def get(customer_id) response = HttpHelper.get("#{api_url}/customers/#{customer_id}", headers: headers) response_handler(response) end |
.list(params = nil) ⇒ UnitResponse, UnitError
Get customers by calling Unit’s API
34 35 36 37 |
# File 'lib/unit/api_resources/customer_resource.rb', line 34 def list(params = nil) response = HttpHelper.get("#{api_url}/customers", params: params&.to_hash, headers: headers) response_handler(response) end |
.remove_authorized_users(request) ⇒ UnitResponse, UnitError
Remove authorized users from a customer by calling Unit’s API
64 65 66 67 68 |
# File 'lib/unit/api_resources/customer_resource.rb', line 64 def (request) payload = request.to_json_api response = HttpHelper.delete("#{api_url}/customers/#{request.customer_id}/authorized-users", body: payload, headers: headers) response_handler(response) end |
.update(request) ⇒ UnitResponse, UnitError
Update a customer by calling Unit’s API
17 18 19 20 21 |
# File 'lib/unit/api_resources/customer_resource.rb', line 17 def update(request) payload = request.to_json_api response = HttpHelper.patch("#{api_url}/customers/#{request.customer_id}", body: payload, headers: headers) response_handler(response) end |