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
Class Method Details
.add_authorized_users(request) ⇒ UnitResponse, UnitError
Add authorized users to a customer by calling Unit’s API
52 53 54 55 56 57 58 |
# File 'lib/unit/api_resources/customer_resource.rb', line 52 def (request) payload = request.to_json_api response = HTTParty.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
43 44 45 46 47 |
# File 'lib/unit/api_resources/customer_resource.rb', line 43 def archive(request) payload = request.to_json_api response = HTTParty.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
27 28 29 30 |
# File 'lib/unit/api_resources/customer_resource.rb', line 27 def get(customer_id) response = HTTParty.get("#{api_url}/customers/#{customer_id}", headers: headers) response_handler(response) end |
.list(params = nil) ⇒ UnitResponse, UnitError
Get customers by calling Unit’s API
35 36 37 38 |
# File 'lib/unit/api_resources/customer_resource.rb', line 35 def list(params = nil) response = HTTParty.get("#{api_url}/customers", body: params&.to_hash&.to_json, headers: headers) response_handler(response) end |
.remove_authorized_users(request) ⇒ UnitResponse, UnitError
Remove authorized users from a customer by calling Unit’s API
63 64 65 66 67 |
# File 'lib/unit/api_resources/customer_resource.rb', line 63 def (request) payload = request.to_json_api response = HTTParty.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
18 19 20 21 22 |
# File 'lib/unit/api_resources/customer_resource.rb', line 18 def update(request) payload = request.to_json_api response = HTTParty.patch("#{api_url}/customers/#{request.customer_id}", body: payload, headers: headers) response_handler(response) end |