Skip to content

Commit

Permalink
feat: add support for listing Schema apps by organization
Browse files Browse the repository at this point in the history
  • Loading branch information
rossiam committed Aug 14, 2024
1 parent 2fc34d6 commit 4151977
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-bobcats-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smartthings/core-sdk": minor
---

add support for listing Schema apps by organization
7 changes: 5 additions & 2 deletions src/endpoint/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,11 @@ export class SchemaEndpoint extends Endpoint {
/**
* Returns a list of all ST Schema C2C connectors belonging to the principal (i.e. the user)
*/
public async list(): Promise<SchemaApp[]> {
const response = await this.client.get<SchemaAppList>('apps')
public async list(options?: { includeAllOrganizations?: boolean }): Promise<SchemaApp[]> {
// Querying Schema apps requires a different API for listing by organization in addition to
// the standard header other endpoints use.
const useOrganizationEndpoint = this.client.config.headers?.['X-ST-Organization'] || options?.includeAllOrganizations
const response = await this.client.get<SchemaAppList>('apps' + (useOrganizationEndpoint ? '/organizations/' : ''))
return response.endpointApps
}

Expand Down

0 comments on commit 4151977

Please sign in to comment.