Skip to content

Commit

Permalink
Updating token constant
Browse files Browse the repository at this point in the history
Signed-off-by: wambuipixel <[email protected]>
  • Loading branch information
wambui-pixel committed Apr 5, 2024
1 parent cb15cbd commit 0a6a5f6
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 113 deletions.
4 changes: 4 additions & 0 deletions examples/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const mySdk = new SDK({
usersUrl: defaultUrl + ':9002'
})

// Channels.ts examples.

const token = '<token>'

mySdk.channels
.CreateChannel({ name: '<channelId>' }, '<token>')
.then((response: any) => {
Expand Down
49 changes: 20 additions & 29 deletions examples/things.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ const mySdk = new SDK({
usersUrl: defaultUrl + ':9002'
})

// Things.js examples.
// Things.ts examples.

const token = '<token>'

mySdk.things
.Create(
{ name: '<thingName>' }, '<token>'
{ name: '<thingName>' }, token
)
.then((response: any) => {
console.log('response:', response)
Expand All @@ -22,18 +24,7 @@ mySdk.things
})

mySdk.things
.GetAll({ offset: 0, limit: 10 }, '<token>')

.then((response: any) => {
console.log('response:', response)
})

.catch((error) => {
console.log(error)
})

mySdk.things
.Disable({ id: '<thingId>' }, '<token>')
.Disable({ id: '<thingId>' }, token)
.then((response: any) => {
console.log('response:', response)
})
Expand All @@ -42,7 +33,7 @@ mySdk.things
})

mySdk.things
.Enable({ id: '<thingId>' }, '<token>')
.Enable({ id: '<thingId>' }, token)
.then((response: any) => {
console.log('response:', response)
})
Expand All @@ -51,8 +42,8 @@ mySdk.things
})

mySdk.things
.Update(
{ id: '<thingId>', name: '<thingName>' }, '<token>')
.UpdateThing(
{ id: '<thingId>', name: '<thingName>' }, token)
.then((response: any) => {
console.log('response:', response)
})
Expand All @@ -61,7 +52,7 @@ mySdk.things
})

mySdk.things
.UpdateThingSecret({ id: '<thingId>', credentials: { secret: 'newSecret' } }, '<token>'
.UpdateThingSecret({ id: '<thingId>', credentials: { secret: 'newSecret' } }, token
)
.then((response: any) => {
console.log(response)
Expand All @@ -73,7 +64,7 @@ mySdk.things
mySdk.things
.UpdateThingTags(
{ id: '<thingId>', tags: ['<tag1>', '<tag2>'] },
'<token>'
token
)
.then((response: any) => {
console.log(response)
Expand All @@ -83,7 +74,7 @@ mySdk.things
})

mySdk.things
.ThingsByChannel({ id: '<thingId>' }, { offset: 0, limit: 5 }, '<token>')
.ThingsByChannel('<channelId>', { offset: 0, limit: 5 }, token)
.then((response: any) => {
console.log(response)
})
Expand All @@ -92,7 +83,7 @@ mySdk.things
})

mySdk.things
.Things({ offset: 0, limit: 10 }, '<token>')
.Things({ offset: 0, limit: 10 }, token)
.then((response: any) => {
console.log('response:', response)
})
Expand All @@ -101,7 +92,7 @@ mySdk.things
})

mySdk.things
.Thing('<thingId>', '<token>')
.Thing('<thingId>', token)
.then((response: any) => {
console.log('response: ', response)
})
Expand All @@ -110,7 +101,7 @@ mySdk.things
})

mySdk.things
.ThingsPermissions('<thingId>', '<token>')
.ThingsPermissions('<thingId>', token)
.then((response: any) => {
console.log('response: ', response)
})
Expand All @@ -131,10 +122,10 @@ mySdk.things
.ShareThing(
'<thingId>',

'<relation>',
{ relation: 'administrator' },
[
'<userId1>', '<userId2>'
], '<token>')
], token)
.then((response: any) => {
console.log('response: ', response)
})
Expand All @@ -149,7 +140,7 @@ mySdk.things

[
'<userId1>', '<userId2>'
], '<token>')
], token)
.then((response: any) => {
console.log('response:', response)
})
Expand All @@ -161,7 +152,7 @@ mySdk.things
.ListThingUsers(
'<thingId>',
{ offset: 0, limit: 10 },
'<token>'
token
)
.then((response: any) => {
console.log('response:', response)
Expand All @@ -171,7 +162,7 @@ mySdk.things
})

mySdk.things
.DeleteThing({ id: '<thingId>' }, '<token>')
.DeleteThing({ id: '<thingId>' }, token)
.then((response: any) => {
console.log('response: ', response)
})
Expand All @@ -180,7 +171,7 @@ mySdk.things
})

mySdk.things
.CreateThings([{ name: '<thingName>' }, { name: '<thingName>' }], '<token>')
.CreateThings([{ name: '<thingName>' }, { name: '<thingName>' }], token)
.then((response: any) => {
console.log('response:', response)
})
Expand Down
4 changes: 2 additions & 2 deletions src/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export interface PageRes {
limit: number
}

export interface BulkThings {
things: Thing[]
export interface Relation {
relation: 'administrator' | 'editor' | 'viewer' | 'member'
}
>>>>>>> f98ebdf (resolving comments)
2 changes: 1 addition & 1 deletion src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SDK {
hostUrl = defaultUrl
}: SDKConfig = {}) {
this.users = new Users({ usersUrl, thingsUrl, hostUrl })
this.domains = new Domains(domainsUrl)
this.domains = new Domains({ domainsUrl, usersUrl })
this.things = new Things({ thingsUrl, usersUrl })
this.channels = new Channels({ usersUrl, thingsUrl })
}
Expand Down
Loading

0 comments on commit 0a6a5f6

Please sign in to comment.