Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
101arrowz committed Jul 11, 2023
1 parent a73be92 commit 271514a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ const { SocketSdk } = require('@socketsecurity/sdk')
### Utility methods

* `getQuota()`
* `getSettings()`
* `getOrganizations()`
* `postSettings(selectors)`
* `selectors`: An array of settings selectors, e.g. `[{ organization: 'id' }]`

## Additional exports

Expand Down
24 changes: 20 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,30 @@ class SocketSdk {
}
}

/** @returns {Promise<SocketSdkResultType<'getSettings'>>} */
async getSettings () {
/** @returns {Promise<SocketSdkResultType<'getOrganizations'>>} */
async getOrganizations () {
try {
const client = await this.#getClient()
const data = await client.get('settings').json()
const data = await client.get('organizations').json()
return { success: true, status: 200, data }
} catch (err) {
return /** @type {SocketSdkErrorType<'getSettings'>} */ (this.#handleApiError(err))
return /** @type {SocketSdkErrorType<'getQuota'>} */ (this.#handleApiError(err))
}
}

/**
* @param {Array<{ organization?: string }>} selectors
* @returns {Promise<SocketSdkResultType<'postSettings'>>}
*/
async postSettings (selectors) {
try {
const client = await this.#getClient()
const data = await client.post('settings', {
json: selectors
}).json()
return { success: true, status: 200, data }
} catch (err) {
return /** @type {SocketSdkErrorType<'postSettings'>} */ (this.#handleApiError(err))
}
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 271514a

Please sign in to comment.