Beispiel #1
0
        public async Task can_place_buyorder()
        {
            SetupServerSingleResponse(Sell2);

            var create = new PlaceSell
            {
                Amount        = 10m,
                Currency      = "BTC",
                PaymentMethod = "B28EB04F-BD70-4308-90A1-96065283A001"
            };
            var r = await client.Sells.PlaceSellOrderAsync("fff", create);

            var truth = new Response <Sell>
            {
                Data = Sell2Model
            };

            truth.Should().BeEquivalentTo(r);

            server.ShouldHaveRequestBody(
                @"{""amount"":10.0,""currency"":""BTC"",""payment_method"":""B28EB04F-BD70-4308-90A1-96065283A001"",""agree_btc_amount_varies"":false,""commit"":false,""quote"":false}");

            server.ShouldHaveExactCall($"https://api.coinbase.com/v2/accounts/fff/sells")
            .WithVerb(HttpMethod.Post);
        }
Beispiel #2
0
 /// <summary>
 /// Sells a user-defined amount of bitcoin, bitcoin cash, litecoin or ethereum.
 /// There are two ways to define sell amounts–you can use either the amount or the total parameter:
 /// 1.When supplying amount, you’ll get the amount of bitcoin, bitcoin cash, litecoin or ethereum defined. With amount it’s recommended to use BTC or ETH as the currency value, but you can always specify a fiat currency and the amount will be converted to BTC or ETH respectively.
 /// 2.When supplying total, your payment method will be credited the total amount and you’ll get the amount in BTC or ETH after fees have been reduced from the subtotal. With total it’s recommended to use the currency of the payment method as the currency parameter, but you can always specify a different currency and it will be converted.
 /// Given the price of digital currency depends on the time of the call and amount of the sell, it’s recommended to use the commit: false parameter to create an uncommitted sell to get a quote and then to commit that with a separate request.
 ///If you need to query the sell price without locking in the sell, you can use quote: true option. This returns an unsaved sell and unlike commit: false, this sell can’t be completed. This option is useful when you need to show the detailed sell price quote for the user when they are filling a form or similar situation.
 /// </summary>
 Task <Response <Sell> > ISellsEndpoint.PlaceSellOrderAsync(string accountId, PlaceSell placeSell, CancellationToken cancellationToken)
 {
     return(this.AccountsEndpoint
            .AppendPathSegments(accountId, "sells")
            .WithClient(this)
            .PostJsonAsync(placeSell, cancellationToken)
            .ReceiveJson <Response <Sell> >());
 }
Beispiel #3
0
        public async Task can_deser_sellorder()
        {
            SetupServerSingleResponse(SellOrder);

            var create = new PlaceSell
            {
                Amount        = 10m,
                Currency      = "BTC",
                PaymentMethod = "B28EB04F-BD70-4308-90A1-96065283A001"
            };

            Func <Task <Response <Sell> > > action = async() =>
                                                     await client.Sells.PlaceSellOrderAsync("fff", create);

            action.Should().NotThrow();
        }