-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NOISSUE - Updating Things and Channels Service #9
Merged
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2dff6d0
updating things.ts
wambui-pixel 1fbc83d
updating things to use async functions
wambui-pixel f8ccdf0
Adding more functionalities to things.ts
wambui-pixel 7792d5c
Adding Linter
wambui-pixel 79c90fa
Update Channels.ts
wambui-pixel 439ad2f
resolving comments
wambui-pixel 9ab1085
Fixing Cl failing issues
wambui-pixel 7715936
Fix users.ts
wambui-pixel 3eede79
Updating doc strings
wambui-pixel 668d111
Updating token constant
wambui-pixel 6faa013
Fixing Relation on things.ts
wambui-pixel 3b9a2c6
Fix Rebase error
wambui-pixel 3617ee2
Fix Lint errors on users.ts
wambui-pixel d729aed
Fix Lint errors on sdk.ts
wambui-pixel 985e57a
Fix requested changes
wambui-pixel 73c1143
Adding groupRelation to defs.ts
wambui-pixel 7f08811
Fix lint error in def.ts
wambui-pixel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,202 @@ | ||||||
// Import the SDK class from the mainflux-sdk package | ||||||
import SDK from '../src/sdk' | ||||||
|
||||||
const defaultUrl = 'http://localhost' | ||||||
|
||||||
const mySdk = new SDK({ | ||||||
thingsUrl: defaultUrl + ':9000', | ||||||
usersUrl: defaultUrl + ':9002' | ||||||
}) | ||||||
|
||||||
// Channels.ts examples. | ||||||
|
||||||
const token = '<token>' | ||||||
|
||||||
mySdk.channels | ||||||
.CreateChannel({ name: '<channelId>' }, token) | ||||||
.then((response: any) => { | ||||||
console.log('response:', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.Channel('<channelID>', token) | ||||||
.then((response: any) => { | ||||||
console.log(response) | ||||||
}) | ||||||
.catch((error: any) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.Channels({ offset: 0, limit: 10 }, token) | ||||||
.then((response: any) => { | ||||||
console.log('response:', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.UpdateChannel( | ||||||
{ id: '<channelId>', name: '<channelName>' }, | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response:', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.Disable({ id: '<channelId>' }, token) | ||||||
.then((response: any) => { | ||||||
console.log('response:', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.Enable({ id: '<channelId>' }, token) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.ChannelsByThing( | ||||||
'<thingId>', | ||||||
{ offset: 0, limit: 5 }, | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response:', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.ConnectThing( | ||||||
'<thingId>', | ||||||
'<channelId>', | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.DisconnectThing( | ||||||
'<thingId>', | ||||||
'<channelId>', | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.Connect( | ||||||
'<thingId>', | ||||||
'<channelId>', | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response:', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.Disconnect( | ||||||
'<thingId>', | ||||||
'<channelId>', | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.ListChannelUsers( | ||||||
'<channelId>', | ||||||
{ offset: 0, limit: 5 }, | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error: any) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.ListChannelUsersGroups( | ||||||
'<channelId>', | ||||||
{ offset: 0, limit: 5 }, | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error: any) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.ChannelPermissions('<channelId>', token) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.AddUserToChannel( | ||||||
'<channelId>', | ||||||
[ | ||||||
'<thingId>', '<thingId>' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
], | ||||||
'editor', | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) | ||||||
|
||||||
mySdk.channels | ||||||
.RemoveUserFromChannel( | ||||||
'<channelId>', | ||||||
[ | ||||||
'<thingId>', '<thingId>' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
], | ||||||
'editor', | ||||||
token | ||||||
) | ||||||
.then((response: any) => { | ||||||
console.log('response: ', response) | ||||||
}) | ||||||
.catch((error) => { | ||||||
console.log(error) | ||||||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
// Import the SDK class from the mainflux-sdk package | ||
import SDK from '../src/sdk' | ||
|
||
const defaultUrl = 'http://localhost' | ||
|
||
const mySdk = new SDK({ | ||
thingsUrl: defaultUrl + ':9000', | ||
usersUrl: defaultUrl + ':9002' | ||
}) | ||
|
||
// Things.ts examples. | ||
|
||
const token = '<token>' | ||
|
||
mySdk.things | ||
.Create( | ||
{ name: '<thingName>' }, token | ||
) | ||
.then((response: any) => { | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.Disable({ id: '<thingId>' }, token) | ||
.then((response: any) => { | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.error(error) | ||
}) | ||
|
||
mySdk.things | ||
.Enable({ id: '<thingId>' }, token) | ||
.then((response: any) => { | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.error(error) | ||
}) | ||
|
||
mySdk.things | ||
.UpdateThing( | ||
{ id: '<thingId>', name: '<thingName>' }, token) | ||
.then((response: any) => { | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.UpdateThingSecret({ id: '<thingId>', credentials: { secret: 'newSecret' } }, token | ||
) | ||
.then((response: any) => { | ||
console.log(response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.UpdateThingTags( | ||
{ id: '<thingId>', tags: ['<tag1>', '<tag2>'] }, | ||
token | ||
) | ||
.then((response: any) => { | ||
console.log(response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.ThingsByChannel('<channelId>', { offset: 0, limit: 5 }, token) | ||
.then((response: any) => { | ||
console.log(response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.Things({ offset: 0, limit: 10 }, token) | ||
.then((response: any) => { | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.Thing('<thingId>', token) | ||
.then((response: any) => { | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.ThingsPermissions('<thingId>', token) | ||
.then((response: any) => { | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.IdentifyThing('<thingKey>') | ||
.then((response: any) => { | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.ShareThing( | ||
'<thingId>', | ||
|
||
'administrator', | ||
wambui-pixel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[ | ||
'<userId1>', '<userId2>' | ||
], token) | ||
.then((response: any) => { | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.UnShareThing( | ||
'<thingId>', | ||
'<relation>', | ||
|
||
[ | ||
'<userId1>', '<userId2>' | ||
], token) | ||
.then((response: any) => { | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.ListThingUsers( | ||
'<thingId>', | ||
{ offset: 0, limit: 10 }, | ||
token | ||
) | ||
.then((response: any) => { | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.DeleteThing({ id: '<thingId>' }, token) | ||
.then((response: any) => { | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.CreateThings([{ name: '<thingName>' }, { name: '<thingName>' }], token) | ||
.then((response: any) => { | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error) | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.