-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: wambuipixel <[email protected]>
- Loading branch information
1 parent
dd9be19
commit 5544659
Showing
7 changed files
with
1,152 additions
and
1,178 deletions.
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
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
// Import the SDK class from the mainflux-sdk package | ||
import SDK from "../src/sdk"; | ||
import SDK from '../src/sdk' | ||
|
||
const defaultUrl = "http://localhost"; | ||
const defaultUrl = 'http://localhost' | ||
|
||
const mySdk = new SDK({ | ||
usersUrl: defaultUrl + ":9002", | ||
usersUrl: defaultUrl + ':9002' | ||
// groupsUrl: defaultUrl + ":9002", | ||
// thingsUrl: defaultUrl + ":9000", | ||
// channelsUrl: defaultUrl + ":9000", | ||
// httpadapterUrl: defaultUrl, | ||
// readersUrl: defaultUrl + ":9011", | ||
// certsUrl: defaultUrl + ":9019", | ||
// bootstrapsUrl: defaultUrl + ":9013", | ||
}); | ||
}) | ||
|
||
mySdk.users | ||
.CreateToken({ identity: "[email protected]", secret: "12345678" }) | ||
.CreateToken({ identity: '[email protected]', secret: '12345678' }) | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
// //Things.js examples. | ||
|
||
|
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 |
---|---|---|
@@ -1,208 +1,188 @@ | ||
// Import the SDK class from the mainflux-sdk package | ||
import SDK from "../src/sdk"; | ||
import SDK from '../src/sdk' | ||
|
||
const defaultUrl = "http://localhost"; | ||
const defaultUrl = 'http://localhost' | ||
|
||
const mySdk = new SDK({ | ||
thingsUrl: defaultUrl + ":9000", | ||
}); | ||
thingsUrl: defaultUrl + ':9000' | ||
}) | ||
|
||
const token = | ||
"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIzZTlkMTNiMy1lMTgxLTQwNjktODdjNS0yMGQ3MmJlY2M4M2YiLCJleHAiOjE3MTIwMzk5MzMsImlhdCI6MTcxMjAzNjMzMywiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiYjJmZTZhZmUtOGYwNS00NDgzLWFhY2QtN2QyMGVhMjVkOWE1IiwidHlwZSI6MCwidXNlciI6ImIyZmU2YWZlLThmMDUtNDQ4My1hYWNkLTdkMjBlYTI1ZDlhNSJ9.tA_2fGtYlT-zn316AwX_wtw0uXgE7DYFUA_ZvXKCvm1Pofl_WiAWMRt5YcqU_TbGDXmrgJxUd-Ifa9aSYMaFKA"; | ||
// //Things.js examples. | ||
// // //Things.js examples. | ||
|
||
mySdk.things | ||
.Create( | ||
{ | ||
name: "thing_name", | ||
}, | ||
<"token"> | ||
{ name: 'thing_name' }, '<token>' | ||
) | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.GetAll({ offset: 0, limit: 10 }, "<token>") | ||
.GetAll({ offset: 0, limit: 10 }, '<token>') | ||
|
||
.then((response: any) => { | ||
console.log("response:", response); | ||
console.log('response:', response) | ||
}) | ||
|
||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.Disable({ id: "<thing_id>" }, "<token>") | ||
.Disable({ id: 'thing_id' }, '<token>') | ||
.then((response: any) => { | ||
console.log("response:", response); | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
console.error(error) | ||
}) | ||
|
||
mySdk.things | ||
.Enable({ id: "<thing_id>" }, "<token>") | ||
.Enable({ id: 'thing_id' }, '<token>') | ||
.then((response: any) => { | ||
console.log("response:", response); | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}); | ||
console.error(error) | ||
}) | ||
|
||
mySdk.things | ||
.Update( | ||
{ id: "thing_id", name: "thing_name" }, | ||
"<token>", | ||
) | ||
{ id: 'thing_id', name: 'thing_name' }, '<token>') | ||
.then((response: any) => { | ||
console.log("response:", response); | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.UpdateThingSecret( | ||
{ | ||
id: "thing_id", | ||
credentials: { secret: "new_secret" }, | ||
}, | ||
"<token>", | ||
.UpdateThingSecret({ id: 'thing_id', credentials: { secret: 'new_secret' } }, '<token>' | ||
) | ||
.then((response: any) => { | ||
console.log(response); | ||
console.log(response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.UpdateThingTags( | ||
{ id: "<thing_id>", tags: ["<tag1>", "<tag2>"] }, | ||
"<token>", | ||
{ id: 'thing_id', tags: ['<tag1>', '<tag2>'] }, | ||
'<token>' | ||
) | ||
.then((response: any) => { | ||
console.log(response); | ||
console.log(response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.ThingsByChannel({ id: "thing_id" }, { offset: 0, limit: 5 }, "<token>") | ||
.ThingsByChannel({ id: 'thing_id' }, { offset: 0, limit: 5 }, '<token>') | ||
.then((response: any) => { | ||
console.log(response); | ||
console.log(response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.Things({ offset: 0, limit: 10 }, "<token>") | ||
.Things({ offset: 0, limit: 10 }, '<token>') | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.Thing("thing_id", "<token>") | ||
.Thing('thing_id', '<token>') | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.ThingsPermissions("thing_id", "<token>") | ||
.ThingsPermissions('thing_id', '<token>') | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.IdentifyThing({ id: "thing_id" }) | ||
.IdentifyThing('thing_key') | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.ShareThing( | ||
"thing_id", | ||
{ | ||
Relation: "relation", | ||
UserID: [ | ||
"user_id1", | ||
"user_id2", | ||
], | ||
}, | ||
"<token>", | ||
) | ||
'thing_id', | ||
|
||
'administrator', | ||
[ | ||
'user_id1', 'user_id2' | ||
], '<token>') | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.UnShareThing( | ||
"thing_id", | ||
{ | ||
Relation: "admin", | ||
UserID: [ | ||
"user_id1", | ||
"user_id2", | ||
], | ||
}, | ||
"<token>", | ||
) | ||
'thing_id', | ||
'administrator', | ||
|
||
[ | ||
'user_id1', 'user_id2' | ||
], '<token>') | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.ListThingUsers( | ||
"thing_id", | ||
'thing_id', | ||
{ offset: 0, limit: 10 }, | ||
"<token>", | ||
'<token>' | ||
) | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.DeleteThing({ id: "thing_id" }, "<token>") | ||
.DeleteThing({ id: 'thing_id' }, '<token>') | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response: ', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) | ||
|
||
mySdk.things | ||
.CreateThings([{ name: "thing_name" }, { name: "thing_name" }], "<token>") | ||
.CreateThings([{ name: 'thing_name' }, { name: 'thing_name' }], '<token>') | ||
.then((response: any) => { | ||
console.log("response: ", response); | ||
console.log('response:', response) | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
console.log(error) | ||
}) |
Oops, something went wrong.