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