Skip to content

Commit 045bf54

Browse files
committed
fix: minor st-schema invite updates
1 parent aa2ccca commit 045bf54

File tree

3 files changed

+6
-36
lines changed

3 files changed

+6
-36
lines changed

.changeset/thick-students-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smartthings/core-sdk": patch
3+
---
4+
5+
minor updates to new ST Schema invites

src/endpoint/invites-schemaApp.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@ export type SchemaAppInvitation = SchemaAppId & {
2525
description?: string
2626
expiration?: number
2727
acceptUrl?: string
28+
acceptances: number
2829
declineUrl?: string
2930
shortCode?: string
3031
}
3132

32-
export type SchemaAppAcceptanceStatus = Omit<SchemaAppInvitation, 'id'> & {
33-
isAccepted?: boolean
34-
}
35-
3633

3734
export class InvitesSchemaAppEndpoint extends Endpoint {
3835
constructor(config: EndpointClientConfig) {
@@ -50,12 +47,4 @@ export class InvitesSchemaAppEndpoint extends Endpoint {
5047
public async revoke(invitationId: string): Promise<void> {
5148
await this.client.delete(invitationId)
5249
}
53-
54-
public async getAcceptanceStatus(invitationId: string): Promise<SchemaAppAcceptanceStatus> {
55-
return this.client.get('checkAcceptance', { invitationId })
56-
}
57-
58-
public async accept(shortCode: string): Promise<SchemaAppId> {
59-
return this.client.put(`${shortCode}/accept`)
60-
}
6150
}

test/unit/invites-schemaApp.test.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ afterEach(() => {
1010
const postSpy = jest.spyOn(EndpointClient.prototype, 'post').mockImplementation()
1111
const getPagedItemsSpy = jest.spyOn(EndpointClient.prototype, 'getPagedItems').mockImplementation()
1212
const deleteSpy = jest.spyOn(EndpointClient.prototype, 'delete')
13-
const getSpy = jest.spyOn(EndpointClient.prototype, 'get').mockImplementation()
14-
const putSpy = jest.spyOn(EndpointClient.prototype, 'put').mockImplementation()
1513

1614
const authenticator = new NoOpAuthenticator()
1715
const invitesEndpoint = new InvitesSchemaAppEndpoint( {authenticator})
@@ -45,25 +43,3 @@ test('revoke', async () => {
4543
expect(deleteSpy).toHaveBeenCalledTimes(1)
4644
expect(deleteSpy).toHaveBeenCalledWith('schema-app-id')
4745
})
48-
49-
test('getAcceptanceStatus', async () => {
50-
const status = [{ description: 'invitation description', isAccepted: true }]
51-
52-
getSpy.mockResolvedValueOnce(status)
53-
54-
expect(await invitesEndpoint.getAcceptanceStatus('invitation-id')).toBe(status)
55-
56-
expect(getSpy).toHaveBeenCalledTimes(1)
57-
expect(getSpy).toHaveBeenCalledWith('checkAcceptance', { invitationId: 'invitation-id' })
58-
})
59-
60-
test('accept', async () => {
61-
const schemaAppId = { schemaAppId: 'schema-app-id' }
62-
63-
putSpy.mockResolvedValueOnce(schemaAppId)
64-
65-
expect(await invitesEndpoint.accept('short-code')).toBe(schemaAppId)
66-
67-
expect(putSpy).toHaveBeenCalledTimes(1)
68-
expect(putSpy).toHaveBeenCalledWith('short-code/accept')
69-
})

0 commit comments

Comments
 (0)