-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add claims API functions * Switch to GA * rename variable
- Loading branch information
Showing
16 changed files
with
1,151 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
# The Claim object has all the details for the filed claims | ||
class EasyPost::Models::Claim < EasyPost::Models::EasyPostObject | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
class EasyPost::Services::Claim < EasyPost::Services::Service | ||
MODEL_CLASS = EasyPost::Models::Claim | ||
|
||
# Create an Claim object | ||
def create(params = {}) | ||
response = @client.make_request(:post, 'claims', params) | ||
|
||
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) | ||
end | ||
|
||
# Retrieve an Claim object | ||
def retrieve(id) | ||
response = @client.make_request(:get, "claims/#{id}", nil) | ||
|
||
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) | ||
end | ||
|
||
# Retrieve all Claim objects | ||
def all(params = {}) | ||
filters = { key: 'claims' } | ||
|
||
get_all_helper('claims', MODEL_CLASS, params, filters) | ||
end | ||
|
||
# Get the next page of claims. | ||
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 | ||
|
||
# Cancel a filed claim | ||
def cancel(id) | ||
response = @client.make_request(:post, "claims/#{id}/cancel", nil) | ||
|
||
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
spec/cassettes/claim/EasyPost_Services_Claim_all_retrieves_all_claim_objects.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.