-
Notifications
You must be signed in to change notification settings - Fork 67
Examples
coinbase.accountResource.list { result in
switch result {
case .success(let accountsList):
// ...
case .failure(let error):
// ..
}
}
coinbase.accountResource.account(id: <account_id>, completion: completion)
coinbase.accountResource.updateAccount(id: <account_id>, name: <new_name>, completion: completion)
coinbase.accountResource.deleteAccount(id: <account_id>, completion: completion)
let sendParameters = SendTransactionParameters(to: "[email protected]",
amount: "0.01",
currency: "BTC",
description: "Thanks for the coffee!")
coinbase.transactionResource.send(accountID: <account_id>,
twoFactorAuthToken: <2fa_token>,
parameters: sendParameters,
completion: completion)
The to
parameter can be a bitcoin address, bitcoin cash address, litecoin address, ethereum address, or an email of the recipient. The description
parameter is a note which will be included in the email that the recipient receives.
let sendParameters = SendTransactionParameters(to: "[email protected]",
amount: "2.55",
currency: "USD",
description: "Thanks for the coffee!")
coinbase.transactionResource.send(accountID: <account_id>,
twoFactorAuthToken: <2fa_token>,
parameters: sendParameters,
completion: completion)
Reed about Two factor authentication
let requestParameters = RequestTransactionParameters(to: "[email protected]",
amount: "0.01",
currency: "BTC",
description: "Invoice for window cleaning")
coinbase.transactionResource.request(accountID: <account_id>,
parameters: requestParameters,
completion: completion)
This will send an email to the recipient, requesting payment.
The request can be re-sent
coinbase.transactionResource.resendRequest(accountID: <account_id>,
transactionID: <transaction_id>,
completion: completion)
or canceled
coinbase.transactionResource.cancelRequest(accountID: <account_id>,
transactionID: <transaction_id>,
completion: completion)
To fulfill the request a recipient should call
coinbase.transactionResource.completeRequest(accountID: <account_id>,
transactionID: <transaction_id>,
completion: completion)
The result list is in descending order by default (newest item first). Default limit is set to 25.
coinbase.transactionResource.list(accountID: <account_id>,
completion: completion)
This will fetch a transaction with all fields expanded:
coinbase.transactionResource.transaction(accountID: <account_id>,
transactionID: <transaction_id>,
expandOptions: [.all],
completion: completion)
Buying and selling requires user to add a payment method through the web app first.
Then you can place buy/sell order and pass an amount
of crypto currency you want to buy/sell.
For buy:
let buyParameters = BuySellParameters(amount: "0.01",
currency: "BTC",
paymentMethod: <payment_method_id>)
coinbase.buyResource.placeOrder(accountID: <account_id>,
parameters: buyParameters,
completion: completion)
For sell:
let sellParameters = BuySellParameters(amount: "0.01",
currency: "BTC",
paymentMethod: <payment_method_id>)
coinbase.sellResource.placeOrder(accountID: <account_id>,
parameters: sellParameters,
completion: completion)
You can use list
to view history of buys and sells.
For history of buys:
coinbase.buyResource.list(accountID: <account_id>,
completion: completion)
For history of sells:
coinbase.sellResource.list(accountID: <account_id>,
completion: completion)