Skip to content

Commit 12eb390

Browse files
Justintime50claude
andauthored
feat: add a generic API request interface (#342)
# Description Adds a generic API request interface to make arbitrary API requests. <!-- Please provide a general summary of your PR changes and link any related issues or other pull requests. --> # Testing <!-- Please provide details on how you tested this code. See below. - All pull requests must be tested (unit tests where possible with accompanying cassettes, or provide a screenshot of end-to-end testing when unit tests are not possible) - New features must get a new unit test - Bug fixes/refactors must re-record existing cassettes --> # Pull Request Type Please select the option(s) that are relevant to this PR. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Improvement (fixing a typo, updating readme, renaming a variable name, etc) --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent afbb4d3 commit 12eb390

File tree

5 files changed

+98
-1
lines changed

5 files changed

+98
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## v7.6.0 (2026-02-25)
4+
5+
- Adds generic `make_api_call` function
6+
37
## v7.5.0 (2026-02-20)
48

59
- Adds the following functions:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.5.0
1+
7.6.0

lib/easypost/client.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ def unsubscribe_all_response_hooks
144144
EasyPost::Hooks.unsubscribe_all(:response)
145145
end
146146

147+
# Make an API call to the EasyPost API
148+
#
149+
# This public, generic interface is useful for making arbitrary API calls to the EasyPost API that
150+
# are not yet supported by the client library's services. When possible, the service for your use case
151+
# should be used instead as it provides a more convenient and higher-level interface depending on the endpoint.
152+
#
153+
# @param method [Symbol] the HTTP Verb (get, post, put, patch, delete, etc.)
154+
# @param endpoint [String] URI path of the resource
155+
# @param params [Object] (nil) object to be used as the request parameters
156+
# @return [EasyPost::Models::EasyPostObject] EasyPost object parsed from the response body
157+
def make_api_call(method, endpoint, params = nil)
158+
response = make_request(method, endpoint, params)
159+
160+
EasyPost::InternalUtilities::Json.convert_json_to_object(response)
161+
end
162+
147163
private
148164

149165
def http_config

spec/cassettes/client/EasyPost_Client_client_object_make_an_API_call_using_the_generic_make_api_call_method.yml

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/client_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,14 @@
233233
expect(EasyPost::Hooks.any_subscribers?(:response)).to eq(false)
234234
end
235235
end
236+
237+
it 'make an API call using the generic make_api_call method', :vcr do
238+
client = described_class.new(api_key: ENV['EASYPOST_TEST_API_KEY'])
239+
240+
response = client.make_api_call(:get, '/addresses', { page_size: 1 })
241+
242+
expect(response['addresses'].length).to eq(1)
243+
expect(response['addresses'][0]['object']).to eq('Address')
244+
end
236245
end
237246
end

0 commit comments

Comments
 (0)