Skip to content

Commit

Permalink
Merge pull request #150 from mwarzybok-sumoheavy/feature/SP-736
Browse files Browse the repository at this point in the history
SP-736 Type Review: C#
  • Loading branch information
bobbrodie committed Feb 26, 2024
2 parents 6f714fe + 4fb1b2c commit 0371f2a
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 81 deletions.
13 changes: 4 additions & 9 deletions BitPay/Models/Invoice/Invoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public class Invoice
{
private string _currency = "";
private dynamic? _exchangeRates;
private dynamic? _refundAddresses;


// Creates a minimal invoice request object.
public Invoice(decimal price, string currency)
{
Expand Down Expand Up @@ -187,13 +186,9 @@ public string Currency
public string? ExceptionStatus { get; set; }

[JsonProperty(PropertyName = "refundAddresses")]
public dynamic? RefundAddresses
{
get => _refundAddresses;
set => _refundAddresses = JsonConvert.DeserializeObject(value?.ToString(Formatting.None));
}

[JsonProperty(PropertyName = "refundAddressRequestPendin")]
public List<Dictionary<string, InvoiceRefundAddresses>>? RefundAddresses { get; set; }

[JsonProperty(PropertyName = "refundAddressRequestPending")]
public bool? RefundAddressRequestPending { get; set; }

[JsonProperty(PropertyName = "buyerProvidedEmail")]
Expand Down
30 changes: 30 additions & 0 deletions BitPay/Models/Invoice/InvoiceRefundAddresses.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2019 BitPay.
// All rights reserved.

using System;

using Newtonsoft.Json;

namespace BitPay.Models.Invoice
{
public class InvoiceRefundAddresses
{
public InvoiceRefundAddresses(string type, DateTime date)
{
Type = type;
Date = date;
}

[JsonProperty(PropertyName = "type")]
public string Type { get; set; }

[JsonProperty(PropertyName = "date")]
public DateTime Date { get; set; }

[JsonProperty(PropertyName = "tag")]
public int? Tag { get; set; }

[JsonProperty(PropertyName = "email")]
public string? Email { get; set; }
}
}
67 changes: 67 additions & 0 deletions BitPay/Models/Invoice/InvoiceWebhook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) 2019 BitPay.
// All rights reserved.

using System.Collections.Generic;
using System.Numerics;

using Newtonsoft.Json;

namespace BitPay.Models.Invoice
{
public class InvoiceWebhook
{
[JsonProperty(PropertyName = "id")]
public string? Id { get; set; }

[JsonProperty(PropertyName = "url")]
public string? Url { get; set; }

[JsonProperty(PropertyName = "posData")]
public string? PosData { get; set; }

[JsonProperty(PropertyName = "status")]
public string? Status { get; set; }

[JsonProperty(PropertyName = "price")]
public double? Price { get; set; }

[JsonProperty(PropertyName = "currency")]
public string? Currency { get; set; }

[JsonProperty(PropertyName = "invoiceTime")]
public string? InvoiceTime { get; set; }

[JsonProperty(PropertyName = "currencyTime")]
public string? CurrencyTime { get; set; }

[JsonProperty(PropertyName = "exceptionStatus")]
public string? ExceptionStatus { get; set; }

[JsonProperty(PropertyName = "buyerFields")]
public BuyerFields? BuyerFields { get; set; }

[JsonProperty(PropertyName = "paymentSubtotals")]
public Dictionary<string, BigInteger>? PaymentSubtotals { get; set; }

[JsonProperty(PropertyName = "paymentTotals")]
public Dictionary<string, BigInteger>? PaymentTotals { get; set; }

[JsonProperty(PropertyName = "exchangeRates")]
public Dictionary<string, Dictionary<string, decimal>>? ExchangeRates { get; set; }

[JsonProperty(PropertyName = "amountPaid")]
public double? AmountPaid { get; set; }

[JsonProperty(PropertyName = "orderId")]
public string? OrderId { get; set; }

[JsonProperty(PropertyName = "transactionCurrency")]
public string? TransactionCurrency { get; set; }

[JsonProperty(PropertyName = "inInvoiceId")]
public string? InInvoiceId { get; set; }

[JsonProperty(PropertyName = "inPaymentRequest")]
public string? InPaymentRequest { get; set; }
}
}
24 changes: 24 additions & 0 deletions BitPay/Models/Invoice/RefundWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,29 @@ public class RefundWebhook

[JsonProperty(PropertyName = "supportRequest")]
public string? SupportRequest { get; set; }

[JsonProperty(PropertyName = "reference")]
public string? Reference { get; set; }

[JsonProperty(PropertyName = "guid")]
public string? ResourceGuid { get; set; }

[JsonProperty(PropertyName = "refundAddress")]
public string? RefundAddress { get; set; }

[JsonProperty(PropertyName = "type")]
public string? Type { get; set; }

[JsonProperty(PropertyName = "txid")]
public string? Txid { get; set; }

[JsonProperty(PropertyName = "transactionCurrency")]
public string? TransactionCurrency { get; set; }

[JsonProperty(PropertyName = "transactionAmount")]
public double? TransactionAmount { get; set; }

[JsonProperty(PropertyName = "transactionRefundFee")]
public double? TransactionRefundFee { get; set; }
}
}
2 changes: 1 addition & 1 deletion BitPay/Models/Ledger/LedgerEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LedgerEntry
{
[JsonProperty(PropertyName = "type")] public string? Type { get; set; }

[JsonProperty(PropertyName = "amount")] public int? Amount { get; set; }
[JsonProperty(PropertyName = "amount")] public string? Amount { get; set; }

[JsonProperty(PropertyName = "code")] public int? Code { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion BitPay/Models/Payout/PayoutTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class PayoutInstructionTransaction
public DateTime? Date { get; set; }

[JsonProperty(PropertyName = "confirmations")]
public string? Confirmations { get; set; }
public int? Confirmations { get; set; }

public PayoutInstructionTransaction(decimal amount)
{
Expand Down
9 changes: 8 additions & 1 deletion BitPay/Models/Payout/PayoutWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ public class PayoutWebhook

[JsonProperty(PropertyName = "transactions")]
public List<InvoiceTransaction>? Transactions { get; set; }


[JsonProperty(PropertyName = "accountId")]
public string? AccountId { get; set; }

[JsonProperty(PropertyName = "dateExecuted")]
public DateTime? DateExecuted { get; set; }

[JsonProperty(PropertyName = "groupId")]
public string? GroupId { get; set; }
}
}

0 comments on commit 0371f2a

Please sign in to comment.