-
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
Conversation
5544659
to
807b344
Compare
807b344
to
4efc7a9
Compare
src/sdk.ts
Outdated
import Things from './things' | ||
// import Groups from "./groups"; |
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.
remove all the commented out code.
src/defs.ts
Outdated
@@ -57,9 +55,14 @@ export interface GroupsPage { | |||
export interface Channel { | |||
id?: string | |||
name?: string | |||
parent_id?: string | |||
credentials?: { |
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.
a channel does not have credentials.
Channel struct looks like this:
type Channel struct {
ID string `json:"id,omitempty"`
DomainID string `json:"domain_id,omitempty"`
ParentID string `json:"parent_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
Level int `json:"level,omitempty"`
Path string `json:"path,omitempty"`
Children []*Channel `json:"children,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Status string `json:"status,omitempty"`
Permissions []string `json:"permissions,omitempty"`
}
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.
refer to the go sdk for these items
src/defs.ts
Outdated
@@ -34,6 +29,9 @@ export interface Thing { | |||
owner?: string | |||
metadata?: Record<string, any> | |||
status?: string | |||
createdAt?: string |
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.
Lets use snake case for these
src/defs.ts
Outdated
@@ -18,14 +18,9 @@ export interface UsersPage { | |||
page: PageRes | |||
} | |||
|
|||
export interface PageRes { |
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.
why are you deleting this interface?
src/channels.ts
Outdated
* | ||
*/ | ||
const options: RequestInit = { | ||
method: 'post', |
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.
Keep the method names in capital for all
method: 'post', | |
method: 'POST, |
src/channels.ts
Outdated
'Content-Type': this.contentType, | ||
Authorization: `Bearer ${token}` | ||
}, | ||
body: JSON.stringify(payload) |
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.
body: JSON.stringify(payload) | |
body: JSON.stringify({ subject: thingId, object: channelId }) |
4442172
to
2edec88
Compare
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
2edec88
to
6faa013
Compare
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
examples/channels.ts
Outdated
const token = '<token>' | ||
|
||
mySdk.channels | ||
.CreateChannel({ name: '<channelId>' }, token) |
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.
.CreateChannel({ name: '<channelId>' }, token) | |
.CreateChannel({ name: '<channelName>' }, token) |
examples/channels.ts
Outdated
.AddUserToChannel( | ||
'<channelId>', | ||
[ | ||
'<thingId>', '<thingId>' |
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.
'<thingId>', '<thingId>' | |
'<userId>', '<userId>' |
examples/channels.ts
Outdated
.RemoveUserFromChannel( | ||
'<channelId>', | ||
[ | ||
'<thingId>', '<thingId>' |
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.
'<thingId>', '<thingId>' | |
'<userId>', '<userId>' |
src/channels.ts
Outdated
'Content-Type': this.contentType, | ||
Authorization: `Bearer ${token}` | ||
}, | ||
body: JSON.stringify({ subject: thingId, object: channelId }) |
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.
body: JSON.stringify({ subject: thingId, object: channelId }) | |
body: JSON.stringify({ thing_id: thingId, channel_id: channelId }) |
src/channels.ts
Outdated
'Content-Type': this.contentType, | ||
Authorization: `Bearer ${token}` | ||
}, | ||
body: JSON.stringify({ subject: thingId, object: channelId }) |
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.
body: JSON.stringify({ subject: thingId, object: channelId }) | |
body: JSON.stringify({ thing_id: thingId, channel_id: channelId }) |
src/channels.ts
Outdated
const errorRes = await response.json() | ||
throw this.channelError.HandleError(errorRes.error, response.status) | ||
} | ||
const channelData: Channel = await response.json() |
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.
const channelData: Channel = await response.json() | |
const updatedChannel: Channel = await response.json() |
src/channels.ts
Outdated
const errorRes = await response.json() | ||
throw this.channelError.HandleError(errorRes.error, response.status) | ||
} | ||
const channelsData: ChannelsPage = await response.json() |
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.
const channelsData: ChannelsPage = await response.json() | |
const channels: ChannelsPage = await response.json() |
src/channels.ts
Outdated
const errorRes = await response.json() | ||
throw this.channelError.HandleError(errorRes.error, response.status) | ||
} | ||
const channelData: ChannelsPage = await response.json() |
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.
const channelData: ChannelsPage = await response.json() | |
const channels: ChannelsPage = await response.json() |
src/channels.ts
Outdated
const errorRes = await response.json() | ||
throw this.channelError.HandleError(errorRes.error, response.status) | ||
} | ||
const channelData: Channel = await response.json() |
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.
const channelData: Channel = await response.json() | |
const channel: Channel = await response.json() |
src/channels.ts
Outdated
const errorRes = await response.json() | ||
throw this.channelError.HandleError(errorRes.error, response.status) | ||
} | ||
const channelData: Channel = await response.json() |
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.
const channelData: Channel = await response.json() | |
const newChannel: Channel = await response.json() |
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
Signed-off-by: wambuipixel <[email protected]>
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.
LGTM
What does this do?
Updating Things .ts
Which issue(s) does this PR fix/relate to? NOISSUE
Resolves #15 and #17
List any changes that modify/break current functionality
Migrating things.js to things.ts
Have you included tests for your changes?
NO
Did you document any new/modified functionality?
NO
Notes