Skip to content

Commit

Permalink
NOISSUE - Update naming and docs (#5)
Browse files Browse the repository at this point in the history
* fix errors

Signed-off-by: Musilah <[email protected]>

* fix packages

Signed-off-by: Musilah <[email protected]>

---------

Signed-off-by: Musilah <[email protected]>
  • Loading branch information
Musilah authored Mar 25, 2024
1 parent 1041159 commit 88ebb32
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 1,611 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@

END OF TERMS AND CONDITIONS

Copyright Mainflux
Copyright Magistrala

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## JavaScript SDK

This is the Mainflux Javascript SDK, a javascript driver for [Mainflux HTTP API](https://docs.mainflux.io/api/) API reference in the Swagger UI can be found [here](https://api.mainflux.io/).
This is the Magistrala Javascript SDK, a javascript driver for [Magistrala HTTP API](https://docs.mainflux.io/api/) API reference in the Swagger UI can be found [here](https://api.mainflux.io/).

Does both system administration (provisioning) and messaging.

## Professional Support

There are many companies offering professional support for the Mainflux system.
There are many companies offering professional support for the Magistrala system.

If you need this kind of support, best is to reach out to [@drasko](https://github.com/drasko) directly, and he will point you out to the best-matching support team.

## Contributing

Thank you for your interest in Mainflux and the desire to contribute!
Thank you for your interest in Magistrala and the desire to contribute!

1. Take a look at our [open issues](https://github.com/mainflux/sdk-js/issues). The [good-first-issue](https://github.com/mainflux/sdk-js/labels/good-first-issue) label is specifically for issues that are great for getting started.
1. Take a look at our [open issues](https://github.com/absmach/sdk-js/issues). The [good-first-issue](https://github.com/absmach/sdk-js/labels/good-first-issue) label is specifically for issues that are great for getting started.
2. Checkout the [contribution guide](CONTRIBUTING.md) to learn more about our style and conventions.
3. Make your changes compatible to our workflow.

Expand All @@ -24,7 +24,7 @@ The node module can be used from `index.js` and examples are located in `example
## Community

- [Google group](https://groups.google.com/forum/#!forum/mainflux)
- [Gitter](https://gitter.im/mainflux/mainflux?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
- [Gitter](https://gitter.im/absmach/magistrala?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
- [Twitter](https://twitter.com/mainflux)

## License
Expand Down
2 changes: 1 addition & 1 deletion bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ require = (function () {
* @method Messages - Messages is used to manage messages.
* It provides methods for sending and reading messages.
* @param {string} readers_url - The url of the readers service.
* @param {string} httpadapter_url - The URL of the Mainflux Messages adapter.
* @param {string} httpadapter_url - The URL of the Magistrala Messages adapter.
* @param {string} content_type - The content type of the request.
* @returns {Messages} - Returns a Messages object.
*/
Expand Down
19 changes: 1 addition & 18 deletions mainflux/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,11 @@ class Bootstrap {
*
*/
constructor(bootstraps_url) {
this.bootstraps_url = bootstraps_url;
this.bootstraps_url = new URL(bootstraps_url);
this.content_type = "application/json";
this.bootstrapsEndpoint = "configs";
}

Create(config, token) {
//Create a bootstrap configuration
/**
* @class Bootstrap
* Bootstrap is used to manage bootstrap configurations.
* It is used to create, update, view and remove bootstrap configurations.
* It is also used to bootstrap a thing.
* @param {string} bootstraps_url - The url of the bootstraps service.
* @returns {Bootstrap} - Returns a Bootstrap object.
*
*/
constructor(bootstraps_url){
this.bootstraps_url = new URL (bootstraps_url);
this.content_type = "application/json";
this.bootstrapsEndpoint = "configs";
}

ValidateConfigAndToken(config, token){
//Validate config
if (typeof config !== "object" || config === null) {
Expand Down
15 changes: 1 addition & 14 deletions mainflux/certs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,11 @@ class Certs {
* @returns {Certs} - Returns a Certs object.
*/
constructor(certs_url) {
this.certs_url = certs_url;
this.certs_url = new URL(certs_url);
this.content_type = "application/json";
this.certsEndpoint = "certs";
}

Issue(thing_id, valid, token) {
//Issue a certificate
/**
*@class Certs - Certs is used to manage certificates.
*It is used to issue, view and revoke certificates.
* @param {string} certs_url - The url of the certs service.
* @returns {Certs} - Returns a Certs object.
*/
constructor(certs_url) {
this.certs_url = new URL(certs_url);
this.content_type = "application/json";
this.certsEndpoint = "certs";
}
ValidateThingIDAndToken(thing_id, token) {
if (typeof thing_id !== "string" || thing_id === null) {
throw new Error('Invalid thing_id parameter. Expected a string.');
Expand Down
15 changes: 0 additions & 15 deletions mainflux/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,7 @@ class Channels {
* @returns {Object} -Channels object
*
*/
constructor(channels_url) {
this.channels_url = channels_url;
this.content_type = "application/json";
this.channelsEndpoint = "channels";
}

Create(channel, token) {
//Creates a new channel
/**
* @class Channels -
* Channels API is used for managing Channels. It is used for creating new
* channels, retrieving them, updating them and disabling them
* @param {string} channels_url - URL to the Channels service.
* @returns {Object} -Channels object
*
*/
constructor(channels_url) {
this.channels_url = new URL (channels_url);
this.content_type = "application/json";
Expand Down
20 changes: 1 addition & 19 deletions mainflux/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,10 @@ class Groups {
* @returns {Groups} - Returns a Groups object.
*/
constructor(groups_url) {
this.groups_url = groups_url;
this.groups_url = new URL(groups_url);
this.content_type = "application/json";
this.groupsEndpoint = "groups";
}
// groupError = new Errors;

Create(group, token) {
// Create a new group.
/**
* @class Groups -
* Groups API client is used for managing groups. It is used for
* creating, updating, deleting, and retrieving groups.
* @param {string} groups_url - The URL of the Groups service.
* @returns {Groups} - Returns a Groups object.
*/
constructor(groups_url) {
this.groups_url = new URL (groups_url);
this.content_type = "application/json";
this.groupsEndpoint = "groups";
}
// groupError = new Errors;
//Validation function

ValidateGroupAndToken(group, token) {
if (typeof group !== 'object' || group === null || Array.isArray(group)) {
Expand Down
30 changes: 2 additions & 28 deletions mainflux/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,11 @@ class Messages {
* @method Messages - Messages is used to manage messages.
* It provides methods for sending and reading messages.
* @param {string} readers_url - The url of the readers service.
* @param {string} httpadapter_url - The URL of the Mainflux Messages adapter.
* @param {string} httpadapter_url - The URL of the Magistrala Messages adapter.
* @param {string} content_type - The content type of the request.
* @returns {Messages} - Returns a Messages object.
*/
constructor(readers_url, httpadapter_url) {
this.readers_url = readers_url;
this.httpadapter_url = httpadapter_url;
this.content_type = "application/json";
}

Send(channel_id, msg, thing_key) {
//Send a message
/**
* @method Messages - Messages is used to manage messages.
* It provides methods for sending and reading messages.
* @param {string} readers_url - The url of the readers service.
* @returns {Messages} - Returns a Messages object.
*/

constructor(readers_url, httpadapter_url){
this.readers_url = new URL (readers_url);
this.httpadapter_url = new URL (httpadapter_url);
Expand Down Expand Up @@ -63,19 +50,6 @@ class Messages {
const chan_id = chan_name_parts[0];
let subtopic = "";

Read(channel_id, token) {
//Read messages
/**
*
* @method Read - Read messages from a given channel. Messages are read from a reader
* add-on such as timescale. Messages are read from a http port specific to the reader
* @param {string} channel_id - The channel_id of the channel to read the message from.
* @param {string} token - The token to be used for authentication.
*/
const chan_name_parts = channel_id.split(".", 2);
const chan_id = chan_name_parts[0];
let subtopic = "";

const options = {
method: "post",
maxBodyLength: 2000,
Expand Down
12 changes: 0 additions & 12 deletions mainflux/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ class Users {
this.usersEndpoint = "users";
}

Create(user, token) {
// Creates a new user
/**
* @class Users -
* Users API is used for creating and managing users.
* It is used for creating new users, logging in, refreshing tokens,
* getting user information, updating user information, disabling
* and enabling users.
* @param {String} users_url - URL to the Users service.
* @returns {Object} - Users object.
*/

// Validation function
ValidateUserAndToken(user, token) {
if (typeof user !== 'object' || user === null || Array.isArray(user)) {
Expand Down
Loading

0 comments on commit 88ebb32

Please sign in to comment.