Skip to content

Commit

Permalink
Merge pull request #17 from tiagosiebler/jerko
Browse files Browse the repository at this point in the history
feat(): renamed clients
  • Loading branch information
JJ-Cro authored Sep 13, 2024
2 parents 92e1573 + 9b52a4b commit 9252d34
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions examples/advanced-private-rest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AdvancedTradeClient } from '../src/index.js';
import { CBAdvancedTradeClient } from '../src/index.js';

async function main() {
const client = new AdvancedTradeClient({
const client = new CBAdvancedTradeClient({
// cdpApiKey: credsTradePermission,
apiKeyName: '',
apiPrivateKey: '',
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced-public-rest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AdvancedTradeClient } from '../src/AdvancedTradeClient.js';
import { CBAdvancedTradeClient } from '../src/index.js';

const advancedTradeClient = new AdvancedTradeClient({});
const advancedTradeClient = new CBAdvancedTradeClient({});

async function main() {
try {
Expand Down
4 changes: 2 additions & 2 deletions examples/cb-app-private.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CoinbaseAppClient } from '../src/index.js';
import { CBAppClient } from '../src/index.js';

async function main() {
const client = new CoinbaseAppClient({
const client = new CBAppClient({
// cdpApiKey: credsTradePermission,
apiKeyName: '',
apiPrivateKey: '',
Expand Down
4 changes: 2 additions & 2 deletions examples/coinbase-international-client-rest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CoinbaseInternational } from '../src/CoinbaseInternational.js';
import { CBInternationalClient } from '../src/index.js';

const coinbaseInternational = new CoinbaseInternational({});
const coinbaseInternational = new CBInternationalClient({});

async function main() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import {
* REST client for Coinbase's Advanced Trade API:
* https://docs.cdp.coinbase.com/advanced-trade/docs/api-overview/
*/
export class AdvancedTradeClient extends BaseRestClient {
export class CBAdvancedTradeClient extends BaseRestClient {
constructor(
restClientOptions: RestClientOptions = {},
requestOptions: AxiosRequestConfig = {},
Expand Down
2 changes: 1 addition & 1 deletion src/CoinbaseAppClient.ts → src/CBAppClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
* REST client for Coinbase's Coinbase App API:
* https://docs.cdp.coinbase.com/coinbase-app/docs/welcome
*/
export class CoinbaseAppClient extends BaseRestClient {
export class CBAppClient extends BaseRestClient {
constructor(
restClientOptions: RestClientOptions = {},
requestOptions: AxiosRequestConfig = {},
Expand Down
2 changes: 1 addition & 1 deletion src/CoinbaseExchange.ts → src/CBExchangeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
* REST client for Coinbase's Institutional Exchange API:
* https://docs.cdp.coinbase.com/exchange/docs/welcome
*/
export class CoinbaseExchange extends BaseRestClient {
export class CBExchangeClient extends BaseRestClient {
constructor(
restClientOptions: RestClientOptions = {},
requestOptions: AxiosRequestConfig = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
* REST client for Coinbase's Institutional International Exchange API:
* https://docs.cdp.coinbase.com/intx/docs/welcome
*/
export class CoinbaseInternational extends BaseRestClient {
export class CBInternationalClient extends BaseRestClient {
constructor(
restClientOptions: RestClientOptions = {},
requestOptions: AxiosRequestConfig = {},
Expand Down
2 changes: 1 addition & 1 deletion src/CoinbasePrime.ts → src/CBPrimeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
* REST client for Coinbase Prime API:
* https://docs.cdp.coinbase.com/prime/docs/welcome
*/
export class CoinbasePrime extends BaseRestClient {
export class CBPrimeClient extends BaseRestClient {
constructor(
restClientOptions: RestClientOptions = {},
requestOptions: AxiosRequestConfig = {},
Expand Down
15 changes: 8 additions & 7 deletions src/WebsocketClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { AdvancedTradeClient } from './AdvancedTradeClient.js';
import { CBAdvancedTradeClient } from './CBAdvancedTradeClient.js';
import { BaseWebsocketClient, EmittableEvent } from './lib/BaseWSClient.js';
import { neverGuard } from './lib/misc-util.js';
import {
Expand Down Expand Up @@ -44,18 +44,19 @@ export const PUBLIC_WS_KEYS: WsKey[] = [
type WsTopic = string;

export class WebsocketClient extends BaseWebsocketClient<WsKey> {
private RESTClientCache: Record<WsMarket, AdvancedTradeClient | undefined> = {
advancedTrade: undefined,
};
private RESTClientCache: Record<WsMarket, CBAdvancedTradeClient | undefined> =
{
advancedTrade: undefined,
};

private getRESTClient(wsKey: WsKey): AdvancedTradeClient {
private getRESTClient(wsKey: WsKey): CBAdvancedTradeClient {
if (wsKey === 'spotPublicV1' || wsKey === 'spotPrivateV1') {
const clientType = 'advancedTrade';
if (this.RESTClientCache[clientType]) {
return this.RESTClientCache[clientType];
}

this.RESTClientCache[clientType] = new AdvancedTradeClient({
this.RESTClientCache[clientType] = new CBAdvancedTradeClient({
apiKeyName: this.options.apiKey,
apiPrivateKey: this.options.apiSecret,
});
Expand All @@ -67,7 +68,7 @@ export class WebsocketClient extends BaseWebsocketClient<WsKey> {
return this.RESTClientCache[clientType];
}

this.RESTClientCache[clientType] = new AdvancedTradeClient({
this.RESTClientCache[clientType] = new CBAdvancedTradeClient({
apiKeyName: this.options.apiKey,
apiPrivateKey: this.options.apiSecret,
});
Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export * from './AdvancedTradeClient.js';
export * from './CoinbaseAppClient.js';
export * from './CoinbaseInternational.js';
export * from './CoinbasePrime.js';
export * from './CBAdvancedTradeClient.js';
export * from './CBAppClient.js';
export * from './CBExchangeClient.js';
export * from './CBInternationalClient.js';
export * from './CBPrimeClient.js';
export * from './lib/websocket/logger.js';
export * from './lib/websocket/websocket-util.js';
export * from './types/request/advanced-trade-client.js';
Expand Down

0 comments on commit 9252d34

Please sign in to comment.