https://github.com/getshifter/shifter-sdk-js
npm i -S @shifter/sdk
https://github.com/getshifter/shifter-sdk-js
Last synced: 9 months ago
JSON representation
npm i -S @shifter/sdk
- Host: GitHub
- URL: https://github.com/getshifter/shifter-sdk-js
- Owner: getshifter
- License: mit
- Created: 2021-05-18T03:14:52.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-18T03:25:16.000Z (about 5 years ago)
- Last Synced: 2025-09-22T01:40:01.348Z (9 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@shifter/sdk
- Size: 632 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Shifter API wrapper SDK (Using axios).
## Usage
### Get API Access Token
```typescript
import {
Configuration,
LoginApi,
SitesApi,
} from '@shifter/sdk'
const getConfByLogin = async () => {
const loginClient = new LoginApi()
const params = {
username: process.env.SHIFTER_USERNAME,
password: process.env.SHIFTER_PASSWORD
}
const {
data: {
AccessToken: apiKey
}
} = await loginClient.loginPost(params)
const conf = new Configuration({
apiKey
})
return conf
}
```
### Example (List sites)
```typescript
import {
Configuration,
LoginApi,
SitesApi,
} from '@shifter/sdk'
const listSitesWithLogin = async () => {
const loginClient = new LoginApi()
const params = {
username: process.env.SHIFTER_USERNAME,
password: process.env.SHIFTER_PASSWORD
}
const {
data: {
AccessToken: apiKey
}
} = await loginClient.loginPost(params)
if (!apiKey) throw new Error('UnAuthorized')
const conf = new Configuration({
apiKey
})
const client = new SitesApi(conf)
console.log(await client.sitesGet())
}
listSitesWithLogin()
.catch(e => {
console.log(e)
})
```
## API Document
[WIP]
https://getshifter.github.io/shifter-sdk-js/
## Development
### Data source
Open API Docs: https://developer.getshifter.io/swagger.yaml
### Build SDK
```bash
$ ./bin/generate-sdk.sh
```
### Update docs
```bash
$ git checkout master
$ yarn docs
$ git add ./docs/
$ git commit -m "docs: update docs"
$ git push origin master
```
### Publish SDK to npm
```bash
$ yarn build
$ npm version [patch|minor|major]
$ npm publish .
```