-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regenerate sdk, a lot of method name changed, enum name changed. no d…
…uplicate models now. Add readme.md
- Loading branch information
1 parent
7e84de7
commit c9b3e57
Showing
96 changed files
with
494 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
|
||
cp sdk/typescript/inversify/README.md sdk/typescript/inversify/dist/ | ||
cp sdk/typescript/inversify/package.json sdk/typescript/inversify/dist/ | ||
cp sdk/typescript/inversify/tsconfig.json sdk/typescript/inversify/dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# bgm-sdk-inversify | ||
|
||
A typescript sdk for bgm.tv API. for API reference, see: [https://bangumi.github.io/api/](https://bangumi.github.io/api/) | ||
|
||
To use this SDK, you need to use with RxJS 6+ and Inversify. | ||
|
||
## Install | ||
|
||
```shell | ||
npm install @irohalab/bgm-sdk-inversify --save | ||
``` | ||
|
||
Optionally, install dependencies | ||
```shell | ||
npm install inversify reflect-metadata rxjs typescript --save, | ||
``` | ||
|
||
## Usage | ||
|
||
```typescript | ||
import { DefaultService, DefaultServiceInterface, ApiServiceBinder } from '@irohalab/bgm-sdk-inversify'; | ||
import { injectable } from 'inversify'; | ||
import { Subject } from './subject'; | ||
import { lastValueFrom } from 'rxjs'; | ||
|
||
const TYPES = { | ||
DefaultService: 'DefaultService' | ||
} | ||
|
||
@injectable() | ||
export class YourInjectableService { | ||
constructor(@inject(TYPES.DefaultService) private _bgmClient: DefaultService) { | ||
} | ||
|
||
async getSubject(bgmId: number): Promise<Subject> { | ||
return await lastValueFrom(this._bgmClient.getSujectById(bgmId)); | ||
} | ||
} | ||
|
||
const container = new Container(); | ||
ApiServiceBinder.with(container); | ||
container.bind<YourInjectableService>(YourInjectableService).to(ApiServiceBinder); | ||
const yourService = container.get<YourInjectableService>(YourInjectableService); | ||
const subject = await yourService.getSubject(324295); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.