Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilson Lin committed Oct 24, 2023
1 parent 290ad7b commit e069a52
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/main/java/com/dnsimple/data/Charge.java
Original file line number Diff line number Diff line change
@@ -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<ChargeItem> items;

public Charge(String invoicedAt, String totalAmount, String balanceAmount, String reference, String state, List<ChargeItem> 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<ChargeItem> getItems() {
return this.items;
}
}

45 changes: 45 additions & 0 deletions src/main/java/com/dnsimple/data/ChargeItem.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

37 changes: 37 additions & 0 deletions src/main/java/com/dnsimple/endpoints/Billing.java
Original file line number Diff line number Diff line change
@@ -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 <a href="https://developer.dnsimple.com/v2/billing/#listCharges">https://developer.dnsimple.com/v2/billing/#listCharges</a>
*/
public ListResponse<Charge> listCharges(Number account, ListOptions options) {
return client.list(
GET,
String.format("/%s/billing/charges", account),
options,
null, Charge.class
);
}
}

0 comments on commit e069a52

Please sign in to comment.