Skip to content

Commit

Permalink
Add allChildren and getNextPage functions (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen293 authored Jan 4, 2024
1 parent 7e5526a commit f6849ed
Show file tree
Hide file tree
Showing 6 changed files with 401 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 = 'users/children';

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 = 'users/children';
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 f6849ed

Please sign in to comment.