Class: EasyPost::Services::Insurance
- Defined in:
- lib/easypost/services/insurance.rb
Constant Summary collapse
Instance Method Summary collapse
-
#all(params = {}) ⇒ Object
Retrieve all Insurance objects.
-
#create(params = {}) ⇒ Object
Create an Insurance object.
-
#get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of insurances.
-
#refund(id) ⇒ Object
Refund an Insurance object.
-
#retrieve(id) ⇒ Object
Retrieve an Insurance object.
Methods inherited from Service
Constructor Details
This class inherits a constructor from EasyPost::Services::Service
Instance Method Details
#all(params = {}) ⇒ Object
Retrieve all Insurance objects
22 23 24 25 26 |
# File 'lib/easypost/services/insurance.rb', line 22 def all(params = {}) filters = { key: 'insurances' } get_all_helper('insurances', MODEL_CLASS, params, filters) end |
#create(params = {}) ⇒ Object
Create an Insurance object
7 8 9 10 11 12 |
# File 'lib/easypost/services/insurance.rb', line 7 def create(params = {}) wrapped_params = { insurance: params } response = @client.make_request(:post, 'insurances', wrapped_params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end |
#get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of insurances.
29 30 31 32 33 34 35 36 |
# File 'lib/easypost/services/insurance.rb', line 29 def get_next_page(collection, page_size = nil) raise EasyPost::Errors::EndOfPaginationError.new unless more_pages?(collection) params = { before_id: collection.insurances.last.id } params[:page_size] = page_size unless page_size.nil? all(params) end |
#refund(id) ⇒ Object
Refund an Insurance object
39 40 41 42 43 |
# File 'lib/easypost/services/insurance.rb', line 39 def refund(id) response = @client.make_request(:post, "insurances/#{id}/refund") EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end |
#retrieve(id) ⇒ Object
Retrieve an Insurance object
15 16 17 18 19 |
# File 'lib/easypost/services/insurance.rb', line 15 def retrieve(id) response = @client.make_request(:get, "insurances/#{id}") EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end |