Permalink
Browse files

added transparent post api wrappers and more regular api wrappers for…

… invoices, payments etc.
  • Loading branch information...
thobach committed Aug 4, 2011
1 parent 2c09613 commit 313eb50a644c03ec075d59000eb067723f263a22
View
@@ -7,13 +7,13 @@ The Recurly Java Client library is an open source wrapper library to talk to Rec
Usage
-----
-Please refer to the JUnit test cases in [RecurlyTest](http://github.com/gslab/recurly-client-java/blob/master/src/com/kwanzoo/recurly/test/RecurlyTest.java)
+Please refer to the JUnit test cases in [RecurlyTest](https://github.com/thobach/recurly-client-java/blob/master/src/com/kwanzoo/recurly/test/RecurlyTest.java)
Installation
------------
-Just add the latest jar(under [dist/](http://github.com/gslab/recurly-client-java/blob/master/dist/recurly-client-java-SNAPSHOT.jar)) to your classpath.
+Just add the latest jar(under [dist/](https://github.com/thobach/recurly-client-java/blob/master/dist/recurly-client-java-SNAPSHOT.jar)) to your classpath.
Dependencies
@@ -24,6 +24,6 @@ This wrapper relies on the excellent [Jersey REST client API](https://jersey.dev
Developed By
-------------
-This code was developed by Manoj Mathai, GSLab, for Kwanzoo Inc.
-
+The initial code was developed by Manoj Mathai, GSLab, for Kwanzoo Inc.
+The Transparent Post API and further API integration was done by Thomas Bachmann, Mambu GmbH.
Binary file not shown.
View
4 src/com/kwanzoo/recurly/Base.java 100644 → 100755
@@ -92,6 +92,10 @@ private static WebResource getNewWebResource(){
return webResource.path(path).header("Authorization", base64AuthStr).accept(MediaType.APPLICATION_XML_TYPE);
}
+ public static WebResource.Builder getWebResourceBuilderHtml(final String path) {
+ return webResource.path(path).header("Authorization", base64AuthStr).accept(MediaType.TEXT_HTML);
+ }
+
//This method needs to be invoked only once, just before performing the first recurly operation
public static void setAuth(final String recurlyUsername, final String recurlyPassword){
base64AuthStr = new String(Base64.encode(recurlyUsername + ":" + recurlyPassword));
View
No changes.
@@ -0,0 +1,50 @@
+package com.kwanzoo.recurly;
+
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "charge")
+public class Charge extends Base {
+
+ private static String resourceName = "charges";
+
+ @XmlElement(name = "amount_in_cents")
+ public Integer amount_in_cents;
+
+ @XmlElement(name = "description")
+ public String description;
+
+ @XmlElement(name = "id")
+ public String id;
+
+ @XmlElement(name = "account_code")
+ public String account_code;
+
+ @XmlElement(name = "start_date")
+ public Date start_date;
+
+ @XmlElement(name = "end_date")
+ public Date end_date;
+
+ @XmlElement(name = "created_at")
+ public Date created_at;
+
+ @Override
+ protected String getResourcePath() {
+ return Account.pluralResourceName + "/" + account_code + "/" + resourceName;
+ }
+
+ @Override
+ protected String getResourceCreationPath() {
+ return getResourcePath();
+ }
+
+ public Charge() {
+ }
+
+ public Charge(final String accountCode) {
+ this.account_code = accountCode;
+ }
+}
@@ -0,0 +1,29 @@
+package com.kwanzoo.recurly;
+
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "invoice")
+public class Invoice {
+
+ @XmlElement(name = "subtotal_in_cents")
+ public Integer subtotal_in_cents;
+
+ @XmlElement(name = "total_in_cents")
+ public Integer total_in_cents;
+
+ @XmlElement(name = "id")
+ public String id;
+
+ @XmlElement(name = "account_code")
+ public String account_code;
+
+ @XmlElement(name = "invoice_number")
+ public Integer invoice_number;
+
+ @XmlElement(name = "date")
+ public Date date;
+
+}
@@ -0,0 +1,87 @@
+package com.kwanzoo.recurly;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.sun.jersey.api.client.UniformInterfaceException;
+
+@XmlRootElement(name = "invoice")
+public class InvoiceDetailed extends Base {
+
+ private static String resourceName = "invoices";
+
+ @XmlElement(name = "subtotal_in_cents")
+ public Integer subtotal_in_cents;
+
+ @XmlElement(name = "total_in_cents")
+ public Integer total_in_cents;
+
+ @XmlElement(name = "vat_amount_in_cents")
+ public Integer vat_amount_in_cents;
+
+ @XmlElement(name = "paid_in_cents")
+ public Integer paid_in_cents;
+
+ @XmlElement(name = "total_due_in_cents")
+ public Integer total_due_in_cents;
+
+ @XmlElement(name = "discount_in_cents")
+ public Integer discount_in_cents;
+
+ @XmlElement(name = "id")
+ public String id;
+
+ @XmlElement(name = "account_code")
+ public String account_code;
+
+ @XmlElement(name = "invoice_number")
+ public Integer invoice_number;
+
+ @XmlElement(name = "vat_number")
+ public String vat_number;
+
+ @XmlElement(name = "status")
+ public String status;
+
+ @XmlElementWrapper(name = "payments")
+ @XmlElement(name = "payment")
+ public List<Payment> payment;
+
+ @XmlElementWrapper(name = "line_items")
+ @XmlElement(name = "line_item")
+ public List<LineItem> line_item;
+
+ @Override
+ protected String getResourcePath() {
+ return resourceName + "/" + id;
+ }
+
+ protected static String getResourcePath(String invoiceId) {
+ return resourceName + "/" + invoiceId;
+ }
+
+ @Override
+ protected String getResourceCreationPath() {
+ return getResourcePath();
+ }
+
+ public InvoiceDetailed() {
+ }
+
+ public InvoiceDetailed(final String invoice_id) {
+ this.id = invoice_id;
+ }
+
+ public static InvoiceDetailed get(final String invoiceId) throws Exception{
+ try{
+ return getWebResourceBuilder(getResourcePath(invoiceId)).get(InvoiceDetailed.class);
+ }
+ catch(final UniformInterfaceException uie){
+ throwStatusBasedException(uie.getResponse());
+ return null;
+ }
+ }
+}
@@ -0,0 +1,45 @@
+package com.kwanzoo.recurly;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.sun.jersey.api.client.UniformInterfaceException;
+
+@XmlRootElement(name = "invoices")
+public class Invoices extends Base {
+
+ private static String resourceName = "invoices";
+
+ @XmlElement(name = "invoice")
+ public List<Invoice> invoice;
+
+ public String account_code;
+
+ @Override
+ protected String getResourcePath() {
+ return Account.pluralResourceName + "/" + account_code + "/" + resourceName;
+ }
+
+ private static String getResourcePath(String accountCode) {
+ return Account.pluralResourceName + "/" + accountCode + "/" + resourceName;
+ }
+
+ @Override
+ protected String getResourceCreationPath() {
+ return getResourcePath();
+ }
+
+ public Invoices() {
+ }
+
+ public static Invoices get(final String accountCode) throws Exception {
+ try {
+ return getWebResourceBuilder(getResourcePath(accountCode)).get(Invoices.class);
+ } catch (final UniformInterfaceException uie) {
+ throwStatusBasedException(uie.getResponse());
+ return null;
+ }
+ }
+}
@@ -0,0 +1,34 @@
+package com.kwanzoo.recurly;
+
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "line_item")
+public class LineItem {
+
+ @XmlElement(name = "id")
+ public String id;
+
+ @XmlElement(name="type")
+ public String type;
+
+ @XmlElement(name = "description")
+ public String description;
+
+ @XmlElement(name = "applied_coupon_code")
+ public String applied_coupon_code;
+
+ @XmlElement(name = "amount_in_cents")
+ public Integer amount_in_cents;
+
+ @XmlElement(name = "start_date")
+ public Date start_date;
+
+ @XmlElement(name = "end_date")
+ public Date end_date;
+
+ @XmlElement(name = "created_at")
+ public Date created_at;
+}
@@ -0,0 +1,25 @@
+package com.kwanzoo.recurly;
+
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "payment")
+public class Payment {
+
+ @XmlElement(name = "id")
+ public String id;
+
+ @XmlElement(name = "reference")
+ public String reference;
+
+ @XmlElement(name = "message")
+ public String message;
+
+ @XmlElement(name = "amount_in_cents")
+ public Integer amount_in_cents;
+
+ @XmlElement(name = "date")
+ public Date date;
+}
Oops, something went wrong.

0 comments on commit 313eb50

Please sign in to comment.