@insignia-education/api-sdk-js 0.9.22 → 0.9.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insignia-education/api-sdk-js",
3
- "version": "0.9.22",
3
+ "version": "0.9.23",
4
4
  "description": "JavaScript SDK for the Insignia Education API",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -5,7 +5,14 @@ export default class Courses {
5
5
  this.#client = client;
6
6
  }
7
7
 
8
- get(id = null) { return id ? this.#client.get(`/courses/${id}`) : this.#client.get('/courses'); }
8
+ get(id = null, { page = null, perPage = null } = {}) {
9
+ if (id) return this.#client.get(`/courses/${id}`);
10
+ const params = new URLSearchParams();
11
+ if (page) params.set('page', page);
12
+ if (perPage) params.set('per_page', perPage);
13
+ const qs = params.toString();
14
+ return this.#client.get(qs ? `/courses?${qs}` : '/courses');
15
+ }
9
16
  create(data) { return this.#client.put('/courses', data); }
10
17
  edit(id, data) { return this.#client.patch(`/courses/${id}`, data); }
11
18
  delete(id) { return this.#client.del(`/courses/${id}`); }
@@ -236,8 +236,11 @@ describe('Courses', () => {
236
236
  let c, r;
237
237
  beforeEach(() => { c = mockClient(); r = new Courses(c); });
238
238
 
239
- test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/courses'); });
240
- test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/courses/1'); });
239
+ test('get all', () => { r.get(); expect(c.get).toHaveBeenCalledWith('/courses'); });
240
+ test('get all with page', () => { r.get(null, { page: 2 }); expect(c.get).toHaveBeenCalledWith('/courses?page=2'); });
241
+ test('get all with perPage', () => { r.get(null, { perPage: 25 }); expect(c.get).toHaveBeenCalledWith('/courses?per_page=25'); });
242
+ test('get all with both', () => { r.get(null, { page: 2, perPage: 25 }); expect(c.get).toHaveBeenCalledWith('/courses?page=2&per_page=25'); });
243
+ test('get by id', () => { r.get(1); expect(c.get).toHaveBeenCalledWith('/courses/1'); });
241
244
  test('create', () => { r.create({}); expect(c.put).toHaveBeenCalledWith('/courses', {}); });
242
245
  test('edit', () => { r.edit(1, {}); expect(c.patch).toHaveBeenCalledWith('/courses/1', {}); });
243
246
  test('delete', () => { r.delete(1); expect(c.del).toHaveBeenCalledWith('/courses/1'); });
@@ -123,3 +123,16 @@ describe('PaymentMethods', () => {
123
123
  });
124
124
  });
125
125
 
126
+ describe('users/cash-receivers', () => {
127
+ test('get By currency id() returns a list', async () => {
128
+ await api.users.cashReceivers()
129
+ .then(response => {
130
+ expect(response.length > 0).toBe(true);
131
+ response.forEach(user => {
132
+ expect(user["id"]).toBeDefined();
133
+ expect(user["name"]).toBeDefined();
134
+ })
135
+ })
136
+ });
137
+ });
138
+