diff --git a/lib/buyer.ts b/lib/buyer.ts index 4a279ff..cc23cc4 100644 --- a/lib/buyer.ts +++ b/lib/buyer.ts @@ -57,7 +57,7 @@ export interface Buyer extends Resource { export class BuyerEndpoint extends Endpoint { constructor(marketplace: MarketplaceEndpoint, id: string) { - super(marketplace.base + `/buyers/${id}`, marketplace.apiKey); + super(marketplace.base + `/buyers/${id}`, marketplace.apiKey, marketplace.apiSecret); } async get() { diff --git a/lib/endpoint.ts b/lib/endpoint.ts index 58ca593..4b3c568 100644 --- a/lib/endpoint.ts +++ b/lib/endpoint.ts @@ -15,7 +15,7 @@ enum StatusClass { } export abstract class Endpoint { - constructor(readonly base: string, readonly apiKey: string) { } + constructor(readonly base: string, readonly apiKey: string, readonly apiSecret: string) { } private static statusClass(statusCode: number): StatusClass { return Math.floor(statusCode / 100); @@ -31,7 +31,7 @@ export abstract class Endpoint { public async request(method: string, route: string = '', payload?: object): Promise { const headers = new Headers({ - Authorization: `Basic ${btoa(`${this.apiKey}:${this.apiKey}`)}`, + Authorization: `Basic ${btoa(`${this.apiKey}:${this.apiSecret}`)}`, }); let uri; diff --git a/lib/marketplace.ts b/lib/marketplace.ts index afc40e8..4431f12 100644 --- a/lib/marketplace.ts +++ b/lib/marketplace.ts @@ -36,7 +36,7 @@ export interface Marketplace extends Resource { export class MarketplaceEndpoint extends Endpoint { constructor(zoop: Zoop, id: string) { - super(zoop.base + `/marketplaces/${id}`, zoop.apiKey); + super(zoop.base + `/marketplaces/${id}`, zoop.apiKey, zoop.apiSecret); } buyer(id: string): BuyerEndpoint { diff --git a/lib/seller.ts b/lib/seller.ts index 51633d6..a24c67b 100644 --- a/lib/seller.ts +++ b/lib/seller.ts @@ -12,7 +12,7 @@ export interface Seller extends Resource { export class SellerEndpoint extends Endpoint { constructor(marketplace: MarketplaceEndpoint, id: string) { - super(marketplace.base + `/sellers/${id}`, marketplace.apiKey); + super(marketplace.base + `/sellers/${id}`, marketplace.apiKey, marketplace.apiSecret); } async get() { diff --git a/lib/token.ts b/lib/token.ts index 1d930a8..87c8a14 100644 --- a/lib/token.ts +++ b/lib/token.ts @@ -44,7 +44,7 @@ export type Token = BankAccountToken | CardToken; export class TokenEndpoint extends Endpoint { constructor(marketplace: MarketplaceEndpoint, id: string) { - super(marketplace.base + `/tokens/${id}`, marketplace.apiKey); + super(marketplace.base + `/tokens/${id}`, marketplace.apiKey, marketplace.apiSecret); } async get() { diff --git a/lib/transaction.ts b/lib/transaction.ts index 01f65a8..3191cff 100644 --- a/lib/transaction.ts +++ b/lib/transaction.ts @@ -56,7 +56,7 @@ export interface Transaction extends Resource { export class TransactionEndpoint extends Endpoint { constructor(marketplace: MarketplaceEndpoint, id: string) { - super(marketplace.base + `/transactions/${id}`, marketplace.apiKey); + super(marketplace.base + `/transactions/${id}`, marketplace.apiKey, marketplace.apiSecret); } async get() { diff --git a/lib/zoop.ts b/lib/zoop.ts index 05dd2f5..bac9416 100644 --- a/lib/zoop.ts +++ b/lib/zoop.ts @@ -5,8 +5,8 @@ import { AnyResource, Resource } from './resource'; const API_BASE = 'https://api.zoop.ws/v1'; export class Zoop extends Endpoint { - constructor(readonly apiKey: string) { - super(API_BASE, apiKey); + constructor(readonly apiKey: string, readonly apiSecret: string = apiKey) { + super(API_BASE, apiKey, apiSecret); } marketplace(id: string) {