@allthings/sdk
Advanced tools
Comparing version 0.1.0-8 to 0.1.0-9
@@ -372,3 +372,3 @@ #!/usr/bin/env node | ||
]; | ||
function restSdk(userOptions = DEFAULT_API_WRAPPER_OPTIONS) { | ||
function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) { | ||
const options = Object.assign({}, DEFAULT_API_WRAPPER_OPTIONS, userOptions); | ||
@@ -388,3 +388,3 @@ if (!options.clientId && !options.accessToken) { | ||
}; | ||
return API_METHODS.reduce((methods, method) => (Object.assign({}, methods, { [method.name]: partial(method, methodNameToHttpVerbMap[method.name.substr(0, 6)] || get$$1) })), { del: del$$1, get: get$$1, patch: patch$$1, post: post$$1 }); | ||
return API_METHODS.reduce((methods, method) => (Object.assign({}, methods, { [method.name]: partial(method, methodNameToHttpVerbMap[method.name.substr(0, 6)] || get$$1) })), { delete: del$$1, get: get$$1, patch: patch$$1, post: post$$1 }); | ||
} | ||
@@ -400,4 +400,17 @@ | ||
})(EnumResource || (EnumResource = {})); | ||
var EnumCountryCode; | ||
(function (EnumCountryCode) { | ||
EnumCountryCode["CH"] = "CH"; | ||
EnumCountryCode["DE"] = "DE"; | ||
EnumCountryCode["FR"] = "FR"; | ||
EnumCountryCode["IT"] = "IT"; | ||
EnumCountryCode["NL"] = "NL"; | ||
EnumCountryCode["PT"] = "PT"; | ||
EnumCountryCode["US"] = "US"; | ||
})(EnumCountryCode || (EnumCountryCode = {})); | ||
var EnumLocale; | ||
(function (EnumLocale) { | ||
EnumLocale["ch_de"] = "ch_DE"; | ||
EnumLocale["ch_fr"] = "ch_FR"; | ||
EnumLocale["ch_it"] = "ch_it"; | ||
EnumLocale["de_DE"] = "de_DE"; | ||
@@ -409,9 +422,17 @@ EnumLocale["it_IT"] = "it_IT"; | ||
})(EnumLocale || (EnumLocale = {})); | ||
var EnumTimezone; | ||
(function (EnumTimezone) { | ||
EnumTimezone["EuropeBerlin"] = "Europe/Berlin"; | ||
EnumTimezone["EuropeLondon"] = "Europe/London"; | ||
EnumTimezone["EuropeSofia"] = "Europe/Sofia"; | ||
EnumTimezone["EuropeZurich"] = "Europe/Zurich"; | ||
EnumTimezone["UTC"] = "UTC"; | ||
})(EnumTimezone || (EnumTimezone = {})); | ||
async function main() { | ||
const [, , action, ...args] = process.argv; | ||
const restClient = restSdk(); | ||
const client = restClient(); | ||
console.log('\n\n', args); | ||
if (action === 'list-active-users') { | ||
console.log(await restClient.getCurrentUser()); | ||
console.log(await client.getCurrentUser()); | ||
} | ||
@@ -418,0 +439,0 @@ else { |
@@ -368,3 +368,3 @@ 'use strict'; | ||
]; | ||
function restSdk(userOptions = DEFAULT_API_WRAPPER_OPTIONS) { | ||
function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) { | ||
const options = Object.assign({}, DEFAULT_API_WRAPPER_OPTIONS, userOptions); | ||
@@ -384,3 +384,3 @@ if (!options.clientId && !options.accessToken) { | ||
}; | ||
return API_METHODS.reduce((methods, method) => (Object.assign({}, methods, { [method.name]: partial(method, methodNameToHttpVerbMap[method.name.substr(0, 6)] || get$$1) })), { del: del$$1, get: get$$1, patch: patch$$1, post: post$$1 }); | ||
return API_METHODS.reduce((methods, method) => (Object.assign({}, methods, { [method.name]: partial(method, methodNameToHttpVerbMap[method.name.substr(0, 6)] || get$$1) })), { delete: del$$1, get: get$$1, patch: patch$$1, post: post$$1 }); | ||
} | ||
@@ -395,3 +395,15 @@ | ||
})(exports.EnumResource || (exports.EnumResource = {})); | ||
(function (EnumCountryCode) { | ||
EnumCountryCode["CH"] = "CH"; | ||
EnumCountryCode["DE"] = "DE"; | ||
EnumCountryCode["FR"] = "FR"; | ||
EnumCountryCode["IT"] = "IT"; | ||
EnumCountryCode["NL"] = "NL"; | ||
EnumCountryCode["PT"] = "PT"; | ||
EnumCountryCode["US"] = "US"; | ||
})(exports.EnumCountryCode || (exports.EnumCountryCode = {})); | ||
(function (EnumLocale) { | ||
EnumLocale["ch_de"] = "ch_DE"; | ||
EnumLocale["ch_fr"] = "ch_FR"; | ||
EnumLocale["ch_it"] = "ch_it"; | ||
EnumLocale["de_DE"] = "de_DE"; | ||
@@ -403,3 +415,10 @@ EnumLocale["it_IT"] = "it_IT"; | ||
})(exports.EnumLocale || (exports.EnumLocale = {})); | ||
(function (EnumTimezone) { | ||
EnumTimezone["EuropeBerlin"] = "Europe/Berlin"; | ||
EnumTimezone["EuropeLondon"] = "Europe/London"; | ||
EnumTimezone["EuropeSofia"] = "Europe/Sofia"; | ||
EnumTimezone["EuropeZurich"] = "Europe/Zurich"; | ||
EnumTimezone["UTC"] = "UTC"; | ||
})(exports.EnumTimezone || (exports.EnumTimezone = {})); | ||
exports.restSdk = restSdk; | ||
exports.restClient = restClient; |
@@ -366,3 +366,3 @@ import { generate } from 'shortid'; | ||
]; | ||
function restSdk(userOptions = DEFAULT_API_WRAPPER_OPTIONS) { | ||
function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) { | ||
const options = Object.assign({}, DEFAULT_API_WRAPPER_OPTIONS, userOptions); | ||
@@ -382,3 +382,3 @@ if (!options.clientId && !options.accessToken) { | ||
}; | ||
return API_METHODS.reduce((methods, method) => (Object.assign({}, methods, { [method.name]: partial(method, methodNameToHttpVerbMap[method.name.substr(0, 6)] || get$$1) })), { del: del$$1, get: get$$1, patch: patch$$1, post: post$$1 }); | ||
return API_METHODS.reduce((methods, method) => (Object.assign({}, methods, { [method.name]: partial(method, methodNameToHttpVerbMap[method.name.substr(0, 6)] || get$$1) })), { delete: del$$1, get: get$$1, patch: patch$$1, post: post$$1 }); | ||
} | ||
@@ -394,4 +394,17 @@ | ||
})(EnumResource || (EnumResource = {})); | ||
var EnumCountryCode; | ||
(function (EnumCountryCode) { | ||
EnumCountryCode["CH"] = "CH"; | ||
EnumCountryCode["DE"] = "DE"; | ||
EnumCountryCode["FR"] = "FR"; | ||
EnumCountryCode["IT"] = "IT"; | ||
EnumCountryCode["NL"] = "NL"; | ||
EnumCountryCode["PT"] = "PT"; | ||
EnumCountryCode["US"] = "US"; | ||
})(EnumCountryCode || (EnumCountryCode = {})); | ||
var EnumLocale; | ||
(function (EnumLocale) { | ||
EnumLocale["ch_de"] = "ch_DE"; | ||
EnumLocale["ch_fr"] = "ch_FR"; | ||
EnumLocale["ch_it"] = "ch_it"; | ||
EnumLocale["de_DE"] = "de_DE"; | ||
@@ -403,3 +416,11 @@ EnumLocale["it_IT"] = "it_IT"; | ||
})(EnumLocale || (EnumLocale = {})); | ||
var EnumTimezone; | ||
(function (EnumTimezone) { | ||
EnumTimezone["EuropeBerlin"] = "Europe/Berlin"; | ||
EnumTimezone["EuropeLondon"] = "Europe/London"; | ||
EnumTimezone["EuropeSofia"] = "Europe/Sofia"; | ||
EnumTimezone["EuropeZurich"] = "Europe/Zurich"; | ||
EnumTimezone["UTC"] = "UTC"; | ||
})(EnumTimezone || (EnumTimezone = {})); | ||
export { restSdk, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, EnumResource, EnumLocale }; | ||
export { restClient, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, EnumCountryCode, EnumLocale, EnumResource, EnumTimezone }; |
#!/usr/bin/env node | ||
import { restSdk } from './'; | ||
import { restClient } from '.'; | ||
export async function main() { | ||
const [, , action, ...args] = process.argv; | ||
const restClient = restSdk(); | ||
const client = restClient(); | ||
console.log('\n\n', args); | ||
if (action === 'list-active-users') { | ||
console.log(await restClient.getCurrentUser()); | ||
console.log(await client.getCurrentUser()); | ||
} | ||
@@ -10,0 +10,0 @@ else { |
@@ -1,2 +0,2 @@ | ||
export { default as restSdk, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, } from './rest'; | ||
export { EnumResource, EnumLocale, InterfaceAllthingsRestClient, InterfaceAllthingsRestClientOptions, } from './rest/types'; | ||
export { default as restClient, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, } from './rest'; | ||
export { EnumCountryCode, EnumLocale, EnumResource, EnumTimezone, InterfaceAllthingsRestClient, InterfaceAllthingsRestClientOptions, } from './rest/types'; |
@@ -1,2 +0,2 @@ | ||
export { default as restSdk, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, } from './rest'; | ||
export { EnumResource, EnumLocale, } from './rest/types'; | ||
export { default as restClient, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, } from './rest'; | ||
export { EnumCountryCode, EnumLocale, EnumResource, EnumTimezone, } from './rest/types'; |
@@ -5,2 +5,2 @@ import { EnumUnitType } from './methods/unit'; | ||
export { EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole }; | ||
export default function restSdk(userOptions?: InterfaceAllthingsRestClientOptions): InterfaceAllthingsRestClient; | ||
export default function restClient(userOptions?: InterfaceAllthingsRestClientOptions): InterfaceAllthingsRestClient; |
@@ -45,3 +45,3 @@ import { DEFAULT_API_WRAPPER_OPTIONS } from '../constants'; | ||
export { EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole }; | ||
export default function restSdk(userOptions = DEFAULT_API_WRAPPER_OPTIONS) { | ||
export default function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) { | ||
const options = Object.assign({}, DEFAULT_API_WRAPPER_OPTIONS, userOptions); | ||
@@ -61,3 +61,3 @@ if (!options.clientId && !options.accessToken) { | ||
}; | ||
return API_METHODS.reduce((methods, method) => (Object.assign({}, methods, { [method.name]: partial(method, methodNameToHttpVerbMap[method.name.substr(0, 6)] || get) })), { del, get, patch, post }); | ||
return API_METHODS.reduce((methods, method) => (Object.assign({}, methods, { [method.name]: partial(method, methodNameToHttpVerbMap[method.name.substr(0, 6)] || get) })), { delete: del, get, patch, post }); | ||
} |
@@ -1,2 +0,2 @@ | ||
import restApi from './'; | ||
import restApi from '.'; | ||
const mockAccessToken = 'foobar-token'; | ||
@@ -3,0 +3,0 @@ const mockClientId = 'foobar-clientId'; |
import { MethodHttpGet } from '../get'; | ||
import { MethodHttpPatch } from '../patch'; | ||
import { MethodHttpPost } from '../post'; | ||
import { EnumCountryCode } from '../types'; | ||
export interface IGroup { | ||
readonly address: Partial<{ | ||
readonly city: string | null; | ||
readonly country: string | null; | ||
readonly country: EnumCountryCode | null; | ||
readonly houseNumber: string | null; | ||
@@ -9,0 +10,0 @@ readonly latitude: number | null; |
import { generate as generateId } from 'shortid'; | ||
import restApi from '..'; | ||
import { APP_ID, APP_PROPERTY_MANAGER_ID } from '../../../test/constants'; | ||
import { EnumCountryCode, EnumTimezone } from '../types'; | ||
const api = restApi(); | ||
const testPropertyData = { | ||
name: 'Foobar Group Property', | ||
timezone: 'Europe/Berlin', | ||
timezone: EnumTimezone.EuropeBerlin, | ||
}; | ||
@@ -13,2 +14,9 @@ const testData = { | ||
}; | ||
const testAddressData = { | ||
city: 'Springfield', | ||
country: EnumCountryCode.DE, | ||
houseNumber: '742', | ||
postalCode: '1111', | ||
street: 'Evergreen Terrace', | ||
}; | ||
describe('createGroup()', () => { | ||
@@ -41,2 +49,3 @@ it('should be able to create a new group', async () => { | ||
const updateData = { | ||
address: Object.assign({}, testAddressData), | ||
description: 'Bio Vegan Gluten Free Group', | ||
@@ -46,2 +55,3 @@ externalId: generateId(), | ||
const result = await api.updateGroupById(group.id, updateData); | ||
expect(result.address.country).toEqual(EnumCountryCode.DE); | ||
expect(result.description).toEqual(updateData.description); | ||
@@ -48,0 +58,0 @@ expect(result.externalId).toEqual(updateData.externalId); |
@@ -5,2 +5,5 @@ import { MethodHttpGet } from '../get'; | ||
export interface IUtilisationPeriod { | ||
readonly _embedded: { | ||
readonly invitations: ReadonlyArray<any>; | ||
}; | ||
readonly endDate: string | null; | ||
@@ -7,0 +10,0 @@ readonly externalId: string | null; |
@@ -21,3 +21,15 @@ import { MethodHttpDelete } from './delete'; | ||
} | ||
export declare enum EnumCountryCode { | ||
CH = "CH", | ||
DE = "DE", | ||
FR = "FR", | ||
IT = "IT", | ||
NL = "NL", | ||
PT = "PT", | ||
US = "US" | ||
} | ||
export declare enum EnumLocale { | ||
ch_de = "ch_DE", | ||
ch_fr = "ch_FR", | ||
ch_it = "ch_it", | ||
de_DE = "de_DE", | ||
@@ -29,2 +41,9 @@ it_IT = "it_IT", | ||
} | ||
export declare enum EnumTimezone { | ||
EuropeBerlin = "Europe/Berlin", | ||
EuropeLondon = "Europe/London", | ||
EuropeSofia = "Europe/Sofia", | ||
EuropeZurich = "Europe/Zurich", | ||
UTC = "UTC" | ||
} | ||
export interface InterfaceAllthingsRestClientOptions { | ||
@@ -31,0 +50,0 @@ readonly accessToken?: string; |
@@ -9,4 +9,17 @@ export var EnumResource; | ||
})(EnumResource || (EnumResource = {})); | ||
export var EnumCountryCode; | ||
(function (EnumCountryCode) { | ||
EnumCountryCode["CH"] = "CH"; | ||
EnumCountryCode["DE"] = "DE"; | ||
EnumCountryCode["FR"] = "FR"; | ||
EnumCountryCode["IT"] = "IT"; | ||
EnumCountryCode["NL"] = "NL"; | ||
EnumCountryCode["PT"] = "PT"; | ||
EnumCountryCode["US"] = "US"; | ||
})(EnumCountryCode || (EnumCountryCode = {})); | ||
export var EnumLocale; | ||
(function (EnumLocale) { | ||
EnumLocale["ch_de"] = "ch_DE"; | ||
EnumLocale["ch_fr"] = "ch_FR"; | ||
EnumLocale["ch_it"] = "ch_it"; | ||
EnumLocale["de_DE"] = "de_DE"; | ||
@@ -18,1 +31,9 @@ EnumLocale["it_IT"] = "it_IT"; | ||
})(EnumLocale || (EnumLocale = {})); | ||
export var EnumTimezone; | ||
(function (EnumTimezone) { | ||
EnumTimezone["EuropeBerlin"] = "Europe/Berlin"; | ||
EnumTimezone["EuropeLondon"] = "Europe/London"; | ||
EnumTimezone["EuropeSofia"] = "Europe/Sofia"; | ||
EnumTimezone["EuropeZurich"] = "Europe/Zurich"; | ||
EnumTimezone["UTC"] = "UTC"; | ||
})(EnumTimezone || (EnumTimezone = {})); |
{ | ||
"name": "@allthings/sdk", | ||
"version": "0.1.0-8", | ||
"version": "0.1.0-9", | ||
"description": "", | ||
@@ -56,3 +56,3 @@ "author": "Allthings GmbH", | ||
"dependencies": { | ||
"bottleneck": "2.5.0", | ||
"bottleneck": "2.5.1", | ||
"got": "8.3.1", | ||
@@ -67,13 +67,13 @@ "mem": "3.0.1", | ||
"@types/got": "8.3.1", | ||
"@types/jest": "23.1.2", | ||
"@types/jest": "23.1.4", | ||
"@types/mem": "1.1.2", | ||
"@types/node": "10.3.6", | ||
"@types/node": "10.5.1", | ||
"@types/shortid": "0.0.29", | ||
"coveralls": "3.0.1", | ||
"coveralls": "3.0.2", | ||
"husky": "0.14.3", | ||
"jest": "23.2.0", | ||
"jest": "23.3.0", | ||
"lint-staged": "7.2.0", | ||
"nsp": "3.2.1", | ||
"nyc": "12.0.2", | ||
"prettier": "1.13.6", | ||
"prettier": "1.13.7", | ||
"rimraf": "2.6.2", | ||
@@ -85,3 +85,3 @@ "rollup": "0.62.0", | ||
"rollup-plugin-node-resolve": "3.3.0", | ||
"semantic-release": "15.6.0", | ||
"semantic-release": "15.6.3", | ||
"ts-jest": "22.4.6", | ||
@@ -88,0 +88,0 @@ "tslint": "5.10.0", |
@@ -16,3 +16,3 @@ Allthings Node/Javascript SDK | ||
```sh | ||
yarn add @allthings/sdk | ||
yarn add allthings | ||
``` | ||
@@ -23,3 +23,3 @@ | ||
const client = allthings.restSdk({ | ||
const client = allthings.restClient({ | ||
accessToken: '043dab7447450772example1214b552838003522', | ||
@@ -71,3 +71,3 @@ }) | ||
const client = allthings.restSdk({ | ||
const client = allthings.restClient({ | ||
accessToken: '043dab7447450772example1214b552838003522', | ||
@@ -88,37 +88,37 @@ }) | ||
* [`restSdk()`](#module-export-restSdk) | ||
* [`client.createAgent()`](#restsdk-client-createagent) | ||
* [`client.createAgentPermissions()`](#restsdk-client-createagent) | ||
* [`client.createApp()`](#restsdk-client-createagent) | ||
* [`client.createIdLookup()`](#restsdk-client-createagent) | ||
* [`client.createGroup()`](#restsdk-client-createagent) | ||
* [`client.getGroupById()`](#restsdk-client-createagent) | ||
* [`client.updateGroupById()`](#restsdk-client-createagent) | ||
* [`client.createProperty()`](#restsdk-client-createagent) | ||
* [`client.getPropertyById()`](#restsdk-client-createagent) | ||
* [`client.updatePropertyById()`](#restsdk-client-createagent) | ||
* [`client.createRegistrationCode()`](#restsdk-client-createagent) | ||
* [`client.createUnit()`](#restsdk-client-createagent) | ||
* [`client.getUnitById()`](#restsdk-client-createagent) | ||
* [`client.createUser()`](#restsdk-client-createagent) | ||
* [`client.createUserPermission()`](#restsdk-client-createagent) | ||
* [`client.deleteUserPermission()`](#restsdk-client-createagent) | ||
* [`client.getUsers()`](#restsdk-client-createagent) | ||
* [`client.getCurrentUser()`](#restsdk-client-createagent) | ||
* [`client.getUserById()`](#restsdk-client-createagent) | ||
* [`client.getUserPermissions()`](#restsdk-client-createagent) | ||
* [`client.updateUserById()`](#restsdk-client-createagent) | ||
* [`client.createUtilisationPeriod()`](#restsdk-client-createagent) | ||
* [`client.getUtilisationPeriodById()`](#restsdk-client-createagent) | ||
* [`client.updateUtilisationPeriodById()`](#restsdk-client-createagent) | ||
* [`client.delete()`](#restsdk-client-delete) | ||
* [`client.get()`](#restsdk-client-get) | ||
* [`client.post()`](#restsdk-client-post) | ||
* [`client.patch()`](#restsdk-client-patch) | ||
* [`restClient()`](#module-export-restClient) | ||
* [`client.createAgent()`](#restclient-client-createagent) | ||
* [`client.createAgentPermissions()`](#restclient-client-createagent) | ||
* [`client.createApp()`](#restclient-client-createagent) | ||
* [`client.createIdLookup()`](#restclient-client-createagent) | ||
* [`client.createGroup()`](#restclient-client-createagent) | ||
* [`client.getGroupById()`](#restclient-client-createagent) | ||
* [`client.updateGroupById()`](#restclient-client-createagent) | ||
* [`client.createProperty()`](#restclient-client-createagent) | ||
* [`client.getPropertyById()`](#restclient-client-createagent) | ||
* [`client.updatePropertyById()`](#restclient-client-createagent) | ||
* [`client.createRegistrationCode()`](#restclient-client-createagent) | ||
* [`client.createUnit()`](#restclient-client-createagent) | ||
* [`client.getUnitById()`](#restclient-client-createagent) | ||
* [`client.createUser()`](#restclient-client-createagent) | ||
* [`client.createUserPermission()`](#restclient-client-createagent) | ||
* [`client.deleteUserPermission()`](#restclient-client-createagent) | ||
* [`client.getUsers()`](#restclient-client-createagent) | ||
* [`client.getCurrentUser()`](#restclient-client-createagent) | ||
* [`client.getUserById()`](#restclient-client-createagent) | ||
* [`client.getUserPermissions()`](#restclient-client-createagent) | ||
* [`client.updateUserById()`](#restclient-client-createagent) | ||
* [`client.createUtilisationPeriod()`](#restclient-client-createagent) | ||
* [`client.getUtilisationPeriodById()`](#restclient-client-createagent) | ||
* [`client.updateUtilisationPeriodById()`](#restclient-client-createagent) | ||
* [`client.delete()`](#restclient-client-delete) | ||
* [`client.get()`](#restclient-client-get) | ||
* [`client.post()`](#restclient-client-post) | ||
* [`client.patch()`](#restclient-client-patch) | ||
--- | ||
<a name="module-export-restSdk" /> | ||
<a name="module-export-restclient" /> | ||
### restSdk(configurationOptions?): Client | ||
### restClient(configurationOptions?): Client | ||
@@ -130,3 +130,3 @@ Create an client instance of the SDK. | ||
const client = allthings.restSdk(configurationOptions) | ||
const client = allthings.restClient(configurationOptions) | ||
``` | ||
@@ -136,3 +136,3 @@ | ||
<a name="restsdk-client-createagent" /> | ||
<a name="restclient-client-createagent" /> | ||
@@ -139,0 +139,0 @@ ### client.createAgent() |
132888
2650
+ Addedbottleneck@2.5.1(transitive)
- Removedbottleneck@2.5.0(transitive)
Updatedbottleneck@2.5.1