Skip to content

Commit

Permalink
changed request params
Browse files Browse the repository at this point in the history
  • Loading branch information
doljko committed Jan 30, 2024
1 parent 4ebf456 commit d079d6d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/@fleetbase/sdk.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/@fleetbase/sdk.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/fleetbase.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/fleetbase.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/fleetbase.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/fleetbase.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/sdk",
"version": "1.2.7",
"version": "1.2.8",
"description": "Fleetbase JS & Node SDK",
"main": "dist/cjs/fleetbase.js",
"module": "dist/esm/fleetbase.js",
Expand All @@ -19,7 +19,10 @@
"dev": "rollup -c -w",
"test": "mocha --require @babel/polyfill --require @babel/register --require source-map-support/register tests/*.test.js",
"prepare": "husky install",
"format": "prettier . --write"
"format": "prettier . --write",
"publish-verdaccio": "npm publish --registry http://localhost:4873",
"unpublish-verdaccio": "npm unpublish --registry http://localhost:4873 --force",
"reset-verdaccio": "pnpm unpublish-verdaccio && pnpm publish-verdaccio"
},
"author": "Ronald A. Richardson <ron@fleetbase.io> (https://ron.dev)",
"license": "BSD-3-Clause",
Expand Down
18 changes: 15 additions & 3 deletions src/resources/driver.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import Resource from '../resource';
import { StoreActions, isPhone, isEmail } from '../utils';
import Organization from './organization';
import { StoreActions, isPhone, Collection } from '../utils';
import { isArray } from '../utils/array';

const serializeOrganizations = (response, adapter) => {
if (isArray(response)) {
return response.map((organizationJson) => {
return new Organization(organizationJson, adapter);
});
}

return new Organization(response, adapter);
};

const driverActions = new StoreActions({
// const { error } = await fleetbase.drivers.login('+1 111-1111');
Expand All @@ -25,11 +37,11 @@ const driverActions = new StoreActions({
},

listOrganizations: function (id, params = {}, options = {}) {
return this.adapter.post(`drivers/${id}/list-organizations`, params, options).then(this.afterFetch.bind(this));
return this.adapter.get(`drivers/${id}/organizations`, params, options).then((response) => serializeOrganizations(response, this.adapter));
},

switchOrganization: function (id, params = {}, options = {}) {
return this.adapter.post(`drivers/${id}/switch-organization`, params, options).then(this.afterFetch.bind(this));
return this.adapter.post(`drivers/${id}/switch-organization`, params, options).then((response) => serializeOrganizations(response, this.adapter));
},

retrieve: function (id) {
Expand Down

0 comments on commit d079d6d

Please sign in to comment.