Skip to content

Commit

Permalink
2.0.0 - added fatJar to download an all in one jar file. Update the j…
Browse files Browse the repository at this point in the history
…ava client to the lastest api changes. Closes #6 and Closes #7

updated docs
  • Loading branch information
ppone committed Dec 4, 2017
1 parent 2e9cb5f commit 17bea4e
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
language: java
dist: precise
jdk:
- oraclejdk8
- oraclejdk7
script:
- gradle -i check
- ./gradlew -i check
after_success:
- ./gradlew cobertura coveralls
notifications:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ You can build the jar file by doing
gradle jar
```

or build the complete all in one jar file by doing

```
gradle fatJar
```

## Requirements

- Gradle 3.0
Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ cobertura.coverageFormats = ['html', 'xml']
// Apply the java plugin to add support for Java
apply plugin: 'java'

task fatJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}

// In this section you declare where to find the dependencies of your project
repositories {
Expand All @@ -16,7 +21,7 @@ repositories {
jcenter()
}

version = '1.1.2'
version = '2.0.0'

// coveralls plugin depends on xml format report

Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/invoiced/entity/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ protected long getParentID() {
@JsonProperty("taxes")
public Tax[] taxes;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("disabled_payment_methods")
public String[] disabledPaymentMethods;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("type")
public String type;
Expand All @@ -99,6 +103,10 @@ protected long getParentID() {
@JsonProperty("attention_to")
public String attentionTo;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("stripe_token")
public String stripeToken;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("address1")
public String address1;
Expand Down Expand Up @@ -135,12 +143,10 @@ protected long getParentID() {
@JsonProperty("notes")
public String notes;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("statement_pdf_url")
@JsonProperty(value = "statement_pdf_url", access = JsonProperty.Access.WRITE_ONLY)
public String statementPdfUrl;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("created_at")
@JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
public long createdAt;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
Expand Down
33 changes: 13 additions & 20 deletions src/main/java/com/invoiced/entity/Invoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.invoiced.exception.EntityException;
import com.invoiced.util.Util;

//@JsonIgnoreProperties(value = { "paid" }, allowSetters = true)
public class Invoice extends AbstractEntity<Invoice> {

public Invoice(Connection conn) {
Expand Down Expand Up @@ -94,12 +97,10 @@ protected long getParentID() {
@JsonProperty("closed")
public boolean closed;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("paid")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
public boolean paid;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("status")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
public String status;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
Expand All @@ -118,12 +119,10 @@ protected long getParentID() {
@JsonProperty("attempt_count")
public long attemptCount;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("next_payment_attempt")
@JsonProperty(value = "next_payment_attempt", access = JsonProperty.Access.WRITE_ONLY)
public long nextPaymentAttempt;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("subscription")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
public long subscription;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
Expand Down Expand Up @@ -158,32 +157,26 @@ protected long getParentID() {
@JsonProperty("taxes")
public Tax[] taxes;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("total")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
public double total;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("balance")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
public double balance;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("tags")
public Object[] tags;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("url")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
public String url;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("payment_url")
@JsonProperty(value = "payment_url", access = JsonProperty.Access.WRITE_ONLY)
public String paymentUrl;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("pdf_url")
@JsonProperty(value = "pdf_url", access = JsonProperty.Access.WRITE_ONLY)
public String pdfUrl;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("created_at")
@JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
public long createdAt;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
Expand Down
32 changes: 21 additions & 11 deletions src/main/java/com/invoiced/entity/Subscription.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ public class Subscription extends AbstractEntity<Subscription> {

public Subscription(Connection conn) {
super(conn, Subscription.class);

}

Subscription() {
super(Subscription.class);

}

@Override
Expand Down Expand Up @@ -81,22 +83,32 @@ protected long getParentID() {
@JsonProperty("cycles")
public int cycles;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("period_start")
@JsonProperty(value = "period_start", access = JsonProperty.Access.WRITE_ONLY)
public long periodStart;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("period_end")
@JsonProperty(value = "period_end", access = JsonProperty.Access.WRITE_ONLY)
public long periodEnd;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("snap_to_nth_day")
public long snapToNthDay;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("cancel_at_period_end")
public boolean cancelAtPeriodEnd;
public Boolean cancelAtPeriodEnd;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("canceled_at")
@JsonProperty(value = "canceled_at", access = JsonProperty.Access.WRITE_ONLY)
public long canceledAt;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("prorate")
public Boolean prorate;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("proration_date")
public long prorationDate;


@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("status")
public String status;
Expand All @@ -113,12 +125,10 @@ protected long getParentID() {
@JsonProperty("taxes")
public String[] taxes;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("url")
@JsonProperty(value = "url", access = JsonProperty.Access.WRITE_ONLY)
public String url;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("created_at")
@JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
public long createdAt;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/invoiced/entity/SubscriptionAddOn.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ public class SubscriptionAddOn extends AbstractItem {
@JsonProperty("id")
public long id;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("object")
public String object;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("description")
public String description;


@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("catalog_item")
public String catalogItem;
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/invoiced/entity/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ protected long getParentID() {
@JsonProperty("invoice")
public long invoice;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("credit_note")
public long creditNote;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("date")
public long date;
Expand Down Expand Up @@ -118,16 +122,13 @@ protected long getParentID() {
@JsonProperty("failure_reason")
public String failureReason;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("parent_transaction")
@JsonProperty(value = "parent_transaction", access = JsonProperty.Access.WRITE_ONLY)
public long parentTransaction;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("pdf_url")
@JsonProperty(value = "pdf_url", access = JsonProperty.Access.WRITE_ONLY)
public String pdfUrl;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("created_at")
@JsonProperty(value = "created_at", access = JsonProperty.Access.WRITE_ONLY)
public long createdAt;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/invoiced/entity/InvoiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void testJsonSerialization() {
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

try {
String jsonInString = "{\n \"id\": 46225,\n \"customer\": 15444,\n \"name\": null,\n \"currency\": \"usd\",\n \"draft\": false,\n \"closed\": false,\n \"paid\": false,\n \"status\": \"not_sent\",\n \"chase\": false,\n \"next_chase_on\": null,\n \"collection_mode\": \"manual\",\n \"attempt_count\": 0,\n \"next_payment_attempt\": null,\n \"subscription\": null,\n \"number\": \"INV-0016\",\n \"date\": 1416290400,\n \"due_date\": 1417500000,\n \"payment_terms\": \"NET 14\",\n \"items\": [\n {\n \"id\": 7,\n \"catalog_item\": null,\n \"type\": \"product\",\n \"name\": \"Copy Paper, Case\",\n \"description\": null,\n \"quantity\": 1,\n \"unit_cost\": 45,\n \"amount\": 45,\n \"discountable\": true,\n \"discounts\": [],\n \"taxable\": true,\n \"taxes\": [],\n \"metadata\": {}\n },\n {\n \"id\": 8,\n \"catalog_item\": \"delivery\",\n \"type\": \"service\",\n \"name\": \"Delivery\",\n \"description\": \"\",\n \"quantity\": 1,\n \"unit_cost\": 10,\n \"amount\": 10,\n \"discountable\": true,\n \"discounts\": [],\n \"taxable\": true,\n \"taxes\": [],\n \"metadata\": {}\n }\n ],\n \"notes\": null,\n \"subtotal\": 55,\n \"discounts\": [],\n \"taxes\": [\n {\n \"id\": 20554,\n \"amount\": 3.85,\n \"tax_rate\": null\n }\n ],\n \"total\": 51.15,\n \"balance\": 51.15,\n \"tags\": [],\n \"url\": \"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY\",\n \"payment_url\": \"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY/payment\",\n \"pdf_url\": \"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY/pdf\",\n \"created_at\": 1415229884,\n \"metadata\": {}\n}";
String jsonInString = "{\n \"id\": 46225,\n \"customer\": 15444,\n \"name\": null,\n \"currency\": \"usd\",\n \"draft\": false,\n \"closed\": false,\n \"paid\": true,\n \"status\": \"not_sent\",\n \"chase\": false,\n \"next_chase_on\": null,\n \"collection_mode\": \"manual\",\n \"attempt_count\": 0,\n \"next_payment_attempt\": null,\n \"subscription\": null,\n \"number\": \"INV-0016\",\n \"date\": 1416290400,\n \"due_date\": 1417500000,\n \"payment_terms\": \"NET 14\",\n \"items\": [\n {\n \"id\": 7,\n \"catalog_item\": null,\n \"type\": \"product\",\n \"name\": \"Copy Paper, Case\",\n \"description\": null,\n \"quantity\": 1,\n \"unit_cost\": 45,\n \"amount\": 45,\n \"discountable\": true,\n \"discounts\": [],\n \"taxable\": true,\n \"taxes\": [],\n \"metadata\": {}\n },\n {\n \"id\": 8,\n \"catalog_item\": \"delivery\",\n \"type\": \"service\",\n \"name\": \"Delivery\",\n \"description\": \"\",\n \"quantity\": 1,\n \"unit_cost\": 10,\n \"amount\": 10,\n \"discountable\": true,\n \"discounts\": [],\n \"taxable\": true,\n \"taxes\": [],\n \"metadata\": {}\n }\n ],\n \"notes\": null,\n \"subtotal\": 55,\n \"discounts\": [],\n \"taxes\": [\n {\n \"id\": 20554,\n \"amount\": 3.85,\n \"tax_rate\": null\n }\n ],\n \"total\": 51.15,\n \"balance\": 51.15,\n \"tags\": [],\n \"url\": \"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY\",\n \"payment_url\": \"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY/payment\",\n \"pdf_url\": \"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY/pdf\",\n \"created_at\": 1415229884,\n \"metadata\": {}\n}";

Invoice i1 = mapper.readValue(jsonInString, Invoice.class);

Expand All @@ -254,7 +254,7 @@ public void testJsonSerialization() {
assertTrue("Currency is incorrect", i1.currency.equals("usd"));
assertTrue("Draft is incorrect", i1.draft == false);
assertTrue("Closed is incorrect", i1.closed == false);
assertTrue("Paid is incorrect", i1.paid == false);
assertTrue("Paid is incorrect", i1.paid == true);
assertTrue("Status is incorrect", i1.status.equals("not_sent"));
assertTrue("Chase is incorrect", i1.chase == false);
assertTrue("Next Chase On is incorrect", i1.nextChaseOn == 0);
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/mappings/connection_rr_13.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": "/invoices",
"bodyPatterns": [
{
"equalToJson": "{\"customer\":15444,\"draft\":false,\"closed\":false,\"paid\":false,\"sent\":false,\"chase\":false,\"payment_terms\":\"NET 14\",\"items\":[{\"name\":\"Copy paper, Case\",\"quantity\":1.0,\"unit_cost\":45.0,\"discountable\":false,\"taxable\":false},{\"catalog_item\":\"delivery\",\"quantity\":1.0,\"discountable\":false,\"taxable\":false}],\"taxes\":[{\"amount\":3.85}]}"
"equalToJson": "{\"customer\":15444,\"draft\":false,\"closed\":false,\"sent\":false,\"chase\":false,\"payment_terms\":\"NET 14\",\"items\":[{\"name\":\"Copy paper, Case\",\"quantity\":1.0,\"unit_cost\":45.0,\"discountable\":false,\"taxable\":false},{\"catalog_item\":\"delivery\",\"quantity\":1.0,\"discountable\":false,\"taxable\":false}],\"taxes\":[{\"amount\":3.85}]}"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/mappings/connection_rr_15.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": "/invoices/46225",
"bodyPatterns": [
{
"equalToJson": "{\"id\":46225,\"customer\":15444,\"name\":\"July Paper Delivery\",\"number\":\"INV-0016\",\"collection_mode\":\"manual\",\"currency\":\"usd\",\"draft\":false,\"closed\":false,\"paid\":false,\"status\":\"not_sent\",\"sent\":true,\"chase\":false,\"date\":1416290400,\"due_date\":1417500000,\"payment_terms\":\"NET 14\",\"items\":[{\"id\":7,\"type\":\"product\",\"name\":\"Copy Paper, Case\",\"quantity\":1.0,\"unit_cost\":45.0,\"amount\":45.0,\"discountable\":true,\"taxable\":true},{\"id\":8,\"catalog_item\":\"delivery\",\"type\":\"service\",\"name\":\"Delivery\",\"quantity\":1.0,\"unit_cost\":10.0,\"amount\":10.0,\"discountable\":true,\"taxable\":true}],\"notes\":\"The order was delivered on Jul 20, 2015\",\"subtotal\":55.0,\"taxes\":[{\"id\":20554,\"amount\":3.85}],\"total\":51.15,\"balance\":51.15,\"url\":\"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY\",\"payment_url\":\"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY/payment\",\"pdf_url\":\"https://dundermifflin.invoiced.com/invoices/IZmXbVOPyvfD3GPBmyd6FwXY/pdf\",\"created_at\":1415229884}"
"equalToJson": "{\"id\":46225,\"customer\":15444,\"name\":\"July Paper Delivery\",\"number\":\"INV-0016\",\"collection_mode\":\"manual\",\"currency\":\"usd\",\"draft\":false,\"closed\":false,\"sent\":true,\"chase\":false,\"date\":1416290400,\"due_date\":1417500000,\"payment_terms\":\"NET 14\",\"items\":[{\"id\":7,\"type\":\"product\",\"name\":\"Copy Paper, Case\",\"quantity\":1.0,\"unit_cost\":45.0,\"amount\":45.0,\"discountable\":true,\"taxable\":true},{\"id\":8,\"catalog_item\":\"delivery\",\"type\":\"service\",\"name\":\"Delivery\",\"quantity\":1.0,\"unit_cost\":10.0,\"amount\":10.0,\"discountable\":true,\"taxable\":true}],\"notes\":\"The order was delivered on Jul 20, 2015\",\"subtotal\":55.0,\"taxes\":[{\"id\":20554,\"amount\":3.85}]}"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/mappings/connection_rr_19.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": "/subscriptions/595",
"bodyPatterns": [
{
"equalToJson": "{\"id\":595,\"customer\":15444,\"plan\":\"pro\",\"start_date\":1420391704,\"quantity\":1,\"period_start\":1446657304,\"period_end\":1449249304,\"status\":\"active\",\"addons\":[{\"id\":3,\"catalog_item\":\"ipad-license\",\"quantity\":11,\"created_at\":1420391704}],\"url\":\"https:\/\/dundermifflin.invoiced.com\/subscriptions\/o2mAd2wWVfYy16XZto7xHwXX\",\"created_at\":1420391704}"
"equalToJson": "{\"id\":595,\"customer\":15444,\"plan\":\"pro\",\"start_date\":1420391704,\"cancel_at_period_end\":false,\"quantity\":1,\"status\":\"active\",\"addons\":[{\"id\":3,\"catalog_item\":\"ipad-license\",\"quantity\":11,\"created_at\":1420391704}]}"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/mappings/connection_rr_23.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": "/transactions/20939",
"bodyPatterns": [
{
"equalToJson": "{\"id\":20939,\"customer\":15460,\"invoice\":44648,\"date\":1410843600,\"type\":\"payment\",\"method\":\"check\",\"status\":\"succeeded\",\"currency\":\"usd\",\"amount\":800.0,\"notes\":\"Check was received by Jan\",\"pdf_url\":\"https://dundermifflin.invoiced.com/payments/IZmXbVOPyvfD3GPBmyd6FwXY/pdf\",\"created_at\":1415228628}"
"equalToJson": "{\"id\":20939,\"customer\":15460,\"invoice\":44648,\"date\":1410843600,\"type\":\"payment\",\"method\":\"check\",\"status\":\"succeeded\",\"currency\":\"usd\",\"amount\":800.0,\"notes\":\"Check was received by Jan\"}"
}
]
},
Expand Down

0 comments on commit 17bea4e

Please sign in to comment.