Exemple #1
0
 /// <summary>
 /// Test access to a facade
 /// </summary>
 /// <param name="facade">The facade</param>
 /// <returns>True authorized, else false</returns>
 public virtual bool TestAccess(Facade facade)
 {
     return(TestAccessAsync(facade).GetAwaiter().GetResult());
 }
Exemple #2
0
 /// <summary>
 /// Retrieve an invoice by id and token.
 /// </summary>
 /// <param name="invoiceId">The id of the requested invoice.</param>
 /// <param name="facade">The facade used (default POS).</param>
 /// <returns>The invoice object retrieved from the server.</returns>
 public virtual async Task <Invoice> GetInvoiceAsync(String invoiceId, Facade facade = null)
 {
     return(await GetInvoiceAsync <Invoice>(invoiceId, facade));
 }
Exemple #3
0
 /// <summary>
 /// Retrieve an invoice by id and token.
 /// </summary>
 /// <param name="invoiceId">The id of the requested invoice.</param>
 /// <param name="facade">The facade used (default POS).</param>
 /// <returns>The invoice object retrieved from the server.</returns>
 public virtual Invoice GetInvoice(String invoiceId, Facade facade = null)
 {
     return(GetInvoiceAsync(invoiceId, facade).GetAwaiter().GetResult());
 }
Exemple #4
0
 /// <summary>
 /// Create an invoice using the specified facade.
 /// </summary>
 /// <param name="invoice">An invoice request object.</param>
 /// <param name="facade">The facade used (default POS).</param>
 /// <returns>A new invoice object returned from the server.</returns>
 public virtual Invoice CreateInvoice(Invoice invoice, Facade facade = null)
 {
     return(CreateInvoiceAsync(invoice, facade).GetAwaiter().GetResult());
 }
Exemple #5
0
        /// <summary>
        /// Request authorization (a token) for this client in the specified facade.
        /// </summary>
        /// <param name="label">The label of this token.</param>
        /// <param name="facade">The facade for which authorization is requested.</param>
        /// <returns>A pairing code for this client.  This code must be used to authorize this client at BitPay.com/api-tokens.</returns>
        public virtual async Task <PairingCode> RequestClientAuthorizationAsync(string label, Facade facade)
        {
            Token token = new Token();

            token.Id     = _Auth.SIN;
            token.Guid   = Guid.NewGuid().ToString();
            token.Facade = facade.ToString();
            token.Count  = 1;
            token.Label  = label ?? "DEFAULT";
            String json = JsonConvert.SerializeObject(token);
            HttpResponseMessage response = await this.PostAsync("tokens", json).ConfigureAwait(false);

            var tokens = await this.ParseResponse <List <Token> >(response).ConfigureAwait(false);

            // Expecting a single token resource.
            if (tokens.Count != 1)
            {
                throw new BitPayException("Error - failed to get token resource; expected 1 token, got " + tokens.Count);
            }
            _Auth.SaveToken(tokens[0].Facade, tokens[0].Value);
            return(new PairingCode(tokens[0].PairingCode));
        }
Exemple #6
0
 /// <summary>
 /// Request authorization (a token) for this client in the specified facade.
 /// </summary>
 /// <param name="label">The label of this token.</param>
 /// <param name="facade">The facade for which authorization is requested.</param>
 /// <returns>A pairing code for this client.  This code must be used to authorize this client at BitPay.com/api-tokens.</returns>
 public virtual PairingCode RequestClientAuthorization(string label, Facade facade)
 {
     return(RequestClientAuthorizationAsync(label, facade).GetAwaiter().GetResult());
 }