Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ const params: WithdrawalHistoryRequest = {
const res = await privateApi.getWithdrawalHistory(params);
```

##### getSubscribe
```typescript
const res = await privateApi.getSubscribe();
```

## 実装の確認/モックについて

以下のリポジトリのモックサーバーを用いて
Expand Down
7 changes: 7 additions & 0 deletions src/lib/private-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ const getTradeHistoryTest = async () => {
assert.equal(res.success, 1);
};

const getSubscribeTest = async () => {
const privateApi = new PrivateApi(config.privateApi);
const res = await privateApi.getSubscribe();
assert.equal(res.success, 1);
};

describe('PrivateAPI Test', () => {
it('should init', testInit);
it('should callback', optionalCallbackTest);
Expand All @@ -263,4 +269,5 @@ describe('PrivateAPI Test', () => {
it('POST /user/request_withdrawal', requestWithdrawalTest);
it('GET /user/withdrawal_history', getWithdrawalHistoryTest);
it('GET /user/spot/trade_history', getTradeHistoryTest);
it('GET /user/subscribe', getSubscribeTest);
});
12 changes: 10 additions & 2 deletions src/lib/private-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
OrderResponse,
OrdersResponse,
Response,
SubscribeResponse,
TradeHistoryResponse,
WithdrawalAccountResponse,
WithdrawalHistoryResponse,
Expand Down Expand Up @@ -49,7 +50,6 @@ export class PrivateApi extends Api {
private nonce: number;
private timeWindow: number;


constructor(config: PrivateApiConfig, options?: ApiOptions) {
config.endPoint = config.endPoint || URL_API_BITBANK;
super(config, options);
Expand Down Expand Up @@ -125,6 +125,11 @@ export class PrivateApi extends Api {
return this.post(path, params);
}

public getSubscribe(): Promise<Response<SubscribeResponse>> {
const path = '/user/subscribe';
return this.get(path, {});
}

get<T>(path: string, query?: {}) {
let params = '';
if (query && Object.keys(query).length) {
Expand Down Expand Up @@ -163,7 +168,10 @@ export class PrivateApi extends Api {

private makeRequestTimeHeader(uri: string): any {
const requestTime = new Date().getTime();
const message: string = requestTime.toString().concat(this.timeWindow.toString()).concat(uri);
const message: string = requestTime
.toString()
.concat(this.timeWindow.toString())
.concat(uri);
return {
'Content-Type': 'application/json',
'ACCESS-KEY': this.apiKey,
Expand Down
5 changes: 5 additions & 0 deletions src/lib/responseType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,8 @@ export interface CircuitBreakInfoResponse {
reopen_timestamp: number | null;
timestamp: number;
}

export interface SubscribeResponse {
pubnub_channel: string;
pubnub_token: string;
}