-
Notifications
You must be signed in to change notification settings - Fork 56
TSM-07: convert Group B services to TypeScript #564
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
Merged
Justin Hammond (Justintime50)
merged 6 commits into
ts-migrate/06-services-group-a
from
ts-migrate/07-services-group-b
Sep 1, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f807bec
TSM-07: convert Group B services to TypeScript
Justintime50 dcc398e
TSM-07: add permissive create parameter types for Group B services
Justintime50 80ccda3
TSM-07: convert Group B tests and beta/report services to TypeScript
Justintime50 1f8dc4f
TSM-07: add source-derived fixture type assertions in tests
Justintime50 9f7eada
TSM-07: type service return values to models and collections
Justintime50 b0fa98d
Apply lint fixes for TS service tests
Justintime50 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,4 +1,22 @@ | ||
| import baseService from './base_service'; | ||
| import Pickup from '../models/pickup'; | ||
|
|
||
| type PickupCreateParameters = Record<string, unknown> & { | ||
| address?: Record<string, unknown> | string | null; | ||
|
Comment on lines
+4
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought: interface BasePickupCreateParameters {
address: Address | string;
// ... |
||
| carrier_accounts?: Array<Record<string, unknown> | string> | null; | ||
| confirmation?: string | null; | ||
| instructions?: string | null; | ||
| is_account_address?: boolean | null; | ||
| max_datetime?: string | null; | ||
| min_datetime?: string | null; | ||
| pickup_rates?: Record<string, unknown> | null; | ||
| reference?: string | null; | ||
| status?: string | null; | ||
| shipment?: Record<string, unknown> | string | null; | ||
| batch?: Record<string, unknown> | string | null; | ||
| }; | ||
| type PickupCollection = Record<string, unknown>; | ||
| type PickupListResponse = { pickups: Pickup[]; has_more: boolean }; | ||
|
|
||
| export default (easypostClient) => | ||
| /** | ||
|
|
@@ -12,7 +30,7 @@ export default (easypostClient) => | |
| * @param {Object} params - The parameters to create a pickup with. | ||
| * @returns {Pickup} - The created pickup. | ||
| */ | ||
| static async create(params) { | ||
| static async create(params: PickupCreateParameters): Promise<Pickup> { | ||
| const url = 'pickups'; | ||
|
|
||
| const wrappedParams = { | ||
|
|
@@ -30,7 +48,7 @@ export default (easypostClient) => | |
| * @param {string} service - The service to purchase the pickup with. | ||
| * @returns {Pickup} - The purchased pickup. | ||
| */ | ||
| static async buy(id, carrier, service) { | ||
| static async buy(id: string, carrier: string, service: string): Promise<Pickup> { | ||
| const url = `pickups/${id}/buy`; | ||
| const wrappedParams = { carrier, service }; | ||
| try { | ||
|
|
@@ -48,7 +66,7 @@ export default (easypostClient) => | |
| * @param {string} id - The ID of the pickup to cancel. | ||
| * @returns {Pickup} - The cancelled pickup. | ||
| */ | ||
| static async cancel(id) { | ||
| static async cancel(id: string): Promise<Pickup> { | ||
| const url = `pickups/${id}/cancel`; | ||
| try { | ||
| const response = await easypostClient._post(url); | ||
|
|
@@ -65,7 +83,7 @@ export default (easypostClient) => | |
| * @param {Object} [params] - The parameters to filter the pickups by. | ||
| * @returns {Object} - An object containing a list of {@link Pickup pickups} and pagination information. | ||
| */ | ||
| static async all(params = {}) { | ||
| static async all(params: Record<string, unknown> = {}): Promise<PickupListResponse> { | ||
| const url = 'pickups'; | ||
|
|
||
| return this._all(url, params); | ||
|
|
@@ -77,7 +95,10 @@ export default (easypostClient) => | |
| * @param {Number} pageSize The number of records to return on each page | ||
| * @returns {EasyPostObject|Promise<never>} The retrieved {@link EasyPostObject}-based class instance, or a `Promise` that rejects with an error. | ||
| */ | ||
| static async getNextPage(pickups, pageSize = null) { | ||
| static async getNextPage( | ||
| pickups: PickupCollection, | ||
| pageSize: number | null = null, | ||
| ): Promise<PickupListResponse> { | ||
| const url = 'pickups'; | ||
| return this._getNextPage(url, 'pickups', pickups, pageSize); | ||
| } | ||
|
|
@@ -88,7 +109,7 @@ export default (easypostClient) => | |
| * @param {string} id - The ID of the pickup to retrieve. | ||
| * @returns {Pickup} - The retrieved pickup. | ||
| */ | ||
| static async retrieve(id) { | ||
| static async retrieve(id: string): Promise<Pickup> { | ||
| const url = `pickups/${id}`; | ||
|
|
||
| return this._retrieve(url); | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought:
These new types are still not as thorough as the old ones. For example, for the create batch params, here are the existing types in https://github.com/EasyPost/easypost-node/blob/master/types/Batch/BatchCreateParameters.d.ts:
Where shipment is a fully fleshed type listing the fields and their types.
I'm wondering if the plan is to eventually go through and use these existing types or if they should be reimplemented here? We are already importing the batch type. I wonder if we should import the create param here as well?