Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add library hooks #277

Merged
merged 4 commits into from
Jul 7, 2023
Merged

[Feature] Add library hooks #277

merged 4 commits into from
Jul 7, 2023

Conversation

jchen293
Copy link
Member

@jchen293 jchen293 commented Jul 5, 2023

Description

  • Adds new RequestHook and ResponseHook classes. (un)subscribe to them with the new subscribeToRequestHook, subscribeToResponseHook, unsubscribeFromRequestHook, or unsubscribeFromResponseHook methods of an EasyPostClient

Testing

Add new unit tests

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)

@jchen293 jchen293 changed the title Library hook [Feature] Add library hooks Jul 5, 2023
@jchen293 jchen293 marked this pull request as ready for review July 5, 2023 22:02
@jchen293 jchen293 requested a review from a team July 5, 2023 22:02
@jchen293 jchen293 requested a review from nwithan8 July 5, 2023 22:18
@jchen293 jchen293 merged commit c724afc into master Jul 7, 2023
16 checks passed
@jchen293 jchen293 deleted the library_hook branch July 7, 2023 18:05
Comment on lines +62 to +71
public static Object testRequestHooks(RequestHookResponses datas) {
assertEquals("https://api.easypost.com/v2/parcels", datas.getPath());
assertEquals("POST", datas.getMethod());
assertNotNull(datas.getHeaders());
assertNotNull(datas.getRequestBody());
assertNotNull(datas.getRequestTimestamp());
assertNotNull(datas.getRequestUuid());

return true;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see a follow-up PR where we rename datas to data. People will use tests as an example and datas plural doesn't make sense.

Same with RequestHookResponses should not be plural and be RequestHookResponse instead

*/
@Test
public void testCreateParcelWithRequestHook() throws EasyPostException {
vcr.setUpTest("create");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like if we renamed the create to something different since we aren't really creating a hook but are instead capturing the details of a request that we hooked into. Renaming the cassette will help reduce confusion about its purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants