Skip to content

Commit

Permalink
add allChildren and getNextPage functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen293 committed Dec 11, 2023
1 parent 7e5526a commit f68bf30
Show file tree
Hide file tree
Showing 6 changed files with 405 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## Next release

- Adds `allChildren` function in User service to get a paginated list of children
- Adds `getNextPage` function in User service to get next paginated list of children

## v7.0.0 (2023-12-06)

- Removes `withCarbonOffset` parameter from shipment create and buy functions
Expand Down
29 changes: 29 additions & 0 deletions src/services/user_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,33 @@ export default (easypostClient) =>
return Promise.reject(e);
}
}

/**
* Retrieve a paginated list of children user {@link User user}.
* See {@link https://www.easypost.com/docs/api/node#child-users EasyPost API Documentation} for more information.
* @param {Object} params - Parameters to filter the list of children users.
* @returns {Object} - An object containing a list of {@link Children User} and pagination information.
*/
static async allChildren(params) {
const url = 'beta/users/children'; // TODO: Use GA endpoint

try {
const response = await easypostClient._get(url, params);

return this._convertToEasyPostObject(response.body, params);
} catch (e) {
return Promise.reject(e);
}
}

/**
* Retrieve the next page of children collection.
* @param {Object} children An object containing a list of {@link Children children} and pagination information.
* @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(children, pageSize = null) {
const url = 'beta/users/children'; // TODO: Use GA endpoint
return this._getNextPage(url, 'children', children, pageSize);
}
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f68bf30

Please sign in to comment.