diff --git a/.gitignore b/.gitignore index 8753aeb..4820219 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ nbproject .project .vscode .vscode/* -src/main/java/ca/paymentrails/paymentrails/index.java \ No newline at end of file +src/main/java/com/trolley/trolley/index.java +/.metadata/ diff --git a/README.md b/README.md index 4ddfdb6..ef94ac5 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ Add this dependency to your project's POM: ```xml - ca.paymentrails - paymentrails - 1.0.2 + com.trolley + java-sdk + 1.0.1 ``` @@ -31,8 +31,8 @@ The library is hosted at [https://github.com/paymentRails/java-sdk](https://gith ## Getting Started ```java -import ca.paymentrails.paymentrails.*; -import ca.paymentrails.Exceptions.*; +import com.trolley.java-sdk.*; +import com.trolley.Exceptions.*; public class PaymentRailsExample { public static void main(String[] args) { @@ -51,7 +51,7 @@ public class PaymentRailsExample { ### Usage -Methods should all have Java Doc comments to help you understand their usage. As mentioned the [full API documentation](https://docs.trolley.com) +Methods should all have Java Doc comments to help you understand their usage. As mentioned the [full API documentation](http://docs.trolley.com) is the best source of information about the API. For more information please read the [Java API docs](https://github.com/PaymentRails/java-sdk/tree/master/docs) is available. The best starting point is: diff --git a/docs/classes/batchgateway.md b/docs/classes/batchgateway.md index b728a76..04f2fe4 100644 --- a/docs/classes/batchgateway.md +++ b/docs/classes/batchgateway.md @@ -3,21 +3,21 @@ # Class: BatchGateway Gateway class for batches -*__class__*: BatchGateway +_**class**_: BatchGateway ## Index ### Methods -* [create](BatchGateway.md#create) -* [find](BatchGateway.md#find) -* [generateQuote](BatchGateway.md#generatequote) -* [paymentList](BatchGateway.md#paymentlist) -* [delete](BatchGateway.md#delete) -* [search](BatchGateway.md#search) -* [processBatch](BatchGateway.md#processBatch) -* [summary](BatchGateway.md#summary) -* [update](BatchGateway.md#update) +- [create](BatchGateway.md#create) +- [find](BatchGateway.md#find) +- [generateQuote](BatchGateway.md#generatequote) +- [paymentList](BatchGateway.md#paymentlist) +- [delete](BatchGateway.md#delete) +- [search](BatchGateway.md#search) +- [processBatch](BatchGateway.md#processBatch) +- [summary](BatchGateway.md#summary) +- [update](BatchGateway.md#update) --- @@ -27,19 +27,19 @@ Gateway class for batches ### create -► **create**(batch: *`Batch`*): `Batch` +► **create**(batch: _`Batch`_): `Batch` -*Defined in [BatchGateway.java:95](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java#L95)* +_Defined in [BatchGateway.java:95](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/BatchGateway.java#L95)_ -Creates a batch with optional payments. This is the interface that is provide by the [Create Batch](https://docs.trolley.com/api/#create-a-batch) API +Creates a batch with optional payments. This is the interface that is provide by the [Create Batch](http://docs.trolley.com/api/#create-a-batch) API Batch batch = client.batch.create("{\"sourceCurrency\": \"USD\", \"description\":\"Docs Create\"}"); **Parameters:** -| Param | Type | Description | -| ------ | ------ | ------ | -| batch | `Batch` | - | +| Param | Type | Description | +| ----- | ------- | ----------- | +| batch | `Batch` | - | **Returns:** `Batch` @@ -49,9 +49,9 @@ Creates a batch with optional payments. This is the interface that is provide by ### find -► **find**(batchId: *`string`*): `Batch` +► **find**(batchId: _`string`_): `Batch` -*Defined in [BatchGateway.java:67](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java#L67)* +_Defined in [BatchGateway.java:67](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/BatchGateway.java#L67)_ Retrieves a batch based on the batch id @@ -71,9 +71,9 @@ Retrieves a batch based on the batch id ### generateQuote -► **generateQuote**(batchId: *`string`*): `Batch` +► **generateQuote**(batchId: _`string`_): `Batch` -*Defined in [BatchGateway.java:182](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java#L182)* +_Defined in [BatchGateway.java:182](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/BatchGateway.java#L182)_ Generate a FX quote for this batch @@ -91,9 +91,9 @@ Generate a FX quote for this batch ### paymentList -► **paymentList**(batchId: *`string`*, page?: *`number`*, pageSize?: *`number`*): `Payment`[] +► **paymentList**(batchId: _`string`_, page?: _`number`_, pageSize?: _`number`_): `Payment`[] -*Defined in [BatchGateway.java:166](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java#L166)* +_Defined in [BatchGateway.java:166](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/BatchGateway.java#L166)_ Return a paginated list of payments for this batch @@ -113,9 +113,9 @@ Return a paginated list of payments for this batch ### delete -► **delete**(batchId: *`string`*): `Boolean` +► **delete**(batchId: _`string`_): `Boolean` -*Defined in [BatchGateway.java:132](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java#L132)* +_Defined in [BatchGateway.java:132](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/BatchGateway.java#L132)_ Delete the given batch @@ -135,19 +135,19 @@ Delete the given batch ### search -► **search**(page?: *`number`*, pageSize?: *`number`*, term?: *`string`*): `Batch`[] +► **search**(page?: _`number`_, pageSize?: _`number`_, term?: _`string`_): `Batch`[] -*Defined in [BatchGateway.java:146](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java#L146)* +_Defined in [BatchGateway.java:146](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/BatchGateway.java#L146)_ Search for a batch matching the given term **Parameters:** -| Param | Type | Default value | Description | -| ------ | ------ | ------ | ------ | -| page | `number` | 1 | - | -| pageSize | `number` | 10 | - | -| term | `string` | "" | string search term | +| Param | Type | Default value | Description | +| -------- | -------- | ------------- | ------------------ | +| page | `number` | 1 | - | +| pageSize | `number` | 10 | - | +| term | `string` | "" | string search term | **Returns:** `Batch`[] @@ -157,9 +157,9 @@ Search for a batch matching the given term ### processBatch -► **processBatch**(batchId: *`string`*): `Batch` +► **processBatch**(batchId: _`string`_): `Batch` -*Defined in [BatchGateway.java:194](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java#L194)* +_Defined in [BatchGateway.java:194](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/BatchGateway.java#L194)_ Start processing this batch @@ -177,9 +177,9 @@ Start processing this batch ### summary -► **summary**(batchId: *`string`*): `String` +► **summary**(batchId: _`string`_): `String` -*Defined in [BatchGateway.java:206](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java#L206)* +_Defined in [BatchGateway.java:206](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/BatchGateway.java#L206)_ Get a transaction totaled summary for this batch @@ -193,4 +193,4 @@ Get a transaction totaled summary for this batch **Returns:** `String` ---- \ No newline at end of file +--- diff --git a/docs/classes/configuration.md b/docs/classes/configuration.md index 6ed5dbd..08c2dd6 100644 --- a/docs/classes/configuration.md +++ b/docs/classes/configuration.md @@ -6,9 +6,9 @@ ### Properties -* [apiBase](Configuration.md#apibase) -* [apiKey](Configuration.md#apikey) -* [apiSecret](Configuration.md#apisecret) +- [apiBase](Configuration.md#apibase) +- [apiKey](Configuration.md#apikey) +- [apiSecret](Configuration.md#apisecret) --- @@ -18,9 +18,9 @@ ### environment -**● environment**: *`string`* +**● enviroment**: _`string`_ -*Defined in [Configuration.java:35](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Configuration.java#L35)* +_Defined in [Configuration.java:35](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Configuration.java#L35)_ --- @@ -28,9 +28,9 @@ ### publicKey -**● publicKey**: *`string`* +**● publicKey**: _`string`_ -*Defined in [Configuration.java:33](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Configuration.java#L33)* +_Defined in [Configuration.java:33](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Configuration.java#L33)_ --- @@ -38,9 +38,9 @@ ### privateKey -**● privateKey**: *`string`* +**● privateKey**: _`string`_ -*Defined in [Configuration.java:34](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Configuration.java#L34)* +_Defined in [Configuration.java:34](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Configuration.java#L34)_ --- @@ -48,17 +48,17 @@ ### «Static» environment -► **environment**(environment: *"production"⎮"sandbox"⎮"integration"*): `void` +► **environment**(environment: _"production"⎮"sandbox"⎮"integration"_): `void` -*Defined in [Configuration.java:90](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Configuration.java#L90)* +_Defined in [Configuration.java:90](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Configuration.java#L90)_ Set the Trolley API environment that you're using **Parameters:** -| Param | Type | Description | -| ------ | ------ | ------ | -| environment | "production"⎮"sandbox"⎮"integration" | one of "production" or "sandbox" | +| Param | Type | Description | +| ----------- | ------------------------------------ | -------------------------------- | +| environment | "production"⎮"sandbox"⎮"integration" | one of "production" or "sandbox" | **Returns:** `void` diff --git a/docs/classes/gateway.md b/docs/classes/gateway.md index 9677a42..b72be36 100644 --- a/docs/classes/gateway.md +++ b/docs/classes/gateway.md @@ -6,12 +6,12 @@ ### Properties -* [balances](gateway.md#balances) -* [batch](gateway.md#batch) -* [config](gateway.md#config) -* [payment](gateway.md#payment) -* [recipient](gateway.md#recipient) -* [recipientAccount](gateway.md#recipientaccount) +- [balances](gateway.md#balances) +- [batch](gateway.md#batch) +- [config](gateway.md#config) +- [payment](gateway.md#payment) +- [recipient](gateway.md#recipient) +- [recipientAccount](gateway.md#recipientaccount) --- @@ -21,9 +21,9 @@ ### balances -**● balances**: *[BalancesGateway](balancesgateway.md)* +**● balances**: _[BalancesGateway](balancesgateway.md)_ -*Defined in [Gateway.md:15]* +_Defined in [Gateway.md:15]_ --- @@ -31,9 +31,9 @@ ### batch -**● batch**: *[BatchGateway](batchgateway.md)* +**● batch**: _[BatchGateway](batchgateway.md)_ -*Defined in [Gateway.java:13](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L13)* +_Defined in [Gateway.java:13](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L13)_ --- @@ -41,9 +41,9 @@ ### config -**● config**: *[Configuration](configuration.md)* +**● config**: _[Configuration](configuration.md)_ -*Defined in [Gateway.java:10](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L10)* +_Defined in [Gateway.java:10](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L10)_ --- @@ -51,9 +51,9 @@ ### payment -**● payment**: *[PaymentGateway](paymentgateway.md)* +**● payment**: _[PaymentGateway](paymentgateway.md)_ -*Defined in [Gateway.java:16](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L16)* +_Defined in [Gateway.java:16](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L16)_ --- @@ -61,9 +61,9 @@ ### recipient -**● recipient**: *[RecipientGateway](recipientgateway.md)* +**● recipient**: _[RecipientGateway](recipientgateway.md)_ -*Defined in [Gateway.java:12](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L12)* +_Defined in [Gateway.java:12](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L12)_ --- @@ -71,8 +71,8 @@ ### recipientAccount -**● recipientAccount**: *[RecipientAccountGateway](recipientaccountgateway.md)* +**● recipientAccount**: _[RecipientAccountGateway](recipientaccountgateway.md)_ -*Defined in [Gateway.java:14](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L14)* +_Defined in [Gateway.java:14](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L14)_ ---- \ No newline at end of file +--- diff --git a/docs/classes/paymentgateway.md b/docs/classes/paymentgateway.md index a225a73..7fb78b8 100644 --- a/docs/classes/paymentgateway.md +++ b/docs/classes/paymentgateway.md @@ -6,11 +6,11 @@ ### Methods -* [create](paymentgateway.md#create) -* [find](paymentgateway.md#find) -* [remove](paymentgateway.md#remove) -* [search](paymentgateway.md#search) -* [update](paymentgateway.md#update) +- [create](paymentgateway.md#create) +- [find](paymentgateway.md#find) +- [remove](paymentgateway.md#remove) +- [search](paymentgateway.md#search) +- [update](paymentgateway.md#update) --- @@ -20,9 +20,9 @@ ### create -► **create**(batchId: *`string`*, body: *`any`*): `Payment` +► **create**(batchId: _`string`_, body: _`any`_): `Payment` -*Defined in [PaymentGateway.java:55](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L55)* +_Defined in [PaymentGateway.java:55](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L55)_ Create a new payment in a batch @@ -43,9 +43,9 @@ Create a new payment in a batch ### find -► **find**(paymentId: *`string`*): `Payment` +► **find**(paymentId: _`string`_): `Payment` -*Defined in [PaymentGateway.java:34](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L34)* +_Defined in [PaymentGateway.java:34](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L34)_ Find a specific payment @@ -65,9 +65,9 @@ Find a specific payment ### delete -► **delete**(paymentId: *`string`*, batchId: *`string`*): `boolean` +► **delete**(paymentId: _`string`_, batchId: _`string`_): `boolean` -*Defined in [PaymentGateway.java:90](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L90)* +_Defined in [PaymentGateway.java:90](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L90)_ Delete a given payment -- Note you can only delete non processed payments @@ -88,9 +88,9 @@ Delete a given payment -- Note you can only delete non processed payments ### search -► **search**(batchId: *`string`*, page?: *`number`*, pageSize?: *`number`*, term?: *`string`*): `Payment`[] +► **search**(batchId: _`string`_, page?: _`number`_, pageSize?: _`number`_, term?: _`string`_): `Payment`[] -*Defined in [PaymentGateway.java:105](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L105)* +_Defined in [PaymentGateway.java:105](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L105)_ Search for payments in a given batch @@ -111,9 +111,9 @@ Search for payments in a given batch ### update -► **update**(paymentId: *`string`*, batchId: *`string`*, body: *`any`*): `boolean` +► **update**(paymentId: _`string`_, batchId: _`string`_, body: _`any`_): `boolean` -*Defined in [PaymentGateway.java:74](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Gateway.java#L74)* +_Defined in [PaymentGateway.java:74](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Gateway.java#L74)_ Update a given payment @@ -129,4 +129,4 @@ Update a given payment **Returns:** `boolean` ---- \ No newline at end of file +--- diff --git a/docs/classes/recipientaccountgateway.md b/docs/classes/recipientaccountgateway.md index 84cd0d1..7dfcd31 100644 --- a/docs/classes/recipientaccountgateway.md +++ b/docs/classes/recipientaccountgateway.md @@ -6,11 +6,11 @@ ### Methods -* [findAll](recipientaccountgateway.md#findAll) -* [create](recipientaccountgateway.md#create) -* [find](recipientaccountgateway.md#find) -* [remove](recipientaccountgateway.md#remove) -* [update](recipientaccountgateway.md#update) +- [findAll](recipientaccountgateway.md#findAll) +- [create](recipientaccountgateway.md#create) +- [find](recipientaccountgateway.md#find) +- [remove](recipientaccountgateway.md#remove) +- [update](recipientaccountgateway.md#update) --- @@ -20,9 +20,9 @@ ### all -► **all**(recipientId: *`string`*): `List`(recipientaccount.md)[]> +► **all**(recipientId: _`string`_): `List`(recipientaccount.md)[]> -*Defined in [RecipientAccountGateway.java:33](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java#L33)* +_Defined in [RecipientAccountGateway.java:33](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccountGateway.java#L33)_ Fetch all of the accounts for a given Trolley recipient @@ -43,13 +43,14 @@ Fetch all of the accounts for a given Trolley recipient ### create -► **create**(recipientId: *`string`*, body: *`RecipientAccount`*): `RecipientAccount`(recipientaccount.md)> +► **create**(recipientId: _`string`_, body: _`RecipientAccount`_): `RecipientAccount`(recipientaccount.md)> -*Defined in [RecipientAccountGateway.java:79](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java#L79)* +_Defined in [RecipientAccountGateway.java:79](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccountGateway.java#L79)_ Create a new recipient account RecipientAccount recipientAccount = client.recipientAccount.create("R-112e2c3x","{\"type\":\"bank-transfer\",\"primary\":\"true\",\"country\":\"CA\",\"currency\":\"CAD\",\"accountNum\":\"012345678\",\"bankId\":\"004\",\"branchId\":\"47261\",\"accountHolderName\":\"John Smith\"}"); + **Parameters:** | Param | Type | Description | @@ -65,9 +66,9 @@ Create a new recipient account ### find -► **find**(recipientId: *`string`*, accountId: *`string`*): `RecipientAccount`(recipientaccount.md)> +► **find**(recipientId: _`string`_, accountId: _`string`_): `RecipientAccount`(recipientaccount.md)> -*Defined in [RecipientAccountGateway.java:52](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java#L52)* +_Defined in [RecipientAccountGateway.java:52](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccountGateway.java#L52)_ Fetch a specific account for a given Trolley recipient @@ -88,9 +89,9 @@ RecipientAccount recipientAccount = client.recipientAccount.find("R-ad322121", " ### delete -► **delete**(recipientId: *`string`*, accountId: *`string`*): `boolean` +► **delete**(recipientId: _`string`_, accountId: _`string`_): `boolean` -*Defined in [RecipientAccountGateway.java:121](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java#L121)* +_Defined in [RecipientAccountGateway.java:121](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccountGateway.java#L121)_ Delete the given recipient account. This will only return success, otherwise it will throw an exception (e.g. NotFound) @@ -111,9 +112,9 @@ Delete the given recipient account. This will only return success, otherwise it ### update -► **update**(recipientId: *`string`*, accountId: *`string`*, body: *`RecipientAccount`*): `RecipientAccount`(recipientaccount.md)> +► **update**(recipientId: _`string`_, accountId: _`string`_, body: _`RecipientAccount`_): `RecipientAccount`(recipientaccount.md)> -*Defined in [RecipientAccountGateway.java:102](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java#L102)* +_Defined in [RecipientAccountGateway.java:102](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccountGateway.java#L102)_ Update a recipient account. Note: Updating an account will create a new account ID if it contains any property that isn't just "primary" @@ -129,4 +130,4 @@ Update a recipient account. Note: Updating an account will create a new account **Returns:** `RecipientAccount`(recipientaccount.md)> ---- \ No newline at end of file +--- diff --git a/docs/classes/recipientgateway.md b/docs/classes/recipientgateway.md index cfdbbdc..6e996e3 100644 --- a/docs/classes/recipientgateway.md +++ b/docs/classes/recipientgateway.md @@ -6,11 +6,11 @@ ### Methods -* [create](RecipientGateway.md#create) -* [find](RecipientGateway.md#find) -* [remove](RecipientGateway.md#remove) -* [search](RecipientGateway.md#search) -* [update](RecipientGateway.md#update) +- [create](RecipientGateway.md#create) +- [find](RecipientGateway.md#find) +- [remove](RecipientGateway.md#remove) +- [search](RecipientGateway.md#search) +- [update](RecipientGateway.md#update) --- @@ -20,9 +20,9 @@ ### create -► **create**(body: *[Recipient](../types/recipient.md)*): `Recipient` +► **create**(body: _[Recipient](../types/recipient.md)_): `Recipient` -*Defined in [RecipientGateway.java:82](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java#L82)* +_Defined in [RecipientGateway.java:82](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientGateway.java#L82)_ Create a given recipient @@ -32,9 +32,9 @@ Create a given recipient **Parameters:** -| Param | Type | Description | -| ------ | ------ | ------ | -| body | [Recipient](../types/recipient.md) | The recipient information to create | +| Param | Type | Description | +| ----- | ---------------------------------- | ----------------------------------- | +| body | [Recipient](../types/recipient.md) | The recipient information to create | **Returns:** `Recipient` @@ -44,9 +44,9 @@ Create a given recipient ### find -► **find**(recipientId: *`string`*): `Recipient` +► **find**(recipientId: _`string`_): `Recipient` -*Defined in [RecipientGateway.java:58](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java#L58)* +_Defined in [RecipientGateway.java:58](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientGateway.java#L58)_ Find a specific recipient by their Trolley recipient ID @@ -66,9 +66,9 @@ Recipient recipient = client.recipient.find(R-efr313md8cj); ### delete -► **delete**(recipientId: *`string`*): `boolean` +► **delete**(recipientId: _`string`_): `boolean` -*Defined in [RecipientGateway.java:115](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java#L115)* +_Defined in [RecipientGateway.java:115](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientGateway.java#L115)_ Delete the given recipient. @@ -88,17 +88,17 @@ Delete the given recipient. ### search -► **search**(page: *`number`*, pageSize: *`number`*, term: *`string`*): `Recipient`[] +► **search**(page: _`number`_, pageSize: _`number`_, term: _`string`_): `Recipient`[] -*Defined in [RecipientGateway.java:123](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java#L123)* +_Defined in [RecipientGateway.java:123](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientGateway.java#L123)_ **Parameters:** -| Param | Type | Description | -| ------ | ------ | ------ | -| page | `number` | - | -| pageSize | `number` | - | -| term | `string` | - | +| Param | Type | Description | +| -------- | -------- | ----------- | +| page | `number` | - | +| pageSize | `number` | - | +| term | `string` | - | **Returns:** `Recipient`[] @@ -108,9 +108,9 @@ Delete the given recipient. ### update -► **update**(body: *[Recipient](../types/recipient.md)*): `boolean` +► **update**(body: _[Recipient](../types/recipient.md)_): `boolean` -*Defined in [RecipientGateway.java:100](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java#L100)* +_Defined in [RecipientGateway.java:100](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientGateway.java#L100)_ Update the given recipient @@ -118,10 +118,10 @@ Update the given recipient **Parameters:** -| Param | Type | Description | -| ------ | ------ | ------ | -| body | [Recipient](../types/recipient.md) | the changes to make to the recipient | +| Param | Type | Description | +| ----- | ---------------------------------- | ------------------------------------ | +| body | [Recipient](../types/recipient.md) | the changes to make to the recipient | **Returns:** `boolean` ---- \ No newline at end of file +--- diff --git a/docs/types/batch.md b/docs/types/batch.md index 54f8aa5..e22d941 100644 --- a/docs/types/batch.md +++ b/docs/types/batch.md @@ -2,7 +2,7 @@ # Types: Batch -*__type__*: Batch +_**type**_: Batch ## Properties @@ -10,9 +10,9 @@ ### description -**● description**: *`undefined`⎮`string`* +**● description**: _`undefined`⎮`string`_ -*Defined in [Batch.java:15](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Batch.java#L15)* +_Defined in [Batch.java:15](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Batch.java#L15)_ --- @@ -20,8 +20,8 @@ ### sourceCurrency -**● sourceCurrency**: *`undefined`⎮`string`* +**● sourceCurrency**: _`undefined`⎮`string`_ -*Defined in [Batch.java:14](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Batch.java#L14)* +_Defined in [Batch.java:14](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Batch.java#L14)_ ---- \ No newline at end of file +--- diff --git a/docs/types/configurationparams.md b/docs/types/configurationparams.md index 9f6b683..b2733b1 100644 --- a/docs/types/configurationparams.md +++ b/docs/types/configurationparams.md @@ -8,9 +8,9 @@ ### «Optional» environment -**● environment**: *"production"⎮"sandbox"⎮"integration"⎮"development"* +**● environment**: _"production"⎮"sandbox"⎮"integration"⎮"development"_ -*Defined in [Configuration.java:15](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Configuration.java#L15)* +_Defined in [Configuration.java:15](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Configuration.java#L15)_ The environment that you're using, most likely one of "production" or "sandbox" @@ -20,9 +20,9 @@ The environment that you're using, most likely one of "production" or "sandbox" ### public key -**● public key**: *`string`* +**● public key**: _`string`_ -*Defined in [Configuration.java:7](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Configuration.java#L7)* +_Defined in [Configuration.java:7](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Configuration.java#L7)_ The Trolley public key @@ -32,10 +32,10 @@ The Trolley public key ### private key -**● private key**: *`string`* +**● private key**: _`string`_ -*Defined in [Configuration.java:11](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Configuration.java#L11)* +_Defined in [Configuration.java:11](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Configuration.java#L11)_ The Trolley private key ---- \ No newline at end of file +--- diff --git a/docs/types/payment.md b/docs/types/payment.md index 7b64100..59af32c 100644 --- a/docs/types/payment.md +++ b/docs/types/payment.md @@ -2,7 +2,7 @@ # Types: Payment -*__type__*: Payment +_**type**_: Payment ## Properties @@ -10,9 +10,9 @@ ### «Optional» memo -**● memo**: *`undefined`⎮`string`* +**● memo**: _`undefined`⎮`string`_ -*Defined in [Payment.java:22](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Payment.java#L22)* +_Defined in [Payment.java:22](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Payment.java#L22)_ --- @@ -20,15 +20,15 @@ ### recipient -**● recipient**: *`object`* +**● recipient**: _`object`_ -*Defined in [Payment.java:23](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Payment.java#L23)* +_Defined in [Payment.java:23](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Payment.java#L23)_ #### Type declaration -«Optional» email: `undefined`⎮`string` -«Optional» id: `undefined`⎮`string` -«Optional» referenceId: `undefined`⎮`string` +«Optional» email: `undefined`⎮`string` +«Optional» id: `undefined`⎮`string` +«Optional» referenceId: `undefined`⎮`string` --- @@ -36,9 +36,9 @@ ### «Optional» sourceAmount -**● sourceAmount**: *`undefined`⎮`string`* +**● sourceAmount**: _`undefined`⎮`string`_ -*Defined in [Payment.java:19](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Payment.java#L19)* +_Defined in [Payment.java:19](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Payment.java#L19)_ --- @@ -46,9 +46,9 @@ ### «Optional» targetAmount -**● targetAmount**: *`undefined`⎮`string`* +**● targetAmount**: _`undefined`⎮`string`_ -*Defined in [Payment.java:20](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Payment.java#L20)* +_Defined in [Payment.java:20](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Payment.java#L20)_ --- @@ -56,8 +56,8 @@ ### «Optional» targetCurrency -**● targetCurrency**: *`undefined`⎮`string`* +**● targetCurrency**: _`undefined`⎮`string`_ -*Defined in [Payment.java:21](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Payment.java#L21)* +_Defined in [Payment.java:21](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Payment.java#L21)_ ---- \ No newline at end of file +--- diff --git a/docs/types/recipient.md b/docs/types/recipient.md index 7a7b5e2..02a8467 100644 --- a/docs/types/recipient.md +++ b/docs/types/recipient.md @@ -2,7 +2,7 @@ # Types: Recipient -*__type__*: Recipient +_**type**_: Recipient ## Properties @@ -10,9 +10,9 @@ ### «Optional» account -**● account**: *`any`* +**● account**: _`any`_ -*Defined in [Recipient.java:30](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L29)* +_Defined in [Recipient.java:30](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L29)_ --- @@ -20,9 +20,9 @@ ### «Optional» address -**● address**: *`undefined`⎮`object`* +**● address**: _`undefined`⎮`object`_ -*Defined in [Recipient.java:20](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L20)* +_Defined in [Recipient.java:20](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L20)_ --- @@ -30,9 +30,9 @@ ### «Optional» dob -**● dob**: *`undefined`⎮`string`* +**● dob**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:15](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L15)* +_Defined in [Recipient.java:15](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L15)_ --- @@ -40,9 +40,9 @@ ### «Optional» email -**● email**: *`undefined`⎮`string`* +**● email**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:10](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L10)* +_Defined in [Recipient.java:10](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L10)_ --- @@ -50,9 +50,9 @@ ### «Optional» firstName -**● firstName**: *`undefined`⎮`string`* +**● firstName**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:12](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L12)* +_Defined in [Recipient.java:12](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L12)_ --- @@ -60,9 +60,9 @@ ### «Optional» governmentId -**● governmentId**: *`undefined`⎮`string`* +**● governmentId**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:17](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L17)* +_Defined in [Recipient.java:17](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L17)_ --- @@ -70,9 +70,9 @@ ### «Optional» language -**● language**: *`undefined`⎮`string`* +**● language**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:19](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L19)* +_Defined in [Recipient.java:19](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L19)_ --- @@ -80,9 +80,9 @@ ### «Optional» lastName -**● lastName**: *`undefined`⎮`string`* +**● lastName**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:13](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L13)* +_Defined in [Recipient.java:13](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L13)_ --- @@ -90,9 +90,9 @@ ### «Optional» name -**● name**: *`undefined`⎮`string`* +**● name**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:11](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L11)* +_Defined in [Recipient.java:11](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L11)_ --- @@ -100,9 +100,9 @@ ### «Optional» passport -**● passport**: *`undefined`⎮`string`* +**● passport**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:18](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L18)* +_Defined in [Recipient.java:18](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L18)_ --- @@ -110,9 +110,9 @@ ### «Optional» referenceId -**● referenceId**: *`undefined`⎮`string`* +**● referenceId**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:9](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L9)* +_Defined in [Recipient.java:9](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L9)_ --- @@ -120,9 +120,9 @@ ### «Optional» ssn -**● ssn**: *`undefined`⎮`string`* +**● ssn**: _`undefined`⎮`string`_ -*Defined in [Recipient.java:16](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L16)* +_Defined in [Recipient.java:16](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L16)_ --- @@ -130,8 +130,8 @@ ### «Optional» type -**● type**: *"individual"⎮"business"* +**● type**: _"individual"⎮"business"_ -*Defined in [Recipient.java:14](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/Recipient.java#L14)* +_Defined in [Recipient.java:14](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/Recipient.java#L14)_ ---- \ No newline at end of file +--- diff --git a/docs/types/recipientaccount.md b/docs/types/recipientaccount.md index 1fe3b7e..9977d12 100644 --- a/docs/types/recipientaccount.md +++ b/docs/types/recipientaccount.md @@ -2,7 +2,7 @@ # Types: RecipientAccount -*__type__*: RecipientAccount +_**type**_: RecipientAccount ## Properties @@ -10,18 +10,19 @@ ### «Optional» accountHolderName -**● accountHolderName**: *`undefined`⎮`string`* +**● accountHolderName**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:23](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L23)* +_Defined in [RecipientAccount.java:23](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L23)_ --- + ### «Optional» accountNum -**● accountNum**: *`undefined`⎮`string`* +**● accountNum**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:22](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L22)* +_Defined in [RecipientAccount.java:22](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L22)_ --- @@ -29,9 +30,9 @@ ### «Optional» bankAddress -**● bankAddress**: *`undefined`⎮`string`* +**● bankAddress**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:28](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L28)* +_Defined in [RecipientAccount.java:28](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L28)_ --- @@ -39,9 +40,9 @@ ### «Optional» bankCity -**● bankCity**: *`undefined`⎮`string`* +**● bankCity**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:29](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L29)* +_Defined in [RecipientAccount.java:29](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L29)_ --- @@ -49,9 +50,9 @@ ### «Optional» bankId -**● bankId**: *`undefined`⎮`string`* +**● bankId**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:26](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L26)* +_Defined in [RecipientAccount.java:26](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L26)_ --- @@ -59,9 +60,9 @@ ### «Optional» bankName -**● bankName**: *`undefined`⎮`string`* +**● bankName**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:27](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L27)* +_Defined in [RecipientAccount.java:27](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L27)_ --- @@ -69,9 +70,9 @@ ### «Optional» bankPostalCode -**● bankPostalCode**: *`undefined`⎮`string`* +**● bankPostalCode**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:31](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L31)* +_Defined in [RecipientAccount.java:31](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L31)_ --- @@ -79,9 +80,9 @@ ### «Optional» bankRegionCode -**● bankRegionCode**: *`undefined`⎮`string`* +**● bankRegionCode**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:30](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L30)* +_Defined in [RecipientAccount.java:30](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L30)_ --- @@ -89,9 +90,9 @@ ### «Optional» branchId -**● branchId**: *`undefined`⎮`string`* +**● branchId**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:25](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L25)* +_Defined in [RecipientAccount.java:25](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L25)_ --- @@ -99,9 +100,9 @@ ### «Optional» country -**● country**: *`undefined`⎮`string`* +**● country**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:19](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L19)* +_Defined in [RecipientAccount.java:19](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L19)_ --- @@ -109,9 +110,9 @@ ### currency -**● currency**: *`string`* = "" +**● currency**: _`string`_ = "" -*Defined in [RecipientAccount.java:11](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L11)* +_Defined in [RecipientAccount.java:11](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L11)_ --- @@ -119,9 +120,9 @@ ### «Optional» emailAddress -**● emailAddress**: *`undefined`⎮`string`* +**● emailAddress**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:16](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L16)* +_Defined in [RecipientAccount.java:16](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L16)_ --- @@ -129,9 +130,9 @@ ### «Optional» iban -**● iban**: *`undefined`⎮`string`* +**● iban**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:21](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L21)* +_Defined in [RecipientAccount.java:21](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L21)_ --- @@ -139,9 +140,9 @@ ### id -**● id**: *`string`* = "" +**● id**: _`string`_ = "" -*Defined in [RecipientAccount.java:9](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L9)* +_Defined in [RecipientAccount.java:9](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L9)_ --- @@ -149,9 +150,9 @@ ### primary -**● primary**: *`boolean`* = false +**● primary**: _`boolean`_ = false -*Defined in [RecipientAccount.java:10](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L10)* +_Defined in [RecipientAccount.java:10](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L10)_ --- @@ -159,9 +160,9 @@ ### «Optional» recipientFees -**● recipientFees**: *`undefined`⎮`string`* +**● recipientFees**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:13](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L13)* +_Defined in [RecipientAccount.java:13](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L13)_ --- @@ -169,9 +170,9 @@ ### «Optional» routeType -**● routeType**: *`undefined`⎮`string`* +**● routeType**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:12](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L12)* +_Defined in [RecipientAccount.java:12](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L12)_ --- @@ -179,9 +180,9 @@ ### «Optional» swiftBic -**● swiftBic**: *`string`⎮`null`* +**● swiftBic**: _`string`⎮`null`_ -*Defined in [RecipientAccount.java:24](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L24)* +_Defined in [RecipientAccount.java:24](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L24)_ --- @@ -189,8 +190,8 @@ ### «Optional» type -**● type**: *`undefined`⎮`string`* +**● type**: _`undefined`⎮`string`_ -*Defined in [RecipientAccount.java:20](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java#L20)* +_Defined in [RecipientAccount.java:20](https://github.com/PaymentRails/java-sdk/tree/master/src/main/java/com/trolley/trolley/RecipientAccount.java#L20)_ ---- \ No newline at end of file +--- diff --git a/pom.xml b/pom.xml index e26d126..d12ee1d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,69 +1,159 @@ 4.0.0 - ca.paymentrails - paymentrails - 1.0.2 - Java SDK for Trolley + com.trolley + java-sdk + 1.0 + Java SDK for Trolley API jar Trolley Java SDK + https://github.com/PaymentRails/java-sdk + + + + The MIT License + https://raw.githubusercontent.com/ConvertAPI/convertapi-java/master/LICENSE.txt + repo + + + + + + joshuapr + Joshua Cunningham + joshua@paymentrails.com + Trolley + https://www.trolley.com/ + + architect + developer + + + + + scm:git:git://github.com/PaymentRails/java-sdk.git + scm:git:git://github.com/PaymentRails/java-sdk.git + https://github.com/PaymentRails/java-sdk + HEAD + - UTF-8 + 1.8 1.8 - 1.6.6 - + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + + org.apache.httpcomponents httpclient - 4.5.3 - - - junit - junit - 4.13.1 - test + 4.5.13 + - org.hamcrest - hamcrest-core - 1.3 - test + com.fasterxml.jackson.core + jackson-annotations + LATEST + - org.mockito - mockito-core - 1.10.19 + com.fasterxml.jackson.core + jackson-core + LATEST + - org.powermock - powermock-module-junit4 - ${powermock.version} - test + com.fasterxml.jackson.core + jackson-databind + LATEST + org.powermock powermock-api-mockito - ${powermock.version} + 1.6.6 test + + - com.fasterxml.jackson.core - jackson-databind - 2.9.10.1 + junit + junit + 4.13.2 - - com.fasterxml.jackson.core - jackson-annotations - LATEST - - - com.fasterxml.jackson.core - jackson-core - LATEST - - + \ No newline at end of file diff --git a/pom_old.xml b/pom_old.xml new file mode 100644 index 0000000..0e8dcc0 --- /dev/null +++ b/pom_old.xml @@ -0,0 +1,140 @@ + + + 4.0.0 + com.trolley + java-sdk + 1.0.1 + Java SDK for Trolley API + jar + Trolley Java SDK + + UTF-8 + 8 + 8 + 1.6.6 + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + junit + junit + 4.13.1 + test + + + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito + ${powermock.version} + test + + + com.fasterxml.jackson.core + jackson-databind + 2.13.1 + + + com.fasterxml.jackson.core + jackson-annotations + LATEST + + + com.fasterxml.jackson.core + jackson-core + LATEST + + + \ No newline at end of file diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/src/main/java/ca/paymentrails/Exceptions/AuthenticationException.java b/src/main/java/ca/paymentrails/Exceptions/AuthenticationException.java deleted file mode 100644 index 1be01bc..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/AuthenticationException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class AuthenticationException extends Exception { - - public AuthenticationException() { - super(); - } - - public AuthenticationException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/AuthorizationException.java b/src/main/java/ca/paymentrails/Exceptions/AuthorizationException.java deleted file mode 100644 index 3a62261..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/AuthorizationException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class AuthorizationException extends Exception { - - public AuthorizationException() { - super(); - } - - public AuthorizationException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/DownForMaintenanceException.java b/src/main/java/ca/paymentrails/Exceptions/DownForMaintenanceException.java deleted file mode 100644 index 1934a08..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/DownForMaintenanceException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class DownForMaintenanceException extends Exception { - - public DownForMaintenanceException() { - super(); - } - - public DownForMaintenanceException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/InvalidFieldException.java b/src/main/java/ca/paymentrails/Exceptions/InvalidFieldException.java deleted file mode 100644 index 4acc61e..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/InvalidFieldException.java +++ /dev/null @@ -1,14 +0,0 @@ - -package ca.paymentrails.Exceptions; - -public class InvalidFieldException extends Exception { - - public InvalidFieldException() { - super(); - } - - public InvalidFieldException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/InvalidServerConnectionException.java b/src/main/java/ca/paymentrails/Exceptions/InvalidServerConnectionException.java deleted file mode 100644 index a55bb44..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/InvalidServerConnectionException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class InvalidServerConnectionException extends Exception { - - public InvalidServerConnectionException() { - super(); - } - - public InvalidServerConnectionException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/InvalidStatusCodeException.java b/src/main/java/ca/paymentrails/Exceptions/InvalidStatusCodeException.java deleted file mode 100644 index 3525e12..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/InvalidStatusCodeException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class InvalidStatusCodeException extends Exception { - - public InvalidStatusCodeException() { - super(); - } - - public InvalidStatusCodeException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/MalformedException.java b/src/main/java/ca/paymentrails/Exceptions/MalformedException.java deleted file mode 100644 index 6e47650..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/MalformedException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class MalformedException extends Exception { - - public MalformedException() { - super(); - } - - public MalformedException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/NotFoundException.java b/src/main/java/ca/paymentrails/Exceptions/NotFoundException.java deleted file mode 100644 index 851a0b7..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/NotFoundException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class NotFoundException extends Exception { - - public NotFoundException() { - super(); - } - - public NotFoundException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/TooManyRequestsException.java b/src/main/java/ca/paymentrails/Exceptions/TooManyRequestsException.java deleted file mode 100644 index e74fede..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/TooManyRequestsException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class TooManyRequestsException extends Exception { - - public TooManyRequestsException() { - super(); - } - - public TooManyRequestsException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/Exceptions/UnexpectedException.java b/src/main/java/ca/paymentrails/Exceptions/UnexpectedException.java deleted file mode 100644 index 02ee809..0000000 --- a/src/main/java/ca/paymentrails/Exceptions/UnexpectedException.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.paymentrails.Exceptions; - -public class UnexpectedException extends Exception { - - public UnexpectedException() { - super(); - } - - public UnexpectedException(String message) { - super(message); - } - -} diff --git a/src/main/java/ca/paymentrails/paymentrails/Balances.java b/src/main/java/ca/paymentrails/paymentrails/Balances.java deleted file mode 100644 index d74480e..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Balances.java +++ /dev/null @@ -1,60 +0,0 @@ -package ca.paymentrails.paymentrails; - -public class Balances { - - public EUR EUR; - - public USD USD; - - public CAD CAD; - - public EUR getEUR() { - return EUR; - } - - public void setEUR(EUR EUR) { - this.EUR = EUR; - } - - public USD getUSD() { - return USD; - } - - public void setUSD(USD USD) { - this.USD = USD; - } - - public CAD getCAD() { - return CAD; - } - - public void setCAD(CAD CAD) { - this.CAD = CAD; - } - - /** - * Retrieves all account balances - * - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static String find() throws Exception { - return find(""); - } - - /** - * Retrieves balance based on term - * - * @param term (paypal or paymentrails) - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static String find(String term) throws Exception { - return Configuration.gateway().balances.find(term); - } - -} diff --git a/src/main/java/ca/paymentrails/paymentrails/BalancesGateway.java b/src/main/java/ca/paymentrails/paymentrails/BalancesGateway.java deleted file mode 100644 index eef1bab..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/BalancesGateway.java +++ /dev/null @@ -1,20 +0,0 @@ -package ca.paymentrails.paymentrails; - -import ca.paymentrails.Exceptions.InvalidFieldException; - -public class BalancesGateway { - Client client; - - public BalancesGateway(Configuration config) { - this.client = new Client(config); - } - - public String find(String term) throws Exception { - if (term == null) { - throw new InvalidFieldException("Term cannot be null"); - } - String endPoint = "/v1/balances/" + term; - String response = this.client.get(endPoint); - return response; - } -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/Batch.java b/src/main/java/ca/paymentrails/paymentrails/Batch.java deleted file mode 100644 index f50b375..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Batch.java +++ /dev/null @@ -1,258 +0,0 @@ -package ca.paymentrails.paymentrails; - -import java.util.List; - -public class Batch { - - private String id; - private String status; - private String amount; - private Integer totalPayments; - private String currency; - private String description; - private Object sentAt; - private Object completedAt; - private String createdAt; - private String updatedAt; - private Payments payments; - public String quoteExpiredAt; - - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getAmount() { - return amount; - } - - public void setAmount(String amount) { - this.amount = amount; - } - - public Integer getTotalPayments() { - return totalPayments; - } - - public void setTotalPayments(Integer totalPayments) { - this.totalPayments = totalPayments; - } - - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Object getSentAt() { - return sentAt; - } - - public void setSentAt(Object sentAt) { - this.sentAt = sentAt; - } - - public Object getCompletedAt() { - return completedAt; - } - - public void setCompletedAt(Object completedAt) { - this.completedAt = completedAt; - } - - public String getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(String createdAt) { - this.createdAt = createdAt; - } - - public String getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(String updatedAt) { - this.updatedAt = updatedAt; - } - - public Payments getPayments() { - return payments; - } - - public void setPayments(Payments payments) { - this.payments = payments; - } - - /** - * Retrieves a batch based on the batch id given - * - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static Batch find(String batch_id) throws Exception { - return Configuration.gateway().batch.find(batch_id); - } - - /** - * Updates a batch based on the batch id and body - * - * @param batch_id - * @param body - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static boolean update(String batch_id, String body) throws Exception { - return Configuration.gateway().batch.update(batch_id, body); - } - - /** - * Deletes a batch based on batch id - * - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static boolean delete(String batch_id) throws Exception { - return Configuration.gateway().batch.delete(batch_id); - } - - /** - * Creates a batch based on batch the body - * - * @param body - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static Batch create(String body) throws Exception { - return Configuration.gateway().batch.create(body); - } - - /** - * Generate a quote for a batch - * - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static String generateQuote(String batch_id) throws Exception { - return Configuration.gateway().batch.generateQuote(batch_id); - } - - /** - * Process a batch - * - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static String processBatch(String batch_id) throws Exception { - return Configuration.gateway().batch.processBatch(batch_id); - } - - /** - * List all Batches based on the recipient id and (optional) a given - * wildcard, page amount and page size - * - * @param page - * @param pageSize - * @param message - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List query(int page, int pageSize, String message) throws Exception { - return Configuration.gateway().batch.query(page, pageSize, message); - - } - - /** - * List all batches based on the recipient id and a given wildcard - * - * @param message - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List query(String message) throws Exception { - return query(1, 10, message); - } - - /** - * List all batches - * - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List query() throws Exception { - return query(1, 10, ""); - } - - /** - * List all batches based on the recipient id and (optional) page amount and - * page size - * - * @param page - * @param pageNumber - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List query(int page, int pageNumber) throws Exception { - return query(page, pageNumber, ""); - } - - /** - * Retrieves summary of batch - * - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static BatchSummary summary(String batch_id) throws Exception { - return Configuration.gateway().batch.summary(batch_id); - - } -} diff --git a/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java b/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java deleted file mode 100644 index ede97d2..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/BatchGateway.java +++ /dev/null @@ -1,146 +0,0 @@ -package ca.paymentrails.paymentrails; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -import ca.paymentrails.Exceptions.InvalidFieldException; - -public class BatchGateway { - Client client; - - public BatchGateway(Configuration config) { - this.client = new Client(config); - } - - public Batch find(String batch_id) throws Exception { - if (batch_id == null || batch_id.isEmpty()) { - throw new InvalidFieldException("Batch id cannot be null or empty."); - } - - String endPoint = "/v1/batches/" + batch_id; - String response = this.client.get(endPoint); - return batchFactory(response); - } - - public boolean update(String batch_id, String body) throws Exception { - if (batch_id == null || batch_id.isEmpty()) { - throw new InvalidFieldException("Batch id cannot be null or empty."); - } - if (body == null || body.isEmpty()) { - throw new InvalidFieldException("Body cannot be null or empty."); - } - - String endPoint = "/v1/batches/" + batch_id; - this.client.patch(endPoint, body); - return true; - } - - public boolean delete(String batch_id) throws Exception { - if (batch_id == null || batch_id.isEmpty()) { - throw new InvalidFieldException("Batch id cannot be null or empty."); - } - - String endPoint = "/v1/batches/" + batch_id; - this.client.delete(endPoint); - return true; - } - - public Batch create(String body) throws Exception { - if (body == null || body.isEmpty()) { - throw new InvalidFieldException("Body cannot be null or empty."); - } - - String endPoint = "/v1/batches/"; - String response = this.client.post(endPoint, body); - return batchFactory(response); - } - - public String generateQuote(String batch_id) throws Exception { - if (batch_id == null || batch_id.isEmpty()) { - throw new InvalidFieldException("Batch id cannot be null or empty."); - } - - String endPoint = "/v1/batches/" + batch_id + "/generate-quote"; - String response = this.client.post(endPoint); - return response; - } - - public String processBatch(String batch_id) throws Exception { - if (batch_id == null || batch_id.isEmpty()) { - throw new InvalidFieldException("Batch id cannot be null or empty."); - } - String endPoint = "/v1/batches/" + batch_id + "/start-processing"; - String response = this.client.post(endPoint); - return response; - } - - public List query(int page, int pageSize, String message) throws Exception { - if (page < 0) { - throw new InvalidFieldException("Page cannot be less than 0"); - } - if (pageSize < 0) { - throw new InvalidFieldException("Page size cannot be less than 0"); - } - if (message == null) { - throw new InvalidFieldException("Message cannot be null"); - } - String endPoint = "/v1/batches/?" + "&search=" + message + "&page=" + page + "&pageSize=" + pageSize; - String response = this.client.get(endPoint); - return batchListFactory(response); - } - - public List query(String message) throws Exception { - return query(1, 10, message); - } - - public List query() throws Exception { - return query(1, 10, ""); - } - - public List query(int page, int pageNumber) throws Exception { - return query(page, pageNumber, ""); - } - - public BatchSummary summary(String batch_id) throws Exception { - if (batch_id == null || batch_id.isEmpty()) { - throw new InvalidFieldException("Batch id cannot be null os empty"); - } - - String endPoint = "/v1/batches/" + batch_id + "/summary"; - String response = this.client.get(endPoint); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode node = mapper.readTree(response); - BatchSummary batchSummary = mapper.readValue(node.get("batchSummary").traverse(), BatchSummary.class); - return batchSummary; - } - - private Batch batchFactory(String data) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - JsonNode node = mapper.readTree(data); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - Batch batch = mapper.readValue(node.get("batch").traverse(), Batch.class); - return batch; - } - - private List batchListFactory(String data) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - JsonNode node = mapper.readTree(data); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - Object batch = mapper.readValue(node.get("batches").traverse(), Object.class); - @SuppressWarnings("unchecked") - List batchs = (List) batch; - List batches = new ArrayList(); - for (int i = 0; i < batchs.size(); i++) { - Batch pojo = mapper.convertValue(batchs.get(i), Batch.class); - batches.add(pojo); - } - return batches; - } -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/BatchSummary.java b/src/main/java/ca/paymentrails/paymentrails/BatchSummary.java deleted file mode 100644 index 76a392b..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/BatchSummary.java +++ /dev/null @@ -1,8 +0,0 @@ -package ca.paymentrails.paymentrails; - -public class BatchSummary { - - public Total total; - public Detail detail; - -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/Client.java b/src/main/java/ca/paymentrails/paymentrails/Client.java deleted file mode 100644 index 2985deb..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Client.java +++ /dev/null @@ -1,238 +0,0 @@ -package ca.paymentrails.paymentrails; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.rmi.UnexpectedException; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClients; - -import ca.paymentrails.Exceptions.*; - -public class Client { - - private Configuration config; - - public Client(Configuration config) { - this.config = config; - } - - /** - * Factory Method to create an instance of Client - * - * @return Client - */ - public static Client create(Configuration config) { - return new Client(config); - } - - private String sendRequest(String method, String endPoint, String body) throws Exception { - String StringResponse = ""; - HttpURLConnection con; - try { - String url = this.config.getApiBase() + endPoint; - URL obj = new URL(url); - con = (HttpURLConnection) obj.openConnection(); - - int timeStamp = (int) (System.currentTimeMillis() / 1000L); - String authorizarion = generateAuthorization(timeStamp, method, endPoint, body); - - con.setRequestMethod(method); - - con.setRequestProperty("X-PR-Timestamp", timeStamp + ""); - con.setRequestProperty("Authorization", authorizarion); - con.setRequestProperty("Trolley-Source", "java-sdk_1.0.2"); - con.setRequestProperty("Content-Type", "application/json"); - if (method == "POST" && body != "") { - - con.setDoOutput(true); - try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { - wr.writeBytes(body); - wr.flush(); - } - } - int responseCode = con.getResponseCode(); - - if (responseCode != 200) { - throwStatusCodeException(responseCode, con.getResponseMessage()); - } - StringBuffer response; - try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { - String inputLine; - response = new StringBuffer(); - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - StringResponse = response.toString(); - } catch (IOException e) { - throw new UnexpectedException(StringResponse); - } - - } catch (IOException e) { - throw new UnexpectedException(StringResponse); - } - return StringResponse; - } - - private String sendRequest(String method, String endPoint) throws Exception { - return sendRequest(method, endPoint, ""); - } - - /** - * Makes an HTTP GET request to the API - * - * @param endPoint - * @return The response - * @throws Exception - */ - public String get(String endPoint) throws Exception { - return sendRequest("GET", endPoint); - } - - /** - * Makes an HTTP POST request to the API - * - * @param endPoint - * @param body - * @return The response - * @throws Exception - */ - public String post(String endPoint, String body) throws Exception { - return sendRequest("POST", endPoint, body); - } - - /** - * Makes an HTTP POST request to the API - * - * @param endPoint - * @return The response - * @throws Exception - */ - public String post(String endPoint) throws Exception { - return sendRequest("POST", endPoint); - } - /** - * Makes an HTTP PATCH request to the API - * - * @param endPoint - * @param body - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public String patch(String endPoint, String body) throws Exception { - String StringResponse = ""; - try { - - HttpClient httpclient = HttpClients.createDefault(); - HttpPatch httpPatch = new HttpPatch(this.config.getApiBase() + endPoint); - StringEntity params = new StringEntity(body); - - int timeStamp = (int) (System.currentTimeMillis() / 1000L); - String authorizarion = generateAuthorization(timeStamp, "PATCH", endPoint, body); - - params.setContentType("application/json"); - - httpPatch.setEntity(params); - httpPatch.addHeader("X-PR-Timestamp", timeStamp + ""); - httpPatch.addHeader("Trolley-Source", "java-sdk_1.0.2"); - httpPatch.addHeader("Authorization", authorizarion); - - HttpResponse response = httpclient.execute(httpPatch); - StringBuffer result = new StringBuffer(); - String line = ""; - - BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); - while ((line = rd.readLine()) != null) { - result.append(line); - } - - StringResponse = result.toString(); - - int responseCode = response.getStatusLine().getStatusCode(); - if (responseCode != 200) { - throwStatusCodeException(responseCode, StringResponse); - } - - } catch (IOException e) { - throw new UnexpectedException(StringResponse); - } - return StringResponse; - } - - /** - * Makes an HTTP DELETE request to the API - * - * @param endPoint - * @return The response - * @throws InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public String delete(String endPoint) throws Exception { - return sendRequest("DELETE", endPoint); - } - - private void throwStatusCodeException(int statusCode, String message) throws Exception { - switch (statusCode) { - case 400: - throw new MalformedException(message); - case 401: - throw new AuthenticationException(message); - case 403: - throw new AuthorizationException(message); - case 404: - throw new NotFoundException(statusCode + " " + message); - case 406: - throw new InvalidStatusCodeException(message); - case 429: - throw new TooManyRequestsException(message); - case 500: - throw new InvalidServerConnectionException(message); - case 503: - throw new DownForMaintenanceException(message); - default: - throw new ca.paymentrails.Exceptions.UnexpectedException(message); - } - } - - private String generateAuthorization(int timeStamp, String method, String endPoint, String body) { - String message = timeStamp + "\n" + method + "\n" + endPoint + "\n" + body + "\n"; - try { - String hash = hmacDigest(message, this.config.getPrivateKey(), "HmacSHA256"); - return "prsign " + this.config.getPublicKey() + ":" + hash; - } catch (Exception e) { - return "prsign 1:1"; - } - - } - - private String hmacDigest(String msg, String keyString, String algo) throws Exception { - String digest = null; - SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algo); - Mac mac = Mac.getInstance(algo); - mac.init(key); - - byte[] bytes = mac.doFinal(msg.getBytes("ASCII")); - - StringBuffer hash = new StringBuffer(); - for (int i = 0; i < bytes.length; i++) { - String hex = Integer.toHexString(0xFF & bytes[i]); - if (hex.length() == 1) { - hash.append('0'); - } - hash.append(hex); - } - digest = hash.toString(); - return digest; - } -} diff --git a/src/main/java/ca/paymentrails/paymentrails/Compliance.java b/src/main/java/ca/paymentrails/paymentrails/Compliance.java deleted file mode 100644 index 36e8ec3..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Compliance.java +++ /dev/null @@ -1,35 +0,0 @@ -package ca.paymentrails.paymentrails; - -import java.util.HashMap; -import java.util.Map; - -public class Compliance { - - private String status; - private Object checkedAt; - private Map additionalProperties = new HashMap(); - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Object getCheckedAt() { - return checkedAt; - } - - public void setCheckedAt(Object checkedAt) { - this.checkedAt = checkedAt; - } - - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/Configuration.java b/src/main/java/ca/paymentrails/paymentrails/Configuration.java deleted file mode 100644 index b84e250..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Configuration.java +++ /dev/null @@ -1,109 +0,0 @@ -package ca.paymentrails.paymentrails; - -public class Configuration { - - String apiBase = "https://api.trolley.com"; - String privateKey = ""; - String publicKey = ""; - - public Configuration() { - } - public Configuration(String publicKey, String privateKey){ - this.publicKey = publicKey; - this.privateKey = privateKey; - } - public Configuration(String publicKey, String privateKey, String apiBase) { - this.publicKey = publicKey; - this.privateKey = privateKey; - this.apiBase = setEnviroment(apiBase); - } - - /** - * Getter for the api base - * - * @return the api base - */ - public String getApiBase() { - return this.apiBase; - } - - /** - * Setter for the api base - * - * @param apiBase - */ - public void setApiBase(String apiBase) { - this.apiBase = apiBase; - } - - /** - * Getter for the public static api key - * - * @return publicKey - */ - public String getPublicKey() { - return this.publicKey; - } - - /** - * Setter for the public static key - * - * @param publicKey - */ - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - /** - * Getter for the private key - * - * @param privateKey - */ - public String getPrivateKey() { - return this.privateKey; - } - - /** - * Setter for the private key - * - * @param privateKey - */ - public void setPrivateKey(String privatKey) { - this.privateKey = privatKey; - } - - public static Gateway gateway() { - return new Gateway(Configuration.instantiate()); - } - - public static Client client(Configuration config) { - return new Client(config); - } - - public static Configuration instantiate() { - return new Configuration(); - } - - /** - * Set the API enviroment - * - * @param enviroment - */ - public String setEnviroment(String enviroment) { - switch (enviroment) { - case "production": - case "PRODUCTION": - return "https://api.trolley.com"; - case "development": - case "DEVELOPMENT": - return "http://api.railz.io"; - case "integration": - case "INTEGRATION": - return "http://api.local.dev:3000"; - case "sandbox": - case "SANDBOX": - return "https://api.trolley.com"; - } - return "https://api.trolley.com"; - } -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/EUR.java b/src/main/java/ca/paymentrails/paymentrails/EUR.java deleted file mode 100644 index 7478893..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/EUR.java +++ /dev/null @@ -1,66 +0,0 @@ -package ca.paymentrails.paymentrails; - -public class EUR { - - private Boolean primary; - private String amount; - private String currency; - private String type; - private String accountNumber; - private Boolean display; - - public Boolean getPrimary() { - return primary; - } - - public void setPrimary(Boolean primary) { - this.primary = primary; - } - - public String getAmount() { - return amount; - } - - public void setAmount(String amount) { - this.amount = amount; - } - - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getAccountNumber() { - return accountNumber; - } - - public void setAccountNumber(String accountNumber) { - this.accountNumber = accountNumber; - } - - public Boolean getDisplay() { - return display; - } - - public void setDisplay(Boolean display) { - this.display = display; - } - - @Override - public String toString() { - return "ClassPojo [amount = " + amount + ", accountNumber = " + accountNumber + ", primary = " + primary - + ", display = " + display + ", type = " + type + ", currency = " + currency + "]"; - } - -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/Meta.java b/src/main/java/ca/paymentrails/paymentrails/Meta.java deleted file mode 100644 index 08705b0..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Meta.java +++ /dev/null @@ -1,32 +0,0 @@ -package ca.paymentrails.paymentrails; - -public class Meta { - - private Integer page; - private Integer pages; - private Integer records; - - public Integer getPage() { - return page; - } - - public void setPage(Integer page) { - this.page = page; - } - - public Integer getPages() { - return pages; - } - - public void setPages(Integer pages) { - this.pages = pages; - } - - public Integer getRecords() { - return records; - } - - public void setRecords(Integer records) { - this.records = records; - } -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/Payment.java b/src/main/java/ca/paymentrails/paymentrails/Payment.java deleted file mode 100644 index f6ba890..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Payment.java +++ /dev/null @@ -1,410 +0,0 @@ -package ca.paymentrails.paymentrails; - -import java.util.List; - -public class Payment { - - private String id; - private Recipient recipient; - private String status; - private Boolean isSupplyPayment; - private String returnedAmount; - - private String amount; - private String currency; - private String category; - private RecipientAccount account; - private List tags; - - private String sourceAmount; - private String sourceCurrency; - private String targetAmount; - private String targetCurrency; - private String exchangeRate; - private String fees; - private String recipientFees; - private String fxRate; - private String memo; - private String externalId; - private Object processedAt; - private String createdAt; - private String updatedAt; - private String merchantFees; - private Compliance compliance; - private String payoutMethod; - private String methodDisplay; - Object batch; - - String withholdingAmount; - String withholdingCurrency; - String equivalentWithholdingAmount; - String equivalentWithholdingCurrency; - - public void setEquivalentWithholdingCurrency(String equivalentWithholdingCurrency) { - this.equivalentWithholdingCurrency = equivalentWithholdingCurrency; - } - - public String getEquivalentWithholdingCurrency() { - return equivalentWithholdingCurrency; - } - - public void setEquivalentWithholdingAmount(String equivalentWithholdingAmount) { - this.equivalentWithholdingAmount = equivalentWithholdingAmount; - } - - public String getEquivalentWithholdingAmount() { - return equivalentWithholdingAmount; - } - - public void setWithholdingCurrency(String withholdingCurrency) { - this.withholdingCurrency = withholdingCurrency; - } - - public List getTags() { - return this.tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public RecipientAccount getAccount() { - return account; - } - - public void setAccount(RecipientAccount account) { - this.account = account; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public String getAmount() { - return amount; - } - - public void setAmount(String amount) { - this.amount = amount; - } - - public String getWithholdingCurrency() { - return withholdingCurrency; - } - - public void setWithholdingAmount(String withholdingAmount) { - this.withholdingAmount = withholdingAmount; - } - - public String getWithholdingAmount() { - return withholdingAmount; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Recipient getRecipient() { - return recipient; - } - - public void setRecipient(Recipient recipient) { - this.recipient = recipient; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Boolean getIsSupplyPayment() { - return isSupplyPayment; - } - - public void setIsSupplyPayment(Boolean isSupplyPayment) { - this.isSupplyPayment = isSupplyPayment; - } - - public String getReturnedAmount() { - return returnedAmount; - } - - public void setReturnedAmount(String returnedAmount) { - this.returnedAmount = returnedAmount; - } - - public String getSourceAmount() { - return sourceAmount; - } - - public void setSourceAmount(String sourceAmount) { - this.sourceAmount = sourceAmount; - } - - public String getSourceCurrency() { - return sourceCurrency; - } - - public void setSourceCurrency(String sourceCurrency) { - this.sourceCurrency = sourceCurrency; - } - - public String getTargetAmount() { - return targetAmount; - } - - public void setTargetAmount(String targetAmount) { - this.targetAmount = targetAmount; - } - - public String getTargetCurrency() { - return targetCurrency; - } - - public void setTargetCurrency(String targetCurrency) { - this.targetCurrency = targetCurrency; - } - - public String getExchangeRate() { - return exchangeRate; - } - - public void setExchangeRate(String exchangeRate) { - this.exchangeRate = exchangeRate; - } - - public String getFees() { - return fees; - } - - public void setFees(String fees) { - this.fees = fees; - } - - public String getRecipientFees() { - return recipientFees; - } - - public void setRecipientFees(String recipientFees) { - this.recipientFees = recipientFees; - } - - public String getFxRate() { - return fxRate; - } - - public void setFxRate(String fxRate) { - this.fxRate = fxRate; - } - - public String getMemo() { - return memo; - } - - public void setMemo(String memo) { - this.memo = memo; - } - - public String getExternalId() { - return externalId; - } - - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - public Object getProcessedAt() { - return processedAt; - } - - public void setProcessedAt(Object processedAt) { - this.processedAt = processedAt; - } - - public String getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(String createdAt) { - this.createdAt = createdAt; - } - - public String getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(String updatedAt) { - this.updatedAt = updatedAt; - } - - public String getMerchantFees() { - return merchantFees; - } - - public void setMerchantFees(String merchantFees) { - this.merchantFees = merchantFees; - } - - public Compliance getCompliance() { - return compliance; - } - - public void setCompliance(Compliance compliance) { - this.compliance = compliance; - } - - public String getPayoutMethod() { - return payoutMethod; - } - - public void setPayoutMethod(String payoutMethod) { - this.payoutMethod = payoutMethod; - } - - public String getMethodDisplay() { - return methodDisplay; - } - - public void setMethodDisplay(String methodDisplay) { - this.methodDisplay = methodDisplay; - } - - /** - * Retrieves a batch based on the batch id - * - * @param payment_id - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static Payment find(String payment_id, String batch_id) throws Exception { - return Configuration.gateway().payment.find(payment_id, batch_id); - } - - /** - * Creates a payment based on the body and batch id - * - * @param body - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static Payment create(String body, String batch_id) throws Exception { - return Configuration.gateway().payment.create(body, batch_id); - } - - /** - * Updates a payment based on the payment id, body and batch id - * - * @param payment_id - * @param body - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static boolean update(String payment_id, String body, String batch_id) throws Exception { - return Configuration.gateway().payment.update(payment_id, body, batch_id); - } - - /** - * Deletes a payment based on the payment id and batch id - * - * @param payment_id - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static boolean delete(String payment_id, String batch_id) throws Exception { - return Configuration.gateway().payment.delete(payment_id, batch_id); - } - - /** - * List all payments based on the recipient id and (optional) a given - * wildcard, page amount and page size - * - * @param batch_id - * @param page - * @param pageSize - * @param message - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List query(String batch_id, int page, int pageSize, String message) throws Exception { - - return Configuration.gateway().payment.query(batch_id, page, pageSize, message); - - } - - /** - * List all payments based on the recipient id and a given wildcard - * - * @param batch_id - * @param message - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List query(String batch_id, String message) throws Exception { - return query(batch_id, 1, 10, message); - } - - /** - * List all payments - * - * @param batch_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List query(String batch_id) throws Exception { - return query(batch_id, 1, 10, ""); - } - - /** - * List all payments based on the recipient id and (optional) page amount - * and page size - * - * @param batch_id - * @param page - * @param pageSize - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List query(String batch_id, int page, int pageSize) throws Exception { - - return query(batch_id, page, pageSize, ""); - } -} diff --git a/src/main/java/ca/paymentrails/paymentrails/Payments.java b/src/main/java/ca/paymentrails/paymentrails/Payments.java deleted file mode 100644 index db032f9..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Payments.java +++ /dev/null @@ -1,26 +0,0 @@ -package ca.paymentrails.paymentrails; - -import java.util.List; - -public class Payments { - - private List payments = null; - private Meta meta; - - public List getPayments() { - return payments; - } - - public void setPayments(List payments) { - this.payments = payments; - } - - public Meta getMeta() { - return meta; - } - - public void setMeta(Meta meta) { - this.meta = meta; - } - -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/Recipient.java b/src/main/java/ca/paymentrails/paymentrails/Recipient.java deleted file mode 100644 index 1747413..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/Recipient.java +++ /dev/null @@ -1,438 +0,0 @@ -package ca.paymentrails.paymentrails; - -import java.util.List; - -public class Recipient { - - String id; - String routeType; - String routeMinimum; - String estimatedFees; - String referenceId; - String email; - String name; - String lastName; - String firstName; - String type; - String taxType; - String status; - String language; - String complianceStatus; - String dob; - String passport; - String updatedAt; - String createdAt; - String gravatarUrl; - String governmentId; - String ssn; - String primaryCurrency; - String placeOfBirth; - List tags; - String merchantId; - String payoutMethod; - public Object payout; - String emailAddress; - public Object inactiveReasons; - - Compliance compliance; - List accounts; - Address address; - - String taxForm; - String taxFormStatus; - String taxWithholdingPercentage = "0.0"; - - public String getTaxFormStatus() { - return this.taxFormStatus; - } - - public void setTaxFormStatus(String taxFormStatus) { - this.taxFormStatus = taxForm; - } - - public List getTags() { - return this.tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public String getTaxWithholdingPercentage() { - return this.taxWithholdingPercentage; - } - - public void setTaxWithholdingPercentage(String taxWithholdingPercentage) { - this.taxWithholdingPercentage = taxWithholdingPercentage; - } - - public String getTaxForm() { - return this.taxForm; - } - - public void setTaxForm(String taxForm) { - this.taxForm = taxForm; - } - - public Object getInactiveReasons() { - return inactiveReasons; - } - - public void setInactiveReasons(Object inactiveReasons) { - this.inactiveReasons = inactiveReasons; - } - - public List getAccounts() { - return accounts; - } - - public void setAccounts(List accounts) { - this.accounts = accounts; - } - - public void setAddress(Address address) { - this.address = address; - } - - public Compliance getCompliance() { - return compliance; - } - - public void setCompliance(Compliance compliance) { - this.compliance = compliance; - } - - public String getLastName() { - return this.lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getRouteType() { - return this.routeType; - } - - public void setRouteType(String routeType) { - this.routeType = routeType; - } - - public String getRouteMinimum() { - return this.routeMinimum; - } - - public void setRouteMinimum(String routeMinimum) { - this.routeMinimum = routeMinimum; - } - - public String getEstimatedFees() { - return estimatedFees; - } - - public void setEstimatedFees(String estimatedFees) { - this.estimatedFees = estimatedFees; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getReferenceId() { - return referenceId; - } - - public void setReferenceId(String referenceId) { - this.referenceId = referenceId; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getTaxType() { - return taxType; - } - - public void setTaxType(String taxType) { - this.taxType = taxType; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public String getComplianceStatus() { - return complianceStatus; - } - - public void setComplianceStatus(String complianceStatus) { - this.complianceStatus = complianceStatus; - } - - public String getDob() { - return dob; - } - - public void setDob(String dob) { - this.dob = dob; - } - - public String getPassport() { - return passport; - } - - public void setPassport(String passport) { - this.passport = passport; - } - - public String getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(String updatedAt) { - this.updatedAt = updatedAt; - } - - public String getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(String createdAt) { - this.createdAt = createdAt; - } - - public String getGravatarUrl() { - return gravatarUrl; - } - - public void setGravatarUrl(String gravatarUrl) { - this.gravatarUrl = gravatarUrl; - } - - public String getGovernmentId() { - return governmentId; - } - - public void setGovernmentId(String governmentId) { - this.governmentId = governmentId; - } - - public String getSsn() { - return ssn; - } - - public void setSsn(String ssn) { - this.ssn = ssn; - } - - public String getPrimaryCurrency() { - return primaryCurrency; - } - - public void setPrimaryCurrency(String primaryCurrency) { - this.primaryCurrency = primaryCurrency; - } - - public String getPlaceOfBirth() { - return placeOfBirth; - } - - public void setPlaceOfBirth(String placeOfBirth) { - this.placeOfBirth = placeOfBirth; - } - - public String getMerchantId() { - return merchantId; - } - - public void setMerchantId(String merchantId) { - this.merchantId = merchantId; - } - - public String getPayoutMethod() { - return payoutMethod; - } - - public void setPayoutMethod(String payoutMethod) { - this.payoutMethod = payoutMethod; - } - - /** - * Retrieves a recipient based on the recipient id given - * - * @param recipient_id - * @return The response - * @throws Exception - - */ - - public static Recipient find(String recipient_id) throws Exception { - return Configuration.gateway().recipient.find(recipient_id); - } - - /** - * Retreives the recipient's logs based on the recipient id given - * - * @param recipient_id - * @return the response - * @throws Exception - */ - public static String findLogs(String recipient_id) throws Exception { - String response = Configuration.gateway().recipient.findLogs(recipient_id); - return response; - } - - /** - * Retreives the recipient's payments based on the recipient id given - * - * @param recipient_id - * @return the response - * @throws Exception - */ - public static List findPayments(String recipient_id) throws Exception { - return Configuration.gateway().recipient.findPayments(recipient_id); - - } - - /** - * Creates a recipient based on the body given to the client - * - * @param body - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static Recipient create(String body) throws Exception { - return Configuration.gateway().recipient.create(body); - - } - - /** - * Updates a recipient based on the body given to the client - * - * @param recipient_id - * @param body - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static boolean update(String recipient_id, String body) throws Exception { - return Configuration.gateway().recipient.update(recipient_id, body); - } - - /** - * Delete a recipient based on the recipient id - * - * @param recipient_id - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - */ - public static boolean delete(String recipient_id) throws Exception { - return Configuration.gateway().recipient.delete(recipient_id); - } - - /** - * List all recipients based on the recipient id and (optional) a given - * wildcard, page amount and page size - * - * @param page - * @param pageSize - * @param term - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List search(int page, int pageSize, String term) throws Exception { - return Configuration.gateway().recipient.search(page, pageSize, term); - } - - /** - * List all recipients based on the recipient id and a given wildcard - * - * @param message - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List search(String message) throws Exception { - return search(1, 10, message); - } - - /** - * - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List search() throws Exception { - return search(1, 10, ""); - } - - /** - * List all recipients based on the recipient id and (optional) page amount - * and page size - * - * @param page - * @param pageNumber - * @return The response - * @throws ca.paymentrails.Exceptions.InvalidStatusCodeException - * @throws ca.paymentrails.Exceptions.InvalidConnectionException - * @throws ca.paymentrails.Exceptions.InvalidFieldException - */ - public static List search(int page, int pageNumber) throws Exception { - return search(page, pageNumber, ""); - } - -} diff --git a/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java b/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java deleted file mode 100644 index e9147f3..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/RecipientAccount.java +++ /dev/null @@ -1,232 +0,0 @@ -package ca.paymentrails.paymentrails; - -import java.util.List; - -public class RecipientAccount { - - String type; - Boolean primary; - String currency; - String id; - String recipientId; - String recipientAccountId; - String routeType; - String recipientFees; - String country; - String iban; - String accountNum; - String accountHolderName; - String swiftBic; - String branchId; - String bankId; - String bankName; - String bankAddress; - String bankCity; - String bankRegionCode; - String bankPostalCode; - String emailAddress; - String status; - String disabledAt; - - public String getEmailAddress(){ - return emailAddress; - } - public void setEmailAddress(String emailAddress){ - this.emailAddress = emailAddress; - } - - - public String getDisabledAt(){ - return disabledAt; - } - public void setDisabledAt(String disabledAt){ - this.disabledAt = disabledAt; - } - - public String getStatus(){ - return status; - } - public void setStatus(String status){ - this.status = status; - } - - public String getRecipientId(){ - return recipientId; - } - public void setRecipientId(String recipientId){ - this.recipientId = recipientId; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Boolean getPrimary() { - return primary; - } - - public void setPrimary(Boolean primary) { - this.primary = primary; - } - - public String getCurrency() { - return currency; - } - - public void setCurrency(String currency) { - this.currency = currency; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getRecipientAccountId() { - return recipientAccountId; - } - - public void setRecipientAccountId(String recipientAccountId) { - this.recipientAccountId = recipientAccountId; - } - - public String getRouteType() { - return routeType; - } - - public void setRouteType(String routeType) { - this.routeType = routeType; - } - - public String getRecipientFees() { - return recipientFees; - } - - public void setRecipientFees(String recipientFees) { - this.recipientFees = recipientFees; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getIban() { - return iban; - } - - public void setIban(String iban) { - this.iban = iban; - } - - public String getAccountNum() { - return accountNum; - } - - public void setAccountNum(String accountNum) { - this.accountNum = accountNum; - } - - public String getAccountHolderName() { - return accountHolderName; - } - - public void setAccountHolderName(String accountHolderName) { - this.accountHolderName = accountHolderName; - } - - public String getSwiftBic() { - return swiftBic; - } - - public void setSwiftBic(String swiftBic) { - this.swiftBic = swiftBic; - } - - public String getBranchId() { - return branchId; - } - - public void setBranchId(String branchId) { - this.branchId = branchId; - } - - public String getBankId() { - return bankId; - } - - public void setBankId(String bankId) { - this.bankId = bankId; - } - - public String getBankName() { - return bankName; - } - - public void setBankName(String bankName) { - this.bankName = bankName; - } - - public String getBankAddress() { - return bankAddress; - } - - public void setBankAddress(String bankAddress) { - this.bankAddress = bankAddress; - } - - public String getBankCity() { - return bankCity; - } - - public void setBankCity(String bankCity) { - this.bankCity = bankCity; - } - - public String getBankRegionCode() { - return bankRegionCode; - } - - public void setBankRegionCode(String bankRegionCode) { - this.bankRegionCode = bankRegionCode; - } - - public String getBankPostalCode() { - return bankPostalCode; - } - - public void setBankPostalCode(String bankPostalCode) { - this.bankPostalCode = bankPostalCode; - } - - public static List findAll(String recipient_id) throws Exception { - return Configuration.gateway().recipientAccount.findAll(recipient_id); - } - - public static RecipientAccount find(String recipient_id, String recipient_account_id) throws Exception { - return Configuration.gateway().recipientAccount.find(recipient_id, recipient_account_id); - } - - public static RecipientAccount create(String recipient_id, String body) throws Exception { - return Configuration.gateway().recipientAccount.create(recipient_id, body); - } - - public static RecipientAccount update(String recipient_id, String recipient_account_id, String body) throws Exception { - return Configuration.gateway().recipientAccount.update(recipient_id, recipient_account_id, body); - } - - public static boolean delete(String recipient_id, String recipient_account_id) throws Exception { - return Configuration.gateway().recipientAccount.delete(recipient_id, recipient_account_id); - } - -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java b/src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java deleted file mode 100644 index 593ccb3..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/RecipientAccountGateway.java +++ /dev/null @@ -1,97 +0,0 @@ -package ca.paymentrails.paymentrails; - -import ca.paymentrails.Exceptions.InvalidFieldException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.ArrayList; -import com.fasterxml.jackson.databind.DeserializationFeature; -import java.util.List; - -public class RecipientAccountGateway { - - Client client; - - public RecipientAccountGateway(Configuration config) { - this.client = new Client(config); - } - - public List findAll(String recipient_id) throws Exception { - if (recipient_id == null || recipient_id.isEmpty()) { - throw new InvalidFieldException("Recipient id cannot be null or empty."); - } - - String endPoint = "/v1/recipients/" + recipient_id + "/accounts"; - String response = this.client.get(endPoint); - return recipientAccountListFactory(response); - } - - public RecipientAccount find(String recipient_id, String recipient_account_id) throws Exception { - if (recipient_id == null || recipient_id.isEmpty()) { - throw new InvalidFieldException("Recipient id cannot be null or empty."); - } - - String endPoint = "/v1/recipients/" + recipient_id + "/accounts/" + recipient_account_id; - String response = this.client.get(endPoint); - return recipientAccountFactory(response); - } - - public RecipientAccount create(String recipient_id, String body) throws Exception { - if (recipient_id == null || recipient_id.isEmpty()) { - throw new InvalidFieldException("Recipient id cannot be null or empty."); - } - if (body == null || body.isEmpty()) { - throw new InvalidFieldException("Body cannot be null or empty"); - } - - String endPoint = "/v1/recipients/" + recipient_id + "/accounts"; - String response = this.client.post(endPoint, body); - return recipientAccountFactory(response); - } - - public RecipientAccount update(String recipient_id, String recipient_account_id, String body) throws Exception { - if (recipient_id == null || recipient_id.isEmpty()) { - throw new InvalidFieldException("Recipient id cannot be null or empty."); - } - if (body == null || body.isEmpty()) { - throw new InvalidFieldException("Body cannot be null or empty"); - } - - String endPoint = "/v1/recipients/" + recipient_id + "/accounts/" + recipient_account_id; - String response = this.client.patch(endPoint, body); - return recipientAccountFactory(response); - } - - public boolean delete(String recipient_id, String recipient_account_id) throws Exception { - if (recipient_id == null || recipient_id.isEmpty()) { - throw new InvalidFieldException("Recipient id cannot be null or empty."); - } - - String endPoint = "/v1/recipients/" + recipient_id + "/accounts/" + recipient_account_id; - this.client.delete(endPoint); - return true; - } - - private RecipientAccount recipientAccountFactory(String data) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - JsonNode node = mapper.readTree(data); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - RecipientAccount recipientAccount = mapper.readValue(node.get("account").traverse(), RecipientAccount.class); - return recipientAccount; - } - - private List recipientAccountListFactory(String data) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - JsonNode node = mapper.readTree(data); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - Object recipientAccount = mapper.readValue(node.get("accounts").traverse(), Object.class); - @SuppressWarnings("unchecked") - List recipAccounts = (List) recipientAccount; - List recipientAccounts = new ArrayList(); - for (int i = 0; i < recipAccounts.size(); i++) { - RecipientAccount pojo = mapper.convertValue(recipAccounts.get(i), RecipientAccount.class); - recipientAccounts.add(pojo); - } - return recipientAccounts; - } -} \ No newline at end of file diff --git a/src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java b/src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java deleted file mode 100644 index 0ded248..0000000 --- a/src/main/java/ca/paymentrails/paymentrails/RecipientGateway.java +++ /dev/null @@ -1,125 +0,0 @@ -package ca.paymentrails.paymentrails; - -import ca.paymentrails.Exceptions.InvalidFieldException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import com.fasterxml.jackson.databind.DeserializationFeature; - -public class RecipientGateway { - - Client client; - - public RecipientGateway(Configuration config) { - this.client = new Client(config); - } - - public Recipient find(String recipient_id) throws Exception { - if (recipient_id == null || recipient_id.isEmpty()) { - throw new InvalidFieldException("Recipient id cannot be null or empty."); - } - - String endPoint = "/v1/recipients/" + recipient_id; - String response = this.client.get(endPoint); - return recipientFactory(response); - } - - public String findLogs(String recipient_id) throws Exception { - String endPoint = "/v1/recipients/" + recipient_id + "/logs"; - String response = this.client.get(endPoint); - return response; - } - - public List findPayments(String recipient_id) throws Exception { - String endPoint = "/v1/recipients/" + recipient_id + "/payments"; - String response = this.client.get(endPoint); - ObjectMapper mapper = new ObjectMapper(); - JsonNode node = mapper.readTree(response); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - Object payment = mapper.readValue(node.get("payments").traverse(), Object.class); - @SuppressWarnings("unchecked") - List paymens = (List) payment; - List payments = new ArrayList(); - for (int i = 0; i < paymens.size(); i++) { - Payment pojo = mapper.convertValue(paymens.get(i), Payment.class); - payments.add(pojo); - } - - return payments; - } - - public Recipient create(String body) throws Exception { - if (body == null || body.isEmpty()) { - throw new InvalidFieldException("Body cannot be null or empty"); - } - String endPoint = "/v1/recipients/"; - String response = this.client.post(endPoint, body); - return recipientFactory(response); - } - - public boolean update(String recipient_id, String body) throws Exception { - if (recipient_id == null || recipient_id.isEmpty()) { - throw new InvalidFieldException("Recipient id cannot be null or empty."); - } - if (body == null || body.isEmpty()) { - throw new InvalidFieldException("Body cannot be null or empty"); - } - - String endPoint = "/v1/recipients/" + recipient_id; - this.client.patch(endPoint, body); - return true; - } - - public boolean delete(String recipient_id) throws Exception { - if (recipient_id == null || recipient_id.isEmpty()) { - throw new InvalidFieldException("Recipient id cannot be null or empty."); - } - - String endPoint = "/v1/recipients/" + recipient_id; - this.client.delete(endPoint); - return true; - } - - public List search(int page, int pageSize, String term) throws Exception { - if (page < 0) { - throw new InvalidFieldException("Page cannot be less than 0"); - } - if (pageSize < 0) { - throw new InvalidFieldException("Page size cannot be less than 0"); - } - if (term == null) { - throw new InvalidFieldException("Message cannot be null"); - } - - String endPoint = "/v1/recipients/?" + "&search=" + term + "&page=" + page + "&pageSize=" + pageSize; - String response = this.client.get(endPoint); - - return recipientListFactory(response); - } - - private Recipient recipientFactory(String data) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode node = mapper.readTree(data); - Recipient recipient = mapper.readValue(node.get("recipient").traverse(), Recipient.class); - return recipient; - } - - private List recipientListFactory(String data) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode node = mapper.readTree(data); - - Object recipient = mapper.readValue(node.get("recipients").traverse(), Object.class); - @SuppressWarnings("unchecked") - List recips = (List) recipient; - List recipients = new ArrayList(); - for (int i = 0; i < recips.size(); i++) { - Recipient pojo = mapper.convertValue(recips.get(i), Recipient.class); - recipients.add(pojo); - } - return recipients; - } -} \ No newline at end of file diff --git a/src/main/java/com/trolley/Exceptions/AuthenticationException.java b/src/main/java/com/trolley/Exceptions/AuthenticationException.java new file mode 100644 index 0000000..6432a11 --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/AuthenticationException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class AuthenticationException extends Exception +{ + public AuthenticationException() { + } + + public AuthenticationException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/AuthorizationException.java b/src/main/java/com/trolley/Exceptions/AuthorizationException.java new file mode 100644 index 0000000..9f24e24 --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/AuthorizationException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class AuthorizationException extends Exception +{ + public AuthorizationException() { + } + + public AuthorizationException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/DownForMaintenanceException.java b/src/main/java/com/trolley/Exceptions/DownForMaintenanceException.java new file mode 100644 index 0000000..f2d7aec --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/DownForMaintenanceException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class DownForMaintenanceException extends Exception +{ + public DownForMaintenanceException() { + } + + public DownForMaintenanceException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/InvalidFieldException.java b/src/main/java/com/trolley/Exceptions/InvalidFieldException.java new file mode 100644 index 0000000..4ec0e6c --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/InvalidFieldException.java @@ -0,0 +1,12 @@ + +package com.trolley.Exceptions; + +public class InvalidFieldException extends Exception +{ + public InvalidFieldException() { + } + + public InvalidFieldException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/InvalidServerConnectionException.java b/src/main/java/com/trolley/Exceptions/InvalidServerConnectionException.java new file mode 100644 index 0000000..d41bafb --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/InvalidServerConnectionException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class InvalidServerConnectionException extends Exception +{ + public InvalidServerConnectionException() { + } + + public InvalidServerConnectionException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/InvalidStatusCodeException.java b/src/main/java/com/trolley/Exceptions/InvalidStatusCodeException.java new file mode 100644 index 0000000..a089ce4 --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/InvalidStatusCodeException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class InvalidStatusCodeException extends Exception +{ + public InvalidStatusCodeException() { + } + + public InvalidStatusCodeException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/MalformedException.java b/src/main/java/com/trolley/Exceptions/MalformedException.java new file mode 100644 index 0000000..cf487f8 --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/MalformedException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class MalformedException extends Exception +{ + public MalformedException() { + } + + public MalformedException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/NotFoundException.java b/src/main/java/com/trolley/Exceptions/NotFoundException.java new file mode 100644 index 0000000..6b2b405 --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/NotFoundException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class NotFoundException extends Exception +{ + public NotFoundException() { + } + + public NotFoundException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/TooManyRequestsException.java b/src/main/java/com/trolley/Exceptions/TooManyRequestsException.java new file mode 100644 index 0000000..5ab979f --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/TooManyRequestsException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class TooManyRequestsException extends Exception +{ + public TooManyRequestsException() { + } + + public TooManyRequestsException(final String message) { + super(message); + } +} diff --git a/src/main/java/com/trolley/Exceptions/UnexpectedException.java b/src/main/java/com/trolley/Exceptions/UnexpectedException.java new file mode 100644 index 0000000..7b839fb --- /dev/null +++ b/src/main/java/com/trolley/Exceptions/UnexpectedException.java @@ -0,0 +1,11 @@ +package com.trolley.Exceptions; + +public class UnexpectedException extends Exception +{ + public UnexpectedException() { + } + + public UnexpectedException(final String message) { + super(message); + } +} diff --git a/src/main/java/ca/paymentrails/paymentrails/Address.java b/src/main/java/com/trolley/trolley/Address.java similarity index 50% rename from src/main/java/ca/paymentrails/paymentrails/Address.java rename to src/main/java/com/trolley/trolley/Address.java index 2265b94..22fff04 100644 --- a/src/main/java/ca/paymentrails/paymentrails/Address.java +++ b/src/main/java/com/trolley/trolley/Address.java @@ -1,9 +1,10 @@ -package ca.paymentrails.paymentrails; +package com.trolley.trolley; import java.util.HashMap; import java.util.Map; -public class Address { +public class Address +{ private String street1; private String street2; private String city; @@ -12,77 +13,81 @@ public class Address { private String region; private String phone; private Boolean phoneValidated; - private Map additionalProperties = new HashMap(); - + private Map additionalProperties; + + public Address() { + this.additionalProperties = new HashMap(); + } + public String getStreet1() { - return street1; + return this.street1; } - - public void setStreet1(String street1) { + + public void setStreet1(final String street1) { this.street1 = street1; } - + public String getStreet2() { - return street2; + return this.street2; } - - public void setStreet2(String street2) { + + public void setStreet2(final String street2) { this.street2 = street2; } - + public String getCity() { - return city; + return this.city; } - - public void setCity(String city) { + + public void setCity(final String city) { this.city = city; } - + public String getPostalCode() { - return postalCode; + return this.postalCode; } - - public void setPostalCode(String postalCode) { + + public void setPostalCode(final String postalCode) { this.postalCode = postalCode; } - + public String getCountry() { - return country; + return this.country; } - - public void setCountry(String country) { + + public void setCountry(final String country) { this.country = country; } - + public String getRegion() { - return region; + return this.region; } - - public void setRegion(String region) { + + public void setRegion(final String region) { this.region = region; } - + public String getPhone() { - return phone; + return this.phone; } - - public void setPhone(String phone) { + + public void setPhone(final String phone) { this.phone = phone; } - + public Boolean getPhoneValidated() { - return phoneValidated; + return this.phoneValidated; } - - public void setPhoneValidated(Boolean phoneValidated) { + + public void setPhoneValidated(final Boolean phoneValidated) { this.phoneValidated = phoneValidated; } - + public Map getAdditionalProperties() { return this.additionalProperties; } - - public void setAdditionalProperty(String name, Object value) { + + public void setAdditionalProperty(final String name, final Object value) { this.additionalProperties.put(name, value); } -} \ No newline at end of file +} diff --git a/src/main/java/com/trolley/trolley/Balances.java b/src/main/java/com/trolley/trolley/Balances.java new file mode 100644 index 0000000..53afd8a --- /dev/null +++ b/src/main/java/com/trolley/trolley/Balances.java @@ -0,0 +1,40 @@ +package com.trolley.trolley; + +public class Balances +{ + public EUR EUR; + public USD USD; + public CAD CAD; + + public EUR getEUR() { + return this.EUR; + } + + public void setEUR(final EUR EUR) { + this.EUR = EUR; + } + + public USD getUSD() { + return this.USD; + } + + public void setUSD(final USD USD) { + this.USD = USD; + } + + public CAD getCAD() { + return this.CAD; + } + + public void setCAD(final CAD CAD) { + this.CAD = CAD; + } + + public static String find() throws Exception { + return find(""); + } + + public static String find(final String term) throws Exception { + return Configuration.gateway().balances.find(term); + } +} diff --git a/src/main/java/com/trolley/trolley/BalancesGateway.java b/src/main/java/com/trolley/trolley/BalancesGateway.java new file mode 100644 index 0000000..7127ebd --- /dev/null +++ b/src/main/java/com/trolley/trolley/BalancesGateway.java @@ -0,0 +1,21 @@ +package com.trolley.trolley; + +import com.trolley.Exceptions.InvalidFieldException; + +public class BalancesGateway +{ + Client client; + + public BalancesGateway(final Configuration config) { + this.client = new Client(config); + } + + public String find(final String term) throws Exception { + if (term == null) { + throw new InvalidFieldException("Term cannot be null"); + } + final String endPoint = "/v1/balances/" + term; + final String response = this.client.get(endPoint); + return response; + } +} diff --git a/src/main/java/ca/paymentrails/paymentrails/BankTransfer.java b/src/main/java/com/trolley/trolley/BankTransfer.java similarity index 69% rename from src/main/java/ca/paymentrails/paymentrails/BankTransfer.java rename to src/main/java/com/trolley/trolley/BankTransfer.java index 52b224d..4ff2b46 100644 --- a/src/main/java/ca/paymentrails/paymentrails/BankTransfer.java +++ b/src/main/java/com/trolley/trolley/BankTransfer.java @@ -1,10 +1,10 @@ -package ca.paymentrails.paymentrails; - -public class BankTransfer { +package com.trolley.trolley; +public class BankTransfer +{ public Integer count; public String totalFees; public String merchantFees; public String debitAmount; public String sendingAmount; -} \ No newline at end of file +} diff --git a/src/main/java/com/trolley/trolley/Batch.java b/src/main/java/com/trolley/trolley/Batch.java new file mode 100644 index 0000000..3478d1e --- /dev/null +++ b/src/main/java/com/trolley/trolley/Batch.java @@ -0,0 +1,157 @@ +package com.trolley.trolley; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Batch +{ + private String id; + private String status; + private String amount; + private Integer totalPayments; + private String currency; + private String description; + private Object sentAt; + private Object completedAt; + private String createdAt; + private String updatedAt; + private List payments; + public String quoteExpiredAt; + + public String getId() { + return this.id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(final String status) { + this.status = status; + } + + public String getAmount() { + return this.amount; + } + + public void setAmount(final String amount) { + this.amount = amount; + } + + public Integer getTotalPayments() { + return this.totalPayments; + } + + public void setTotalPayments(final Integer totalPayments) { + this.totalPayments = totalPayments; + } + + public String getCurrency() { + return this.currency; + } + + public void setCurrency(final String currency) { + this.currency = currency; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public Object getSentAt() { + return this.sentAt; + } + + public void setSentAt(final Object sentAt) { + this.sentAt = sentAt; + } + + public Object getCompletedAt() { + return this.completedAt; + } + + public void setCompletedAt(final Object completedAt) { + this.completedAt = completedAt; + } + + public String getCreatedAt() { + return this.createdAt; + } + + public void setCreatedAt(final String createdAt) { + this.createdAt = createdAt; + } + + public String getUpdatedAt() { + return this.updatedAt; + } + + public void setUpdatedAt(final String updatedAt) { + this.updatedAt = updatedAt; + } + + public List getPayments() { + return this.payments; + } + + public void setPayments(final List payments) { + this.payments = payments; + } + + public static Batch find(final String batch_id) throws Exception { + return Configuration.gateway().batch.find(batch_id); + } + + public static boolean update(final String batch_id, final String body) throws Exception { + return Configuration.gateway().batch.update(batch_id, body); + } + + public static boolean delete(final String batch_id) throws Exception { + return Configuration.gateway().batch.delete(batch_id); + } + + public static Batch create(final String body) throws Exception { + return Configuration.gateway().batch.create(body); + } + + public static Batch create(final Batch body) throws Exception { + return Configuration.gateway().batch.create(body); + } + + public static String generateQuote(final String batch_id) throws Exception { + return Configuration.gateway().batch.generateQuote(batch_id); + } + + public static String processBatch(final String batch_id) throws Exception { + return Configuration.gateway().batch.processBatch(batch_id); + } + + public static List query(final int page, final int pageSize, final String message) throws Exception { + return Configuration.gateway().batch.query(page, pageSize, message); + } + + public static List query(final String message) throws Exception { + return query(1, 10, message); + } + + public static List query() throws Exception { + return query(1, 10, ""); + } + + public static List query(final int page, final int pageNumber) throws Exception { + return query(page, pageNumber, ""); + } + + public static BatchSummary summary(final String batch_id) throws Exception { + return Configuration.gateway().batch.summary(batch_id); + } +} diff --git a/src/main/java/com/trolley/trolley/BatchGateway.java b/src/main/java/com/trolley/trolley/BatchGateway.java new file mode 100644 index 0000000..a585cf3 --- /dev/null +++ b/src/main/java/com/trolley/trolley/BatchGateway.java @@ -0,0 +1,169 @@ +package com.trolley.trolley; + +import java.io.IOException; +import java.util.ArrayList; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.DeserializationFeature; +import java.util.List; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.trolley.Exceptions.InvalidFieldException; + +public class BatchGateway +{ + Client client; + + public BatchGateway(final Configuration config) { + this.client = new Client(config); + } + + public Batch find(final String batch_id) throws Exception { + if (batch_id == null || batch_id.isEmpty()) { + throw new InvalidFieldException("Batch id cannot be null or empty."); + } + final String endPoint = "/v1/batches/" + batch_id; + final String response = this.client.get(endPoint); + return this.batchFactory(response); + } + + public boolean update(final String batch_id, final String body) throws Exception { + if (batch_id == null || batch_id.isEmpty()) { + throw new InvalidFieldException("Batch id cannot be null or empty."); + } + if (body == null || body.isEmpty()) { + throw new InvalidFieldException("Body cannot be null or empty."); + } + final String endPoint = "/v1/batches/" + batch_id; + this.client.patch(endPoint, body); + return true; + } + + public boolean update(final String batch_id, final Batch batch) throws Exception { + if (batch_id == null || batch_id.isEmpty()) { + throw new InvalidFieldException("Batch id cannot be null or empty."); + } + if (batch == null) { + throw new InvalidFieldException("Body cannot be null or empty."); + } + final String jsonBatch = new ObjectMapper().writeValueAsString((Object)batch); + final String endPoint = "/v1/batches/" + batch_id; + this.client.patch(endPoint, jsonBatch); + return true; + } + + public boolean delete(final String batch_id) throws Exception { + if (batch_id == null || batch_id.isEmpty()) { + throw new InvalidFieldException("Batch id cannot be null or empty."); + } + final String endPoint = "/v1/batches/" + batch_id; + this.client.delete(endPoint); + return true; + } + + public Batch create(final String body) throws Exception { + if (body == null || body.isEmpty()) { + throw new InvalidFieldException("Body cannot be null or empty."); + } + final String endPoint = "/v1/batches/"; + final String response = this.client.post(endPoint, body); + return this.batchFactory(response); + } + + public Batch create(final Batch batch) throws Exception { + if (batch == null) { + throw new InvalidFieldException("Batch cannot be null."); + } + final String result = new ObjectMapper().writeValueAsString((Object)batch); + final String endPoint = "/v1/batches/"; + final String response = this.client.post(endPoint, result); + return this.batchFactory(response); + } + + public String generateQuote(final String batch_id) throws Exception { + if (batch_id == null || batch_id.isEmpty()) { + throw new InvalidFieldException("Batch id cannot be null or empty."); + } + final String endPoint = "/v1/batches/" + batch_id + "/generate-quote"; + final String response = this.client.post(endPoint); + return response; + } + + public String processBatch(final String batch_id) throws Exception { + if (batch_id == null || batch_id.isEmpty()) { + throw new InvalidFieldException("Batch id cannot be null or empty."); + } + final String endPoint = "/v1/batches/" + batch_id + "/start-processing"; + final String response = this.client.post(endPoint); + return response; + } + + public List query(final int page, final int pageSize, final String message) throws Exception { + if (page < 0) { + throw new InvalidFieldException("Page cannot be less than 0"); + } + if (pageSize < 0) { + throw new InvalidFieldException("Page size cannot be less than 0"); + } + if (message == null) { + throw new InvalidFieldException("Message cannot be null"); + } + final String endPoint = "/v1/batches/?&search=" + message + "&page=" + page + "&pageSize=" + pageSize; + final String response = this.client.get(endPoint); + return this.batchListFactory(response); + } + + public List query(final String message) throws Exception { + return this.query(1, 10, message); + } + + public List query() throws Exception { + return this.query(1, 10, ""); + } + + public List query(final int page, final int pageNumber) throws Exception { + return this.query(page, pageNumber, ""); + } + + public BatchSummary summary(final String batch_id) throws Exception { + if (batch_id == null || batch_id.isEmpty()) { + throw new InvalidFieldException("Batch id cannot be null os empty"); + } + final String endPoint = "/v1/batches/" + batch_id + "/summary"; + final String response = this.client.get(endPoint); + final ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final JsonNode node = mapper.readTree(response); + final BatchSummary batchSummary = (BatchSummary)mapper.readValue(node.get("batchSummary").traverse(), (Class)BatchSummary.class); + return batchSummary; + } + + private Batch batchFactory(final String data) throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode node = mapper.readTree(data); + mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final Object payments = mapper.readValue(node.get("batch").get("payments").get("payments").traverse(), (Class)Object.class); + final List castPayments = (List)payments; + final List paymentList = new ArrayList(); + for (int i = 0; i < castPayments.size(); ++i) { + final Payment payment = (Payment)mapper.convertValue((Object)castPayments.get(i), (Class)Payment.class); + paymentList.add(payment); + } + final Batch batch = (Batch)mapper.readValue(node.get("batch").traverse(), (Class)Batch.class); + batch.setPayments(paymentList); + return batch; + } + + private List batchListFactory(final String data) throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode node = mapper.readTree(data); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final Object batch = mapper.readValue(node.get("batches").traverse(), (Class)Object.class); + final List batchs = (List)batch; + final List batches = new ArrayList(); + for (int i = 0; i < batchs.size(); ++i) { + final Batch pojo = (Batch)mapper.convertValue((Object)batchs.get(i), (Class)Batch.class); + batches.add(pojo); + } + return batches; + } +} diff --git a/src/main/java/com/trolley/trolley/BatchSummary.java b/src/main/java/com/trolley/trolley/BatchSummary.java new file mode 100644 index 0000000..2938941 --- /dev/null +++ b/src/main/java/com/trolley/trolley/BatchSummary.java @@ -0,0 +1,7 @@ +package com.trolley.trolley; + +public class BatchSummary +{ + public Total total; + public Detail detail; +} diff --git a/src/main/java/ca/paymentrails/paymentrails/CAD.java b/src/main/java/com/trolley/trolley/CAD.java similarity index 51% rename from src/main/java/ca/paymentrails/paymentrails/CAD.java rename to src/main/java/com/trolley/trolley/CAD.java index 46f43dd..31f7af7 100644 --- a/src/main/java/ca/paymentrails/paymentrails/CAD.java +++ b/src/main/java/com/trolley/trolley/CAD.java @@ -1,60 +1,59 @@ -package ca.paymentrails.paymentrails; - -public class CAD { +package com.trolley.trolley; +public class CAD +{ private Boolean primary; private String amount; private String currency; private String type; private String accountNumber; private Boolean display; - + public Boolean getPrimary() { - return primary; + return this.primary; } - - public void setPrimary(Boolean primary) { + + public void setPrimary(final Boolean primary) { this.primary = primary; } - + public String getAmount() { - return amount; + return this.amount; } - - public void setAmount(String amount) { + + public void setAmount(final String amount) { this.amount = amount; } - + public String getCurrency() { - return currency; + return this.currency; } - - public void setCurrency(String currency) { + + public void setCurrency(final String currency) { this.currency = currency; } - + public String getType() { - return type; + return this.type; } - - public void setType(String type) { + + public void setType(final String type) { this.type = type; } - + public String getAccountNumber() { - return accountNumber; + return this.accountNumber; } - - public void setAccountNumber(String accountNumber) { + + public void setAccountNumber(final String accountNumber) { this.accountNumber = accountNumber; } - + public Boolean getDisplay() { - return display; + return this.display; } - - public void setDisplay(Boolean display) { + + public void setDisplay(final Boolean display) { this.display = display; } - -} \ No newline at end of file +} diff --git a/src/main/java/com/trolley/trolley/Client.java b/src/main/java/com/trolley/trolley/Client.java new file mode 100644 index 0000000..3d008b5 --- /dev/null +++ b/src/main/java/com/trolley/trolley/Client.java @@ -0,0 +1,218 @@ +package com.trolley.trolley; + +import java.security.Key; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import com.trolley.Exceptions.DownForMaintenanceException; +import com.trolley.Exceptions.InvalidServerConnectionException; +import com.trolley.Exceptions.TooManyRequestsException; +import com.trolley.Exceptions.InvalidStatusCodeException; +import com.trolley.Exceptions.NotFoundException; +import com.trolley.Exceptions.AuthorizationException; +import com.trolley.Exceptions.AuthenticationException; +import com.trolley.Exceptions.MalformedException; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.HttpEntity; +import org.apache.http.entity.StringEntity; +import org.apache.http.client.methods.HttpPatch; +import org.apache.http.impl.client.HttpClients; +import java.io.IOException; +import java.rmi.UnexpectedException; +import java.io.Reader; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.DataOutputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +public class Client +{ + private Configuration config; + + public Client(final Configuration config) { + this.config = config; + } + + public static Client create(final Configuration config) { + return new Client(config); + } + + private String sendRequest(final String method, final String endPoint, final String body) throws Exception { + String StringResponse = ""; + try { + final String url = this.config.getApiBase() + endPoint; + final URL obj = new URL(url); + final HttpURLConnection con = (HttpURLConnection)obj.openConnection(); + final int timeStamp = (int)(System.currentTimeMillis() / 1000L); + final String authorizarion = this.generateAuthorization(timeStamp, method, endPoint, body); + con.setRequestMethod(method); + con.setRequestProperty("X-PR-Timestamp", timeStamp + ""); + con.setRequestProperty("Authorization", authorizarion); + con.setRequestProperty("Content-Type", "application/json"); + if (method == "POST" && body != "") { + con.setDoOutput(true); + final DataOutputStream wr = new DataOutputStream(con.getOutputStream()); + try { + wr.writeBytes(body); + wr.flush(); + wr.close(); + } + catch (Throwable t) { + try { + wr.close(); + } + catch (Throwable exception) { + t.addSuppressed(exception); + } + throw t; + } + } + final int responseCode = con.getResponseCode(); + if (responseCode != 200) { + this.throwStatusCodeException(responseCode, con.getResponseMessage()); + } + try { + final BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + try { + final StringBuffer response = new StringBuffer(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + StringResponse = response.toString(); + in.close(); + } + catch (Throwable t2) { + try { + in.close(); + } + catch (Throwable exception2) { + t2.addSuppressed(exception2); + } + throw t2; + } + } + catch (IOException e) { + throw new UnexpectedException(StringResponse); + } + } + catch (IOException e2) { + throw new UnexpectedException(StringResponse); + } + return StringResponse; + } + + private String sendRequest(final String method, final String endPoint) throws Exception { + return this.sendRequest(method, endPoint, ""); + } + + public String get(final String endPoint) throws Exception { + return this.sendRequest("GET", endPoint); + } + + public String post(final String endPoint, final String body) throws Exception { + return this.sendRequest("POST", endPoint, body); + } + + public String post(final String endPoint) throws Exception { + return this.sendRequest("POST", endPoint); + } + + public String patch(final String endPoint, final String body) throws Exception { + String StringResponse = ""; + try { + final HttpClient httpclient = (HttpClient)HttpClients.createDefault(); + final HttpPatch httpPatch = new HttpPatch(this.config.getApiBase() + endPoint); + final StringEntity params = new StringEntity(body); + final int timeStamp = (int)(System.currentTimeMillis() / 1000L); + final String authorizarion = this.generateAuthorization(timeStamp, "PATCH", endPoint, body); + params.setContentType("application/json"); + httpPatch.setEntity((HttpEntity)params); + httpPatch.addHeader("X-PR-Timestamp", timeStamp + ""); + httpPatch.addHeader("Authorization", authorizarion); + final HttpResponse response = httpclient.execute((HttpUriRequest)httpPatch); + final StringBuffer result = new StringBuffer(); + String line = ""; + final BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); + while ((line = rd.readLine()) != null) { + result.append(line); + } + StringResponse = result.toString(); + final int responseCode = response.getStatusLine().getStatusCode(); + if (responseCode != 200) { + this.throwStatusCodeException(responseCode, StringResponse); + } + } + catch (IOException e) { + throw new UnexpectedException(StringResponse); + } + return StringResponse; + } + + public String delete(final String endPoint) throws Exception { + return this.sendRequest("DELETE", endPoint); + } + + private void throwStatusCodeException(final int statusCode, final String message) throws Exception { + switch (statusCode) { + case 400: { + throw new MalformedException(message); + } + case 401: { + throw new AuthenticationException(message); + } + case 403: { + throw new AuthorizationException(message); + } + case 404: { + throw new NotFoundException(statusCode + " " + message); + } + case 406: { + throw new InvalidStatusCodeException(message); + } + case 429: { + throw new TooManyRequestsException(message); + } + case 500: { + throw new InvalidServerConnectionException(message); + } + case 503: { + throw new DownForMaintenanceException(message); + } + default: { + throw new com.trolley.Exceptions.UnexpectedException(message); + } + } + } + + private String generateAuthorization(final int timeStamp, final String method, final String endPoint, final String body) { + final String message = timeStamp + "\n" + method + "\n" + endPoint + "\n" + body + "\n"; + try { + final String hash = this.hmacDigest(message, this.config.getPrivateKey(), "HmacSHA256"); + return "prsign " + this.config.getPublicKey() + ":" + hash; + } + catch (Exception e) { + return "prsign 1:1"; + } + } + + private String hmacDigest(final String msg, final String keyString, final String algo) throws Exception { + String digest = null; + final SecretKeySpec key = new SecretKeySpec(keyString.getBytes("UTF-8"), algo); + final Mac mac = Mac.getInstance(algo); + mac.init(key); + final byte[] bytes = mac.doFinal(msg.getBytes("ASCII")); + final StringBuffer hash = new StringBuffer(); + for (int i = 0; i < bytes.length; ++i) { + final String hex = Integer.toHexString(0xFF & bytes[i]); + if (hex.length() == 1) { + hash.append('0'); + } + hash.append(hex); + } + digest = hash.toString(); + return digest; + } +} diff --git a/src/main/java/com/trolley/trolley/Compliance.java b/src/main/java/com/trolley/trolley/Compliance.java new file mode 100644 index 0000000..58a3293 --- /dev/null +++ b/src/main/java/com/trolley/trolley/Compliance.java @@ -0,0 +1,39 @@ +package com.trolley.trolley; + +import java.util.HashMap; +import java.util.Map; + +public class Compliance +{ + private String status; + private Object checkedAt; + private Map additionalProperties; + + public Compliance() { + this.additionalProperties = new HashMap(); + } + + public String getStatus() { + return this.status; + } + + public void setStatus(final String status) { + this.status = status; + } + + public Object getCheckedAt() { + return this.checkedAt; + } + + public void setCheckedAt(final Object checkedAt) { + this.checkedAt = checkedAt; + } + + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + public void setAdditionalProperty(final String name, final Object value) { + this.additionalProperties.put(name, value); + } +} diff --git a/src/main/java/com/trolley/trolley/Configuration.java b/src/main/java/com/trolley/trolley/Configuration.java new file mode 100644 index 0000000..2306a64 --- /dev/null +++ b/src/main/java/com/trolley/trolley/Configuration.java @@ -0,0 +1,91 @@ +package com.trolley.trolley; + +public class Configuration +{ + String apiBase; + String privateKey; + String publicKey; + + public Configuration() { + this.apiBase = "https://api.paymentrails.com"; + this.privateKey = ""; + this.publicKey = ""; + } + + public Configuration(final String publicKey, final String privateKey) { + this.apiBase = "https://api.paymentrails.com"; + this.privateKey = ""; + this.publicKey = ""; + this.publicKey = publicKey; + this.privateKey = privateKey; + } + + public Configuration(final String publicKey, final String privateKey, final String apiBase) { + this.apiBase = "https://api.paymentrails.com"; + this.privateKey = ""; + this.publicKey = ""; + this.publicKey = publicKey; + this.privateKey = privateKey; + this.apiBase = this.setEnviroment(apiBase); + } + + public String getApiBase() { + return this.apiBase; + } + + public void setApiBase(final String apiBase) { + this.apiBase = apiBase; + } + + public String getPublicKey() { + return this.publicKey; + } + + public void setPublicKey(final String publicKey) { + this.publicKey = publicKey; + } + + public String getPrivateKey() { + return this.privateKey; + } + + public void setPrivateKey(final String privatKey) { + this.privateKey = privatKey; + } + + public static Gateway gateway() { + return new Gateway(instantiate()); + } + + public static Client client(final Configuration config) { + return new Client(config); + } + + public static Configuration instantiate() { + return new Configuration(); + } + + public String setEnviroment(final String enviroment) { + switch (enviroment) { + case "production": + case "PRODUCTION": { + return "https://api.paymentrails.com"; + } + case "development": + case "DEVELOPMENT": { + return "http://api.railz.io"; + } + case "integration": + case "INTEGRATION": { + return "http://api.local.dev:3000"; + } + case "sandbox": + case "SANDBOX": { + return "https://api.paymentrails.com"; + } + default: { + return "https://api.paymentrails.com"; + } + } + } +} diff --git a/src/main/java/ca/paymentrails/paymentrails/Detail.java b/src/main/java/com/trolley/trolley/Detail.java similarity index 67% rename from src/main/java/ca/paymentrails/paymentrails/Detail.java rename to src/main/java/com/trolley/trolley/Detail.java index 807adcb..0fb6d71 100644 --- a/src/main/java/ca/paymentrails/paymentrails/Detail.java +++ b/src/main/java/com/trolley/trolley/Detail.java @@ -1,10 +1,9 @@ -package ca.paymentrails.paymentrails; +package com.trolley.trolley; import com.fasterxml.jackson.annotation.JsonProperty; -public class Detail { - +public class Detail +{ @JsonProperty("bank-transfer") public BankTransfer bankTransfer; - -} \ No newline at end of file +} diff --git a/src/main/java/com/trolley/trolley/EUR.java b/src/main/java/com/trolley/trolley/EUR.java new file mode 100644 index 0000000..3528ab9 --- /dev/null +++ b/src/main/java/com/trolley/trolley/EUR.java @@ -0,0 +1,64 @@ +package com.trolley.trolley; + +public class EUR +{ + private Boolean primary; + private String amount; + private String currency; + private String type; + private String accountNumber; + private Boolean display; + + public Boolean getPrimary() { + return this.primary; + } + + public void setPrimary(final Boolean primary) { + this.primary = primary; + } + + public String getAmount() { + return this.amount; + } + + public void setAmount(final String amount) { + this.amount = amount; + } + + public String getCurrency() { + return this.currency; + } + + public void setCurrency(final String currency) { + this.currency = currency; + } + + public String getType() { + return this.type; + } + + public void setType(final String type) { + this.type = type; + } + + public String getAccountNumber() { + return this.accountNumber; + } + + public void setAccountNumber(final String accountNumber) { + this.accountNumber = accountNumber; + } + + public Boolean getDisplay() { + return this.display; + } + + public void setDisplay(final Boolean display) { + this.display = display; + } + + @Override + public String toString() { + return "ClassPojo [amount = " + this.amount + ", accountNumber = " + this.accountNumber + ", primary = " + this.primary + ", display = " + this.display + ", type = " + this.type + ", currency = " + this.currency + "]"; + } +} diff --git a/src/main/java/ca/paymentrails/paymentrails/Gateway.java b/src/main/java/com/trolley/trolley/Gateway.java similarity index 84% rename from src/main/java/ca/paymentrails/paymentrails/Gateway.java rename to src/main/java/com/trolley/trolley/Gateway.java index b91d77f..c06a0f6 100644 --- a/src/main/java/ca/paymentrails/paymentrails/Gateway.java +++ b/src/main/java/com/trolley/trolley/Gateway.java @@ -1,7 +1,7 @@ -package ca.paymentrails.paymentrails; - -public class Gateway { +package com.trolley.trolley; +public class Gateway +{ public Configuration config; public RecipientGateway recipient; public Client client; @@ -9,8 +9,8 @@ public class Gateway { public RecipientAccountGateway recipientAccount; public BalancesGateway balances; public PaymentGateway payment; - - public Gateway(Configuration config) { + + public Gateway(final Configuration config) { this.config = config; this.client = new Client(config); this.recipient = new RecipientGateway(config); @@ -18,6 +18,5 @@ public Gateway(Configuration config) { this.recipientAccount = new RecipientAccountGateway(config); this.balances = new BalancesGateway(config); this.payment = new PaymentGateway(config); - } -} \ No newline at end of file +} diff --git a/src/main/java/com/trolley/trolley/Meta.java b/src/main/java/com/trolley/trolley/Meta.java new file mode 100644 index 0000000..db7950c --- /dev/null +++ b/src/main/java/com/trolley/trolley/Meta.java @@ -0,0 +1,32 @@ +package com.trolley.trolley; + +public class Meta +{ + private Integer page; + private Integer pages; + private Integer records; + + public Integer getPage() { + return this.page; + } + + public void setPage(final Integer page) { + this.page = page; + } + + public Integer getPages() { + return this.pages; + } + + public void setPages(final Integer pages) { + this.pages = pages; + } + + public Integer getRecords() { + return this.records; + } + + public void setRecords(final Integer records) { + this.records = records; + } +} diff --git a/src/main/java/com/trolley/trolley/Payment.java b/src/main/java/com/trolley/trolley/Payment.java new file mode 100644 index 0000000..14123a8 --- /dev/null +++ b/src/main/java/com/trolley/trolley/Payment.java @@ -0,0 +1,321 @@ +package com.trolley.trolley; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Payment +{ + private String id; + private Recipient recipient; + private String status; + private Boolean isSupplyPayment; + private String returnedAmount; + private String amount; + private String currency; + private String category; + private RecipientAccount account; + private List tags; + private String sourceAmount; + private String sourceCurrency; + private String targetAmount; + private String targetCurrency; + private String exchangeRate; + private String fees; + private String recipientFees; + private String fxRate; + private String memo; + private String externalId; + private Object processedAt; + private String createdAt; + private String updatedAt; + private String merchantFees; + private Compliance compliance; + private String payoutMethod; + private String methodDisplay; + Object batch; + String withholdingAmount; + String withholdingCurrency; + String equivalentWithholdingAmount; + String equivalentWithholdingCurrency; + + public void setEquivalentWithholdingCurrency(final String equivalentWithholdingCurrency) { + this.equivalentWithholdingCurrency = equivalentWithholdingCurrency; + } + + public String getEquivalentWithholdingCurrency() { + return this.equivalentWithholdingCurrency; + } + + public void setEquivalentWithholdingAmount(final String equivalentWithholdingAmount) { + this.equivalentWithholdingAmount = equivalentWithholdingAmount; + } + + public String getEquivalentWithholdingAmount() { + return this.equivalentWithholdingAmount; + } + + public void setWithholdingCurrency(final String withholdingCurrency) { + this.withholdingCurrency = withholdingCurrency; + } + + public List getTags() { + return this.tags; + } + + public void setTags(final List tags) { + this.tags = tags; + } + + public RecipientAccount getAccount() { + return this.account; + } + + public void setAccount(final RecipientAccount account) { + this.account = account; + } + + public String getCategory() { + return this.category; + } + + public void setCategory(final String category) { + this.category = category; + } + + public String getCurrency() { + return this.currency; + } + + public void setCurrency(final String currency) { + this.currency = currency; + } + + public String getAmount() { + return this.amount; + } + + public void setAmount(final String amount) { + this.amount = amount; + } + + public String getWithholdingCurrency() { + return this.withholdingCurrency; + } + + public void setWithholdingAmount(final String withholdingAmount) { + this.withholdingAmount = withholdingAmount; + } + + public String getWithholdingAmount() { + return this.withholdingAmount; + } + + public String getId() { + return this.id; + } + + public void setId(final String id) { + this.id = id; + } + + public Recipient getRecipient() { + return this.recipient; + } + + public void setRecipient(final Recipient recipient) { + this.recipient = recipient; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(final String status) { + this.status = status; + } + + public Boolean getIsSupplyPayment() { + return this.isSupplyPayment; + } + + public void setIsSupplyPayment(final Boolean isSupplyPayment) { + this.isSupplyPayment = isSupplyPayment; + } + + public String getReturnedAmount() { + return this.returnedAmount; + } + + public void setReturnedAmount(final String returnedAmount) { + this.returnedAmount = returnedAmount; + } + + public String getSourceAmount() { + return this.sourceAmount; + } + + public void setSourceAmount(final String sourceAmount) { + this.sourceAmount = sourceAmount; + } + + public String getSourceCurrency() { + return this.sourceCurrency; + } + + public void setSourceCurrency(final String sourceCurrency) { + this.sourceCurrency = sourceCurrency; + } + + public String getTargetAmount() { + return this.targetAmount; + } + + public void setTargetAmount(final String targetAmount) { + this.targetAmount = targetAmount; + } + + public String getTargetCurrency() { + return this.targetCurrency; + } + + public void setTargetCurrency(final String targetCurrency) { + this.targetCurrency = targetCurrency; + } + + public String getExchangeRate() { + return this.exchangeRate; + } + + public void setExchangeRate(final String exchangeRate) { + this.exchangeRate = exchangeRate; + } + + public String getFees() { + return this.fees; + } + + public void setFees(final String fees) { + this.fees = fees; + } + + public String getRecipientFees() { + return this.recipientFees; + } + + public void setRecipientFees(final String recipientFees) { + this.recipientFees = recipientFees; + } + + public String getFxRate() { + return this.fxRate; + } + + public void setFxRate(final String fxRate) { + this.fxRate = fxRate; + } + + public String getMemo() { + return this.memo; + } + + public void setMemo(final String memo) { + this.memo = memo; + } + + public String getExternalId() { + return this.externalId; + } + + public void setExternalId(final String externalId) { + this.externalId = externalId; + } + + public Object getProcessedAt() { + return this.processedAt; + } + + public void setProcessedAt(final Object processedAt) { + this.processedAt = processedAt; + } + + public String getCreatedAt() { + return this.createdAt; + } + + public void setCreatedAt(final String createdAt) { + this.createdAt = createdAt; + } + + public String getUpdatedAt() { + return this.updatedAt; + } + + public void setUpdatedAt(final String updatedAt) { + this.updatedAt = updatedAt; + } + + public String getMerchantFees() { + return this.merchantFees; + } + + public void setMerchantFees(final String merchantFees) { + this.merchantFees = merchantFees; + } + + public Compliance getCompliance() { + return this.compliance; + } + + public void setCompliance(final Compliance compliance) { + this.compliance = compliance; + } + + public String getPayoutMethod() { + return this.payoutMethod; + } + + public void setPayoutMethod(final String payoutMethod) { + this.payoutMethod = payoutMethod; + } + + public String getMethodDisplay() { + return this.methodDisplay; + } + + public void setMethodDisplay(final String methodDisplay) { + this.methodDisplay = methodDisplay; + } + + public static Payment find(final String payment_id, final String batch_id) throws Exception { + return Configuration.gateway().payment.find(payment_id, batch_id); + } + + public static Payment create(final String body, final String batch_id) throws Exception { + return Configuration.gateway().payment.create(body, batch_id); + } + + public static boolean update(final String payment_id, final String body, final String batch_id) throws Exception { + return Configuration.gateway().payment.update(payment_id, body, batch_id); + } + + public static boolean delete(final String payment_id, final String batch_id) throws Exception { + return Configuration.gateway().payment.delete(payment_id, batch_id); + } + + public static List query(final String batch_id, final int page, final int pageSize, final String message) throws Exception { + return Configuration.gateway().payment.query(batch_id, page, pageSize, message); + } + + public static List query(final String batch_id, final String message) throws Exception { + return query(batch_id, 1, 10, message); + } + + public static List query(final String batch_id) throws Exception { + return query(batch_id, 1, 10, ""); + } + + public static List query(final String batch_id, final int page, final int pageSize) throws Exception { + return query(batch_id, page, pageSize, ""); + } +} diff --git a/src/main/java/ca/paymentrails/paymentrails/PaymentGateway.java b/src/main/java/com/trolley/trolley/PaymentGateway.java similarity index 51% rename from src/main/java/ca/paymentrails/paymentrails/PaymentGateway.java rename to src/main/java/com/trolley/trolley/PaymentGateway.java index d8df8a7..6f07423 100644 --- a/src/main/java/ca/paymentrails/paymentrails/PaymentGateway.java +++ b/src/main/java/com/trolley/trolley/PaymentGateway.java @@ -1,48 +1,46 @@ -package ca.paymentrails.paymentrails; +package com.trolley.trolley; -import ca.paymentrails.Exceptions.InvalidFieldException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; import java.util.ArrayList; +import java.io.IOException; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; +import com.trolley.Exceptions.InvalidFieldException; -public class PaymentGateway { +public class PaymentGateway +{ Client client; - - public PaymentGateway(Configuration config) { + + public PaymentGateway(final Configuration config) { this.client = new Client(config); } - - public Payment find(String payment_id, String batch_id) throws Exception { + + public Payment find(final String payment_id, final String batch_id) throws Exception { if (batch_id == null || batch_id.isEmpty()) { throw new InvalidFieldException("Batch id cannot be null or empty."); } if (payment_id == null || payment_id.isEmpty()) { throw new InvalidFieldException("Payment id cannot be null or empty."); } - - String endPoint = "/v1/batches/" + batch_id + "/payments/" + payment_id; - String response = this.client.get(endPoint); - return paymentFactory(response); + final String endPoint = "/v1/batches/" + batch_id + "/payments/" + payment_id; + final String response = this.client.get(endPoint); + return this.paymentFactory(response); } - - public Payment create(String body, String batch_id) throws Exception { + + public Payment create(final String body, final String batch_id) throws Exception { if (batch_id == null || batch_id.isEmpty()) { throw new InvalidFieldException("Batch id cannot be null or empty."); } if (body == null || body.isEmpty()) { throw new InvalidFieldException("Body cannot be null or empty."); } - - String endPoint = "/v1/batches/" + batch_id + "/payments"; - String response = this.client.post(endPoint, body); - - return paymentFactory(response); + final String endPoint = "/v1/batches/" + batch_id + "/payments"; + final String response = this.client.post(endPoint, body); + return this.paymentFactory(response); } - - public boolean update(String payment_id, String body, String batch_id) throws Exception { + + public boolean update(final String payment_id, final String body, final String batch_id) throws Exception { if (batch_id == null || batch_id.isEmpty()) { throw new InvalidFieldException("Batch id cannot be null or empty."); } @@ -52,27 +50,24 @@ public boolean update(String payment_id, String body, String batch_id) throws Ex if (body == null || body.isEmpty()) { throw new InvalidFieldException("Body cannot be null or empty."); } - - String endPoint = "/v1/batches/" + batch_id + "/payments/" + payment_id; + final String endPoint = "/v1/batches/" + batch_id + "/payments/" + payment_id; this.client.patch(endPoint, body); return true; } - - public boolean delete(String payment_id, String batch_id) throws Exception { + + public boolean delete(final String payment_id, final String batch_id) throws Exception { if (batch_id == null || batch_id.isEmpty()) { throw new InvalidFieldException("Batch id cannot be null or empty."); } if (payment_id == null || payment_id.isEmpty()) { throw new InvalidFieldException("Payment id cannot be null or empty."); } - - String endPoint = "/v1/batches/" + batch_id + "/payments/" + payment_id; + final String endPoint = "/v1/batches/" + batch_id + "/payments/" + payment_id; this.client.delete(endPoint); return true; } - - public List query(String batch_id, int page, int pageSize, String message) throws Exception { - + + public List query(final String batch_id, final int page, final int pageSize, final String message) throws Exception { if (batch_id == null || batch_id.isEmpty()) { throw new InvalidFieldException("Batch id cannot be null or empty."); } @@ -85,34 +80,30 @@ public List query(String batch_id, int page, int pageSize, String messa if (message == null) { throw new InvalidFieldException("Message cannot be null"); } - - String endPoint = "/v1/batches/" + batch_id + "/payments/?" + "&search=" + message + "&page=" + page - + "&pageSize=" + pageSize; - String response = this.client.get(endPoint); - return paymentListFactory(response); + final String endPoint = "/v1/batches/" + batch_id + "/payments/?&search=" + message + "&page=" + page + "&pageSize=" + pageSize; + final String response = this.client.get(endPoint); + return this.paymentListFactory(response); } - - private Payment paymentFactory(String data) throws IOException { - ObjectMapper mapper = new ObjectMapper(); + + private Payment paymentFactory(final String data) throws IOException { + final ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode node = mapper.readTree(data); - Payment payment = mapper.readValue(node.get("payment").traverse(), Payment.class); + final JsonNode node = mapper.readTree(data); + final Payment payment = (Payment)mapper.readValue(node.get("payment").traverse(), (Class)Payment.class); return payment; } - - private List paymentListFactory(String data) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - JsonNode node = mapper.readTree(data); + + private List paymentListFactory(final String data) throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode node = mapper.readTree(data); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - Object payment = mapper.readValue(node.get("payments").traverse(), Object.class); - @SuppressWarnings("unchecked") - List paymens = (List) payment; - List payments = new ArrayList(); - for (int i = 0; i < paymens.size(); i++) { - Payment pojo = mapper.convertValue(paymens.get(i), Payment.class); + final Object payment = mapper.readValue(node.get("payments").traverse(), (Class)Object.class); + final List paymens = (List)payment; + final List payments = new ArrayList(); + for (int i = 0; i < paymens.size(); ++i) { + final Payment pojo = (Payment)mapper.convertValue((Object)paymens.get(i), (Class)Payment.class); payments.add(pojo); } - return payments; } -} \ No newline at end of file +} diff --git a/src/main/java/com/trolley/trolley/Payments.java b/src/main/java/com/trolley/trolley/Payments.java new file mode 100644 index 0000000..fb2608b --- /dev/null +++ b/src/main/java/com/trolley/trolley/Payments.java @@ -0,0 +1,29 @@ +package com.trolley.trolley; + +import java.util.List; + +public class Payments +{ + private List payments; + private Meta meta; + + public Payments() { + this.payments = null; + } + + public List getPayments() { + return this.payments; + } + + public void setPayments(final List payments) { + this.payments = payments; + } + + public Meta getMeta() { + return this.meta; + } + + public void setMeta(final Meta meta) { + this.meta = meta; + } +} diff --git a/src/main/java/com/trolley/trolley/Recipient.java b/src/main/java/com/trolley/trolley/Recipient.java new file mode 100644 index 0000000..34ac122 --- /dev/null +++ b/src/main/java/com/trolley/trolley/Recipient.java @@ -0,0 +1,344 @@ +package com.trolley.trolley; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Recipient +{ + String id; + String routeType; + String estimatedFees; + String referenceId; + String email; + String name; + String lastName; + String firstName; + String type; + String taxType; + String status; + String language; + String complianceStatus; + String dob; + String passport; + String updatedAt; + String createdAt; + String gravatarUrl; + String governmentId; + String ssn; + String primaryCurrency; + String placeOfBirth; + List tags; + String merchantId; + String payoutMethod; + public Object payout; + String emailAddress; + public Object inactiveReasons; + Compliance compliance; + List accounts; + Address address; + String taxForm; + String taxFormStatus; + String taxWithholdingPercentage; + + public Recipient() { + this.taxWithholdingPercentage = "0.0"; + } + + public String getTaxFormStatus() { + return this.taxFormStatus; + } + + public void setTaxFormStatus(final String taxFormStatus) { + this.taxFormStatus = this.taxForm; + } + + public List getTags() { + return this.tags; + } + + public void setTags(final List tags) { + this.tags = tags; + } + + public String getTaxWithholdingPercentage() { + return this.taxWithholdingPercentage; + } + + public void setTaxWithholdingPercentage(final String taxWithholdingPercentage) { + this.taxWithholdingPercentage = taxWithholdingPercentage; + } + + public String getTaxForm() { + return this.taxForm; + } + + public void setTaxForm(final String taxForm) { + this.taxForm = taxForm; + } + + public Object getInactiveReasons() { + return this.inactiveReasons; + } + + public void setInactiveReasons(final Object inactiveReasons) { + this.inactiveReasons = inactiveReasons; + } + + public List getAccounts() { + return this.accounts; + } + + public void setAccounts(final List accounts) { + this.accounts = accounts; + } + + public void setAddress(final Address address) { + this.address = address; + } + + public Address getAddress() { + return this.address; + } + + public Compliance getCompliance() { + return this.compliance; + } + + public void setCompliance(final Compliance compliance) { + this.compliance = compliance; + } + + public String getLastName() { + return this.lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } + + public String getRouteType() { + return this.routeType; + } + + public void setRouteType(final String routeType) { + this.routeType = routeType; + } + + public String getEstimatedFees() { + return this.estimatedFees; + } + + public void setEstimatedFees(final String estimatedFees) { + this.estimatedFees = estimatedFees; + } + + public String getId() { + return this.id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getReferenceId() { + return this.referenceId; + } + + public void setReferenceId(final String referenceId) { + this.referenceId = referenceId; + } + + public String getEmail() { + return this.email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getName() { + return this.name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getFirstName() { + return this.firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getType() { + return this.type; + } + + public void setType(final String type) { + this.type = type; + } + + public String getTaxType() { + return this.taxType; + } + + public void setTaxType(final String taxType) { + this.taxType = taxType; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(final String status) { + this.status = status; + } + + public String getLanguage() { + return this.language; + } + + public void setLanguage(final String language) { + this.language = language; + } + + public String getComplianceStatus() { + return this.complianceStatus; + } + + public void setComplianceStatus(final String complianceStatus) { + this.complianceStatus = complianceStatus; + } + + public String getDob() { + return this.dob; + } + + public void setDob(final String dob) { + this.dob = dob; + } + + public String getPassport() { + return this.passport; + } + + public void setPassport(final String passport) { + this.passport = passport; + } + + public String getUpdatedAt() { + return this.updatedAt; + } + + public void setUpdatedAt(final String updatedAt) { + this.updatedAt = updatedAt; + } + + public String getCreatedAt() { + return this.createdAt; + } + + public void setCreatedAt(final String createdAt) { + this.createdAt = createdAt; + } + + public String getGravatarUrl() { + return this.gravatarUrl; + } + + public void setGravatarUrl(final String gravatarUrl) { + this.gravatarUrl = gravatarUrl; + } + + public String getGovernmentId() { + return this.governmentId; + } + + public void setGovernmentId(final String governmentId) { + this.governmentId = governmentId; + } + + public String getSsn() { + return this.ssn; + } + + public void setSsn(final String ssn) { + this.ssn = ssn; + } + + public String getPrimaryCurrency() { + return this.primaryCurrency; + } + + public void setPrimaryCurrency(final String primaryCurrency) { + this.primaryCurrency = primaryCurrency; + } + + public String getPlaceOfBirth() { + return this.placeOfBirth; + } + + public void setPlaceOfBirth(final String placeOfBirth) { + this.placeOfBirth = placeOfBirth; + } + + public String getMerchantId() { + return this.merchantId; + } + + public void setMerchantId(final String merchantId) { + this.merchantId = merchantId; + } + + public String getPayoutMethod() { + return this.payoutMethod; + } + + public void setPayoutMethod(final String payoutMethod) { + this.payoutMethod = payoutMethod; + } + + public static Recipient find(final String recipient_id) throws Exception { + return Configuration.gateway().recipient.find(recipient_id); + } + + public static String findLogs(final String recipient_id) throws Exception { + final String response = Configuration.gateway().recipient.findLogs(recipient_id); + return response; + } + + public static List findPayments(final String recipient_id) throws Exception { + return Configuration.gateway().recipient.findPayments(recipient_id); + } + + public static Recipient create(final String body) throws Exception { + return Configuration.gateway().recipient.create(body); + } + + public static boolean update(final String recipient_id, final String body) throws Exception { + return Configuration.gateway().recipient.update(recipient_id, body); + } + + public static boolean delete(final String recipient_id) throws Exception { + return Configuration.gateway().recipient.delete(recipient_id); + } + + public static List search(final int page, final int pageSize, final String term) throws Exception { + return Configuration.gateway().recipient.search(page, pageSize, term); + } + + public static List search(final String message) throws Exception { + return search(1, 10, message); + } + + public static List search() throws Exception { + return search(1, 10, ""); + } + + public static List search(final int page, final int pageNumber) throws Exception { + return search(page, pageNumber, ""); + } +} diff --git a/src/main/java/com/trolley/trolley/RecipientAccount.java b/src/main/java/com/trolley/trolley/RecipientAccount.java new file mode 100644 index 0000000..e7d0648 --- /dev/null +++ b/src/main/java/com/trolley/trolley/RecipientAccount.java @@ -0,0 +1,237 @@ + +package com.trolley.trolley; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class RecipientAccount +{ + String type; + Boolean primary; + String currency; + String id; + String recipientId; + String recipientAccountId; + String routeType; + String recipientFees; + String country; + String iban; + String accountNum; + String accountHolderName; + String swiftBic; + String branchId; + String bankId; + String bankName; + String bankAddress; + String bankCity; + String bankRegionCode; + String bankPostalCode; + String emailAddress; + String status; + String disabledAt; + + public String getEmailAddress() { + return this.emailAddress; + } + + public void setEmailAddress(final String emailAddress) { + this.emailAddress = emailAddress; + } + + public String getDisabledAt() { + return this.disabledAt; + } + + public void setDisabledAt(final String disabledAt) { + this.disabledAt = disabledAt; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(final String status) { + this.status = status; + } + + public String getRecipientId() { + return this.recipientId; + } + + public void setRecipientId(final String recipientId) { + this.recipientId = recipientId; + } + + public String getType() { + return this.type; + } + + public void setType(final String type) { + this.type = type; + } + + public Boolean getPrimary() { + return this.primary; + } + + public void setPrimary(final Boolean primary) { + this.primary = primary; + } + + public String getCurrency() { + return this.currency; + } + + public void setCurrency(final String currency) { + this.currency = currency; + } + + public String getId() { + return this.id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getRecipientAccountId() { + return this.recipientAccountId; + } + + public void setRecipientAccountId(final String recipientAccountId) { + this.recipientAccountId = recipientAccountId; + } + + public String getRouteType() { + return this.routeType; + } + + public void setRouteType(final String routeType) { + this.routeType = routeType; + } + + public String getRecipientFees() { + return this.recipientFees; + } + + public void setRecipientFees(final String recipientFees) { + this.recipientFees = recipientFees; + } + + public String getCountry() { + return this.country; + } + + public void setCountry(final String country) { + this.country = country; + } + + public String getIban() { + return this.iban; + } + + public void setIban(final String iban) { + this.iban = iban; + } + + public String getAccountNum() { + return this.accountNum; + } + + public void setAccountNum(final String accountNum) { + this.accountNum = accountNum; + } + + public String getAccountHolderName() { + return this.accountHolderName; + } + + public void setAccountHolderName(final String accountHolderName) { + this.accountHolderName = accountHolderName; + } + + public String getSwiftBic() { + return this.swiftBic; + } + + public void setSwiftBic(final String swiftBic) { + this.swiftBic = swiftBic; + } + + public String getBranchId() { + return this.branchId; + } + + public void setBranchId(final String branchId) { + this.branchId = branchId; + } + + public String getBankId() { + return this.bankId; + } + + public void setBankId(final String bankId) { + this.bankId = bankId; + } + + public String getBankName() { + return this.bankName; + } + + public void setBankName(final String bankName) { + this.bankName = bankName; + } + + public String getBankAddress() { + return this.bankAddress; + } + + public void setBankAddress(final String bankAddress) { + this.bankAddress = bankAddress; + } + + public String getBankCity() { + return this.bankCity; + } + + public void setBankCity(final String bankCity) { + this.bankCity = bankCity; + } + + public String getBankRegionCode() { + return this.bankRegionCode; + } + + public void setBankRegionCode(final String bankRegionCode) { + this.bankRegionCode = bankRegionCode; + } + + public String getBankPostalCode() { + return this.bankPostalCode; + } + + public void setBankPostalCode(final String bankPostalCode) { + this.bankPostalCode = bankPostalCode; + } + + public static List findAll(final String recipient_id) throws Exception { + return Configuration.gateway().recipientAccount.findAll(recipient_id); + } + + public static RecipientAccount find(final String recipient_id, final String recipient_account_id) throws Exception { + return Configuration.gateway().recipientAccount.find(recipient_id, recipient_account_id); + } + + public static RecipientAccount create(final String recipient_id, final String body) throws Exception { + return Configuration.gateway().recipientAccount.create(recipient_id, body); + } + + public static RecipientAccount update(final String recipient_id, final String recipient_account_id, final String body) throws Exception { + return Configuration.gateway().recipientAccount.update(recipient_id, recipient_account_id, body); + } + + public static boolean delete(final String recipient_id, final String recipient_account_id) throws Exception { + return Configuration.gateway().recipientAccount.delete(recipient_id, recipient_account_id); + } +} diff --git a/src/main/java/com/trolley/trolley/RecipientAccountGateway.java b/src/main/java/com/trolley/trolley/RecipientAccountGateway.java new file mode 100644 index 0000000..1498645 --- /dev/null +++ b/src/main/java/com/trolley/trolley/RecipientAccountGateway.java @@ -0,0 +1,118 @@ + +package com.trolley.trolley; + +import java.util.ArrayList; +import java.io.IOException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.trolley.Exceptions.InvalidFieldException; +import java.util.List; + +public class RecipientAccountGateway +{ + Client client; + + public RecipientAccountGateway(final Configuration config) { + this.client = new Client(config); + } + + public List findAll(final String recipient_id) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + final String endPoint = "/v1/recipients/" + recipient_id + "/accounts"; + final String response = this.client.get(endPoint); + return this.recipientAccountListFactory(response); + } + + public RecipientAccount find(final String recipient_id, final String recipient_account_id) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + final String endPoint = "/v1/recipients/" + recipient_id + "/accounts/" + recipient_account_id; + final String response = this.client.get(endPoint); + return this.recipientAccountFactory(response); + } + + public RecipientAccount create(final String recipient_id, final String body) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + if (body == null || body.isEmpty()) { + throw new InvalidFieldException("Body cannot be null or empty"); + } + final String endPoint = "/v1/recipients/" + recipient_id + "/accounts"; + final String response = this.client.post(endPoint, body); + return this.recipientAccountFactory(response); + } + + public RecipientAccount create(final String recipient_id, final RecipientAccount account) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + if (account == null) { + throw new InvalidFieldException("Body cannot be null or empty"); + } + final String jsonAccount = new ObjectMapper().writeValueAsString((Object)account); + final String endPoint = "/v1/recipients/" + recipient_id + "/accounts"; + final String response = this.client.post(endPoint, jsonAccount); + return this.recipientAccountFactory(response); + } + + public RecipientAccount update(final String recipient_id, final String recipient_account_id, final String body) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + if (body == null || body.isEmpty()) { + throw new InvalidFieldException("Body cannot be null or empty"); + } + final String endPoint = "/v1/recipients/" + recipient_id + "/accounts/" + recipient_account_id; + final String response = this.client.patch(endPoint, body); + return this.recipientAccountFactory(response); + } + + public RecipientAccount update(final String recipient_id, final String recipient_account_id, final RecipientAccount account) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + if (account == null) { + throw new InvalidFieldException("Body cannot be null or empty"); + } + final String jsonAccount = new ObjectMapper().writeValueAsString((Object)account); + final String endPoint = "/v1/recipients/" + recipient_id + "/accounts/" + recipient_account_id; + final String response = this.client.patch(endPoint, jsonAccount); + return this.recipientAccountFactory(response); + } + + public boolean delete(final String recipient_id, final String recipient_account_id) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + final String endPoint = "/v1/recipients/" + recipient_id + "/accounts/" + recipient_account_id; + this.client.delete(endPoint); + return true; + } + + private RecipientAccount recipientAccountFactory(final String data) throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode node = mapper.readTree(data); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final RecipientAccount recipientAccount = (RecipientAccount)mapper.readValue(node.get("account").traverse(), (Class)RecipientAccount.class); + return recipientAccount; + } + + private List recipientAccountListFactory(final String data) throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode node = mapper.readTree(data); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final Object recipientAccount = mapper.readValue(node.get("accounts").traverse(), (Class)Object.class); + final List recipAccounts = (List)recipientAccount; + final List recipientAccounts = new ArrayList(); + for (int i = 0; i < recipAccounts.size(); ++i) { + final RecipientAccount pojo = (RecipientAccount)mapper.convertValue((Object)recipAccounts.get(i), (Class)RecipientAccount.class); + recipientAccounts.add(pojo); + } + return recipientAccounts; + } +} diff --git a/src/main/java/com/trolley/trolley/RecipientGateway.java b/src/main/java/com/trolley/trolley/RecipientGateway.java new file mode 100644 index 0000000..9da04a0 --- /dev/null +++ b/src/main/java/com/trolley/trolley/RecipientGateway.java @@ -0,0 +1,140 @@ + +package com.trolley.trolley; + +import java.io.IOException; +import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.List; +import com.trolley.Exceptions.InvalidFieldException; + +public class RecipientGateway +{ + Client client; + + public RecipientGateway(final Configuration config) { + this.client = new Client(config); + } + + public Recipient find(final String recipient_id) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + final String endPoint = "/v1/recipients/" + recipient_id; + final String response = this.client.get(endPoint); + return this.recipientFactory(response); + } + + public String findLogs(final String recipient_id) throws Exception { + final String endPoint = "/v1/recipients/" + recipient_id + "/logs"; + final String response = this.client.get(endPoint); + return response; + } + + public List findPayments(final String recipient_id) throws Exception { + final String endPoint = "/v1/recipients/" + recipient_id + "/payments"; + final String response = this.client.get(endPoint); + final ObjectMapper mapper = new ObjectMapper(); + final JsonNode node = mapper.readTree(response); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final Object payment = mapper.readValue(node.get("payments").traverse(), (Class)Object.class); + final List paymens = (List)payment; + final List payments = new ArrayList(); + for (int i = 0; i < paymens.size(); ++i) { + final Payment pojo = (Payment)mapper.convertValue((Object)paymens.get(i), (Class)Payment.class); + payments.add(pojo); + } + return payments; + } + + public Recipient create(final String body) throws Exception { + if (body == null || body.isEmpty()) { + throw new InvalidFieldException("Body cannot be null or empty"); + } + final String endPoint = "/v1/recipients/"; + final String response = this.client.post(endPoint, body); + return this.recipientFactory(response); + } + + public Recipient create(final Recipient recipient) throws Exception { + if (recipient == null) { + throw new InvalidFieldException("Body cannot be null or empty"); + } + final String jsonRecipient = new ObjectMapper().writeValueAsString((Object)recipient); + final String endPoint = "/v1/recipients/"; + final String response = this.client.post(endPoint, jsonRecipient); + return this.recipientFactory(response); + } + + public boolean update(final String recipient_id, final String body) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + if (body == null || body.isEmpty()) { + throw new InvalidFieldException("Body cannot be null or empty"); + } + final String endPoint = "/v1/recipients/" + recipient_id; + this.client.patch(endPoint, body); + return true; + } + + public boolean update(final String recipient_id, final Recipient recipient) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + if (recipient == null) { + throw new InvalidFieldException("Body cannot be null or empty"); + } + final String jsonRecipient = new ObjectMapper().writeValueAsString((Object)recipient); + final String endPoint = "/v1/recipients/" + recipient_id; + this.client.patch(endPoint, jsonRecipient); + return true; + } + + public boolean delete(final String recipient_id) throws Exception { + if (recipient_id == null || recipient_id.isEmpty()) { + throw new InvalidFieldException("Recipient id cannot be null or empty."); + } + final String endPoint = "/v1/recipients/" + recipient_id; + this.client.delete(endPoint); + return true; + } + + public List search(final int page, final int pageSize, final String term) throws Exception { + if (page < 0) { + throw new InvalidFieldException("Page cannot be less than 0"); + } + if (pageSize < 0) { + throw new InvalidFieldException("Page size cannot be less than 0"); + } + if (term == null) { + throw new InvalidFieldException("Message cannot be null"); + } + final String endPoint = "/v1/recipients/?&search=" + term + "&page=" + page + "&pageSize=" + pageSize; + final String response = this.client.get(endPoint); + return this.recipientListFactory(response); + } + + private Recipient recipientFactory(final String data) throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final JsonNode node = mapper.readTree(data); + final Recipient recipient = (Recipient)mapper.readValue(node.get("recipient").traverse(), (Class)Recipient.class); + return recipient; + } + + private List recipientListFactory(final String data) throws IOException { + final ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + final JsonNode node = mapper.readTree(data); + final Object recipient = mapper.readValue(node.get("recipients").traverse(), (Class)Object.class); + final List recips = (List)recipient; + final List recipients = new ArrayList(); + for (int i = 0; i < recips.size(); ++i) { + final Recipient pojo = (Recipient)mapper.convertValue((Object)recips.get(i), (Class)Recipient.class); + recipients.add(pojo); + } + return recipients; + } +} diff --git a/src/main/java/ca/paymentrails/paymentrails/Total.java b/src/main/java/com/trolley/trolley/Total.java similarity index 71% rename from src/main/java/ca/paymentrails/paymentrails/Total.java rename to src/main/java/com/trolley/trolley/Total.java index ef7e67b..48aadc1 100644 --- a/src/main/java/ca/paymentrails/paymentrails/Total.java +++ b/src/main/java/com/trolley/trolley/Total.java @@ -1,10 +1,11 @@ -package ca.paymentrails.paymentrails; -public class Total { +package com.trolley.trolley; +public class Total +{ public Integer count; public String totalFees; public String merchantFees; public String debitAmount; public String sendingAmount; -} \ No newline at end of file +} diff --git a/src/main/java/ca/paymentrails/paymentrails/USD.java b/src/main/java/com/trolley/trolley/USD.java similarity index 51% rename from src/main/java/ca/paymentrails/paymentrails/USD.java rename to src/main/java/com/trolley/trolley/USD.java index 2976037..80cd1c3 100644 --- a/src/main/java/ca/paymentrails/paymentrails/USD.java +++ b/src/main/java/com/trolley/trolley/USD.java @@ -1,59 +1,60 @@ -package ca.paymentrails.paymentrails; -public class USD { +package com.trolley.trolley; +public class USD +{ private Boolean primary; private String amount; private String currency; private String type; private String accountNumber; private Boolean display; - + public Boolean getPrimary() { - return primary; + return this.primary; } - - public void setPrimary(Boolean primary) { + + public void setPrimary(final Boolean primary) { this.primary = primary; } - + public String getAmount() { - return amount; + return this.amount; } - - public void setAmount(String amount) { + + public void setAmount(final String amount) { this.amount = amount; } - + public String getCurrency() { - return currency; + return this.currency; } - - public void setCurrency(String currency) { + + public void setCurrency(final String currency) { this.currency = currency; } - + public String getType() { - return type; + return this.type; } - - public void setType(String type) { + + public void setType(final String type) { this.type = type; } - + public String getAccountNumber() { - return accountNumber; + return this.accountNumber; } - - public void setAccountNumber(String accountNumber) { + + public void setAccountNumber(final String accountNumber) { this.accountNumber = accountNumber; } - + public Boolean getDisplay() { - return display; + return this.display; } - - public void setDisplay(Boolean display) { + + public void setDisplay(final Boolean display) { this.display = display; } -} \ No newline at end of file +} diff --git a/src/test/java/ca/paymentrails/paymentrails/integration/BatchTest.java b/src/test/java/com/trolley/sdk/integration/BatchTest.java similarity index 63% rename from src/test/java/ca/paymentrails/paymentrails/integration/BatchTest.java rename to src/test/java/com/trolley/sdk/integration/BatchTest.java index 302fa83..a4d481a 100644 --- a/src/test/java/ca/paymentrails/paymentrails/integration/BatchTest.java +++ b/src/test/java/com/trolley/sdk/integration/BatchTest.java @@ -1,31 +1,34 @@ -package ca.paymentrails.paymentrails.integration; +package com.trolley.sdk.integration; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; +import com.trolley.trolley.Batch; +import com.trolley.trolley.BatchSummary; +import com.trolley.trolley.Configuration; +import com.trolley.trolley.Gateway; +import com.trolley.trolley.Payment; +import com.trolley.trolley.Payments; +import com.trolley.trolley.Recipient; + import org.junit.BeforeClass; import org.junit.Test; import org.powermock.core.classloader.annotations.PrepareForTest; -import ca.paymentrails.paymentrails.Batch; -import ca.paymentrails.paymentrails.BatchSummary; -import ca.paymentrails.paymentrails.Configuration; -import ca.paymentrails.paymentrails.Gateway; -import ca.paymentrails.paymentrails.Payment; -import ca.paymentrails.paymentrails.Recipient; - -@PrepareForTest(Recipient.class) +@PrepareForTest(Batch.class) public class BatchTest { private static Configuration config; @BeforeClass public static void setupConfig() { - final String ACCESS_KEY = "YourAccessKey"; - final String SECRET_KEY = "YourSecretKey"; + final String ACCESS_KEY = "ALC7AsydFDU2KKHZH4S7RZVL"; + final String SECRET_KEY = "OMJZ4C7BGTMKIF4YXSPBGGPLAVONJILGRXQTDXQR"; final String ENVIRONMENT = "production"; // RecipientTest recipientTest = new RecipientTest(); @@ -60,6 +63,22 @@ public void testCreate() throws Exception { assertEquals(batch.getCurrency(), "GBP"); } + @Test + public void testCreateObject() throws Exception { + Gateway client = new Gateway(config); + + Batch batchToCreate = new Batch(); + batchToCreate.setCurrency("GBP"); + batchToCreate.setDescription("Integration Test Create"); + + Batch createdBatch = client.batch.create(batchToCreate); + assertEquals(createdBatch.getCurrency(), "GBP"); + assertEquals(createdBatch.getDescription(), "Integration Test Create"); + + client.batch.delete(createdBatch.getId()); + + } + @Test public void testUpdate() throws Exception { Gateway client = new Gateway(config); @@ -79,7 +98,7 @@ public void testUpdate() throws Exception { assertNotNull(response); } - @Test + /* @Test public void testCreateWithPayments() throws Exception { Gateway client = new Gateway(config); @@ -88,14 +107,51 @@ public void testCreateWithPayments() throws Exception { String body = "{\"payments\": [{\"recipient\": {\"id\": " + "\"" + recipientAlpha.getId() + "\"" + "},\"amount\": \"10.00\", \"currency\": \"EUR\"}]}"; Batch batch = client.batch.create(body); + assertEquals(batch.getCurrency(), "GBP"); + + Batch updatedBatch = new Batch(); + updatedBatch.setDescription("Integration Update Object"); + boolean response = client.batch.update(batch.getId(), updatedBatch); + + assertNotNull(response); + Batch batch1 = client.batch.find(batch.getId()); + assertEquals(batch1.getDescription(), "Integration Update Object"); + + response = client.batch.delete(batch1.getId()); + assertNotNull(response); + } */ + + @Test + public void testCreateWithPayments() throws Exception { + Gateway client = new Gateway(config); + + Recipient recipientAlpha = createRecipient(); + Payment payment = new Payment(); + + payment.setAmount("15"); + payment.setCurrency("USD"); + payment.setRecipient(recipientAlpha); + + List paymentList = new ArrayList(); + paymentList.add(payment); + + Payments payments = new Payments(); + payments.setPayments(paymentList); + + Batch batchToCreate = new Batch(); + batchToCreate.setPayments(paymentList); + + Batch batch = client.batch.create(batchToCreate); assertNotNull(batch); assertNotNull(batch.getId()); - Batch batch1 = client.batch.find(batch.getId()); - assertNotNull(batch1); + List batchPayments = batch.getPayments(); + assertEquals(1, batchPayments.size()); + + assertEquals("15.00", batchPayments.get(0).getAmount()); + assertEquals("USD", batchPayments.get(0).getCurrency()); - assertEquals(1, batch1.getPayments().getPayments().size()); } @Test @@ -135,8 +191,13 @@ public void testProcessing() throws Exception { BatchSummary batchSummary = client.batch.summary(batch.getId()); assertNotNull(batchSummary); - String batch1 = client.batch.generateQuote(batch.getId()); - assertNotNull(batch1); + try{ + String batch1 = client.batch.generateQuote(batch.getId()); + assertNotNull(batch1); + }catch(Exception e){ + System.err.println(e); + } + String batch2 = client.batch.processBatch(batch.getId()); assertNotNull(batch2); diff --git a/src/test/java/ca/paymentrails/paymentrails/integration/RecipientTest.java b/src/test/java/com/trolley/sdk/integration/RecipientTest.java similarity index 79% rename from src/test/java/ca/paymentrails/paymentrails/integration/RecipientTest.java rename to src/test/java/com/trolley/sdk/integration/RecipientTest.java index f9d770e..4f73117 100644 --- a/src/test/java/ca/paymentrails/paymentrails/integration/RecipientTest.java +++ b/src/test/java/com/trolley/sdk/integration/RecipientTest.java @@ -1,34 +1,29 @@ - -package ca.paymentrails.paymentrails.integration; +package com.trolley.sdk.integration; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import org.powermock.core.classloader.annotations.PrepareForTest; -import ca.paymentrails.paymentrails.Configuration; -import ca.paymentrails.paymentrails.Recipient; -import ca.paymentrails.paymentrails.RecipientAccount; -import ca.paymentrails.paymentrails.Gateway; +import com.trolley.trolley.Configuration; +import com.trolley.trolley.Gateway; +import com.trolley.trolley.Recipient; +import com.trolley.trolley.RecipientAccount; -import java.util.ArrayList; import java.util.List; import java.util.UUID; @PrepareForTest(Recipient.class) public class RecipientTest { - // Testing order: alphabetical - private static Configuration config; @BeforeClass public static void setupConfig() { - final String ACCESS_KEY = "YourAccessKey"; - final String SECRET_KEY = "YourSecretKey"; + final String ACCESS_KEY = "ALC7AsydFDU2KKHZH4S7RZVL"; + final String SECRET_KEY = "OMJZ4C7BGTMKIF4YXSPBGGPLAVONJILGRXQTDXQR"; final String ENVIRONMENT = "production"; // RecipientTest recipientTest = new RecipientTest(); @@ -69,8 +64,8 @@ public void testLifecycle() throws Exception { boolean response = client.recipient.update(recipient.getId(), body); assertNotNull(response); - Recipient anotherRecipient = client.recipient.find(recipient.getId()); - assertEquals(anotherRecipient.getFirstName(), "Bob"); + Recipient anotheRecipient = client.recipient.find(recipient.getId()); + assertEquals(anotheRecipient.getFirstName(), "Bob"); response = client.recipient.delete(recipient.getId()); assertNotNull(response); @@ -80,7 +75,7 @@ public void testLifecycle() throws Exception { } @Test - public void testRecipientAccount() throws Exception { + public void testAccount() throws Exception { Gateway client = new Gateway(config); UUID uuid = UUID.randomUUID(); @@ -114,13 +109,4 @@ public void testRecipientAccount() throws Exception { assertEquals(1, recipientAccounts1.size()); } - @Test - public void testRecipientRouteMinimum() throws Exception { - Gateway client = new Gateway(config); - ArrayList recipients = (ArrayList)client.recipient.search(1,20,""); - //Making sure routeMinimum is not null before asserting it's value - assertNotNull(recipients.get(0).getRouteMinimum()); - //Making sure routeMinium is set to a non-null value - assertTrue(Integer.parseInt(recipients.get(0).getRouteMinimum()) >= 0); - } } \ No newline at end of file