From e069a52fcfc28307112983c5e8575261abe4988a Mon Sep 17 00:00:00 2001 From: Wilson Lin Date: Tue, 24 Oct 2023 21:03:53 +1100 Subject: [PATCH] Initial commit --- src/main/java/com/dnsimple/data/Charge.java | 51 +++++++++++++++++++ .../java/com/dnsimple/data/ChargeItem.java | 45 ++++++++++++++++ .../java/com/dnsimple/endpoints/Billing.java | 37 ++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 src/main/java/com/dnsimple/data/Charge.java create mode 100644 src/main/java/com/dnsimple/data/ChargeItem.java create mode 100644 src/main/java/com/dnsimple/endpoints/Billing.java diff --git a/src/main/java/com/dnsimple/data/Charge.java b/src/main/java/com/dnsimple/data/Charge.java new file mode 100644 index 0000000..260dbe0 --- /dev/null +++ b/src/main/java/com/dnsimple/data/Charge.java @@ -0,0 +1,51 @@ + +package com.dnsimple.data; + +import com.dnsimple.data.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Charge { + private final String invoicedAt; + private final String totalAmount; + private final String balanceAmount; + private final String reference; + private final String state; + private final List items; + + public Charge(String invoicedAt, String totalAmount, String balanceAmount, String reference, String state, List items) { + this.invoicedAt = invoicedAt; + this.totalAmount = totalAmount; + this.balanceAmount = balanceAmount; + this.reference = reference; + this.state = state; + this.items = items; + } + + public String getInvoicedAt() { + return this.invoicedAt; + } + + public String getTotalAmount() { + return this.totalAmount; + } + + public String getBalanceAmount() { + return this.balanceAmount; + } + + public String getReference() { + return this.reference; + } + + public String getState() { + return this.state; + } + + public List getItems() { + return this.items; + } +} + \ No newline at end of file diff --git a/src/main/java/com/dnsimple/data/ChargeItem.java b/src/main/java/com/dnsimple/data/ChargeItem.java new file mode 100644 index 0000000..6389498 --- /dev/null +++ b/src/main/java/com/dnsimple/data/ChargeItem.java @@ -0,0 +1,45 @@ + +package com.dnsimple.data; + +import com.dnsimple.data.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ChargeItem { + private final String description; + private final String amount; + private final Number productId; + private final String productType; + private final String productReference; + + public ChargeItem(String description, String amount, Number productId, String productType, String productReference) { + this.description = description; + this.amount = amount; + this.productId = productId; + this.productType = productType; + this.productReference = productReference; + } + + public String getDescription() { + return this.description; + } + + public String getAmount() { + return this.amount; + } + + public Number getProductId() { + return this.productId; + } + + public String getProductType() { + return this.productType; + } + + public String getProductReference() { + return this.productReference; + } +} + \ No newline at end of file diff --git a/src/main/java/com/dnsimple/endpoints/Billing.java b/src/main/java/com/dnsimple/endpoints/Billing.java new file mode 100644 index 0000000..55c342b --- /dev/null +++ b/src/main/java/com/dnsimple/endpoints/Billing.java @@ -0,0 +1,37 @@ + +package com.dnsimple.endpoints; + +import com.dnsimple.data.*; +import com.dnsimple.http.HttpEndpointClient; +import com.dnsimple.request.*; +import com.dnsimple.response.EmptyResponse; +import com.dnsimple.response.ListResponse; +import com.dnsimple.response.SimpleResponse; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.dnsimple.http.HttpMethod.*; + +public class Billing { + private final HttpEndpointClient client; + + public Billing(HttpEndpointClient client) { + this.client = client; + } + + /** + * Lists the billing charges for the account. + * + * @see https://developer.dnsimple.com/v2/billing/#listCharges + */ + public ListResponse listCharges(Number account, ListOptions options) { + return client.list( + GET, + String.format("/%s/billing/charges", account), + options, + null, Charge.class + ); + } +} \ No newline at end of file