[coinbase] Update Account.getTransactions (#36010)

* [coinbase] Update Account.getTransactions

This is to update the signature of `Account.getTransactions` to match that which is present in the module.

https://github.com/coinbase/coinbase-node/blob/master/lib/model/Account.js#L98 for relevant JS code.

* [coinbase] Additional nested fixes

- The coinbase client only "unwraps" the `data` attribute
in certain circumstances.  This addresses issues I was seeing
while attempting to leverage some of the other resource
This commit is contained in:
Justin Nauman 2019-06-10 12:12:28 -05:00 committed by Andrew Casey
parent ea2b8bd4a6
commit 3eb966a761
2 changed files with 57 additions and 51 deletions

View File

@ -37,7 +37,7 @@ client.getAccount("abcdef", (error: Error | null, account: coinbase.Account): vo
account.getTransaction("abcdef", (error: Error | null, deposit: coinbase.Transaction): void => undefined);
account.getTransactions((error: Error | null, deposit: coinbase.Transaction[]): void => undefined);
account.getTransactions({}, (error: Error | null, deposit: coinbase.Transaction[]): void => undefined);
account.getWithdrawal("abcdef", (error: Error | null, deposit: coinbase.Withdrawal): void => undefined);
@ -54,13 +54,13 @@ client.getAccount("abcdef", (error: Error | null, account: coinbase.Account): vo
});
account.sell(
{ agree_btc_amount_varies: true, amount: "1", commit: true, currency: "BTC", payment_method: "abcdef", quote: true},
{ agree_btc_amount_varies: true, amount: "1", commit: true, currency: "BTC", payment_method: "abcdef", quote: true },
(error: Error | null, sell: coinbase.Sell): void => {
sell.commit((error: Error | null, sell: coinbase.Sell): void => undefined);
}
);
account.sell(
{ currency: "BTC", payment_method: "abcdef", total: "3"},
{ currency: "BTC", payment_method: "abcdef", total: "3" },
(error: Error | null, sell: coinbase.Sell): void => {
sell.commit((error: Error | null, sell: coinbase.Sell): void => undefined);
}
@ -80,16 +80,16 @@ client.getAccount("abcdef", (error: Error | null, account: coinbase.Account): vo
account.update({ name: "foo" }, (error: Error | null, result: coinbase.Account): void => undefined);
account.withdraw({ amount: "1", commit: false, currency: "ETH", payment_method: "abcdef"}, (error: Error | null, result: coinbase.Withdrawal): void => {
account.withdraw({ amount: "1", commit: false, currency: "ETH", payment_method: "abcdef" }, (error: Error | null, result: coinbase.Withdrawal): void => {
result.commit((error: Error | null, result: coinbase.Withdrawal): void => undefined);
});
});
client.getBuyPrice({ currencyPair: "USD-BTC" }, (error: Error | null, result: coinbase.Price): void => undefined);
client.getCurrencies((error: Error | null, result: coinbase.Currency[]): void => undefined);
client.getCurrencies((error: Error | null, result: coinbase.Currencies): void => undefined);
client.getExchangeRates({currency: "ETC"}, (error: Error | null, result: coinbase.ExchangeRate): void => undefined);
client.getExchangeRates({ currency: "ETC" }, (error: Error | null, result: coinbase.ExchangeRate): void => undefined);
client.getPaymentMethod("foo", (error: Error | null, result: coinbase.PaymentMethod): void => undefined);

View File

@ -600,7 +600,7 @@ export class Account implements Resource {
* Lists accounts transactions.
* Scope: wallet:transactions:read
*/
getTransactions(cb: (error: Error | null, result: Transaction[]) => void): void;
getTransactions(opts: {}, cb: (error: Error | null, result: Transaction[]) => void): void;
/**
* Show an individual transaction for an account
@ -966,29 +966,29 @@ export class Buy implements Resource {
}
export interface Fee {
/**
* Amount associated to this fee
*/
amount: MoneyHash;
/**
* Fee beneficiary ("bank", "coinbase", ...)
*/
type: string;
/**
* Amount associated to this fee
*/
amount: MoneyHash;
/**
* Fee beneficiary ("bank", "coinbase", ...)
*/
type: string;
}
export interface UnitPrice {
/**
* Amount as floating-point in a string
*/
amount: string;
/**
* Currency e.g. "BTC" (see Client#getCurrencies() for available strings)
*/
currency: string;
/**
* Type of price
*/
scale: number;
/**
* Amount as floating-point in a string
*/
amount: string;
/**
* Currency e.g. "BTC" (see Client#getCurrencies() for available strings)
*/
currency: string;
/**
* Type of price
*/
scale: number;
}
export type SellStatus = "created" | "completed" | "canceled";
@ -1337,35 +1337,41 @@ export interface PaymentMethodLimit {
* Information about one supported currency. Currency codes will conform to the ISO 4217 standard where possible.
* Currencies which have or had no representation in ISO 4217 may use a custom code (e.g. BTC).
*/
export interface Currency {
/**
* Abbreviation e.g. "USD" or "BTC"
*/
id: string;
/**
* Full name e.g. "United Arab Emirates Dirham"
*/
name: string;
/**
* Floating-point number in a string
*/
min_size: string;
export interface Currencies {
data: [{
/**
* Abbreviation e.g. "USD" or "BTC"
*/
id: string;
/**
* Full name e.g. "United Arab Emirates Dirham"
*/
name: string;
/**
* Floating-point number in a string
*/
min_size: string;
}];
}
export interface ExchangeRate {
/**
* Base currency
*/
currency: string;
/**
* Rates as floating points in strings; indexed by currency id
*/
rates: { [index: string]: string };
data: {
/**
* Base currency
*/
currency: string;
/**
* Rates as floating points in strings; indexed by currency id
*/
rates: { [index: string]: string };
};
}
export interface Time {
iso: string;
epoch: number;
data: {
iso: string;
epoch: number;
};
}
export class Client {
@ -1421,7 +1427,7 @@ export class Client {
* representation in ISO 4217 may use a custom code (e.g. BTC).
* Scope: none
*/
getCurrencies(cb: (error: Error | null, result: Currency[]) => void): void;
getCurrencies(cb: (error: Error | null, result: Currencies) => void): void;
/**
* Get current exchange rates. Default base currency is USD but it can be defined as any supported currency.