diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4472daee..cc4435c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,9 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 + - name: Grant execute permission for gradlew run: chmod +x gradlew + - name: Build with Gradle run: ./gradlew test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..14ba2b1a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path + +name: Maven Package + +on: + release: + types: [created] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew test + + - name: Publish package + run: ./gradlew uploadArchives + env: + PGP_SIGNING_KEY: ${{ secrets.PGP_SIGNING_KEY }} + PGP_SIGNING_PASSWORD: ${{ secrets.PGP_SIGNING_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} \ No newline at end of file diff --git a/MIGRATING.md b/MIGRATING.md new file mode 100644 index 00000000..258e7b01 --- /dev/null +++ b/MIGRATING.md @@ -0,0 +1,37 @@ +# Migration Guide + +### Migrating from v3 to v4 + +Most of the changes are related to the consistency of field, method and class names. + +The benefit of having these consistencies allow the users of library to have predictable and consistent usage. + +It also allows us to update our library quickly by using code generation in future releases. + +The following contain all changes from v3 to v4. + +#### Schedules +* Rename `ChargeScheduling` and `TransferScheduling` to `ChargeSchedule` and `TransferSchedule` respectively. + +#### Cards +* Change order of params + - `Card.UpdateRequestBuilder(cardId, customerId)` contains wrong order of params (it should be `Card.UpdateRequestBuilder(customerId, cardId)`. + + - `Document.GetRequestBuilder(documentId, disputeId)` to `Document.GetRequestBuilder(disputeId, documentId)` + +#### Date & Time + - `Dispute.closedDate` -> `closedAt` (`closed_at` in API) + - `Receipt.issuedDate` -> `issuedOn` (`issued_on` in API) + - `Occurrence.scheduleDate` -> `scheduleOn` (`scheduled_on` in API) + - `Occurrence.retryDate` -> `retryOn` (`retry_on` in API) + - `Schedule.startDate` -> `startOn` (`start_on` in API) + - `Schedule.endDate` -> `endOn` (`end_on` in API) + - `Schedule.nextOccurrencesDates` -> `nextOccurrencesOn` (`next_occurrences_on` in API) + +### Migrating to v3 + +The alteration made in the v3.0.0 of `omise-java` are breaking changes and would require code changes +from your side if you have already been using this library from previous versions. We have put +together a guide to make this process easier by pointing the changes to you. You can find the complete [version 3 migration guide here][1]. + +[1]: https://www.omise.co/omise-java-v3-migration \ No newline at end of file diff --git a/README.md b/README.md index 6e6ae4e2..549ffe50 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Maven Central][9]][10] [![Github Actions][0]][1] [![Discourse Forum][14]][15] -`Omise-java` provides a set of Java bindings to the [Omise REST API][5]. Please contact +`omise-java` provides a set of Java bindings to the [Omise REST API][5]. Please contact [support@omise.co][7] if you have any questions regarding this library and the functionality it provides. @@ -21,7 +21,7 @@ Adds to your `build.gradle` file. ```gradle dependencies { - compile 'co.omise:omise-java:3.1.+' + compile 'co.omise:omise-java:4.0.+' } ``` @@ -46,14 +46,13 @@ $ gradle shadowJar BUILD SUCCESSFUL $ ls builds/libs -omise-java-3.1.1-all.jar +omise-java-4.0.0-all.jar ``` -### Migrate to version 3 +### Migration Guide -The alteration made in the v3.0.0 of `omise-java` are breaking changes and would require code changes -from your side if you have already been using this library from previous versions. We have put -together a guide to make this process easier by pointing the changes to you. You can find the complete [version 3 migration guide here][16]. +* [v4](MIGRATING.md#migrating-from-v3-to-v4) +* [v3](MIGRATING.md#migrating-to-v3) ## USAGE @@ -112,5 +111,4 @@ System.out.println("created charge: " + charge.getId()); [12]: https://dashboard.omise.co/test/api-keys [13]: https://github.com/johnrengelman/shadow [14]: https://img.shields.io/badge/discourse-forum-1a53f0.svg?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAAqlJREFUKBU9UVtLVFEU%2FvY%2B27mPtxl1dG7HbNRx0rwgFhJBPohBL9JTZfRQ0YO9RU%2FVL6iHCIKelaCXqIewl4gEBbEyxSGxzKkR8TbemmbmnDlzVvsYtOHbey1Y317fWh8DwCVMCfSHww3ElCs7CjuzbOcNIaEo9SbtlDRjZiNPY%2BvrqSWrTh7l3yPvrmh0KBZW59HcREjEqcGpElAuESRxopU648dTwfrIyH%2BCFXSH1cFgJLqHlma6443SG0CfqYY2NZjQnkV8eiMgP6ijjnizHglErlocdl5VA0mT3v102dseL2W14cYM99%2B9XGY%2FlQArd8Mo6JhbSJUePHytvf2UdnW0qen93cKQ4nWXX1%2FyOkZufsuZN0L7PPzkthDDZ4FQLajSA6XWR8HWIK861sCfj68ggGwl83mzfMclBmAQ%2BktrqBu9wOhcD%2BB0ErSiFFyEkdcYhKD27mal9%2F5FY36b4BB%2FTvO8XdQhlUe11F3WG2fc7QLlC8wai3MGGQCGDkcZQyymCqAPSmati3s45ygWseeqADwuWS%2F3wGS5hClDMMstxvJFHQuGU26yHsY6iHtL0sIaOyZzB9hZz0hHZW71kySSl6LIJlSgj5s5LO6VG53aFgpOfOFCyoFmYsOS5HZIaxVwKYsLSbJJn2kfU%2BlNdms5WMLqQRklX0FX26eFRnKYwzX0XRsgR0uUrWxplM7oqPIq8r8cZrdLNLqaABayxZMTTx2HVfglbP4xkcvqZEMNfmglevRi1ny5mGfJfTuQiBEq%2FMBvG0NqDh2TY47sbtJAuO%2Fe9%2Fn3STRFosm2WIxsFSFrFUfwHb11JNBNcaZSp8yb%2FEhHW3suWRNZRzDGvxb0oifk5lmnX2V2J2dEJkX1Q0baZ1MvYXPXHvhAga7x9PTEyj8a%2BF%2BXbxiTn78bSQAAAABJRU5ErkJggg%3D%3D -[15]: https://forum.omise.co -[16]: https://www.omise.co/omise-java-v3-migration +[15]: https://forum.omise.co \ No newline at end of file diff --git a/build.gradle b/build.gradle index eb84b7ab..8942f86d 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.ben-manes.versions' group 'co.omise' -version '3.1.1' +version '4.0.0' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -45,6 +45,11 @@ distributions { } signing { + def signingKey = System.getenv("PGP_SIGNING_KEY") + def signingPwd = System.getenv("PGP_SIGNING_PASSWORD") + + useInMemoryPgpKeys(signingKey, signingPwd) + sign configurations.archives } @@ -57,14 +62,15 @@ uploadArchives { repositories.mavenDeployer { beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - if (project.properties.containsKey('ossrhUsername') && project.properties.containsKey('ossrhPassword')) { - repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') { - authentication(userName: ossrhUsername, password: ossrhPassword) - } + def ossrhUsername = System.getenv("SONATYPE_USERNAME") + def ossrhPassword = System.getenv("SONATYPE_PASSWORD") - snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') { - authentication(userName: ossrhUsername, password: ossrhPassword) - } + repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') { + authentication(userName: ossrhUsername, password: ossrhPassword) } pom.project { @@ -90,8 +96,8 @@ uploadArchives { developers { developer { id 'chakrit' - name 'Chakrit Wichian' - email 'chakrit@omise.co' + name 'Omise' + email 'support@omise.co' } } } diff --git a/src/main/java/co/omise/Example.java b/src/main/java/co/omise/Example.java index c63be0f4..5eeeda24 100644 --- a/src/main/java/co/omise/Example.java +++ b/src/main/java/co/omise/Example.java @@ -470,7 +470,7 @@ void listSchedule() throws IOException, ClientException, OmiseException { } void listChargeSchedule() throws IOException, ClientException, OmiseException { - Request> request = new Schedule.ChargeScheduleListRequestBuilder().build(); + Request> request = new Charge.ListSchedulesRequestBuilder().build(); ScopedList schedules = client().sendRequest(request); System.out.printf("total no. of charge schedules: %d", schedules.getTotal()); @@ -504,7 +504,7 @@ void createSchedule() throws ClientException, IOException, OmiseException { .on(new ScheduleOn.Params().daysOfMonth(2)) .startDate(LocalDate.parse("2017-04-27")) .endDate(LocalDate.parse("2018-04-27")) - .charge(new ChargeScheduling.Params() + .charge(new ChargeSchedule.Params() .customer("cust_test_55bb3hkywglfyyachha") .amount(88800) .description("Monthly membership fee")) diff --git a/src/main/java/co/omise/models/Account.java b/src/main/java/co/omise/models/Account.java index 207cdb44..16ac05c1 100644 --- a/src/main/java/co/omise/models/Account.java +++ b/src/main/java/co/omise/models/Account.java @@ -5,50 +5,152 @@ import co.omise.requests.ResponseType; import com.fasterxml.jackson.annotation.JsonProperty; import okhttp3.HttpUrl; +import okhttp3.RequestBody; + +import java.io.IOException; +import java.util.List; +import java.util.Map; /** - * Represents Omise Account object and contains its {@link RequestBuilder}. + * Account object * * @see Account API */ public class Account extends Model { - private String email; + @JsonProperty("api_version") + private String apiVersion; + @JsonProperty("auto_activate_recipients") + private boolean autoActivateRecipients; + @JsonProperty("chain_enabled") + private boolean chainEnabled; + @JsonProperty("chain_return_uri") + private String chainReturnUri; + private String country; private String currency; + private String email; + private String location; + @JsonProperty("metadata_export_keys") + private Map metadataExportKeys; + @JsonProperty("supported_currencies") + private List supportedCurrencies; @JsonProperty("team") private String teamId; + @JsonProperty("webhook_uri") + private String webhookUri; + @JsonProperty("zero_interest_installments") + private boolean zeroInterestInstallments; - public Account() { + public String getApiVersion() { + return this.apiVersion; } - public String getEmail() { - return email; + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; } - public void setEmail(String email) { - this.email = email; + public boolean isAutoActivateRecipients() { + return this.autoActivateRecipients; + } + + public void setAutoActivateRecipients(boolean autoActivateRecipients) { + this.autoActivateRecipients = autoActivateRecipients; + } + + public boolean isChainEnabled() { + return this.chainEnabled; + } + + public void setChainEnabled(boolean chainEnabled) { + this.chainEnabled = chainEnabled; + } + + public String getChainReturnUri() { + return this.chainReturnUri; + } + + public void setChainReturnUri(String chainReturnUri) { + this.chainReturnUri = chainReturnUri; + } + + public String getCountry() { + return this.country; + } + + public void setCountry(String country) { + this.country = country; } public String getCurrency() { - return currency; + return this.currency; } public void setCurrency(String currency) { this.currency = currency; } + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public Map getMetadataExportKeys() { + return this.metadataExportKeys; + } + + public void setMetadataExportKeys(Map metadataExportKeys) { + this.metadataExportKeys = metadataExportKeys; + } + + public List getSupportedCurrencies() { + return this.supportedCurrencies; + } + + public void setSupportedCurrencies(List supportedCurrencies) { + this.supportedCurrencies = supportedCurrencies; + } + public String getTeamId() { - return teamId; + return this.teamId; } public void setTeamId(String teamId) { this.teamId = teamId; } - /** - * The {@link RequestBuilder} class for getting the user's Account. This class only overrides the path() method from its parent. - */ + public String getWebhookUri() { + return this.webhookUri; + } + + public void setWebhookUri(String webhookUri) { + this.webhookUri = webhookUri; + } + + public boolean isZeroInterestInstallments() { + return this.zeroInterestInstallments; + } + + public void setZeroInterestInstallments(boolean zeroInterestInstallments) { + this.zeroInterestInstallments = zeroInterestInstallments; + } + public static class GetRequestBuilder extends RequestBuilder { + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "account"); @@ -59,4 +161,63 @@ protected ResponseType type() { return new ResponseType<>(Account.class); } } -} + + public static class UpdateRequestBuilder extends RequestBuilder { + + @JsonProperty("chain_enabled") + private boolean chainEnabled; + @JsonProperty("chain_return_uri") + private String chainReturnUri; + @JsonProperty("metadata_export_keys") + private Map metadataExportKeys; + @JsonProperty("webhook_uri") + private String webhookUri; + @JsonProperty("zero_interest_installments") + private boolean zeroInterestInstallments; + + @Override + protected String method() { + return PATCH; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "account"); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Account.class); + } + + public UpdateRequestBuilder chainEnabled(boolean chainEnabled) { + this.chainEnabled = chainEnabled; + return this; + } + + public UpdateRequestBuilder chainReturnUri(String chainReturnUri) { + this.chainReturnUri = chainReturnUri; + return this; + } + + public UpdateRequestBuilder metadataExportKeys(Map metadataExportKeys) { + this.metadataExportKeys = metadataExportKeys; + return this; + } + + public UpdateRequestBuilder webhookUri(String webhookUri) { + this.webhookUri = webhookUri; + return this; + } + + public UpdateRequestBuilder zeroInterestInstallments(boolean zeroInterestInstallments) { + this.zeroInterestInstallments = zeroInterestInstallments; + return this; + } + + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Balance.java b/src/main/java/co/omise/models/Balance.java index 0ac82c96..3eab059e 100644 --- a/src/main/java/co/omise/models/Balance.java +++ b/src/main/java/co/omise/models/Balance.java @@ -3,50 +3,71 @@ import co.omise.Endpoint; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; +import com.fasterxml.jackson.annotation.JsonProperty; import okhttp3.HttpUrl; +import okhttp3.RequestBody; + +import java.io.IOException; /** - * Represents Omise Balance object and contains its {@link RequestBuilder} + * Balance object * * @see Balance API */ public class Balance extends Model { - private long transferable; - private long total; private String currency; + private String location; + private long reserve; + private long total; + private long transferable; - public Balance() { + public String getCurrency() { + return this.currency; } - public long getTransferable() { - return transferable; + public void setCurrency(String currency) { + this.currency = currency; } - public void setTransferable(long transferable) { - this.transferable = transferable; + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public long getReserve() { + return this.reserve; + } + + public void setReserve(long reserve) { + this.reserve = reserve; } public long getTotal() { - return total; + return this.total; } public void setTotal(long total) { this.total = total; } - public String getCurrency() { - return currency; + public long getTransferable() { + return this.transferable; } - public void setCurrency(String currency) { - this.currency = currency; + public void setTransferable(long transferable) { + this.transferable = transferable; } - /** - * The {@link RequestBuilder} class for getting the user's Balance. - */ public static class GetRequestBuilder extends RequestBuilder { + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "balance"); @@ -57,4 +78,4 @@ protected ResponseType type() { return new ResponseType<>(Balance.class); } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/BankAccount.java b/src/main/java/co/omise/models/BankAccount.java index 4d55b0bd..b0bb7920 100644 --- a/src/main/java/co/omise/models/BankAccount.java +++ b/src/main/java/co/omise/models/BankAccount.java @@ -3,28 +3,40 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Represents Omise Bank Account object. + * Bank Account object * * @see Bank Account API */ public class BankAccount extends Model { - private String brand; - private String number; - @JsonProperty("last_digits") - private String lastDigits; - private String name; @JsonProperty("bank_code") private String bankCode; @JsonProperty("branch_code") private String branchCode; + private String brand; + @JsonProperty("last_digits") + private String lastDigits; + private String name; @JsonProperty("type") private String accountType; - public BankAccount() { + public String getBankCode() { + return this.bankCode; + } + + public void setBankCode(String bankCode) { + this.bankCode = bankCode; + } + + public String getBranchCode() { + return this.branchCode; + } + + public void setBranchCode(String branchCode) { + this.branchCode = branchCode; } public String getBrand() { - return brand; + return this.brand; } public void setBrand(String brand) { @@ -32,7 +44,7 @@ public void setBrand(String brand) { } public String getLastDigits() { - return lastDigits; + return this.lastDigits; } public void setLastDigits(String lastDigits) { @@ -40,31 +52,15 @@ public void setLastDigits(String lastDigits) { } public String getName() { - return name; + return this.name; } public void setName(String name) { this.name = name; } - public String getBankCode() { - return bankCode; - } - - public void setBankCode(String bankCode) { - this.bankCode = bankCode; - } - - public String getBranchCode() { - return branchCode; - } - - public void setBranchCode(String branchCode) { - this.branchCode = branchCode; - } - public String getAccountType() { - return accountType; + return this.accountType; } public void setAccountType(String accountType) { @@ -72,41 +68,46 @@ public void setAccountType(String accountType) { } public static class Params extends co.omise.models.Params { - @JsonProperty - private String brand; - @JsonProperty - private String number; - @JsonProperty - private String name; @JsonProperty("bank_code") private String bankCode; + @JsonProperty("branch_code") private String branchCode; - @JsonProperty("account_type") + + @JsonProperty + private String brand; + + @JsonProperty + private String name; + + @JsonProperty + private String number; + + @JsonProperty("type") private String accountType; - public Params brand(String brand) { - this.brand = brand; + public Params bankCode(String bankCode) { + this.bankCode = bankCode; return this; } - public Params number(String number) { - this.number = number; + public Params branchCode(String branchCode) { + this.branchCode = branchCode; return this; } - public Params name(String name) { - this.name = name; + public Params brand(String brand) { + this.brand = brand; return this; } - public Params bankCode(String bankCode) { - this.bankCode = bankCode; + public Params name(String name) { + this.name = name; return this; } - public Params branchCode(String branchCode) { - this.branchCode = branchCode; + public Params number(String number) { + this.number = number; return this; } @@ -115,4 +116,4 @@ public Params accountType(String accountType) { return this; } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Capability.java b/src/main/java/co/omise/models/Capability.java index 4f39aa66..c625e104 100644 --- a/src/main/java/co/omise/models/Capability.java +++ b/src/main/java/co/omise/models/Capability.java @@ -5,34 +5,51 @@ import co.omise.requests.ResponseType; import com.fasterxml.jackson.annotation.JsonProperty; import okhttp3.HttpUrl; +import okhttp3.RequestBody; +import java.io.IOException; import java.util.List; /** - * Represents Omise Capability object and contains its {@link RequestBuilder} + * Capability object * * @see Capability API */ public class Capability extends Model { private List banks; + private String country; + private String location; @JsonProperty("payment_methods") private List paymentMethods; @JsonProperty("zero_interest_installments") private boolean zeroInterestInstallments; - public Capability() { - } - public List getBanks() { - return banks; + return this.banks; } public void setBanks(List banks) { this.banks = banks; } + public String getCountry() { + return this.country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + public List getPaymentMethods() { - return paymentMethods; + return this.paymentMethods; } public void setPaymentMethods(List paymentMethods) { @@ -40,7 +57,7 @@ public void setPaymentMethods(List paymentMethods) { } public boolean isZeroInterestInstallments() { - return zeroInterestInstallments; + return this.zeroInterestInstallments; } public void setZeroInterestInstallments(boolean zeroInterestInstallments) { @@ -49,6 +66,11 @@ public void setZeroInterestInstallments(boolean zeroInterestInstallments) { public static class GetRequestBuilder extends RequestBuilder { + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "capability"); @@ -59,4 +81,4 @@ protected ResponseType type() { return new ResponseType<>(Capability.class); } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Card.java b/src/main/java/co/omise/models/Card.java index 5abf91fe..bf8e5a6f 100644 --- a/src/main/java/co/omise/models/Card.java +++ b/src/main/java/co/omise/models/Card.java @@ -13,81 +13,103 @@ import java.io.IOException; /** - * Represents Omise Card object. + * Card object * - * @see Cards API + * @see Card API */ public class Card extends Model { - private String country; - private String city; private String bank; - @JsonProperty("postal_code") - private String postalCode; - private String financing; - @JsonProperty("first_digits") - private String firstDigits; - @JsonProperty("last_digits") - private String lastDigits; private String brand; + private String city; + private String country; @JsonProperty("expiration_month") private int expirationMonth; @JsonProperty("expiration_year") private int expirationYear; + private String financing; private String fingerprint; + @JsonProperty("first_digits") + private String firstDigits; + @JsonProperty("last_digits") + private String lastDigits; + private String location; private String name; + @JsonProperty("phone_number") + private String phoneNumber; + @JsonProperty("postal_code") + private String postalCode; @JsonProperty("security_code_check") private boolean securityCodeCheck; + private String state; private String street1; private String street2; - private String state; - @JsonProperty("phone_number") - private String phoneNumber; - public Card() { + public String getBank() { + return this.bank; } - public String getCountry() { - return country; + public void setBank(String bank) { + this.bank = bank; } - public void setCountry(String country) { - this.country = country; + public String getBrand() { + return this.brand; + } + + public void setBrand(String brand) { + this.brand = brand; } public String getCity() { - return city; + return this.city; } public void setCity(String city) { this.city = city; } - public String getBank() { - return bank; + public String getCountry() { + return this.country; } - public void setBank(String bank) { - this.bank = bank; + public void setCountry(String country) { + this.country = country; } - public String getPostalCode() { - return postalCode; + public int getExpirationMonth() { + return this.expirationMonth; } - public void setPostalCode(String postalCode) { - this.postalCode = postalCode; + public void setExpirationMonth(int expirationMonth) { + this.expirationMonth = expirationMonth; + } + + public int getExpirationYear() { + return this.expirationYear; + } + + public void setExpirationYear(int expirationYear) { + this.expirationYear = expirationYear; } public String getFinancing() { - return financing; + return this.financing; } public void setFinancing(String financing) { this.financing = financing; } + public String getFingerprint() { + return this.fingerprint; + } + + public void setFingerprint(String fingerprint) { + this.fingerprint = fingerprint; + } + public String getFirstDigits() { - return firstDigits; + return this.firstDigits; } public void setFirstDigits(String firstDigits) { @@ -95,64 +117,59 @@ public void setFirstDigits(String firstDigits) { } public String getLastDigits() { - return lastDigits; + return this.lastDigits; } public void setLastDigits(String lastDigits) { this.lastDigits = lastDigits; } - public String getBrand() { - return brand; + public String getLocation() { + return this.location; } - public void setBrand(String brand) { - this.brand = brand; - } - - @JsonIgnore - public YearMonth getExpiration() { - return new YearMonth(expirationYear, expirationMonth); + public void setLocation(String location) { + this.location = location; } - public int getExpirationMonth() { - return expirationMonth; + public String getName() { + return this.name; } - public void setExpirationMonth(int expirationMonth) { - this.expirationMonth = expirationMonth; + public void setName(String name) { + this.name = name; } - public int getExpirationYear() { - return expirationYear; + public String getPhoneNumber() { + return this.phoneNumber; } - public void setExpirationYear(int expirationYear) { - this.expirationYear = expirationYear; + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; } - public String getFingerprint() { - return fingerprint; + public String getPostalCode() { + return this.postalCode; } - public void setFingerprint(String fingerprint) { - this.fingerprint = fingerprint; + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; } - public String getName() { - return name; + public boolean isSecurityCodeCheck() { + return this.securityCodeCheck; } - public void setName(String name) { - this.name = name; + public void setSecurityCodeCheck(boolean securityCodeCheck) { + this.securityCodeCheck = securityCodeCheck; } - public boolean isSecurityCodeCheck() { - return securityCodeCheck; + public String getState() { + return this.state; } - public void setSecurityCodeCheck(boolean securityCodeCheck) { - this.securityCodeCheck = securityCodeCheck; + public void setState(String state) { + this.state = state; } public String getStreet1() { @@ -171,38 +188,67 @@ public void setStreet2(String street2) { this.street2 = street2; } - public String getState() { - return this.state; + @JsonIgnore + public YearMonth getExpiration() { + return new YearMonth(expirationYear, expirationMonth); } - public void setState(String state) { - this.state = state; - } + public static class Create extends co.omise.models.Params { + @JsonProperty + private String city; - public String getPhoneNumber() { - return this.phoneNumber; - } + @JsonProperty + private String country; - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } + @JsonProperty("expiration_month") + private int expirationMonth; + + @JsonProperty("expiration_year") + private int expirationYear; - // Duplicated, for now. Since we don't people trying to update card numbers. - public static class Create extends co.omise.models.Params { @JsonProperty private String name; + @JsonProperty private String number; + + @JsonProperty("phone_number") + private String phoneNumber; + + @JsonProperty("postal_code") + private String postalCode; + @JsonProperty("security_code") private String securityCode; + @JsonProperty - private String city; - @JsonProperty("postal_code") - private String postalCode; - @JsonProperty("expiration_month") - private int expirationMonth; - @JsonProperty("expiration_year") - private int expirationYear; + private String state; + + @JsonProperty + private String street1; + + @JsonProperty + private String street2; + + public Create city(String city) { + this.city = city; + return this; + } + + public Create country(String country) { + this.country = country; + return this; + } + + public Create expirationMonth(int expirationMonth) { + this.expirationMonth = expirationMonth; + return this; + } + + public Create expirationYear(int expirationYear) { + this.expirationYear = expirationYear; + return this; + } public Create name(String name) { this.name = name; @@ -214,52 +260,82 @@ public Create number(String number) { return this; } - public Create securityCode(String code) { - this.securityCode = code; + public Create phoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; return this; } - public Create city(String city) { - this.city = city; + public Create postalCode(String postalCode) { + this.postalCode = postalCode; return this; } - public Create postalCode(String postalCode) { - this.postalCode = postalCode; + public Create securityCode(String securityCode) { + this.securityCode = securityCode; return this; } - public Create expirationMonth(int expirationMonth) { - this.expirationMonth = expirationMonth; + public Create state(String state) { + this.state = state; return this; } - public Create expirationYear(int expirationYear) { - this.expirationYear = expirationYear; + public Create street1(String street1) { + this.street1 = street1; + return this; + } + + public Create street2(String street2) { + this.street2 = street2; return this; } public Create expiration(YearMonth expiration) { return expirationMonth(expiration.getMonthOfYear()) - .expirationYear(expiration.getYear()); + .expirationYear(expiration.getYear()); } public Create expiration(int month, int year) { return expirationMonth(month) - .expirationYear(year); + .expirationYear(year); } } - /** - * The {@link RequestBuilder} class for retrieving a particular Card. - */ - public static class GetRequestBuilder extends RequestBuilder { - private String cardId; + public static class DeleteRequestBuilder extends RequestBuilder { private String customerId; - - public GetRequestBuilder(String cardId, String customerId) { + private String cardId; + public DeleteRequestBuilder(String customerId, String cardId) { + this.customerId = customerId; this.cardId = cardId; + } + + @Override + protected String method() { + return DELETE; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "customers", customerId, "cards", cardId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Card.class); + } + } + + public static class GetRequestBuilder extends RequestBuilder { + private String customerId; + private String cardId; + public GetRequestBuilder(String customerId, String cardId) { this.customerId = customerId; + this.cardId = cardId; + } + + @Override + protected String method() { + return GET; } @Override @@ -273,37 +349,33 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for updating a particular Card. - */ public static class UpdateRequestBuilder extends RequestBuilder { - private String cardId; private String customerId; + private String cardId; - @JsonProperty - private String name; @JsonProperty private String city; - @JsonProperty("postal_code") - private String postalCode; @JsonProperty("expiration_month") private int expirationMonth; @JsonProperty("expiration_year") private int expirationYear; - - public UpdateRequestBuilder(String cardId, String customerId) { - this.cardId = cardId; + @JsonProperty + private String name; + @JsonProperty("postal_code") + private String postalCode; + public UpdateRequestBuilder(String customerId, String cardId) { this.customerId = customerId; + this.cardId = cardId; } @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "customers", customerId, "cards", cardId); + protected String method() { + return PATCH; } @Override - protected RequestBody payload() throws IOException { - return serialize(); + protected HttpUrl path() { + return buildUrl(Endpoint.API, "customers", customerId, "cards", cardId); } @Override @@ -311,26 +383,11 @@ protected ResponseType type() { return new ResponseType<>(Card.class); } - @Override - protected String method() { - return PATCH; - } - - public UpdateRequestBuilder name(String name) { - this.name = name; - return this; - } - public UpdateRequestBuilder city(String city) { this.city = city; return this; } - public UpdateRequestBuilder postalCode(String postalCode) { - this.postalCode = postalCode; - return this; - } - public UpdateRequestBuilder expirationMonth(int expirationMonth) { this.expirationMonth = expirationMonth; return this; @@ -341,68 +398,53 @@ public UpdateRequestBuilder expirationYear(int expirationYear) { return this; } - public UpdateRequestBuilder expiration(YearMonth expiration) { - return expirationMonth(expiration.getMonthOfYear()) - .expirationYear(expiration.getYear()); - } - - public UpdateRequestBuilder expiration(int month, int year) { - return expirationMonth(month) - .expirationYear(year); + public UpdateRequestBuilder name(String name) { + this.name = name; + return this; } - } - - /** - * The {@link RequestBuilder} class for deleting a particular Customer. - */ - public static class DeleteRequestBuilder extends RequestBuilder { - private String cardId; - private String customerId; - public DeleteRequestBuilder(String cardId, String customerId) { - this.cardId = cardId; - this.customerId = customerId; + public UpdateRequestBuilder postalCode(String postalCode) { + this.postalCode = postalCode; + return this; } - @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "customers", customerId, "cards", cardId); + public UpdateRequestBuilder expiration(YearMonth expiration) { + return expirationMonth(expiration.getMonthOfYear()) + .expirationYear(expiration.getYear()); } - @Override - protected ResponseType type() { - return new ResponseType<>(Card.class); + public UpdateRequestBuilder expiration(int month, int year) { + return expirationMonth(month) + .expirationYear(year); } @Override - protected String method() { - return DELETE; + protected RequestBody payload() throws IOException { + return serialize(); } } - /** - * The {@link RequestBuilder} class for retrieving all Cards that belong to a customer. - */ public static class ListRequestBuilder extends RequestBuilder> { private String customerId; - private ScopedList.Options options; - public ListRequestBuilder(String customerId) { this.customerId = customerId; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - - return new HttpUrlBuilder( - Endpoint.API, "customers", serializer()) - .segments(customerId, "cards") - .params(options) - .build(); + return new HttpUrlBuilder(Endpoint.API, "customers", serializer()) + .segments(customerId, "cards") + .params(options) + .build(); } @Override diff --git a/src/main/java/co/omise/models/Chain.java b/src/main/java/co/omise/models/Chain.java new file mode 100644 index 00000000..82b77abc --- /dev/null +++ b/src/main/java/co/omise/models/Chain.java @@ -0,0 +1,129 @@ +package co.omise.models; + +import co.omise.Endpoint; +import co.omise.requests.RequestBuilder; +import co.omise.requests.ResponseType; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import okhttp3.HttpUrl; +import okhttp3.RequestBody; + +import java.io.IOException; + +/** + * Chain object + * + * @see Chain API + */ +public class Chain extends Model { + private String email; + private String key; + private String location; + private boolean revoked; + + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getKey() { + return this.key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public boolean isRevoked() { + return this.revoked; + } + + public void setRevoked(boolean revoked) { + this.revoked = revoked; + } + + public static class ListRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "chains", serializer()) + .segments() + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; + } + } + + public static class GetRequestBuilder extends RequestBuilder { + private String chainId; + public GetRequestBuilder(String chainId) { + this.chainId = chainId; + } + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "chains", chainId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Chain.class); + } + } + + public static class RevokeRequestBuilder extends RequestBuilder { + private String chainId; + public RevokeRequestBuilder(String chainId) { + this.chainId = chainId; + } + + @Override + protected String method() { + return POST; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "chains", chainId, "revoke"); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Chain.class); + } + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Charge.java b/src/main/java/co/omise/models/Charge.java index 6d4c7cc3..00118b37 100644 --- a/src/main/java/co/omise/models/Charge.java +++ b/src/main/java/co/omise/models/Charge.java @@ -1,6 +1,8 @@ package co.omise.models; import co.omise.Endpoint; +import co.omise.models.schedules.ChargeSchedule; +import co.omise.models.schedules.Schedule; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,164 +16,203 @@ import java.util.Map; /** - * Represents Omise Charge object and contains all of its {@link RequestBuilder}. + * Charge object * - * @see Charges API + * @see Charge API */ public class Charge extends Model { - private ChargeStatus status; private long amount; - private String currency; - private String description; - private Map metadata; - private boolean capture; + @JsonProperty("authorize_uri") + private String authorizeUri; private boolean authorized; - private boolean reversed; - private boolean paid; - private String transaction; + private String branch; + private boolean capturable; + private boolean capture; private Card card; - @JsonProperty("refunded_amount") - private long refundedAmount; - private ScopedList refunds; - @JsonProperty("failure_code") - private String failureCode; - @JsonProperty("failure_message") - private String failureMessage; + private String currency; private String customer; - private String ip; + private String description; + private String device; + private boolean disputable; private Dispute dispute; - @JsonProperty("return_uri") - private String returnUri; - @JsonProperty("authorize_uri") - private String authorizeUri; - @JsonProperty("installment_terms") - private int installmentTerms; - private Source source; + private boolean expired; + @JsonProperty("expired_at") + private DateTime expiredAt; @JsonProperty("expires_at") private DateTime expiresAt; - private boolean disputable; - private boolean capturable; - private boolean reversible; - private boolean refundable; + @JsonProperty("failure_code") + private String failureCode; + @JsonProperty("failure_message") + private String failureMessage; private long fee; @JsonProperty("fee_vat") private long feeVat; + @JsonProperty("funding_amount") + private long fundingAmount; + @JsonProperty("funding_currency") + private String fundingCurrency; private long interest; @JsonProperty("interest_vat") private long interestVat; + private String ip; + private String link; + private String location; + private Map metadata; private long net; + private boolean paid; + @JsonProperty("paid_at") + private DateTime paidAt; + @JsonProperty("platform_fee") + private PlatformFee platformFee; + private boolean refundable; + @JsonProperty("refunded_amount") + private long refundedAmount; + private ScopedList refunds; + @JsonProperty("return_uri") + private String returnUri; + private boolean reversed; + @JsonProperty("reversed_at") + private DateTime reversedAt; + private boolean reversible; + private String schedule; + private Source source; + private ChargeStatus status; + private String terminal; + private String transaction; + private boolean voided; @JsonProperty("zero_interest_installments") private boolean zeroInterestInstallments; - public Charge() { - } - - public ChargeStatus getStatus() { - return status; + public long getAmount() { + return this.amount; } - public void setStatus(ChargeStatus status) { - this.status = status; + public void setAmount(long amount) { + this.amount = amount; } - public long getAmount() { - return amount; + public String getAuthorizeUri() { + return this.authorizeUri; } - public void setAmount(long amount) { - this.amount = amount; + public void setAuthorizeUri(String authorizeUri) { + this.authorizeUri = authorizeUri; } - public String getCurrency() { - return currency; + public boolean isAuthorized() { + return this.authorized; } - public void setCurrency(String currency) { - this.currency = currency; + public void setAuthorized(boolean authorized) { + this.authorized = authorized; } - public String getDescription() { - return description; + public String getBranch() { + return this.branch; } - public void setDescription(String description) { - this.description = description; + public void setBranch(String branch) { + this.branch = branch; } - public Map getMetadata() { - return metadata; + public boolean isCapturable() { + return this.capturable; } - public void setMetadata(Map metadata) { - this.metadata = metadata; + public void setCapturable(boolean capturable) { + this.capturable = capturable; } public boolean isCapture() { - return capture; + return this.capture; } public void setCapture(boolean capture) { this.capture = capture; } - public boolean isAuthorized() { - return authorized; + public Card getCard() { + return this.card; } - public void setAuthorized(boolean authorized) { - this.authorized = authorized; + public void setCard(Card card) { + this.card = card; } - public boolean isReversed() { - return reversed; + public String getCurrency() { + return this.currency; } - public void setReversed(boolean reversed) { - this.reversed = reversed; + public void setCurrency(String currency) { + this.currency = currency; } - public boolean isPaid() { - return paid; + public String getCustomer() { + return this.customer; } - public void setPaid(boolean paid) { - this.paid = paid; + public void setCustomer(String customer) { + this.customer = customer; } - public String getTransaction() { - return transaction; + public String getDescription() { + return this.description; } - public void setTransaction(String transaction) { - this.transaction = transaction; + public void setDescription(String description) { + this.description = description; } - public Card getCard() { - return card; + public String getDevice() { + return this.device; } - public void setCard(Card card) { - this.card = card; + public void setDevice(String device) { + this.device = device; } - public long getRefundedAmount() { - return refundedAmount; + public boolean isDisputable() { + return this.disputable; } - public void setRefundedAmount(long refundedAmount) { - this.refundedAmount = refundedAmount; + public void setDisputable(boolean disputable) { + this.disputable = disputable; } - public ScopedList getRefunds() { - return refunds; + public Dispute getDispute() { + return this.dispute; } - public void setRefunds(ScopedList refunds) { - this.refunds = refunds; + public void setDispute(Dispute dispute) { + this.dispute = dispute; + } + + public boolean isExpired() { + return this.expired; + } + + public void setExpired(boolean expired) { + this.expired = expired; + } + + public DateTime getExpiredAt() { + return this.expiredAt; + } + + public void setExpiredAt(DateTime expiredAt) { + this.expiredAt = expiredAt; + } + + public DateTime getExpiresAt() { + return this.expiresAt; + } + + public void setExpiresAt(DateTime expiresAt) { + this.expiresAt = expiresAt; } public String getFailureCode() { - return failureCode; + return this.failureCode; } public void setFailureCode(String failureCode) { @@ -179,185 +220,297 @@ public void setFailureCode(String failureCode) { } public String getFailureMessage() { - return failureMessage; + return this.failureMessage; } public void setFailureMessage(String failureMessage) { this.failureMessage = failureMessage; } - public String getCustomer() { - return customer; + public long getFee() { + return this.fee; } - public void setCustomer(String customer) { - this.customer = customer; + public void setFee(long fee) { + this.fee = fee; + } + + public long getFeeVat() { + return this.feeVat; + } + + public void setFeeVat(long feeVat) { + this.feeVat = feeVat; + } + + public long getFundingAmount() { + return this.fundingAmount; + } + + public void setFundingAmount(long fundingAmount) { + this.fundingAmount = fundingAmount; + } + + public String getFundingCurrency() { + return this.fundingCurrency; + } + + public void setFundingCurrency(String fundingCurrency) { + this.fundingCurrency = fundingCurrency; + } + + public long getInterest() { + return this.interest; + } + + public void setInterest(long interest) { + this.interest = interest; + } + + public long getInterestVat() { + return this.interestVat; + } + + public void setInterestVat(long interestVat) { + this.interestVat = interestVat; } public String getIp() { - return ip; + return this.ip; } public void setIp(String ip) { this.ip = ip; } - public Dispute getDispute() { - return dispute; + public String getLink() { + return this.link; } - public void setDispute(Dispute dispute) { - this.dispute = dispute; + public void setLink(String link) { + this.link = link; } - public String getReturnUri() { - return returnUri; + public String getLocation() { + return this.location; } - public void setReturnUri(String returnUri) { - this.returnUri = returnUri; + public void setLocation(String location) { + this.location = location; } - public String getAuthorizeUri() { - return authorizeUri; + public Map getMetadata() { + return this.metadata; } - public void setAuthorizeUri(String authorizeUri) { - this.authorizeUri = authorizeUri; + public void setMetadata(Map metadata) { + this.metadata = metadata; } - public int getInstallmentTerms() { - return installmentTerms; + public long getNet() { + return this.net; } - public void setInstallmentTerms(int installmentTerms) { - this.installmentTerms = installmentTerms; + public void setNet(long net) { + this.net = net; } - public Source getSource() { - return source; + public boolean isPaid() { + return this.paid; } - public void setSource(Source source) { - this.source = source; + public void setPaid(boolean paid) { + this.paid = paid; } - public DateTime getExpiresAt() { - return expiresAt; + public DateTime getPaidAt() { + return this.paidAt; } - public void setExpiresAt(DateTime expiresAt) { - this.expiresAt = expiresAt; + public void setPaidAt(DateTime paidAt) { + this.paidAt = paidAt; } - - public boolean isZeroInterestInstallments() { - return this.zeroInterestInstallments; + + public PlatformFee getPlatformFee() { + return this.platformFee; } - public void setZeroInterestInstallments(boolean zeroInterestInstallments) { - this.zeroInterestInstallments = zeroInterestInstallments; + public void setPlatformFee(PlatformFee platformFee) { + this.platformFee = platformFee; } - public boolean isDisputable() { - return disputable; + public boolean isRefundable() { + return this.refundable; } - public void setDisputable(boolean disputable) { - this.disputable = disputable; + public void setRefundable(boolean refundable) { + this.refundable = refundable; } - public boolean isCapturable() { - return capturable; + public long getRefundedAmount() { + return this.refundedAmount; } - public void setCapturable(boolean capturable) { - this.capturable = capturable; + public void setRefundedAmount(long refundedAmount) { + this.refundedAmount = refundedAmount; + } + + public ScopedList getRefunds() { + return this.refunds; + } + + public void setRefunds(ScopedList refunds) { + this.refunds = refunds; + } + + public String getReturnUri() { + return this.returnUri; + } + + public void setReturnUri(String returnUri) { + this.returnUri = returnUri; + } + + public boolean isReversed() { + return this.reversed; + } + + public void setReversed(boolean reversed) { + this.reversed = reversed; + } + + public DateTime getReversedAt() { + return this.reversedAt; + } + + public void setReversedAt(DateTime reversedAt) { + this.reversedAt = reversedAt; } public boolean isReversible() { - return reversible; + return this.reversible; } public void setReversible(boolean reversible) { this.reversible = reversible; } - public boolean isRefundable() { - return refundable; + public String getSchedule() { + return this.schedule; } - public void setRefundable(boolean refundable) { - this.refundable = refundable; + public void setSchedule(String schedule) { + this.schedule = schedule; } - public long getFee() { - return fee; + public Source getSource() { + return this.source; } - public void setFee(long fee) { - this.fee = fee; + public void setSource(Source source) { + this.source = source; } - public long getFeeVat() { - return feeVat; + public ChargeStatus getStatus() { + return this.status; } - public void setFeeVat(long feeVat) { - this.feeVat = feeVat; + public void setStatus(ChargeStatus status) { + this.status = status; } - public long getInterest() { - return interest; + public String getTerminal() { + return this.terminal; } - public void setInterest(long interest) { - this.interest = interest; + public void setTerminal(String terminal) { + this.terminal = terminal; } - public long getInterestVat() { - return interestVat; + public String getTransaction() { + return this.transaction; } - public void setInterestVat(long interestVat) { - this.interestVat = interestVat; + public void setTransaction(String transaction) { + this.transaction = transaction; } - public long getNet() { - return net; + public boolean isVoided() { + return this.voided; } - public void setNet(long net) { - this.net = net; + public void setVoided(boolean voided) { + this.voided = voided; + } + + public boolean isZeroInterestInstallments() { + return this.zeroInterestInstallments; + } + + public void setZeroInterestInstallments(boolean zeroInterestInstallments) { + this.zeroInterestInstallments = zeroInterestInstallments; + } + + public static class ListRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "charges", serializer()) + .segments() + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; + } } - /** - * The {@link RequestBuilder} class for creating a Charge. - */ public static class CreateRequestBuilder extends RequestBuilder { + @JsonProperty("zero_interest_installments") + private boolean zeroInterestInstallments; + @JsonProperty - private String customer; + private long amount; @JsonProperty - private String card; + private boolean capture; @JsonProperty - private long amount; + private String card; @JsonProperty private String currency; @JsonProperty + private String customer; + @JsonProperty private String description; + @JsonProperty("expires_at") + private DateTime expiresAt; + @JsonProperty + private String ip; @JsonProperty private Map metadata; + @JsonProperty("platform_fee") + private PlatformFee.Params platformFee; @JsonProperty - private Boolean capture; - @JsonProperty("installment_terms") - private Integer installmentTerms; + private String reference; @JsonProperty("return_uri") private String returnUri; @JsonProperty private String source; - @JsonProperty("expires_at") - private DateTime expiresAt; - @JsonProperty("zero_interest_installments") - private boolean zeroInterestInstallments; @Override protected String method() { @@ -369,28 +522,23 @@ protected HttpUrl path() { return buildUrl(Endpoint.API, "charges"); } - @Override - protected RequestBody payload() throws IOException { - return serialize(); - } - @Override protected ResponseType type() { return new ResponseType<>(Charge.class); } - public CreateRequestBuilder customer(String customer) { - this.customer = customer; + public CreateRequestBuilder amount(long amount) { + this.amount = amount; return this; } - public CreateRequestBuilder card(String card) { - this.card = card; + public CreateRequestBuilder capture(boolean capture) { + this.capture = capture; return this; } - public CreateRequestBuilder amount(long amount) { - this.amount = amount; + public CreateRequestBuilder card(String card) { + this.card = card; return this; } @@ -399,19 +547,23 @@ public CreateRequestBuilder currency(String currency) { return this; } + public CreateRequestBuilder customer(String customer) { + this.customer = customer; + return this; + } + public CreateRequestBuilder description(String description) { this.description = description; return this; } - public CreateRequestBuilder metadata(String key, Object value) { - HashMap tempMap = new HashMap<>(); - if (metadata != null) { - tempMap.putAll(metadata); - } - tempMap.put(key, value); + public CreateRequestBuilder expiresAt(DateTime expiresAt) { + this.expiresAt = expiresAt; + return this; + } - this.metadata = new HashMap<>(tempMap); + public CreateRequestBuilder ip(String ip) { + this.ip = ip; return this; } @@ -420,13 +572,13 @@ public CreateRequestBuilder metadata(Map metadata) { return this; } - public CreateRequestBuilder capture(boolean capture) { - this.capture = capture; + public CreateRequestBuilder platformFee(PlatformFee.Params platformFee) { + this.platformFee = platformFee; return this; } - public CreateRequestBuilder installmentTerms(int installmentTerms) { - this.installmentTerms = installmentTerms; + public CreateRequestBuilder reference(String reference) { + this.reference = reference; return this; } @@ -439,28 +591,104 @@ public CreateRequestBuilder source(String source) { this.source = source; return this; } - + public CreateRequestBuilder zeroInterestInstallments(boolean zeroInterestInstallments) { this.zeroInterestInstallments = zeroInterestInstallments; return this; } - public CreateRequestBuilder expiresAt(DateTime expiresAt) { - this.expiresAt = expiresAt; + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + + public CreateRequestBuilder metadata(String key, Object value) { + HashMap tempMap = new HashMap<>(); + if (metadata != null) { + tempMap.putAll(metadata); + } + tempMap.put(key, value); + + this.metadata = new HashMap<>(tempMap); return this; } } - /** - * The {@link RequestBuilder} class for retrieving a particular Charge. - */ - public static class GetRequestBuilder extends RequestBuilder { + public static class ListEventsRequestBuilder extends RequestBuilder> { private String chargeId; + private ScopedList.Options options; + public ListEventsRequestBuilder(String chargeId) { + this.chargeId = chargeId; + } + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "charges", serializer()) + .segments(chargeId, "events") + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListEventsRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; + } + } + + public static class ListSchedulesRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "charges", serializer()) + .segments("schedules") + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListSchedulesRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; + } + } + public static class GetRequestBuilder extends RequestBuilder { + private String chargeId; public GetRequestBuilder(String chargeId) { this.chargeId = chargeId; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "charges", chargeId); @@ -472,9 +700,6 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for updating a particular Charge. - */ public static class UpdateRequestBuilder extends RequestBuilder { private String chargeId; @@ -482,24 +707,18 @@ public static class UpdateRequestBuilder extends RequestBuilder { private String description; @JsonProperty private Map metadata; - public UpdateRequestBuilder(String chargeId) { this.chargeId = chargeId; } - @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "charges", chargeId); - } - @Override protected String method() { return PATCH; } @Override - protected RequestBody payload() throws IOException { - return serialize(); + protected HttpUrl path() { + return buildUrl(Endpoint.API, "charges", chargeId); } @Override @@ -512,6 +731,16 @@ public UpdateRequestBuilder description(String description) { return this; } + public UpdateRequestBuilder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + public UpdateRequestBuilder metadata(String key, Object value) { HashMap tempMap = new HashMap<>(); if (metadata != null) { @@ -519,26 +748,22 @@ public UpdateRequestBuilder metadata(String key, Object value) { } tempMap.put(key, value); - this.metadata = tempMap; - return this; - } - - public UpdateRequestBuilder metadata(Map metadata) { - this.metadata = new HashMap<>(metadata); + this.metadata = new HashMap<>(tempMap); return this; } } - /** - * The {@link RequestBuilder} class for capturing a particular Charge. Keep in mind, capturing only works for credit card transfers that are not auto-captured. - */ public static class CaptureRequestBuilder extends RequestBuilder { private String chargeId; - public CaptureRequestBuilder(String chargeId) { this.chargeId = chargeId; } + @Override + protected String method() { + return POST; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "charges", chargeId, "capture"); @@ -548,64 +773,93 @@ protected HttpUrl path() { protected ResponseType type() { return new ResponseType<>(Charge.class); } + } + + public static class ExpireRequestBuilder extends RequestBuilder { + private String chargeId; + public ExpireRequestBuilder(String chargeId) { + this.chargeId = chargeId; + } @Override protected String method() { return POST; } - } + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "charges", chargeId, "expire"); + } - /** - * The {@link RequestBuilder} class for reversing a particular Charge. - */ - public static class ReverseRequestBuilder extends RequestBuilder { - private String chargeId; + @Override + protected ResponseType type() { + return new ResponseType<>(Charge.class); + } + } - public ReverseRequestBuilder(String chargeId) { + public static class MarkAsFailedRequestBuilder extends RequestBuilder { + private String chargeId; + public MarkAsFailedRequestBuilder(String chargeId) { this.chargeId = chargeId; } + @Override + protected String method() { + return POST; + } + @Override protected HttpUrl path() { - return buildUrl(Endpoint.API, "charges", chargeId, "reverse"); + return buildUrl(Endpoint.API, "charges", chargeId, "mark_as_failed"); } @Override protected ResponseType type() { return new ResponseType<>(Charge.class); } + } + + public static class MarkAsPaidRequestBuilder extends RequestBuilder { + private String chargeId; + public MarkAsPaidRequestBuilder(String chargeId) { + this.chargeId = chargeId; + } @Override protected String method() { return POST; } - } - - /** - * The {@link RequestBuilder} class for retrieving all Charges that belong to an account. - */ - public static class ListRequestBuilder extends RequestBuilder> { - private ScopedList.Options options; @Override protected HttpUrl path() { - if (options == null) { - options = new ScopedList.Options(); - } + return buildUrl(Endpoint.API, "charges", chargeId, "mark_as_paid"); + } - return buildUrl(Endpoint.API, "charges", options); + @Override + protected ResponseType type() { + return new ResponseType<>(Charge.class); + } + } + + public static class ReverseRequestBuilder extends RequestBuilder { + private String chargeId; + public ReverseRequestBuilder(String chargeId) { + this.chargeId = chargeId; } @Override - protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + protected String method() { + return POST; } - public ListRequestBuilder options(ScopedList.Options options) { - this.options = options; - return this; + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "charges", chargeId, "reverse"); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Charge.class); } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/ChargeStatus.java b/src/main/java/co/omise/models/ChargeStatus.java index fb8acf37..42a4ba59 100644 --- a/src/main/java/co/omise/models/ChargeStatus.java +++ b/src/main/java/co/omise/models/ChargeStatus.java @@ -3,9 +3,16 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum ChargeStatus { - @JsonProperty("failed")Failed, - @JsonProperty("pending")Pending, - @JsonProperty("successful")Successful, - @JsonProperty("reversed")Reversed, - @JsonProperty("expired")Expired, -} + @JsonProperty("expired") + Expired, + @JsonProperty("failed") + Failed, + @JsonProperty("pending") + Pending, + @JsonProperty("reversed") + Reversed, + @JsonProperty("successful") + Successful, + @JsonProperty("unknown") + Unknown; +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Customer.java b/src/main/java/co/omise/models/Customer.java index f69b5871..787e0e7a 100644 --- a/src/main/java/co/omise/models/Customer.java +++ b/src/main/java/co/omise/models/Customer.java @@ -1,6 +1,7 @@ package co.omise.models; import co.omise.Endpoint; +import co.omise.models.schedules.Schedule; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; import com.fasterxml.jackson.annotation.JsonProperty; @@ -13,136 +14,100 @@ import java.util.Map; /** - * Represents Omise Customer object. + * Customer object * - * @see Charges API + * @see Customer API */ public class Customer extends Model { + private ScopedList cards; @JsonProperty("default_card") private String defaultCard; - private String email; private String description; + private String email; + private String location; private Map metadata; - private ScopedList cards; - public Customer() { + public ScopedList getCards() { + return this.cards; + } + + public void setCards(ScopedList cards) { + this.cards = cards; } public String getDefaultCard() { - return defaultCard; + return this.defaultCard; } public void setDefaultCard(String defaultCard) { this.defaultCard = defaultCard; } + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + public String getEmail() { - return email; + return this.email; } public void setEmail(String email) { this.email = email; } - public String getDescription() { - return description; + public String getLocation() { + return this.location; } - public void setDescription(String description) { - this.description = description; + public void setLocation(String location) { + this.location = location; } public Map getMetadata() { - return metadata; + return this.metadata; } public void setMetadata(Map metadata) { this.metadata = metadata; } - public ScopedList getCards() { - return cards; - } - - public void setCards(ScopedList cards) { - this.cards = cards; - } - - /** - * The {@link RequestBuilder} class for creating a Customer. - */ - public static class CreateRequestBuilder extends RequestBuilder { - @JsonProperty - private String email; - @JsonProperty - private String description; - @JsonProperty - private Map metadata; - @JsonProperty - private String card; + public static class DeleteRequestBuilder extends RequestBuilder { + private String customerId; + public DeleteRequestBuilder(String customerId) { + this.customerId = customerId; + } @Override protected String method() { - return POST; + return DELETE; } @Override protected HttpUrl path() { - return buildUrl(Endpoint.API, "customers"); - } - - @Override - protected RequestBody payload() throws IOException { - return serialize(); + return buildUrl(Endpoint.API, "customers", customerId); } @Override protected ResponseType type() { return new ResponseType<>(Customer.class); } - - public CreateRequestBuilder email(String email) { - this.email = email; - return this; - } - - public CreateRequestBuilder description(String description) { - this.description = description; - return this; - } - - public CreateRequestBuilder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - public CreateRequestBuilder metadata(String key, Object value) { - HashMap tempMap = new HashMap<>(); - if (metadata != null) { - tempMap.putAll(metadata); - } - tempMap.put(key, value); - - this.metadata = new HashMap<>(tempMap); - return this; - } - - public CreateRequestBuilder card(String card) { - this.card = card; - return this; - } } - /** - * The {@link RequestBuilder} class for retrieving a particular Customer. - */ public static class GetRequestBuilder extends RequestBuilder { private String customerId; - public GetRequestBuilder(String customerId) { this.customerId = customerId; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "customers", customerId); @@ -154,21 +119,19 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for updating a particular Customer. - */ public static class UpdateRequestBuilder extends RequestBuilder { private String customerId; @JsonProperty - private String email; + private String card; + @JsonProperty("default_card") + private String defaultCard; @JsonProperty private String description; @JsonProperty - private Map metadata; + private String email; @JsonProperty - private String card; - + private Map metadata; public UpdateRequestBuilder(String customerId) { this.customerId = customerId; } @@ -183,19 +146,18 @@ protected HttpUrl path() { return buildUrl(Endpoint.API, "customers", customerId); } - @Override - protected RequestBody payload() throws IOException { - return serialize(); - } - @Override protected ResponseType type() { return new ResponseType<>(Customer.class); } + public UpdateRequestBuilder card(String card) { + this.card = card; + return this; + } - public UpdateRequestBuilder email(String email) { - this.email = email; + public UpdateRequestBuilder defaultCard(String defaultCard) { + this.defaultCard = defaultCard; return this; } @@ -204,11 +166,21 @@ public UpdateRequestBuilder description(String description) { return this; } + public UpdateRequestBuilder email(String email) { + this.email = email; + return this; + } + public UpdateRequestBuilder metadata(Map metadata) { this.metadata = metadata; return this; } + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + public UpdateRequestBuilder metadata(String key, Object value) { HashMap tempMap = new HashMap<>(); if (metadata != null) { @@ -219,27 +191,57 @@ public UpdateRequestBuilder metadata(String key, Object value) { this.metadata = new HashMap<>(tempMap); return this; } + } - public UpdateRequestBuilder card(String card) { - this.card = card; + public static class ListRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "customers", serializer()) + .segments() + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; return this; } } + public static class CreateRequestBuilder extends RequestBuilder { - /** - * The {@link RequestBuilder} class for deleting a particular Customer. - */ - public static class DeleteRequestBuilder extends RequestBuilder { - private String customerId; + @JsonProperty + private String card; + @JsonProperty + private String description; + @JsonProperty + private String email; + @JsonProperty + private Map metadata; - public DeleteRequestBuilder(String customerId) { - this.customerId = customerId; + @Override + protected String method() { + return POST; } @Override protected HttpUrl path() { - return buildUrl(Endpoint.API, "customers", customerId); + return buildUrl(Endpoint.API, "customers"); } @Override @@ -247,34 +249,72 @@ protected ResponseType type() { return new ResponseType<>(Customer.class); } + public CreateRequestBuilder card(String card) { + this.card = card; + return this; + } + + public CreateRequestBuilder description(String description) { + this.description = description; + return this; + } + + public CreateRequestBuilder email(String email) { + this.email = email; + return this; + } + + public CreateRequestBuilder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + @Override - protected String method() { - return DELETE; + protected RequestBody payload() throws IOException { + return serialize(); + } + + public CreateRequestBuilder metadata(String key, Object value) { + HashMap tempMap = new HashMap<>(); + if (metadata != null) { + tempMap.putAll(metadata); + } + tempMap.put(key, value); + + this.metadata = new HashMap<>(tempMap); + return this; } } - /** - * The {@link RequestBuilder} class for retrieving all Customers that belong to an account. - */ - public static class ListRequestBuilder extends RequestBuilder> { + public static class ListSchedulesRequestBuilder extends RequestBuilder> { + private String customerId; private ScopedList.Options options; + public ListSchedulesRequestBuilder(String customerId) { + this.customerId = customerId; + } + + @Override + protected String method() { + return GET; + } @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - - return buildUrl(Endpoint.API, "customers", options); + return new HttpUrlBuilder(Endpoint.API, "customers", serializer()) + .segments(customerId, "schedules") + .params(options) + .build(); } @Override - protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); } - public ListRequestBuilder options(ScopedList.Options options) { + public ListSchedulesRequestBuilder options(ScopedList.Options options) { this.options = options; return this; } diff --git a/src/main/java/co/omise/models/Dispute.java b/src/main/java/co/omise/models/Dispute.java index 9a47e4d1..5b9f3b96 100644 --- a/src/main/java/co/omise/models/Dispute.java +++ b/src/main/java/co/omise/models/Dispute.java @@ -15,63 +15,71 @@ import java.util.Map; /** - * Represents Omise Dispute object. + * Dispute object * - * @see Disputes API + * @see Dispute API */ public class Dispute extends Model { + @JsonProperty("admin_message") + private String adminMessage; private long amount; + private String charge; + @JsonProperty("closed_at") + private DateTime closedAt; private String currency; - private DisputeStatus status; + private ScopedList documents; + @JsonProperty("funding_amount") + private long fundingAmount; + @JsonProperty("funding_currency") + private String fundingCurrency; + private String location; private String message; - private String charge; private Map metadata; - private List transactions; - private ScopedList documents; @JsonProperty("reason_code") private DisputeReasonCode reasonCode; @JsonProperty("reason_message") private String reasonMessage; - @JsonProperty("closed_at") - private DateTime closedDate; - @JsonProperty("funding_amount") - private long fundingAmount; - @JsonProperty("funding_currency") - private String fundingCurrency; + private DisputeStatus status; + private List transactions; - public Dispute() { + public String getAdminMessage() { + return this.adminMessage; + } + + public void setAdminMessage(String adminMessage) { + this.adminMessage = adminMessage; } public long getAmount() { - return amount; + return this.amount; } public void setAmount(long amount) { this.amount = amount; } - public String getCurrency() { - return currency; + public String getCharge() { + return this.charge; } - public void setCurrency(String currency) { - this.currency = currency; + public void setCharge(String charge) { + this.charge = charge; } - public DisputeStatus getStatus() { - return status; + public DateTime getClosedAt() { + return this.closedAt; } - public void setStatus(DisputeStatus status) { - this.status = status; + public void setClosedAt(DateTime closedAt) { + this.closedAt = closedAt; } - public String getMessage() { - return message; + public String getCurrency() { + return this.currency; } - public void setMessage(String message) { - this.message = message; + public void setCurrency(String currency) { + this.currency = currency; } public ScopedList getDocuments() { @@ -82,83 +90,88 @@ public void setDocuments(ScopedList documents) { this.documents = documents; } - public String getCharge() { - return charge; + public long getFundingAmount() { + return this.fundingAmount; } - public void setCharge(String charge) { - this.charge = charge; + public void setFundingAmount(long fundingAmount) { + this.fundingAmount = fundingAmount; } - public Map getMetadata() { - return metadata; + public String getFundingCurrency() { + return this.fundingCurrency; } - public void setMetadata(Map metadata) { - this.metadata = metadata; + public void setFundingCurrency(String fundingCurrency) { + this.fundingCurrency = fundingCurrency; } - public void setReasonCode(DisputeReasonCode reasonCode) { - this.reasonCode = reasonCode; + public String getLocation() { + return this.location; } - public DisputeReasonCode getReasonCode() { - return reasonCode; + public void setLocation(String location) { + this.location = location; } - public void setReasonMessage(String reasonMessage) { - this.reasonMessage = reasonMessage; + public String getMessage() { + return this.message; } - public String getReasonMessage() { - return reasonMessage; + public void setMessage(String message) { + this.message = message; } - public List getTransactions() { - return transactions; + public Map getMetadata() { + return this.metadata; } - public void setTransactions(List transactions) { - this.transactions = transactions; + public void setMetadata(Map metadata) { + this.metadata = metadata; } - public DateTime getClosedDate() { - return closedDate; + public DisputeReasonCode getReasonCode() { + return this.reasonCode; } - public void setClosedDate(DateTime closedDate) { - this.closedDate = closedDate; + public void setReasonCode(DisputeReasonCode reasonCode) { + this.reasonCode = reasonCode; } - public long getFundingAmount() { - return fundingAmount; + public String getReasonMessage() { + return this.reasonMessage; } - public void setFundingAmount(long fundingAmount) { - this.fundingAmount = fundingAmount; + public void setReasonMessage(String reasonMessage) { + this.reasonMessage = reasonMessage; } - public String getFundingCurrency() { - return fundingCurrency; + public DisputeStatus getStatus() { + return this.status; } - public void setFundingCurrency(String fundingCurrency) { - this.fundingCurrency = fundingCurrency; + public void setStatus(DisputeStatus status) { + this.status = status; } - /** - * The {@link RequestBuilder} class for retrieving a particular Dispute. - */ - public static class GetRequestBuilder extends RequestBuilder { - private String disputeId; + public List getTransactions() { + return this.transactions; + } - public GetRequestBuilder(String disputeId) { - this.disputeId = disputeId; + public void setTransactions(List transactions) { + this.transactions = transactions; + } + + public static class ClosedRequestBuilder extends RequestBuilder { + + @Override + protected String method() { + return GET; } @Override - protected HttpUrl path() throws IOException { - return buildUrl(Endpoint.API, "disputes", disputeId); + protected HttpUrl path() { + return buildUrl(Endpoint.API, "disputes", "closed"); } @Override @@ -167,30 +180,29 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for retrieving all Disputes. - */ public static class ListRequestBuilder extends RequestBuilder> { - - private ScopedList.Options options; private DisputeStatus status; + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - String status = this.status == null ? "" : this.status.name().toLowerCase(); return new HttpUrlBuilder(Endpoint.API, "disputes", serializer()) - .segments(status) - .params(options) - .build(); + .segments(this.status == null ? "" : this.status.name().toLowerCase()) + .params(options) + .build(); } @Override protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + return new ResponseType<>(new TypeReference>() {}); } public ListRequestBuilder options(ScopedList.Options options) { @@ -204,33 +216,83 @@ public ListRequestBuilder status(DisputeStatus status) { } } - /** - * The {@link RequestBuilder} class for updating a Dispute. - */ + public static class OpenRequestBuilder extends RequestBuilder { + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "disputes", "open"); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Dispute.class); + } + } + + public static class PendingRequestBuilder extends RequestBuilder { + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "disputes", "pending"); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Dispute.class); + } + } + + public static class GetRequestBuilder extends RequestBuilder { + private String disputeId; + public GetRequestBuilder(String disputeId) { + this.disputeId = disputeId; + } + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "disputes", disputeId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Dispute.class); + } + } + public static class UpdateRequestBuilder extends RequestBuilder { private String disputeId; + @JsonProperty private String message; @JsonProperty private Map metadata; - public UpdateRequestBuilder(String disputeId) { this.disputeId = disputeId; } - @Override - protected HttpUrl path() throws IOException { - return buildUrl(Endpoint.API, "disputes", disputeId); - } - @Override protected String method() { return PATCH; } @Override - protected RequestBody payload() throws IOException { - return serialize(); + protected HttpUrl path() { + return buildUrl(Endpoint.API, "disputes", disputeId); } @Override @@ -248,15 +310,99 @@ public UpdateRequestBuilder metadata(Map metadata) { return this; } + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + public UpdateRequestBuilder metadata(String key, Object value) { HashMap tempMap = new HashMap<>(); if (metadata != null) { tempMap.putAll(metadata); } tempMap.put(key, value); + this.metadata = new HashMap<>(tempMap); return this; } } -} + public static class CloseRequestBuilder extends RequestBuilder { + private String disputeId; + + @JsonProperty + private DisputeStatus status; + public CloseRequestBuilder(String disputeId) { + this.disputeId = disputeId; + } + + @Override + protected String method() { + return PATCH; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "disputes", disputeId, "close"); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Dispute.class); + } + + public CloseRequestBuilder status(DisputeStatus status) { + this.status = status; + return this; + } + + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + } + + public static class AcceptRequestBuilder extends RequestBuilder { + private String disputeId; + public AcceptRequestBuilder(String disputeId) { + this.disputeId = disputeId; + } + + @Override + protected String method() { + return PATCH; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "disputes", disputeId, "accept"); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Dispute.class); + } + } + + public static class CreateDisputeRequestBuilder extends RequestBuilder { + private String chargeId; + public CreateDisputeRequestBuilder(String chargeId) { + this.chargeId = chargeId; + } + + @Override + protected String method() { + return POST; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "charges", chargeId, "disputes"); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Dispute.class); + } + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/DisputeReasonCode.java b/src/main/java/co/omise/models/DisputeReasonCode.java index 1d8f917d..abf9b253 100644 --- a/src/main/java/co/omise/models/DisputeReasonCode.java +++ b/src/main/java/co/omise/models/DisputeReasonCode.java @@ -3,20 +3,36 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum DisputeReasonCode { - @JsonProperty("cancelled_recurring_transaction")CancelledRecurringTransaction, - @JsonProperty("credit_not_processed")CreditNotProcessed, - @JsonProperty("duplicate_processing")DuplicateProcessing, - @JsonProperty("expired_card")ExpiredCard, - @JsonProperty("goods_or_services_not_provided")GoodsOrServicesNotProvided, - @JsonProperty("incorrect_currency")IncorrectCurrency, - @JsonProperty("incorrect_transaction_amount")IncorrectTransactionAmount, - @JsonProperty("late_presentment")LatePresentment, - @JsonProperty("non_matching_account_number")NonMatchingAccountNumber, - @JsonProperty("not_as_described_or_defective_merchandise")NotAsDescribedOrDefectiveMerchandise, - @JsonProperty("not_available")NotAvailable, - @JsonProperty("not_recorded")NotRecorded, - @JsonProperty("other")Other, - @JsonProperty("paid_by_other_means")PaidByOtherMeans, - @JsonProperty("transaction_not_recognised")TransactionNotRecognised, - @JsonProperty("unauthorized_charge")UnauthorizedCharge; + @JsonProperty("cancelled_recurring_transaction") + CancelledRecurringTransaction, + @JsonProperty("credit_not_processed") + CreditNotProcessed, + @JsonProperty("duplicate_processing") + DuplicateProcessing, + @JsonProperty("expired_card") + ExpiredCard, + @JsonProperty("goods_or_services_not_provided") + GoodsOrServicesNotProvided, + @JsonProperty("incorrect_currency") + IncorrectCurrency, + @JsonProperty("incorrect_transaction_amount") + IncorrectTransactionAmount, + @JsonProperty("late_presentment") + LatePresentment, + @JsonProperty("non_matching_account_number") + NonMatchingAccountNumber, + @JsonProperty("not_as_described_or_defective_merchandise") + NotAsDescribedOrDefectiveMerchandise, + @JsonProperty("not_available") + NotAvailable, + @JsonProperty("not_recorded") + NotRecorded, + @JsonProperty("other") + Other, + @JsonProperty("paid_by_other_means") + PaidByOtherMeans, + @JsonProperty("transaction_not_recognised") + TransactionNotRecognised, + @JsonProperty("unauthorized_charge") + UnauthorizedCharge; } \ No newline at end of file diff --git a/src/main/java/co/omise/models/DisputeStatus.java b/src/main/java/co/omise/models/DisputeStatus.java index f82ebc1f..8a94b6d6 100644 --- a/src/main/java/co/omise/models/DisputeStatus.java +++ b/src/main/java/co/omise/models/DisputeStatus.java @@ -3,9 +3,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum DisputeStatus { - @JsonProperty("open")Open, - @JsonProperty("pending")Pending, - @JsonProperty("won")Won, - @JsonProperty("lost")Lost, - @JsonProperty("closed")Closed, -} + @JsonProperty("closed") + Closed, + @JsonProperty("lost") + Lost, + @JsonProperty("open") + Open, + @JsonProperty("pending") + Pending, + @JsonProperty("won") + Won; +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Document.java b/src/main/java/co/omise/models/Document.java index 67e02444..abe9624c 100644 --- a/src/main/java/co/omise/models/Document.java +++ b/src/main/java/co/omise/models/Document.java @@ -48,7 +48,7 @@ public void setLocation(String location) { public static class DeleteRequestBuilder extends RequestBuilder { private String disputeId; private String documentId; - public DeleteRequestBuilder(String documentId, String disputeId) { + public DeleteRequestBuilder(String disputeId, String documentId) { this.disputeId = disputeId; this.documentId = documentId; } @@ -72,7 +72,7 @@ protected ResponseType type() { public static class GetRequestBuilder extends RequestBuilder { private String disputeId; private String documentId; - public GetRequestBuilder(String documentId, String disputeId) { + public GetRequestBuilder(String disputeId, String documentId) { this.disputeId = disputeId; this.documentId = documentId; } @@ -111,9 +111,9 @@ protected HttpUrl path() { options = new ScopedList.Options(); } return new HttpUrlBuilder(Endpoint.API, "disputes", serializer()) - .segments(disputeId, "documents") - .params(options) - .build(); + .segments(disputeId, "documents") + .params(options) + .build(); } @Override diff --git a/src/main/java/co/omise/models/Event.java b/src/main/java/co/omise/models/Event.java index 4af3815c..15dd9002 100644 --- a/src/main/java/co/omise/models/Event.java +++ b/src/main/java/co/omise/models/Event.java @@ -3,48 +3,69 @@ import co.omise.Endpoint; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; import okhttp3.HttpUrl; +import okhttp3.RequestBody; + +import java.io.IOException; +import java.util.List; /** - * Represents Omise Event object. + * Event object * - * @see Events API + * @see Event API */ public class Event extends Model { + private T data; private String key; + private String location; + @JsonProperty("webhook_deliveries") + private List webhookDeliveries; - private T data; + public T getData() { + return this.data; + } - public Event() { + public void setData(T data) { + this.data = data; } public String getKey() { - return key; + return this.key; } public void setKey(String key) { this.key = key; } - public T getData() { - return data; + public String getLocation() { + return this.location; } - public void setData(T data) { - this.data = data; + public void setLocation(String location) { + this.location = location; + } + + public List getWebhookDeliveries() { + return this.webhookDeliveries; + } + + public void setWebhookDeliveries(List webhookDeliveries) { + this.webhookDeliveries = webhookDeliveries; } - /** - * The {@link RequestBuilder} class for retrieving a particular Event. - */ public static class GetRequestBuilder extends RequestBuilder { private String eventId; - public GetRequestBuilder(String eventId) { this.eventId = eventId; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "events", eventId); @@ -56,25 +77,28 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for retrieving all Events that belong to an account. - */ public static class ListRequestBuilder extends RequestBuilder> { private ScopedList.Options options; + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - - return buildUrl(Endpoint.API, "events", options); + return new HttpUrlBuilder(Endpoint.API, "events", serializer()) + .segments() + .params(options) + .build(); } @Override protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + return new ResponseType<>(new TypeReference>() {}); } public ListRequestBuilder options(ScopedList.Options options) { diff --git a/src/main/java/co/omise/models/Export.java b/src/main/java/co/omise/models/Export.java new file mode 100644 index 00000000..ea022267 --- /dev/null +++ b/src/main/java/co/omise/models/Export.java @@ -0,0 +1,103 @@ +package co.omise.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Map; + +public class Export extends Model { + @JsonProperty("download_uri") + private String downloadUri; + @JsonProperty("file_type") + private String fileType; + @JsonProperty("filter_params") + private Map filterParams; + @JsonProperty("filter_type") + private String filterType; + private String location; + private String name; + @JsonProperty("object_type") + private String objectType; + private long rows; + private String status; + private String team; + + public String getDownloadUri() { + return this.downloadUri; + } + + public void setDownloadUri(String downloadUri) { + this.downloadUri = downloadUri; + } + + public String getFileType() { + return this.fileType; + } + + public void setFileType(String fileType) { + this.fileType = fileType; + } + + public Map getFilterParams() { + return this.filterParams; + } + + public void setFilterParams(Map filterParams) { + this.filterParams = filterParams; + } + + public String getFilterType() { + return this.filterType; + } + + public void setFilterType(String filterType) { + this.filterType = filterType; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getObjectType() { + return this.objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public long getRows() { + return this.rows; + } + + public void setRows(long rows) { + this.rows = rows; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTeam() { + return this.team; + } + + public void setTeam(String team) { + this.team = team; + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/FlowType.java b/src/main/java/co/omise/models/FlowType.java index 01de5a75..e7edce01 100644 --- a/src/main/java/co/omise/models/FlowType.java +++ b/src/main/java/co/omise/models/FlowType.java @@ -1,14 +1,15 @@ package co.omise.models; - import com.fasterxml.jackson.annotation.JsonProperty; public enum FlowType { - @JsonProperty("redirect") Redirect, - @JsonProperty("offline") Offline; + @JsonProperty("offline") + Offline, + @JsonProperty("redirect") + Redirect; @Override public String toString() { return super.toString().toLowerCase(); } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Forex.java b/src/main/java/co/omise/models/Forex.java index f44ff99b..a2554c77 100644 --- a/src/main/java/co/omise/models/Forex.java +++ b/src/main/java/co/omise/models/Forex.java @@ -3,50 +3,66 @@ import co.omise.Endpoint; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; +import com.fasterxml.jackson.annotation.JsonProperty; import okhttp3.HttpUrl; +import okhttp3.RequestBody; +import java.io.IOException; + +/** + * Forex object + * + * @see Forex API + */ public class Forex extends Model { - private double rate; private String base; + private String location; private String quote; - - public Forex() { - } + private Double rate; public String getBase() { - return base; + return this.base; } public void setBase(String base) { this.base = base; } + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + public String getQuote() { - return quote; + return this.quote; } public void setQuote(String quote) { this.quote = quote; } - public double getRate() { - return rate; + public Double getRate() { + return this.rate; } - public void setRate(double rate) { + public void setRate(Double rate) { this.rate = rate; } - /** - * The {@link RequestBuilder} class for getting the exchange rate of a particular currency. - */ public static class GetRequestBuilder extends RequestBuilder { private String currency; - public GetRequestBuilder(String currency) { this.currency = currency; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "forex", currency); @@ -57,4 +73,4 @@ protected ResponseType type() { return new ResponseType<>(Forex.class); } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Link.java b/src/main/java/co/omise/models/Link.java index 0c03511a..1de5969c 100644 --- a/src/main/java/co/omise/models/Link.java +++ b/src/main/java/co/omise/models/Link.java @@ -7,106 +7,195 @@ import com.fasterxml.jackson.core.type.TypeReference; import okhttp3.HttpUrl; import okhttp3.RequestBody; +import org.joda.time.DateTime; import java.io.IOException; /** - * Represents Omise Link object. + * Links object * - * @see Link API + * @see Links API */ public class Link extends Model { private long amount; + private ScopedList charges; private String currency; - private boolean used; - private boolean multiple; - private String title; private String description; - private ScopedList charges; + private String location; + private boolean multiple; @JsonProperty("payment_uri") private String paymentUri; - - public Link() { - } + private String title; + private boolean used; + @JsonProperty("used_at") + private DateTime usedAt; public long getAmount() { - return amount; + return this.amount; } public void setAmount(long amount) { this.amount = amount; } + public ScopedList getCharges() { + return this.charges; + } + + public void setCharges(ScopedList charges) { + this.charges = charges; + } + public String getCurrency() { - return currency; + return this.currency; } public void setCurrency(String currency) { this.currency = currency; } - public boolean isUsed() { - return used; + public String getDescription() { + return this.description; } - public void setUsed(boolean used) { - this.used = used; + public void setDescription(String description) { + this.description = description; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; } public boolean isMultiple() { - return multiple; + return this.multiple; } public void setMultiple(boolean multiple) { this.multiple = multiple; } + public String getPaymentUri() { + return this.paymentUri; + } + + public void setPaymentUri(String paymentUri) { + this.paymentUri = paymentUri; + } + public String getTitle() { - return title; + return this.title; } public void setTitle(String title) { this.title = title; } - public String getDescription() { - return description; + public boolean isUsed() { + return this.used; } - public void setDescription(String description) { - this.description = description; + public void setUsed(boolean used) { + this.used = used; } - public ScopedList getCharges() { - return charges; + public DateTime getUsedAt() { + return this.usedAt; } - public void setCharges(ScopedList charges) { - this.charges = charges; + public void setUsedAt(DateTime usedAt) { + this.usedAt = usedAt; } - public String getPaymentUri() { - return paymentUri; + public static class DeleteRequestBuilder extends RequestBuilder { + private String linkId; + public DeleteRequestBuilder(String linkId) { + this.linkId = linkId; + } + + @Override + protected String method() { + return DELETE; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "links", linkId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Link.class); + } } - public void setPaymentUri(String paymentUri) { - this.paymentUri = paymentUri; + public static class GetRequestBuilder extends RequestBuilder { + private String linkId; + public GetRequestBuilder(String linkId) { + this.linkId = linkId; + } + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "links", linkId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Link.class); + } + } + + public static class ListRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "links", serializer()) + .segments() + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; + } } - /** - * The {@link RequestBuilder} class for creating a Link. - */ public static class CreateRequestBuilder extends RequestBuilder { + @JsonProperty private long amount; @JsonProperty private String currency; @JsonProperty - private String title; - @JsonProperty private String description; @JsonProperty - private Boolean multiple; + private boolean multiple; + @JsonProperty + private String title; @Override protected String method() { @@ -118,11 +207,6 @@ protected HttpUrl path() { return buildUrl(Endpoint.API, "links"); } - @Override - protected RequestBody payload() throws IOException { - return serialize(); - } - @Override protected ResponseType type() { return new ResponseType<>(Link.class); @@ -138,11 +222,6 @@ public CreateRequestBuilder currency(String currency) { return this; } - public CreateRequestBuilder title(String title) { - this.title = title; - return this; - } - public CreateRequestBuilder description(String description) { this.description = description; return this; @@ -152,50 +231,47 @@ public CreateRequestBuilder multiple(boolean multiple) { this.multiple = multiple; return this; } - } - /** - * The {@link RequestBuilder} class for retrieving a particular Link. - */ - public static class GetRequestBuilder extends RequestBuilder { - private String linkId; - - public GetRequestBuilder(String linkId) { - this.linkId = linkId; - } - - @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "links", linkId); + public CreateRequestBuilder title(String title) { + this.title = title; + return this; } @Override - protected ResponseType type() { - return new ResponseType<>(Link.class); + protected RequestBody payload() throws IOException { + return serialize(); } } - /** - * The {@link RequestBuilder} class for retrieving all Links that belong to an account. - */ - public static class ListRequestBuilder extends RequestBuilder> { + public static class ListChargesRequestBuilder extends RequestBuilder> { + private String linkId; private ScopedList.Options options; + public ListChargesRequestBuilder(String linkId) { + this.linkId = linkId; + } + + @Override + protected String method() { + return GET; + } @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - - return buildUrl(Endpoint.API, "links", options); + return new HttpUrlBuilder(Endpoint.API, "links", serializer()) + .segments(linkId, "charges") + .params(options) + .build(); } @Override - protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() {}); + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); } - public ListRequestBuilder options(ScopedList.Options options) { + public ListChargesRequestBuilder options(ScopedList.Options options) { this.options = options; return this; } diff --git a/src/main/java/co/omise/models/MfaRecoveryCodes.java b/src/main/java/co/omise/models/MfaRecoveryCodes.java new file mode 100644 index 00000000..aaf995e6 --- /dev/null +++ b/src/main/java/co/omise/models/MfaRecoveryCodes.java @@ -0,0 +1,15 @@ +package co.omise.models; + +import java.util.List; + +public class MfaRecoveryCodes extends Model { + private List codes; + + public List getCodes() { + return this.codes; + } + + public void setCodes(List codes) { + this.codes = codes; + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/ModelTypeResolver.java b/src/main/java/co/omise/models/ModelTypeResolver.java index 12653b70..f221738b 100644 --- a/src/main/java/co/omise/models/ModelTypeResolver.java +++ b/src/main/java/co/omise/models/ModelTypeResolver.java @@ -1,7 +1,10 @@ package co.omise.models; +import co.omise.models.schedules.ChargeSchedule; import co.omise.models.schedules.Occurrence; import co.omise.models.schedules.Schedule; +import co.omise.models.schedules.TransferSchedule; + import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.DatabindContext; import com.fasterxml.jackson.databind.JavaType; @@ -22,6 +25,8 @@ static Map getKnownTypes() { types.put("bank_account", BankAccount.class); types.put("card", Card.class); types.put("charge", Charge.class); + types.put("scheduled_charge", ChargeSchedule.class); + types.put("scheduled_transfer", TransferSchedule.class); types.put("customer", Customer.class); types.put("dispute", Dispute.class); types.put("event", Event.class); @@ -40,6 +45,7 @@ static Map getKnownTypes() { types.put("payment_method", PaymentMethod.class); types.put("barcode", Barcode.class); types.put("document", Document.class); + types.put("webhook_delivery", WebhookDelivery.class); } return Collections.unmodifiableMap(types); } diff --git a/src/main/java/co/omise/models/Ordering.java b/src/main/java/co/omise/models/Ordering.java index de0a5c56..5d2d2316 100644 --- a/src/main/java/co/omise/models/Ordering.java +++ b/src/main/java/co/omise/models/Ordering.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum Ordering { - @JsonProperty("chronological")Chronological, - @JsonProperty("reverse_chronological")ReverseChronological, -} + @JsonProperty("chronological") + Chronological, + @JsonProperty("reverse_chronological") + ReverseChronological; +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/PaymentMethod.java b/src/main/java/co/omise/models/PaymentMethod.java index 01521e16..f9f7f51b 100644 --- a/src/main/java/co/omise/models/PaymentMethod.java +++ b/src/main/java/co/omise/models/PaymentMethod.java @@ -4,53 +4,43 @@ import java.util.List; -/** - * Represents Omise Payment method object that is found in the response for the Capability API - * - * @see Capability API - */ public class PaymentMethod extends Model { - private String name; - private List currencies; @JsonProperty("card_brands") private List cardBrands; + private List currencies; @JsonProperty("installment_terms") private List installmentTerms; + private String name; - public PaymentMethod() { - } - - public String getName() { - return name; + public List getCardBrands() { + return this.cardBrands; } - public void setName(String name) { - this.name = name; + public void setCardBrands(List cardBrands) { + this.cardBrands = cardBrands; } public List getCurrencies() { - return currencies; + return this.currencies; } public void setCurrencies(List currencies) { this.currencies = currencies; } - public List getCardBrands() { - return cardBrands; - } - - public void setCardBrands(List cardBrands) { - this.cardBrands = cardBrands; - } - public List getInstallmentTerms() { - return installmentTerms; + return this.installmentTerms; } public void setInstallmentTerms(List installmentTerms) { this.installmentTerms = installmentTerms; } + public String getName() { + return this.name; + } -} + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/PlatformFee.java b/src/main/java/co/omise/models/PlatformFee.java new file mode 100644 index 00000000..14676153 --- /dev/null +++ b/src/main/java/co/omise/models/PlatformFee.java @@ -0,0 +1,59 @@ +package co.omise.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class PlatformFee { + private long amount; + private long fixed; + private Double percentage; + + public long getAmount() { + return this.amount; + } + + public void setAmount(long amount) { + this.amount = amount; + } + + public long getFixed() { + return this.fixed; + } + + public void setFixed(long fixed) { + this.fixed = fixed; + } + + public Double getPercentage() { + return this.percentage; + } + + public void setPercentage(Double percentage) { + this.percentage = percentage; + } + + public static class Params extends co.omise.models.Params { + @JsonProperty + private long amount; + + @JsonProperty + private long fixed; + + @JsonProperty + private Double percentage; + + public Params amount(long amount) { + this.amount = amount; + return this; + } + + public Params fixed(long fixed) { + this.fixed = fixed; + return this; + } + + public Params percentage(Double percentage) { + this.percentage = percentage; + return this; + } + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/QrCode.java b/src/main/java/co/omise/models/QrCode.java new file mode 100644 index 00000000..971931e8 --- /dev/null +++ b/src/main/java/co/omise/models/QrCode.java @@ -0,0 +1,34 @@ +package co.omise.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class QrCode extends Model { + private String email; + @JsonProperty("mfa_provisioning_uri") + private String mfaProvisioningUri; + private String secret; + + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getMfaProvisioningUri() { + return this.mfaProvisioningUri; + } + + public void setMfaProvisioningUri(String mfaProvisioningUri) { + this.mfaProvisioningUri = mfaProvisioningUri; + } + + public String getSecret() { + return this.secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Receipt.java b/src/main/java/co/omise/models/Receipt.java index 81d17e91..64342613 100644 --- a/src/main/java/co/omise/models/Receipt.java +++ b/src/main/java/co/omise/models/Receipt.java @@ -6,271 +6,243 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; import okhttp3.HttpUrl; +import okhttp3.RequestBody; import org.joda.time.LocalDate; +import java.io.IOException; + /** - * Represents Omise Receipt object. + * Receipt object * - * @see Receipts API + * @see Receipt API */ -/* -number string The receipt number. -customer_name string The customer's name. -customer_address string The customer's address. -customer_tax_id string The customer's tax id. -customer_email string The customer's email. -customer_statement_name string The customer's statement name. -company_name string Omise company name -company_address string Omise address -company_tax_id string Omise tax id -charge_fee integer The charge fee in the smallest currency unit (e.g. satang, cent). -voided_fee integer The voided fee in the smallest currency unit (e.g. satang, cent). -transfer_fee integer The transfer fee in the smallest currency unit (e.g. satang, cent). -subtotal integer The result of (charge_fee - voided_fee) + transfer_fee. -vat integer The Value-Added Tax of subtotal. -wht integer The Withholding Tax of subtotal. -total integer The total amount in the smallest currency unit (e.g. satang, cent, ...). -credit_note boolean Whether this is a negative (true) or positive (false) fee subunit. -currency string The currency as its lower-cased international 3-letter code, defined by the ISO 4217 standard.*/ public class Receipt extends Model { - private String number; - @JsonProperty("customer_name") - private String customerName; - @JsonProperty("customer_address") - private String customerAddress; - @JsonProperty("customer_tax_id") - private String customerTaxId; - @JsonProperty("customer_email") - private String customerEmail; - @JsonProperty("customer_statement") - private String customerStatement; - @JsonProperty("company_name") - private String companyName; + @JsonProperty("adjustment_transaction") + private Transaction adjustmentTransaction; + @JsonProperty("charge_fee") + private long chargeFee; @JsonProperty("company_address") private String companyAddress; + @JsonProperty("company_name") + private String companyName; @JsonProperty("company_tax_id") private String companyTaxId; - @JsonProperty("charge_fee") - private long chargeFee; - @JsonProperty("voided_fee") - private long voidedFee; - @JsonProperty("transfer_fee") - private long transferFee; - private long subtotal; - private long vat; - private long wht; - private long total; @JsonProperty("credit_note") private boolean creditNote; private String currency; - @JsonProperty("issued_on") - private LocalDate issuedDate; + @JsonProperty("customer_address") + private String customerAddress; + @JsonProperty("customer_email") + private String customerEmail; + @JsonProperty("customer_name") + private String customerName; @JsonProperty("customer_statement_name") private String customerStatementName; + @JsonProperty("customer_tax_id") + private String customerTaxId; + @JsonProperty("issued_on") + private LocalDate issuedOn; + private String location; + private String number; + private long subtotal; + private long total; + @JsonProperty("transfer_fee") + private long transferFee; + private long vat; + @JsonProperty("voided_fee") + private long voidedFee; + private long wht; - public Receipt() { + public Transaction getAdjustmentTransaction() { + return this.adjustmentTransaction; } - public LocalDate getIssuedDate() { - return issuedDate; + public void setAdjustmentTransaction(Transaction adjustmentTransaction) { + this.adjustmentTransaction = adjustmentTransaction; } - public void setIssuedDate(LocalDate issuedDate) { - this.issuedDate = issuedDate; + public long getChargeFee() { + return this.chargeFee; } - public String getCustomerStatementName() { - return customerStatementName; + public void setChargeFee(long chargeFee) { + this.chargeFee = chargeFee; } - public void setCustomerStatementName(String customerStatementName) { - this.customerStatementName = customerStatementName; + public String getCompanyAddress() { + return this.companyAddress; } - public String getNumber() { - return number; + public void setCompanyAddress(String companyAddress) { + this.companyAddress = companyAddress; } - public void setNumber(String number) { - this.number = number; + public String getCompanyName() { + return this.companyName; } - public String getCustomerName() { - return customerName; + public void setCompanyName(String companyName) { + this.companyName = companyName; } - public void setCustomerName(String customerName) { - this.customerName = customerName; + public String getCompanyTaxId() { + return this.companyTaxId; } - public String getCustomerAddress() { - return customerAddress; + public void setCompanyTaxId(String companyTaxId) { + this.companyTaxId = companyTaxId; } - public void setCustomerAddress(String customerAddress) { - this.customerAddress = customerAddress; + public boolean isCreditNote() { + return this.creditNote; } - public String getCustomerTaxId() { - return customerTaxId; + public void setCreditNote(boolean creditNote) { + this.creditNote = creditNote; } - public void setCustomerTaxId(String customerTaxId) { - this.customerTaxId = customerTaxId; + public String getCurrency() { + return this.currency; } - public String getCustomerEmail() { - return customerEmail; + public void setCurrency(String currency) { + this.currency = currency; } - public void setCustomerEmail(String customerEmail) { - this.customerEmail = customerEmail; + public String getCustomerAddress() { + return this.customerAddress; } - public String getCustomerStatement() { - return customerStatement; + public void setCustomerAddress(String customerAddress) { + this.customerAddress = customerAddress; } - public void setCustomerStatement(String customerStatement) { - this.customerStatement = customerStatement; + public String getCustomerEmail() { + return this.customerEmail; } - public String getCompanyName() { - return companyName; + public void setCustomerEmail(String customerEmail) { + this.customerEmail = customerEmail; } - public void setCompanyName(String companyName) { - this.companyName = companyName; + public String getCustomerName() { + return this.customerName; } - public String getCompanyAddress() { - return companyAddress; + public void setCustomerName(String customerName) { + this.customerName = customerName; } - public void setCompanyAddress(String companyAddress) { - this.companyAddress = companyAddress; + public String getCustomerStatementName() { + return this.customerStatementName; } - public String getCompanyTaxId() { - return companyTaxId; + public void setCustomerStatementName(String customerStatementName) { + this.customerStatementName = customerStatementName; } - public void setCompanyTaxId(String companyTaxId) { - this.companyTaxId = companyTaxId; + public String getCustomerTaxId() { + return this.customerTaxId; } - public long getChargeFee() { - return chargeFee; + public void setCustomerTaxId(String customerTaxId) { + this.customerTaxId = customerTaxId; } - public void setChargeFee(long chargeFee) { - this.chargeFee = chargeFee; + public LocalDate IssuedOn() { + return this.issuedOn; } - public long getVoidedFee() { - return voidedFee; + public void setIssuedOn(LocalDate issuedOn) { + this.issuedOn = issuedOn; } - public void setVoidedFee(long voidedFee) { - this.voidedFee = voidedFee; + public String getLocation() { + return this.location; } - public long getTransferFee() { - return transferFee; + public void setLocation(String location) { + this.location = location; } - public void setTransferFee(long transferFee) { - this.transferFee = transferFee; + public String getNumber() { + return this.number; + } + + public void setNumber(String number) { + this.number = number; } public long getSubtotal() { - return subtotal; + return this.subtotal; } public void setSubtotal(long subtotal) { this.subtotal = subtotal; } - public long getVat() { - return vat; + public long getTotal() { + return this.total; } - public void setVat(long vat) { - this.vat = vat; + public void setTotal(long total) { + this.total = total; } - public long getWht() { - return wht; + public long getTransferFee() { + return this.transferFee; } - public void setWht(long wht) { - this.wht = wht; + public void setTransferFee(long transferFee) { + this.transferFee = transferFee; } - public long getTotal() { - return total; + public long getVat() { + return this.vat; } - public void setTotal(long total) { - this.total = total; + public void setVat(long vat) { + this.vat = vat; } - public boolean isCreditNote() { - return creditNote; + public long getVoidedFee() { + return this.voidedFee; } - public void setCreditNote(boolean creditNote) { - this.creditNote = creditNote; + public void setVoidedFee(long voidedFee) { + this.voidedFee = voidedFee; } - public String getCurrency() { - return currency; + public long getWht() { + return this.wht; } - public void setCurrency(String currency) { - this.currency = currency; + public void setWht(long wht) { + this.wht = wht; } - /** - * The {@link RequestBuilder} class for retrieving a particular Receipt. - */ - public static class GetRequestBuilder extends RequestBuilder { - private String receiptId; - - public GetRequestBuilder(String receiptId) { - this.receiptId = receiptId; - } + public static class ListRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "receipts", receiptId); + protected String method() { + return GET; } - @Override - protected ResponseType type() { - return new ResponseType<>(Receipt.class); - } - } - - /** - * The {@link RequestBuilder} class for retrieving all Receipts that belong to an account. - */ - public static class ListRequestBuilder extends RequestBuilder> { - private ScopedList.Options options; - @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - - return buildUrl(Endpoint.API, "receipts", options); + return new HttpUrlBuilder(Endpoint.API, "receipts", serializer()) + .segments() + .params(options) + .build(); } @Override protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + return new ResponseType<>(new TypeReference>() {}); } public ListRequestBuilder options(ScopedList.Options options) { @@ -278,4 +250,26 @@ public ListRequestBuilder options(ScopedList.Options options) { return this; } } + + public static class GetRequestBuilder extends RequestBuilder { + private String receiptId; + public GetRequestBuilder(String receiptId) { + this.receiptId = receiptId; + } + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "receipts", receiptId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Receipt.class); + } + } } \ No newline at end of file diff --git a/src/main/java/co/omise/models/Recipient.java b/src/main/java/co/omise/models/Recipient.java index 3e1bb036..73c769f8 100644 --- a/src/main/java/co/omise/models/Recipient.java +++ b/src/main/java/co/omise/models/Recipient.java @@ -1,149 +1,241 @@ package co.omise.models; import co.omise.Endpoint; +import co.omise.models.schedules.Schedule; +import co.omise.models.schedules.TransferSchedule; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; import okhttp3.HttpUrl; import okhttp3.RequestBody; +import org.joda.time.DateTime; import java.io.IOException; +import java.util.HashMap; import java.util.Map; /** - * Represents Omise Recipient object. + * Recipient object * - * @see Recipients API + * @see Recipient API */ public class Recipient extends Model { - private boolean verified; + @JsonProperty("activated_at") + private DateTime activatedAt; private boolean active; - private String name; - private String email; - private String description; - private RecipientType type; - @JsonProperty("tax_id") - private String taxId; @JsonProperty("bank_account") private BankAccount bankAccount; + @JsonProperty("default") + private boolean isDefault; + private String description; + private String email; @JsonProperty("failure_code") private RecipientFailureCode failureCode; + private String location; private Map metadata; + private String name; + private String schedule; + @JsonProperty("tax_id") + private String taxId; + private RecipientType type; + private boolean verified; + @JsonProperty("verified_at") + private DateTime verifiedAt; - public Recipient() { - } - - public boolean isVerified() { - return verified; + public DateTime getActivatedAt() { + return this.activatedAt; } - public void setVerified(boolean verified) { - this.verified = verified; + public void setActivatedAt(DateTime activatedAt) { + this.activatedAt = activatedAt; } public boolean isActive() { - return active; + return this.active; } public void setActive(boolean active) { this.active = active; } - public String getName() { - return name; + public BankAccount getBankAccount() { + return this.bankAccount; } - public void setName(String name) { - this.name = name; + public void setBankAccount(BankAccount bankAccount) { + this.bankAccount = bankAccount; } - public String getEmail() { - return email; + public boolean IsDefault() { + return this.isDefault; } - public void setEmail(String email) { - this.email = email; + public void setIsDefault(boolean isDefault) { + this.isDefault = isDefault; } public String getDescription() { - return description; + return this.description; } public void setDescription(String description) { this.description = description; } - public RecipientType getType() { - return type; + public String getEmail() { + return this.email; } - public void setType(RecipientType type) { - this.type = type; + public void setEmail(String email) { + this.email = email; + } + + public RecipientFailureCode getFailureCode() { + return this.failureCode; + } + + public void setFailureCode(RecipientFailureCode failureCode) { + this.failureCode = failureCode; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public Map getMetadata() { + return this.metadata; + } + + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSchedule() { + return this.schedule; + } + + public void setSchedule(String schedule) { + this.schedule = schedule; } public String getTaxId() { - return taxId; + return this.taxId; } public void setTaxId(String taxId) { this.taxId = taxId; } - public BankAccount getBankAccount() { - return bankAccount; + public RecipientType getType() { + return this.type; } - public void setBankAccount(BankAccount bankAccount) { - this.bankAccount = bankAccount; + public void setType(RecipientType type) { + this.type = type; } - public RecipientFailureCode getFailureCode() { - return this.failureCode; + public boolean isVerified() { + return this.verified; } - public void setFailureCode(RecipientFailureCode failureCode) { - this.failureCode = failureCode; + public void setVerified(boolean verified) { + this.verified = verified; } - public Map getMetadata() { - return metadata; + public DateTime getVerifiedAt() { + return this.verifiedAt; } - public void setMetadata(Map metadata) { - this.metadata = metadata; + public void setVerifiedAt(DateTime verifiedAt) { + this.verifiedAt = verifiedAt; } - /** - * The {@link RequestBuilder} class for creating a Recipient. - */ - public static class CreateRequestBuilder extends RequestBuilder { + public static class DeleteRequestBuilder extends RequestBuilder { + private String recipientId; + public DeleteRequestBuilder(String recipientId) { + this.recipientId = recipientId; + } + + @Override + protected String method() { + return DELETE; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "recipients", recipientId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Recipient.class); + } + } + + public static class GetRequestBuilder extends RequestBuilder { + private String recipientId; + public GetRequestBuilder(String recipientId) { + this.recipientId = recipientId; + } + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "recipients", recipientId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Recipient.class); + } + } + + public static class UpdateRequestBuilder extends RequestBuilder { + private String recipientId; + @JsonProperty("bank_account") private BankAccount.Params bankAccount; @JsonProperty - private String name; + private String description; @JsonProperty private String email; @JsonProperty - private String description; - @JsonProperty - private RecipientType type; + private Map metadata; @JsonProperty + private String name; + @JsonProperty("tax_id") private String taxId; + @JsonProperty + private RecipientType type; + public UpdateRequestBuilder(String recipientId) { + this.recipientId = recipientId; + } @Override protected String method() { - return POST; + return PATCH; } @Override protected HttpUrl path() { - return buildUrl(Endpoint.API, "recipients"); - } - - @Override - protected RequestBody payload() throws IOException { - return serialize(); + return buildUrl(Endpoint.API, "recipients", recipientId); } @Override @@ -151,94 +243,113 @@ protected ResponseType type() { return new ResponseType<>(Recipient.class); } - public CreateRequestBuilder name(String name) { - this.name = name; + public UpdateRequestBuilder bankAccount(BankAccount.Params bankAccount) { + this.bankAccount = bankAccount; return this; } - public CreateRequestBuilder email(String email) { + public UpdateRequestBuilder description(String description) { + this.description = description; + return this; + } + + public UpdateRequestBuilder email(String email) { this.email = email; return this; } - public CreateRequestBuilder description(String description) { - this.description = description; + public UpdateRequestBuilder metadata(Map metadata) { + this.metadata = metadata; return this; } - public CreateRequestBuilder type(RecipientType type) { - this.type = type; + public UpdateRequestBuilder name(String name) { + this.name = name; return this; } - public CreateRequestBuilder taxId(String taxId) { + public UpdateRequestBuilder taxId(String taxId) { this.taxId = taxId; return this; } - public CreateRequestBuilder bankAccount(BankAccount.Params bankAccount) { - this.bankAccount = bankAccount; + public UpdateRequestBuilder type(RecipientType type) { + this.type = type; + return this; + } + + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + + public UpdateRequestBuilder metadata(String key, Object value) { + HashMap tempMap = new HashMap<>(); + if (metadata != null) { + tempMap.putAll(metadata); + } + tempMap.put(key, value); + + this.metadata = new HashMap<>(tempMap); return this; } } - /** - * The {@link RequestBuilder} class for retrieving a Recipient. - */ - public static class GetRequestBuilder extends RequestBuilder { - private String recipientId; + public static class ListRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; - public GetRequestBuilder(String recipientId) { - this.recipientId = recipientId; + @Override + protected String method() { + return GET; } @Override protected HttpUrl path() { - return buildUrl(Endpoint.API, "recipients", recipientId); + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "recipients", serializer()) + .segments() + .params(options) + .build(); } @Override - protected ResponseType type() { - return new ResponseType<>(Recipient.class); + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; } } - /** - * The {@link RequestBuilder} class for updating a Recipient. - */ - public static class UpdateRequestBuilder extends RequestBuilder { - private String recipientId; + public static class CreateRequestBuilder extends RequestBuilder { @JsonProperty("bank_account") private BankAccount.Params bankAccount; @JsonProperty - private String name; + private String description; @JsonProperty private String email; @JsonProperty - private String description; - @JsonProperty - private RecipientType type; + private Map metadata; @JsonProperty + private String name; + @JsonProperty("tax_id") private String taxId; - - public UpdateRequestBuilder(String recipientId) { - this.recipientId = recipientId; - } + @JsonProperty + private RecipientType type; @Override protected String method() { - return PATCH; + return POST; } @Override protected HttpUrl path() { - return buildUrl(Endpoint.API, "recipients", recipientId); - } - - @Override - protected RequestBody payload() throws IOException { - return serialize(); + return buildUrl(Endpoint.API, "recipients"); } @Override @@ -246,87 +357,111 @@ protected ResponseType type() { return new ResponseType<>(Recipient.class); } - public UpdateRequestBuilder name(String name) { - this.name = name; + public CreateRequestBuilder bankAccount(BankAccount.Params bankAccount) { + this.bankAccount = bankAccount; return this; } - public UpdateRequestBuilder email(String email) { + public CreateRequestBuilder description(String description) { + this.description = description; + return this; + } + + public CreateRequestBuilder email(String email) { this.email = email; return this; } - public UpdateRequestBuilder description(String description) { - this.description = description; + public CreateRequestBuilder metadata(Map metadata) { + this.metadata = metadata; return this; } - public UpdateRequestBuilder type(RecipientType type) { - this.type = type; + public CreateRequestBuilder name(String name) { + this.name = name; return this; } - public UpdateRequestBuilder taxId(String taxId) { + public CreateRequestBuilder taxId(String taxId) { this.taxId = taxId; return this; } - public UpdateRequestBuilder bankAccount(BankAccount.Params bankAccount) { - this.bankAccount = bankAccount; + public CreateRequestBuilder type(RecipientType type) { + this.type = type; + return this; + } + + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + + public CreateRequestBuilder metadata(String key, Object value) { + HashMap tempMap = new HashMap<>(); + if (metadata != null) { + tempMap.putAll(metadata); + } + tempMap.put(key, value); + + this.metadata = new HashMap<>(tempMap); return this; } } - /** - * The {@link RequestBuilder} class for deleting a Recipient. - */ - public static class DeleteRequestBuilder extends RequestBuilder { + public static class ListSchedulesRequestBuilder extends RequestBuilder> { private String recipientId; - - public DeleteRequestBuilder(String recipientId) { + private ScopedList.Options options; + public ListSchedulesRequestBuilder(String recipientId) { this.recipientId = recipientId; } @Override protected String method() { - return DELETE; + return GET; } @Override protected HttpUrl path() { - return buildUrl(Endpoint.API, "recipients", recipientId); + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "recipients", serializer()) + .segments(recipientId, "schedules") + .params(options) + .build(); } @Override - protected ResponseType type() { - return new ResponseType<>(Recipient.class); + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListSchedulesRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; } } - /** - * The {@link RequestBuilder} class for retrieving all Recipients that belong to an account. - */ - public static class ListRequestBuilder extends RequestBuilder> { - private ScopedList.Options options; + public static class VerifyRequestBuilder extends RequestBuilder { + private String recipientId; + public VerifyRequestBuilder(String recipientId) { + this.recipientId = recipientId; + } @Override - protected HttpUrl path() { - if (options == null) { - options = new ScopedList.Options(); - } - - return buildUrl(Endpoint.API, "recipients", options); + protected String method() { + return PATCH; } @Override - protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + protected HttpUrl path() { + return buildUrl(Endpoint.API, "recipients", recipientId, "verify"); } - public ListRequestBuilder options(ScopedList.Options options) { - this.options = options; - return this; + @Override + protected ResponseType type() { + return new ResponseType<>(Recipient.class); } } } \ No newline at end of file diff --git a/src/main/java/co/omise/models/RecipientFailureCode.java b/src/main/java/co/omise/models/RecipientFailureCode.java index 87d9cf9b..bb86e4c4 100644 --- a/src/main/java/co/omise/models/RecipientFailureCode.java +++ b/src/main/java/co/omise/models/RecipientFailureCode.java @@ -3,7 +3,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum RecipientFailureCode { - @JsonProperty("account_not_found")AccountNotFound, - @JsonProperty("bank_not_found")BankNotFound, - @JsonProperty("name_mismatch")NameMismatch; + @JsonProperty("account_not_found") + AccountNotFound, + @JsonProperty("bank_not_found") + BankNotFound, + @JsonProperty("name_mismatch") + NameMismatch; } \ No newline at end of file diff --git a/src/main/java/co/omise/models/RecipientType.java b/src/main/java/co/omise/models/RecipientType.java index b0c9a1c9..54dfb0a3 100644 --- a/src/main/java/co/omise/models/RecipientType.java +++ b/src/main/java/co/omise/models/RecipientType.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum RecipientType { - @JsonProperty("individual")Individual, - @JsonProperty("corporation")Corporation, -} + @JsonProperty("corporation") + Corporation, + @JsonProperty("individual") + Individual; +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/References.java b/src/main/java/co/omise/models/References.java index 801ca4bd..36caa0be 100644 --- a/src/main/java/co/omise/models/References.java +++ b/src/main/java/co/omise/models/References.java @@ -6,64 +6,113 @@ import java.io.Serializable; public class References implements Serializable { - - @JsonProperty("va_code") - private String vaCode; + private String barcode; + @JsonProperty("customer_amount") + private long customerAmount; + @JsonProperty("customer_currency") + private String customerCurrency; + @JsonProperty("customer_exchange_rate") + private Double customerExchangeRate; + @JsonProperty("device_id") + private String deviceId; + @JsonProperty("expires_at") + private DateTime expiresAt; @JsonProperty("omise_tax_id") private String omiseTaxId; + @JsonProperty("payment_code") + private String paymentCode; @JsonProperty("reference_number_1") private String referenceNumber1; @JsonProperty("reference_number_2") private String referenceNumber2; - private String barcode; - @JsonProperty("expires_at") - private DateTime expiresAt; + @JsonProperty("va_code") + private String vaCode; - public String getOmiseTaxId() { - return omiseTaxId; + public String getBarcode() { + return this.barcode; } - public void setOmiseTaxId(String omiseTaxId) { - this.omiseTaxId = omiseTaxId; + public void setBarcode(String barcode) { + this.barcode = barcode; } - public String getReferenceNumber1() { - return referenceNumber1; + public long getCustomerAmount() { + return this.customerAmount; } - public void setReferenceNumber1(String referenceNumber1) { - this.referenceNumber1 = referenceNumber1; + public void setCustomerAmount(long customerAmount) { + this.customerAmount = customerAmount; } - public String getReferenceNumber2() { - return referenceNumber2; + public String getCustomerCurrency() { + return this.customerCurrency; } - public void setReferenceNumber2(String referenceNumber2) { - this.referenceNumber2 = referenceNumber2; + public void setCustomerCurrency(String customerCurrency) { + this.customerCurrency = customerCurrency; } - public String getBarcode() { - return barcode; + public Double getCustomerExchangeRate() { + return this.customerExchangeRate; } - public void setBarcode(String barcode) { - this.barcode = barcode; + public void setCustomerExchangeRate(Double customerExchangeRate) { + this.customerExchangeRate = customerExchangeRate; + } + + public String getDeviceId() { + return this.deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; } public DateTime getExpiresAt() { - return expiresAt; + return this.expiresAt; } public void setExpiresAt(DateTime expiresAt) { this.expiresAt = expiresAt; } + public String getOmiseTaxId() { + return this.omiseTaxId; + } + + public void setOmiseTaxId(String omiseTaxId) { + this.omiseTaxId = omiseTaxId; + } + + public String getPaymentCode() { + return this.paymentCode; + } + + public void setPaymentCode(String paymentCode) { + this.paymentCode = paymentCode; + } + + public String getReferenceNumber1() { + return this.referenceNumber1; + } + + public void setReferenceNumber1(String referenceNumber1) { + this.referenceNumber1 = referenceNumber1; + } + + public String getReferenceNumber2() { + return this.referenceNumber2; + } + + public void setReferenceNumber2(String referenceNumber2) { + this.referenceNumber2 = referenceNumber2; + } + public String getVaCode() { - return vaCode; + return this.vaCode; } public void setVaCode(String vaCode) { this.vaCode = vaCode; } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Refund.java b/src/main/java/co/omise/models/Refund.java index 0b482fa4..01cae2bb 100644 --- a/src/main/java/co/omise/models/Refund.java +++ b/src/main/java/co/omise/models/Refund.java @@ -13,59 +13,75 @@ import java.util.Map; /** - * Represents Omise Refund object. + * Refund object * - * @see Refunds API + * @see Refund API */ public class Refund extends Model { private long amount; - private String currency; private String charge; - private String transaction; - private Map metadata; - private RefundStatus status; + private String currency; @JsonProperty("funding_amount") private long fundingAmount; @JsonProperty("funding_currency") private String fundingCurrency; - - public Refund() { - } + private String location; + private Map metadata; + private RefundStatus status; + private String terminal; + private String transaction; + private boolean voided; public long getAmount() { - return amount; + return this.amount; } public void setAmount(long amount) { this.amount = amount; } + public String getCharge() { + return this.charge; + } + + public void setCharge(String charge) { + this.charge = charge; + } + public String getCurrency() { - return currency; + return this.currency; } public void setCurrency(String currency) { this.currency = currency; } - public String getCharge() { - return charge; + public long getFundingAmount() { + return this.fundingAmount; } - public void setCharge(String charge) { - this.charge = charge; + public void setFundingAmount(long fundingAmount) { + this.fundingAmount = fundingAmount; } - public String getTransaction() { - return transaction; + public String getFundingCurrency() { + return this.fundingCurrency; } - public void setTransaction(String transaction) { - this.transaction = transaction; + public void setFundingCurrency(String fundingCurrency) { + this.fundingCurrency = fundingCurrency; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; } public Map getMetadata() { - return metadata; + return this.metadata; } public void setMetadata(Map metadata) { @@ -73,56 +89,122 @@ public void setMetadata(Map metadata) { } public RefundStatus getStatus() { - return status; + return this.status; } public void setStatus(RefundStatus status) { this.status = status; } - public long getFundingAmount() { - return fundingAmount; + public String getTerminal() { + return this.terminal; } - public void setFundingAmount(long fundingAmount) { - this.fundingAmount = fundingAmount; + public void setTerminal(String terminal) { + this.terminal = terminal; } - public String getFundingCurrency() { - return fundingCurrency; + public String getTransaction() { + return this.transaction; } - public void setFundingCurrency(String fundingCurrency) { - this.fundingCurrency = fundingCurrency; + public void setTransaction(String transaction) { + this.transaction = transaction; + } + + public boolean isVoided() { + return this.voided; + } + + public void setVoided(boolean voided) { + this.voided = voided; + } + + public static class ListRefundsRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "refunds", serializer()) + .segments() + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRefundsRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; + } + } + + public static class ListRequestBuilder extends RequestBuilder> { + private String chargeId; + private ScopedList.Options options; + public ListRequestBuilder(String chargeId) { + this.chargeId = chargeId; + } + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "charges", serializer()) + .segments(chargeId, "refunds") + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; + } } - /** - * The {@link RequestBuilder} class for creating a Refund. - */ public static class CreateRequestBuilder extends RequestBuilder { private String chargeId; + @JsonProperty private long amount; @JsonProperty private Map metadata; - + @JsonProperty("void") + private boolean isVoid; public CreateRequestBuilder(String chargeId) { this.chargeId = chargeId; } - @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "charges", chargeId, "refunds"); - } - @Override protected String method() { return POST; } @Override - protected RequestBody payload() throws IOException { - return serialize(); + protected HttpUrl path() { + return buildUrl(Endpoint.API, "charges", chargeId, "refunds"); } @Override @@ -140,71 +222,49 @@ public CreateRequestBuilder metadata(Map metadata) { return this; } + public CreateRequestBuilder isVoid(boolean isVoid) { + this.isVoid = isVoid; + return this; + } + + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + public CreateRequestBuilder metadata(String key, Object value) { HashMap tempMap = new HashMap<>(); if (metadata != null) { tempMap.putAll(metadata); } tempMap.put(key, value); + this.metadata = new HashMap<>(tempMap); return this; } } - /** - * The {@link RequestBuilder} class for retrieving a particular Refund. - */ public static class GetRequestBuilder extends RequestBuilder { - private final String chargeId; - private final String refundId; - + private String chargeId; + private String refundId; public GetRequestBuilder(String chargeId, String refundId) { this.chargeId = chargeId; this.refundId = refundId; } @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "charges", chargeId, "refunds", refundId); - } - - @Override - protected ResponseType type() { - return new ResponseType<>(Refund.class); - } - } - - /** - * The {@link RequestBuilder} class for retrieving all Refunds that belong to a particular Charge. - */ - public static class ListRequestBuilder extends RequestBuilder> { - private final String chargeId; - private ScopedList.Options options; - - public ListRequestBuilder(String chargeId) { - this.chargeId = chargeId; + protected String method() { + return GET; } @Override protected HttpUrl path() { - if (options == null) { - options = new ScopedList.Options(); - } - return new HttpUrlBuilder(Endpoint.API, "charges", serializer()) - .segments(chargeId, "refunds") - .params(options) - .build(); + return buildUrl(Endpoint.API, "charges", chargeId, "refunds", refundId); } @Override - protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); - } - - public ListRequestBuilder options(ScopedList.Options options) { - this.options = options; - return this; + protected ResponseType type() { + return new ResponseType<>(Refund.class); } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/RefundStatus.java b/src/main/java/co/omise/models/RefundStatus.java index 897570b3..97a11792 100644 --- a/src/main/java/co/omise/models/RefundStatus.java +++ b/src/main/java/co/omise/models/RefundStatus.java @@ -3,6 +3,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum RefundStatus { - @JsonProperty("pending") Pending, - @JsonProperty("closed") Closed -} + @JsonProperty("closed") + Closed; +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Source.java b/src/main/java/co/omise/models/Source.java index 6b76b68e..acd69c40 100644 --- a/src/main/java/co/omise/models/Source.java +++ b/src/main/java/co/omise/models/Source.java @@ -3,6 +3,7 @@ import co.omise.Endpoint; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; +import com.fasterxml.jackson.annotation.JsonEnumDefaultValue; import com.fasterxml.jackson.annotation.JsonProperty; import okhttp3.HttpUrl; import okhttp3.RequestBody; @@ -10,25 +11,27 @@ import java.io.IOException; /** - * Represents Omise Source object. + * Source object * - * @see Source API + * @see Source API */ public class Source extends Model { - - private SourceType type; - private FlowType flow; private long amount; - private String currency; private String barcode; - private References references; + @JsonProperty("charge_status") + private ChargeStatus chargeStatus; + private String currency; private String email; + private FlowType flow; + @JsonProperty("installment_term") + private long installmentTerm; private String location; @JsonProperty("mobile_number") private String mobileNumber; private String name; @JsonProperty("phone_number") private String phoneNumber; + private References references; @JsonProperty("scannable_code") private Barcode scannableCode; @JsonProperty("store_id") @@ -37,56 +40,100 @@ public class Source extends Model { private String storeName; @JsonProperty("terminal_id") private String terminalId; - @JsonProperty("installment_term") - private int installmentTerm; + private SourceType type; @JsonProperty("zero_interest_installments") private boolean zeroInterestInstallments; - public Source() { + public long getAmount() { + return this.amount; } - public SourceType getType() { - return type; + public void setAmount(long amount) { + this.amount = amount; } - public void setType(SourceType type) { - this.type = type; + public String getBarcode() { + return this.barcode; + } + + public void setBarcode(String barcode) { + this.barcode = barcode; + } + + public ChargeStatus getChargeStatus() { + return this.chargeStatus; + } + + public void setChargeStatus(ChargeStatus chargeStatus) { + this.chargeStatus = chargeStatus; + } + + public String getCurrency() { + return this.currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; } public FlowType getFlow() { - return flow; + return this.flow; } public void setFlow(FlowType flow) { this.flow = flow; } - public long getAmount() { - return amount; + public long getInstallmentTerm() { + return this.installmentTerm; } - public void setAmount(long amount) { - this.amount = amount; + public void setInstallmentTerm(long installmentTerm) { + this.installmentTerm = installmentTerm; } - public String getCurrency() { - return currency; + public String getLocation() { + return this.location; } - public void setCurrency(String currency) { - this.currency = currency; + public void setLocation(String location) { + this.location = location; } - public String getBarcode() { - return barcode; + public String getMobileNumber() { + return this.mobileNumber; } - public void setBarcode(String barcode) { - this.barcode = barcode; + public void setMobileNumber(String mobileNumber) { + this.mobileNumber = mobileNumber; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhoneNumber() { + return this.phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; } public References getReferences() { - return references; + return this.references; } public void setReferences(References references) { @@ -102,7 +149,7 @@ public void setScannableCode(Barcode scannableCode) { } public String getStoreId() { - return storeId; + return this.storeId; } public void setStoreId(String storeId) { @@ -110,7 +157,7 @@ public void setStoreId(String storeId) { } public String getStoreName() { - return storeName; + return this.storeName; } public void setStoreName(String storeName) { @@ -118,43 +165,19 @@ public void setStoreName(String storeName) { } public String getTerminalId() { - return terminalId; + return this.terminalId; } public void setTerminalId(String terminalId) { this.terminalId = terminalId; } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public int getInstallmentTerm() { - return installmentTerm; + public SourceType getType() { + return this.type; } - public void setInstallmentTerm(int installmentTerm) { - this.installmentTerm = installmentTerm; + public void setType(SourceType type) { + this.type = type; } public boolean isZeroInterestInstallments() { @@ -165,32 +188,28 @@ public void setZeroInterestInstallments(boolean zeroInterestInstallments) { this.zeroInterestInstallments = zeroInterestInstallments; } - /** - * The {@link RequestBuilder} class for creating a Source. - */ public static class CreateRequestBuilder extends RequestBuilder { + @JsonProperty private long amount; @JsonProperty + private String barcode; + @JsonProperty private String currency; @JsonProperty - private String description; + private String email; + @JsonProperty("installment_term") + private long installmentTerm; + @JsonProperty("mobile_number") + private String mobileNumber; @JsonProperty - private String barcode; + private String name; @JsonProperty("store_id") private String storeId; @JsonProperty("store_name") private String storeName; @JsonProperty("terminal_id") private String terminalId; - @JsonProperty("name") - private String name; - @JsonProperty("email") - private String email; - @JsonProperty("phone_number") - private String phoneNumber; - @JsonProperty("installment_term") - private int installmentTerm; @JsonProperty private SourceType type; @JsonProperty("zero_interest_installments") @@ -206,11 +225,6 @@ protected HttpUrl path() { return buildUrl(Endpoint.API, "sources"); } - @Override - protected RequestBody payload() throws IOException { - return serialize(); - } - @Override protected ResponseType type() { return new ResponseType<>(Source.class); @@ -221,18 +235,33 @@ public CreateRequestBuilder amount(long amount) { return this; } + public CreateRequestBuilder barcode(String barcode) { + this.barcode = barcode; + return this; + } + public CreateRequestBuilder currency(String currency) { this.currency = currency; return this; } - public CreateRequestBuilder type(SourceType type) { - this.type = type; + public CreateRequestBuilder email(String email) { + this.email = email; return this; } - public CreateRequestBuilder barcode(String barcode) { - this.barcode = barcode; + public CreateRequestBuilder installmentTerm(long installmentTerm) { + this.installmentTerm = installmentTerm; + return this; + } + + public CreateRequestBuilder mobileNumber(String mobileNumber) { + this.mobileNumber = mobileNumber; + return this; + } + + public CreateRequestBuilder name(String name) { + this.name = name; return this; } @@ -251,8 +280,8 @@ public CreateRequestBuilder terminalId(String terminalId) { return this; } - public CreateRequestBuilder name(String name) { - this.name = name; + public CreateRequestBuilder type(SourceType type) { + this.type = type; return this; } @@ -261,19 +290,31 @@ public CreateRequestBuilder zeroInterestInstallments(boolean zeroInterestInstall return this; } - public CreateRequestBuilder email(String email) { - this.email = email; - return this; + @Override + protected RequestBody payload() throws IOException { + return serialize(); } + } - public CreateRequestBuilder phoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - return this; + public static class GetRequestBuilder extends RequestBuilder { + private String sourceId; + public GetRequestBuilder(String sourceId) { + this.sourceId = sourceId; } - public CreateRequestBuilder installmentTerm(int installmentTerm) { - this.installmentTerm = installmentTerm; - return this; + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "sources", sourceId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Source.class); } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/SourceType.java b/src/main/java/co/omise/models/SourceType.java index b493cee8..e8b2e600 100644 --- a/src/main/java/co/omise/models/SourceType.java +++ b/src/main/java/co/omise/models/SourceType.java @@ -13,6 +13,8 @@ public enum SourceType { Alipay, @JsonProperty("barcode_alipay") BarcodeAlipay, + @JsonProperty("barcode_wechat") + BarcodeWechat, @JsonProperty("bill_payment_tesco_lotus") BillPaymentTescoLotus, @JsonProperty("econtext") @@ -39,16 +41,16 @@ public enum SourceType { Paynow, @JsonProperty("points_citi") PointsCiti, - @JsonProperty("truemoney") - TrueMoney, @JsonProperty("promptpay") - PromptPay; + PromptPay, + @JsonProperty("truemoney") + TrueMoney; @Override public String toString() { String name = super.toString(); Field[] fields = this.getClass().getDeclaredFields(); - for (Field field : fields) { + for(Field field : fields) { if (field.getName() == name && field.isAnnotationPresent(JsonProperty.class)) { return field.getAnnotation(JsonProperty.class).value(); } diff --git a/src/main/java/co/omise/models/SystemInfo.java b/src/main/java/co/omise/models/SystemInfo.java new file mode 100644 index 00000000..2bca2c33 --- /dev/null +++ b/src/main/java/co/omise/models/SystemInfo.java @@ -0,0 +1,50 @@ +package co.omise.models; + +import co.omise.Endpoint; +import co.omise.requests.RequestBuilder; +import co.omise.requests.ResponseType; +import com.fasterxml.jackson.annotation.JsonProperty; +import okhttp3.HttpUrl; +import okhttp3.RequestBody; + +import java.io.IOException; +import java.util.List; + +public class SystemInfo extends Model { + private String location; + private List versions; + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public List getVersions() { + return this.versions; + } + + public void setVersions(List versions) { + this.versions = versions; + } + + public static class GetRequestBuilder extends RequestBuilder { + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, ""); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(SystemInfo.class); + } + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Token.java b/src/main/java/co/omise/models/Token.java index 02076dd7..7e978054 100644 --- a/src/main/java/co/omise/models/Token.java +++ b/src/main/java/co/omise/models/Token.java @@ -10,51 +10,51 @@ import java.io.IOException; /** - *

- * Full Credit Card data should never go through your server. - * Do not send the credit card data to Omise from your servers directly. - * You must send the card data from the client browser via Javascript (Omise-JS). - * Code involving this class should only be used either with fake data in test mode - * (e.g.: quickly creating some fake data, testing our API from a terminal, etc.), - * or if you are PCI-DSS compliant. - *

- *

- * Sending card data from server requires a valid PCI-DSS certification. - * You can learn more about this in Security Best Practices. - *

- *

- * This class represents Omise Token object. - *

+ * Token object * - * @see Tokens API + * @see Token API */ public class Token extends Model { - private boolean used; private Card card; + @JsonProperty("charge_status") + private ChargeStatus chargeStatus; + private String location; + private boolean used; - public Token() { + public Card getCard() { + return this.card; } - public boolean isUsed() { - return used; + public void setCard(Card card) { + this.card = card; } - public void setUsed(boolean used) { - this.used = used; + public ChargeStatus getChargeStatus() { + return this.chargeStatus; } - public Card getCard() { - return card; + public void setChargeStatus(ChargeStatus chargeStatus) { + this.chargeStatus = chargeStatus; } - public void setCard(Card card) { - this.card = card; + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; + } + + public boolean isUsed() { + return this.used; + } + + public void setUsed(boolean used) { + this.used = used; } - /** - * The {@link RequestBuilder} class for creating a Token. - */ public static class CreateRequestBuilder extends RequestBuilder { + @JsonProperty private Card.Create card; @@ -68,11 +68,6 @@ protected HttpUrl path() { return buildUrl(Endpoint.VAULT, "tokens"); } - @Override - protected RequestBody payload() throws IOException { - return serialize(); - } - @Override protected ResponseType type() { return new ResponseType<>(Token.class); @@ -82,18 +77,24 @@ public CreateRequestBuilder card(Card.Create card) { this.card = card; return this; } + + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } } - /** - * The {@link RequestBuilder} class for retrieving a particular Token. - */ public static class GetRequestBuilder extends RequestBuilder { private String tokenId; - public GetRequestBuilder(String tokenId) { this.tokenId = tokenId; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.VAULT, "tokens", tokenId); @@ -104,5 +105,4 @@ protected ResponseType type() { return new ResponseType<>(Token.class); } } - } \ No newline at end of file diff --git a/src/main/java/co/omise/models/Transaction.java b/src/main/java/co/omise/models/Transaction.java index 6c39b887..efe6387e 100644 --- a/src/main/java/co/omise/models/Transaction.java +++ b/src/main/java/co/omise/models/Transaction.java @@ -6,27 +6,28 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; import okhttp3.HttpUrl; +import okhttp3.RequestBody; import org.joda.time.DateTime; +import java.io.IOException; + /** - * Represents Omise Transaction object. + * Transaction object * - * @see Transactions API + * @see Transaction API */ public class Transaction extends Model { private long amount; private String currency; private TransactionDirection direction; + private String key; + private String location; private String origin; @JsonProperty("transferable_at") - private DateTime transferable; - private String key; - - public Transaction() { - } + private DateTime transferableAt; public long getAmount() { - return amount; + return this.amount; } public void setAmount(long amount) { @@ -34,7 +35,7 @@ public void setAmount(long amount) { } public String getCurrency() { - return currency; + return this.currency; } public void setCurrency(String currency) { @@ -42,48 +43,56 @@ public void setCurrency(String currency) { } public TransactionDirection getDirection() { - return direction; + return this.direction; } public void setDirection(TransactionDirection direction) { this.direction = direction; } - public String getOrigin() { - return origin; + public String getKey() { + return this.key; } - public void setOrigin(String origin) { - this.origin = origin; + public void setKey(String key) { + this.key = key; } - public DateTime getTransferable() { - return transferable; + public String getLocation() { + return this.location; } - public void setTransferable(DateTime transferable) { - this.transferable = transferable; + public void setLocation(String location) { + this.location = location; } - public String getKey() { - return key; + public String getOrigin() { + return this.origin; } - public void setKey(String key) { - this.key = key; + public void setOrigin(String origin) { + this.origin = origin; } - /** - * The {@link RequestBuilder} class for retrieving a particular transaction. - */ - public static class GetRequestBuilder extends RequestBuilder { + public DateTime getTransferableAt() { + return this.transferableAt; + } - private String transactionId; + public void setTransferableAt(DateTime transferableAt) { + this.transferableAt = transferableAt; + } + public static class GetRequestBuilder extends RequestBuilder { + private String transactionId; public GetRequestBuilder(String transactionId) { this.transactionId = transactionId; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "transactions", transactionId); @@ -95,16 +104,12 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for retrieving all transactions that belong to an account. - */ public static class ListRequestBuilder extends RequestBuilder> { - private ScopedList.Options options; - public ListRequestBuilder options(ScopedList.Options options) { - this.options = options; - return this; + @Override + protected String method() { + return GET; } @Override @@ -112,13 +117,20 @@ protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - return buildUrl(Endpoint.API, "transactions", options); + return new HttpUrlBuilder(Endpoint.API, "transactions", serializer()) + .segments() + .params(options) + .build(); } @Override protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/TransactionDirection.java b/src/main/java/co/omise/models/TransactionDirection.java index fdb1e047..7170490f 100644 --- a/src/main/java/co/omise/models/TransactionDirection.java +++ b/src/main/java/co/omise/models/TransactionDirection.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum TransactionDirection { - @JsonProperty("credit") Credit, - @JsonProperty("debit") Debit, -} + @JsonProperty("credit") + Credit, + @JsonProperty("debit") + Debit; +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/Transfer.java b/src/main/java/co/omise/models/Transfer.java index 3c75d78b..e32caf1c 100644 --- a/src/main/java/co/omise/models/Transfer.java +++ b/src/main/java/co/omise/models/Transfer.java @@ -1,6 +1,7 @@ package co.omise.models; import co.omise.Endpoint; +import co.omise.models.schedules.Schedule; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; import com.fasterxml.jackson.annotation.JsonProperty; @@ -10,27 +11,19 @@ import org.joda.time.DateTime; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Map; /** - * Represents Omise Transfer object and contains all of its {@link RequestBuilder}. + * Transfer object * - * @see Tranfers API + * @see Transfer API */ public class Transfer extends Model { - private String recipient; + private long amount; @JsonProperty("bank_account") private BankAccount bankAccount; - private boolean sent; - private boolean paid; - private long fee; - @JsonProperty("fee_vat") - private long feeVat; - @JsonProperty("total_fee") - private long totalFee; - private long net; - private long amount; private String currency; @JsonProperty("fail_fast") private boolean failFast; @@ -38,50 +31,51 @@ public class Transfer extends Model { private String failureCode; @JsonProperty("failure_message") private String failureMessage; - private List transactions; + private long fee; + @JsonProperty("fee_vat") + private long feeVat; + private String location; private Map metadata; - @JsonProperty("sent_at") - private DateTime sentAt; + private long net; + private boolean paid; @JsonProperty("paid_at") private DateTime paidAt; + private String recipient; + private String schedule; + private boolean sendable; + private boolean sent; + @JsonProperty("sent_at") + private DateTime sentAt; + @JsonProperty("total_fee") + private long totalFee; + private List transactions; - public Transfer() { - } - - public String getRecipient() { - return recipient; + public long getAmount() { + return this.amount; } - public void setRecipient(String recipient) { - this.recipient = recipient; + public void setAmount(long amount) { + this.amount = amount; } public BankAccount getBankAccount() { - return bankAccount; - } - - public boolean isSent() { - return sent; + return this.bankAccount; } - public boolean isPaid() { - return paid; - } - - public long getFee() { - return fee; + public void setBankAccount(BankAccount bankAccount) { + this.bankAccount = bankAccount; } - public long getAmount() { - return amount; + public String getCurrency() { + return this.currency; } - public String getCurrency() { - return currency; + public void setCurrency(String currency) { + this.currency = currency; } - public boolean failFast() { - return failFast; + public boolean isFailFast() { + return this.failFast; } public void setFailFast(boolean failFast) { @@ -89,7 +83,7 @@ public void setFailFast(boolean failFast) { } public String getFailureCode() { - return failureCode; + return this.failureCode; } public void setFailureCode(String failureCode) { @@ -97,144 +91,161 @@ public void setFailureCode(String failureCode) { } public String getFailureMessage() { - return failureMessage; + return this.failureMessage; } public void setFailureMessage(String failureMessage) { this.failureMessage = failureMessage; } - public List getTransactions() { - return transactions; + public long getFee() { + return this.fee; } - public void setTransactions(List transactions) { - this.transactions = transactions; + public void setFee(long fee) { + this.fee = fee; + } + + public long getFeeVat() { + return this.feeVat; + } + + public void setFeeVat(long feeVat) { + this.feeVat = feeVat; + } + + public String getLocation() { + return this.location; + } + + public void setLocation(String location) { + this.location = location; } public Map getMetadata() { - return metadata; + return this.metadata; } public void setMetadata(Map metadata) { this.metadata = metadata; } - public boolean isFailFast() { - return failFast; + public long getNet() { + return this.net; } - public DateTime getSentAt() { - return sentAt; + public void setNet(long net) { + this.net = net; + } + + public boolean isPaid() { + return this.paid; + } + + public void setPaid(boolean paid) { + this.paid = paid; } public DateTime getPaidAt() { - return paidAt; + return this.paidAt; } - public void setBankAccount(BankAccount bankAccount) { - this.bankAccount = bankAccount; + public void setPaidAt(DateTime paidAt) { + this.paidAt = paidAt; } - public void setSent(boolean sent) { - this.sent = sent; + public String getRecipient() { + return this.recipient; } - public void setPaid(boolean paid) { - this.paid = paid; + public void setRecipient(String recipient) { + this.recipient = recipient; } - public void setFee(long fee) { - this.fee = fee; + public String getSchedule() { + return this.schedule; } - public void setAmount(long amount) { - this.amount = amount; + public void setSchedule(String schedule) { + this.schedule = schedule; } - public void setCurrency(String currency) { - this.currency = currency; + public boolean isSendable() { + return this.sendable; } - public void setSentAt(DateTime sentAt) { - this.sentAt = sentAt; + public void setSendable(boolean sendable) { + this.sendable = sendable; } - public void setPaidAt(DateTime paidAt) { - this.paidAt = paidAt; + public boolean isSent() { + return this.sent; } - public long getFeeVat() { - return feeVat; + public void setSent(boolean sent) { + this.sent = sent; } - public void setFeeVat(long feeVat) { - this.feeVat = feeVat; + public DateTime getSentAt() { + return this.sentAt; + } + + public void setSentAt(DateTime sentAt) { + this.sentAt = sentAt; } public long getTotalFee() { - return totalFee; + return this.totalFee; } public void setTotalFee(long totalFee) { this.totalFee = totalFee; } - public long getNet() { - return net; + public List getTransactions() { + return this.transactions; } - public void setNet(long net) { - this.net = net; + public void setTransactions(List transactions) { + this.transactions = transactions; } - /** - * The {@link RequestBuilder} class for creating a transfer. - */ - public static class CreateRequestBuilder extends RequestBuilder { - - @JsonProperty - private long amount; - @JsonProperty - private String recipient; - @JsonProperty("fail_fast") - private boolean failFast; - @JsonProperty - private Map metadata; - - public CreateRequestBuilder amount(long amount) { - this.amount = amount; - return this; + public static class DeleteRequestBuilder extends RequestBuilder { + private String transferId; + public DeleteRequestBuilder(String transferId) { + this.transferId = transferId; } - public CreateRequestBuilder recipient(String recipient) { - this.recipient = recipient; - return this; + @Override + protected String method() { + return DELETE; } - public CreateRequestBuilder failFast(boolean failFast) { - this.failFast = failFast; - return this; + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "transfers", transferId); } - public CreateRequestBuilder metadata(Map metadata) { - this.metadata = metadata; - return this; + @Override + protected ResponseType type() { + return new ResponseType<>(Transfer.class); } + } - @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "transfers"); + public static class GetRequestBuilder extends RequestBuilder { + private String transferId; + public GetRequestBuilder(String transferId) { + this.transferId = transferId; } @Override protected String method() { - return POST; + return GET; } @Override - protected RequestBody payload() throws IOException { - return serialize(); + protected HttpUrl path() { + return buildUrl(Endpoint.API, "transfers", transferId); } @Override @@ -243,20 +254,32 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for updating a particular transfer. - */ public static class UpdateRequestBuilder extends RequestBuilder { private String transferId; + @JsonProperty private long amount; @JsonProperty private Map metadata; - public UpdateRequestBuilder(String transferId) { this.transferId = transferId; } + @Override + protected String method() { + return PATCH; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "transfers", transferId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Transfer.class); + } + public UpdateRequestBuilder amount(long amount) { this.amount = amount; return this; @@ -268,93 +291,159 @@ public UpdateRequestBuilder metadata(Map metadata) { } @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "transfers", transferId); + protected RequestBody payload() throws IOException { + return serialize(); + } + + public UpdateRequestBuilder metadata(String key, Object value) { + HashMap tempMap = new HashMap<>(); + if (metadata != null) { + tempMap.putAll(metadata); + } + tempMap.put(key, value); + + this.metadata = new HashMap<>(tempMap); + return this; } + } + + public static class ListRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; @Override protected String method() { - return PATCH; + return GET; } @Override - protected RequestBody payload() throws IOException { - return serialize(); + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "transfers", serializer()) + .segments() + .params(options) + .build(); } @Override - protected ResponseType type() { - return new ResponseType<>(Transfer.class); + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; } } - /** - * The {@link RequestBuilder} class for retrieving a particular transfer. - */ - public static class GetRequestBuilder extends RequestBuilder { + public static class CreateRequestBuilder extends RequestBuilder { - private String transferId; + @JsonProperty + private long amount; + @JsonProperty("fail_fast") + private boolean failFast; + @JsonProperty + private Map metadata; + @JsonProperty + private String recipient; - public GetRequestBuilder(String transferId) { - this.transferId = transferId; + @Override + protected String method() { + return POST; } @Override protected HttpUrl path() { - return buildUrl(Endpoint.API, "transfers", transferId); + return buildUrl(Endpoint.API, "transfers"); } @Override protected ResponseType type() { return new ResponseType<>(Transfer.class); } - } - /** - * The {@link RequestBuilder} class for retrieving all transfers that belong to an account. - */ - public static class ListRequestBuilder extends RequestBuilder> { + public CreateRequestBuilder amount(long amount) { + this.amount = amount; + return this; + } - private ScopedList.Options options; + public CreateRequestBuilder failFast(boolean failFast) { + this.failFast = failFast; + return this; + } - public ListRequestBuilder options(ScopedList.Options options) { - this.options = options; + public CreateRequestBuilder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + public CreateRequestBuilder recipient(String recipient) { + this.recipient = recipient; + return this; + } + + @Override + protected RequestBody payload() throws IOException { + return serialize(); + } + + public CreateRequestBuilder metadata(String key, Object value) { + HashMap tempMap = new HashMap<>(); + if (metadata != null) { + tempMap.putAll(metadata); + } + tempMap.put(key, value); + + this.metadata = new HashMap<>(tempMap); return this; } + } + + public static class ListSchedulesRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - return buildUrl(Endpoint.API, "transfers", options); + return new HttpUrlBuilder(Endpoint.API, "transfers", serializer()) + .segments("schedules") + .params(options) + .build(); } @Override - protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListSchedulesRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; } } - /** - * The {@link RequestBuilder} class for deleting a particular Transfer. - */ - public static class DeleteRequestBuilder extends RequestBuilder { + public static class MarkAsPaidRequestBuilder extends RequestBuilder { private String transferId; - - public DeleteRequestBuilder(String transferId) { + public MarkAsPaidRequestBuilder(String transferId) { this.transferId = transferId; } @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "transfers", transferId); + protected String method() { + return POST; } @Override - protected String method() { - return DELETE; + protected HttpUrl path() { + return buildUrl(Endpoint.API, "transfers", transferId, "mark_as_paid"); } @Override @@ -363,27 +452,20 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for destroying a particular transfer. - * - * @deprecated use {@link DeleteRequestBuilder} instead - */ - @Deprecated - public static class DestroyRequestBuilder extends RequestBuilder { + public static class MarkAsSentRequestBuilder extends RequestBuilder { private String transferId; - - public DestroyRequestBuilder(String transferId) { + public MarkAsSentRequestBuilder(String transferId) { this.transferId = transferId; } @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "transfers", transferId); + protected String method() { + return POST; } @Override - protected String method() { - return DELETE; + protected HttpUrl path() { + return buildUrl(Endpoint.API, "transfers", transferId, "mark_as_sent"); } @Override @@ -391,4 +473,4 @@ protected ResponseType type() { return new ResponseType<>(Transfer.class); } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/WebhookDelivery.java b/src/main/java/co/omise/models/WebhookDelivery.java new file mode 100644 index 00000000..171aa19c --- /dev/null +++ b/src/main/java/co/omise/models/WebhookDelivery.java @@ -0,0 +1,22 @@ +package co.omise.models; + +public class WebhookDelivery extends Model { + private long status; + private String uri; + + public long getStatus() { + return this.status; + } + + public void setStatus(long status) { + this.status = status; + } + + public String getUri() { + return this.uri; + } + + public void setUri(String uri) { + this.uri = uri; + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/ChargeScheduling.java b/src/main/java/co/omise/models/schedules/ChargeSchedule.java similarity index 66% rename from src/main/java/co/omise/models/schedules/ChargeScheduling.java rename to src/main/java/co/omise/models/schedules/ChargeSchedule.java index 7351322a..fc95e087 100644 --- a/src/main/java/co/omise/models/schedules/ChargeScheduling.java +++ b/src/main/java/co/omise/models/schedules/ChargeSchedule.java @@ -1,28 +1,43 @@ package co.omise.models.schedules; -import com.fasterxml.jackson.annotation.JsonInclude; +import co.omise.models.Model; import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; +import java.util.Map; -public class ChargeScheduling implements Serializable { +/** + * Charge Schedule object + * + * @see Charge Schedule API + */ +public class ChargeSchedule extends Model { private long amount; + private String card; private String currency; private String customer; - private String card; @JsonProperty("default_card") - private boolean isDefaultCard; + private boolean defaultCard; + private String description; + private Map metadata; public long getAmount() { - return amount; + return this.amount; } public void setAmount(long amount) { this.amount = amount; } + public String getCard() { + return this.card; + } + + public void setCard(String card) { + this.card = card; + } + public String getCurrency() { - return currency; + return this.currency; } public void setCurrency(String currency) { @@ -30,55 +45,65 @@ public void setCurrency(String currency) { } public String getCustomer() { - return customer; + return this.customer; } public void setCustomer(String customer) { this.customer = customer; } - public String getCard() { - return card; + public boolean isDefaultCard() { + return this.defaultCard; } - public void setCard(String card) { - this.card = card; + public void setDefaultCard(boolean defaultCard) { + this.defaultCard = defaultCard; } - public boolean isDefaultCard() { - return isDefaultCard; + public String getDescription() { + return this.description; } - public void setDefaultCard(boolean defaultCard) { - isDefaultCard = defaultCard; + public void setDescription(String description) { + this.description = description; + } + + public Map getMetadata() { + return this.metadata; + } + + public void setMetadata(Map metadata) { + this.metadata = metadata; } public static class Params extends co.omise.models.Params { @JsonProperty private long amount; + @JsonProperty - private String currency; + private String card; + @JsonProperty - private String description; + private String currency; + @JsonProperty - @JsonInclude(JsonInclude.Include.NON_NULL) private String customer; + @JsonProperty - @JsonInclude(JsonInclude.Include.NON_NULL) - private String card; + private String description; public Params amount(long amount) { this.amount = amount; return this; } - public Params currency(String currency) { - this.currency = currency; + public Params card(String card) { + this.card = card; return this; } - public Params description(String description) { - this.description = description; + public Params currency(String currency) { + this.currency = currency; return this; } @@ -87,9 +112,9 @@ public Params customer(String customer) { return this; } - public Params card(String card) { - this.card = card; + public Params description(String description) { + this.description = description; return this; } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/Occurrence.java b/src/main/java/co/omise/models/schedules/Occurrence.java index d26c2a06..d6b52c5a 100644 --- a/src/main/java/co/omise/models/schedules/Occurrence.java +++ b/src/main/java/co/omise/models/schedules/Occurrence.java @@ -8,141 +8,147 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; import okhttp3.HttpUrl; +import okhttp3.RequestBody; import org.joda.time.DateTime; import org.joda.time.LocalDate; import java.io.IOException; /** - * Represents Omise Occurrence object. + * Occurrence object * * @see Occurrence API */ public class Occurrence extends Model { - private String schedule; - @JsonProperty("scheduled_on") - private LocalDate scheduleDate; - @JsonProperty("retry_on") - private LocalDate retryDate; + private String location; + private String message; @JsonProperty("processed_at") private DateTime processedAt; - private OccurrenceStatus status; - private String message; private String result; + @JsonProperty("retry_on") + private LocalDate retryOn; + private String schedule; + @JsonProperty("scheduled_on") + private LocalDate scheduledOn; + private OccurrenceStatus status; - public Occurrence() { + public String getLocation() { + return this.location; } - public String getSchedule() { - return schedule; + public void setLocation(String location) { + this.location = location; } - public void setSchedule(String schedule) { - this.schedule = schedule; + public String getMessage() { + return this.message; } - public LocalDate getScheduleDate() { - return scheduleDate; + public void setMessage(String message) { + this.message = message; } - public void setScheduleDate(LocalDate scheduleDate) { - this.scheduleDate = scheduleDate; + public DateTime getProcessedAt() { + return this.processedAt; } - public LocalDate getRetryDate() { - return retryDate; + public void setProcessedAt(DateTime processedAt) { + this.processedAt = processedAt; } - public void setRetryDate(LocalDate retryDate) { - this.retryDate = retryDate; + public String getResult() { + return this.result; } - public DateTime getProcessedAt() { - return processedAt; + public void setResult(String result) { + this.result = result; } - public void setProcessedAt(DateTime processedAt) { - this.processedAt = processedAt; + public LocalDate getRetryOn() { + return this.retryOn; } - public OccurrenceStatus getStatus() { - return status; + public void setRetryOn(LocalDate retryOn) { + this.retryOn = retryOn; } - public void setStatus(OccurrenceStatus status) { - this.status = status; + public String getSchedule() { + return this.schedule; } - public String getMessage() { - return message; + public void setSchedule(String schedule) { + this.schedule = schedule; } - public void setMessage(String message) { - this.message = message; + public LocalDate getScheduledOn() { + return this.scheduledOn; } - public String getResult() { - return result; + public void setScheduledOn(LocalDate scheduledOn) { + this.scheduledOn = scheduledOn; } - public void setResult(String result) { - this.result = result; + public OccurrenceStatus getStatus() { + return this.status; } - /** - * The {@link RequestBuilder} class for retrieving all occurrences that belong to a schedule. - */ - public static class ListRequestBuilder extends RequestBuilder> { + public void setStatus(OccurrenceStatus status) { + this.status = status; + } + public static class GetRequestBuilder extends RequestBuilder { + private String occurrenceId; + public GetRequestBuilder(String occurrenceId) { + this.occurrenceId = occurrenceId; + } + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "occurrences", occurrenceId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Occurrence.class); + } + } + + public static class ListRequestBuilder extends RequestBuilder> { private String scheduleId; private ScopedList.Options options; - public ListRequestBuilder(String scheduleId) { this.scheduleId = scheduleId; } @Override - protected HttpUrl path() throws IOException { + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - return new HttpUrlBuilder(Endpoint.API, "schedules", serializer()) - .segments(scheduleId, "occurrences") - .params(options) - .build(); + .segments(scheduleId, "occurrences") + .params(options) + .build(); } @Override protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + return new ResponseType<>(new TypeReference>() {}); } - public Occurrence.ListRequestBuilder options(ScopedList.Options options) { + public ListRequestBuilder options(ScopedList.Options options) { this.options = options; return this; } } - - /** - * The {@link RequestBuilder} class for retrieving a particular occurrence. - */ - public static class GetRequestBuilder extends RequestBuilder { - private String occurrenceId; - - public GetRequestBuilder(String occurrenceId) { - this.occurrenceId = occurrenceId; - } - - @Override - protected HttpUrl path() throws IOException { - return buildUrl(Endpoint.API, "occurrences", occurrenceId); - } - - @Override - protected ResponseType type() { - return new ResponseType<>(Occurrence.class); - } - } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/OccurrenceStatus.java b/src/main/java/co/omise/models/schedules/OccurrenceStatus.java index 78fc495a..17f9ea50 100644 --- a/src/main/java/co/omise/models/schedules/OccurrenceStatus.java +++ b/src/main/java/co/omise/models/schedules/OccurrenceStatus.java @@ -3,7 +3,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum OccurrenceStatus { - @JsonProperty("skipped")Skipped, - @JsonProperty("failed")Failed, - @JsonProperty("successful")Successful, -} + @JsonProperty("failed") + Failed, + @JsonProperty("scheduled") + Scheduled, + @JsonProperty("skipped") + Skipped, + @JsonProperty("successful") + Successful; +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/Schedule.java b/src/main/java/co/omise/models/schedules/Schedule.java index 4416bd65..bac005c1 100644 --- a/src/main/java/co/omise/models/schedules/Schedule.java +++ b/src/main/java/co/omise/models/schedules/Schedule.java @@ -3,177 +3,190 @@ import co.omise.Endpoint; import co.omise.models.Model; import co.omise.models.ScopedList; +import co.omise.models.schedules.Schedule; import co.omise.requests.RequestBuilder; import co.omise.requests.ResponseType; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; import okhttp3.HttpUrl; import okhttp3.RequestBody; +import org.joda.time.DateTime; import org.joda.time.LocalDate; import java.io.IOException; import java.util.List; /** - * Represents Omise Schedule object. + * Schedule object * * @see Schedule API */ public class Schedule extends Model { - private ScheduleStatus status; - private int every; - private SchedulePeriod period; - private ScheduleOn on; + private boolean active; + private ChargeSchedule charge; + @JsonProperty("end_on") + private LocalDate endOn; + @JsonProperty("ended_at") + private DateTime endedAt; + private long every; @JsonProperty("in_words") private String inWords; - @JsonProperty("start_on") - private LocalDate startDate; - @JsonProperty("end_on") - private LocalDate endDate; - private ChargeScheduling charge; - private TransferScheduling transfer; - private ScopedList occurrences; + private String location; @JsonProperty("next_occurrences_on") - private List nextOccurrencesDates; - private boolean active; + private List nextOccurrencesOn; + private ScopedList occurrences; + private ScheduleOn on; + private SchedulePeriod period; + @JsonProperty("start_on") + private LocalDate startOn; + private ScheduleStatus status; + private TransferSchedule transfer; - public Schedule() { + public boolean isActive() { + return this.active; } - public ScheduleStatus getStatus() { - return status; + public void setActive(boolean active) { + this.active = active; } - public void setStatus(ScheduleStatus status) { - this.status = status; + public ChargeSchedule getCharge() { + return this.charge; } - public int getEvery() { - return every; + public void setCharge(ChargeSchedule charge) { + this.charge = charge; } - public void setEvery(int every) { - this.every = every; + public LocalDate getEndOn() { + return this.endOn; } - public SchedulePeriod getPeriod() { - return period; + public void setEndOn(LocalDate endOn) { + this.endOn = endOn; } - public void setPeriod(SchedulePeriod period) { - this.period = period; + public DateTime getEndedAt() { + return this.endedAt; } - public ScheduleOn getOn() { - return on; + public void setEndedAt(DateTime endedAt) { + this.endedAt = endedAt; } - public void setOn(ScheduleOn on) { - this.on = on; + public long getEvery() { + return this.every; + } + + public void setEvery(long every) { + this.every = every; } public String getInWords() { - return inWords; + return this.inWords; } public void setInWords(String inWords) { this.inWords = inWords; } - public LocalDate getStartDate() { - return startDate; + public String getLocation() { + return this.location; } - public void setStartDate(LocalDate startDate) { - this.startDate = startDate; + public void setLocation(String location) { + this.location = location; } - public LocalDate getEndDate() { - return endDate; + public List getNextOccurrencesOn() { + return this.nextOccurrencesOn; } - public void setEndDate(LocalDate endDate) { - this.endDate = endDate; + public void setNextOccurrencesOn(List nextOccurrencesOn) { + this.nextOccurrencesOn = nextOccurrencesOn; } - public ChargeScheduling getCharge() { - return charge; + public ScopedList getOccurrences() { + return this.occurrences; } - public void setCharge(ChargeScheduling charge) { - this.charge = charge; + public void setOccurrences(ScopedList occurrences) { + this.occurrences = occurrences; } - public TransferScheduling getTransfer() { - return transfer; + public ScheduleOn getOn() { + return this.on; } - public void setTransfer(TransferScheduling transfer) { - this.transfer = transfer; + public void setOn(ScheduleOn on) { + this.on = on; } - public ScopedList getOccurrences() { - return occurrences; + public SchedulePeriod getPeriod() { + return this.period; } - public void setOccurrences(ScopedList occurrences) { - this.occurrences = occurrences; + public void setPeriod(SchedulePeriod period) { + this.period = period; } - public List getNextOccurrencesDates() { - return this.nextOccurrencesDates; + public LocalDate getStartOn() { + return this.startOn; } - public void setNextOccurrencesDates(List nextOccurrencesDates) { - this.nextOccurrencesDates = nextOccurrencesDates; + public void setStartOn(LocalDate startOn) { + this.startOn = startOn; } - public boolean isActive() { - return active; + public ScheduleStatus getStatus() { + return this.status; } - public void setActive(boolean active) { - this.active = active; + public void setStatus(ScheduleStatus status) { + this.status = status; } - /** - * The {@link RequestBuilder} class for retrieving all schedules that belong to an account. - */ - public static class ListRequestBuilder extends RequestBuilder> { - private ScopedList.Options options; + public TransferSchedule getTransfer() { + return this.transfer; + } - @Override - protected HttpUrl path() { - if (options == null) { - options = new ScopedList.Options(); - } + public void setTransfer(TransferSchedule transfer) { + this.transfer = transfer; + } - return buildUrl(Endpoint.API, "schedules", options); + public static class DeleteRequestBuilder extends RequestBuilder { + private String scheduleId; + public DeleteRequestBuilder(String scheduleId) { + this.scheduleId = scheduleId; } @Override - protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + protected String method() { + return DELETE; } - public ListRequestBuilder options(ScopedList.Options options) { - this.options = options; - return this; + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "schedules", scheduleId); + } + + @Override + protected ResponseType type() { + return new ResponseType<>(Schedule.class); } } - /** - * The {@link RequestBuilder} class for retrieving a particular schedule. - */ public static class GetRequestBuilder extends RequestBuilder { - private String scheduleId; - public GetRequestBuilder(String scheduleId) { this.scheduleId = scheduleId; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { return buildUrl(Endpoint.API, "schedules", scheduleId); @@ -185,37 +198,70 @@ protected ResponseType type() { } } - /** - * The {@link RequestBuilder} class for creating a schedule. - */ + public static class ListRequestBuilder extends RequestBuilder> { + private ScopedList.Options options; + + @Override + protected String method() { + return GET; + } + + @Override + protected HttpUrl path() { + if (options == null) { + options = new ScopedList.Options(); + } + return new HttpUrlBuilder(Endpoint.API, "schedules", serializer()) + .segments() + .params(options) + .build(); + } + + @Override + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); + } + + public ListRequestBuilder options(ScopedList.Options options) { + this.options = options; + return this; + } + } + public static class CreateRequestBuilder extends RequestBuilder { + @JsonProperty - private int every; + private ChargeSchedule.Params charge; + @JsonProperty("end_date") + private LocalDate endDate; @JsonProperty - private SchedulePeriod period; + private long every; @JsonProperty private ScheduleOn.Params on; + @JsonProperty + private SchedulePeriod period; @JsonProperty("start_date") private LocalDate startDate; - @JsonProperty("end_date") - private LocalDate endDate; - @JsonProperty - private ChargeScheduling.Params charge; @JsonProperty - private TransferScheduling.Params transfer; + private TransferSchedule.Params transfer; - public CreateRequestBuilder every(int units) { - this.every = units; - return this; + @Override + protected String method() { + return POST; } - public CreateRequestBuilder period(SchedulePeriod period) { - this.period = period; - return this; + @Override + protected HttpUrl path() { + return buildUrl(Endpoint.API, "schedules"); } - public CreateRequestBuilder startDate(LocalDate startDate) { - this.startDate = startDate; + @Override + protected ResponseType type() { + return new ResponseType<>(Schedule.class); + } + + public CreateRequestBuilder charge(ChargeSchedule.Params charge) { + this.charge = charge; return this; } @@ -224,126 +270,97 @@ public CreateRequestBuilder endDate(LocalDate endDate) { return this; } - public CreateRequestBuilder on(ScheduleOn.Params on) { - this.on = on; + public CreateRequestBuilder every(long every) { + this.every = every; return this; } - public CreateRequestBuilder charge(ChargeScheduling.Params charge) { - this.charge = charge; + public CreateRequestBuilder on(ScheduleOn.Params on) { + this.on = on; return this; } - public CreateRequestBuilder transfer(TransferScheduling.Params transfer) { - this.transfer = transfer; + public CreateRequestBuilder period(SchedulePeriod period) { + this.period = period; return this; } - @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "schedules"); + public CreateRequestBuilder startDate(LocalDate startDate) { + this.startDate = startDate; + return this; } - @Override - protected String method() { - return POST; + public CreateRequestBuilder transfer(TransferSchedule.Params transfer) { + this.transfer = transfer; + return this; } @Override protected RequestBody payload() throws IOException { return serialize(); } - - @Override - protected ResponseType type() { - return new ResponseType<>(Schedule.class); - } } - /** - * The {@link RequestBuilder} class for destroying a particular schedule. - */ - public static class DeleteRequestBuilder extends RequestBuilder { - + public static class ListOccurrencesRequestBuilder extends RequestBuilder> { private String scheduleId; - - public DeleteRequestBuilder(String scheduleId) { + private ScopedList.Options options; + public ListOccurrencesRequestBuilder(String scheduleId) { this.scheduleId = scheduleId; } - @Override - protected HttpUrl path() { - return buildUrl(Endpoint.API, "schedules", scheduleId); - } - - @Override - protected ResponseType type() { - return new ResponseType<>(Schedule.class); - } - @Override protected String method() { - return DELETE; + return GET; } - } - - /** - * The {@link RequestBuilder} class for retrieving all charge schedules that belong to an account. - */ - public static class ChargeScheduleListRequestBuilder extends RequestBuilder> { - - private ScopedList.Options options; @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - return new HttpUrlBuilder(Endpoint.API, "charges", serializer()) - .segments("schedules") - .params(options) - .build(); + return new HttpUrlBuilder(Endpoint.API, "schedules", serializer()) + .segments(scheduleId, "occurrences") + .params(options) + .build(); } @Override - protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + protected ResponseType> type() { + return new ResponseType<>(new TypeReference>() {}); } - public ChargeScheduleListRequestBuilder options(ScopedList.Options options) { + public ListOccurrencesRequestBuilder options(ScopedList.Options options) { this.options = options; return this; } } - /** - * The {@link RequestBuilder} class for retrieving all charge schedules that belong to a given customer. - */ public static class CustomerScheduleListRequestBuilder extends RequestBuilder> { - private String customerId; private ScopedList.Options options; - public CustomerScheduleListRequestBuilder(String customerId) { this.customerId = customerId; } + @Override + protected String method() { + return GET; + } + @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } return new HttpUrlBuilder(Endpoint.API, "customers", serializer()) - .segments(customerId, "schedules") - .params(options) - .build(); + .segments(customerId, "schedules") + .params(options) + .build(); } @Override protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + return new ResponseType<>(new TypeReference>() {}); } public CustomerScheduleListRequestBuilder options(ScopedList.Options options) { @@ -352,45 +369,46 @@ public CustomerScheduleListRequestBuilder options(ScopedList.Options options) { } } - /** - * The {@link RequestBuilder} class for retrieving all transfer schedules that belong to an account. - */ - public static class TransferScheduleListRequestBuilder extends RequestBuilder> { + public static class RecipientScheduleListRequestBuilder extends RequestBuilder> { + private String recipientId; private ScopedList.Options options; + public RecipientScheduleListRequestBuilder(String recipientId) { + this.recipientId = recipientId; + } + + @Override + protected String method() { + return GET; + } @Override protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - return new HttpUrlBuilder(Endpoint.API, "transfers", serializer()) - .segments("schedules") - .params(options) - .build(); + return new HttpUrlBuilder(Endpoint.API, "recipients", serializer()) + .segments(recipientId, "schedules") + .params(options) + .build(); } @Override protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + return new ResponseType<>(new TypeReference>() {}); } - public TransferScheduleListRequestBuilder options(ScopedList.Options options) { + public RecipientScheduleListRequestBuilder options(ScopedList.Options options) { this.options = options; return this; } } - /** - * The {@link RequestBuilder} class for retrieving all transfer schedules that belong to a given recipient. - */ - public static class RecipientScheduleListRequestBuilder extends RequestBuilder> { - - private String recipientId; + public static class TransferScheduleListRequestBuilder extends RequestBuilder> { private ScopedList.Options options; - public RecipientScheduleListRequestBuilder(String recipientId) { - this.recipientId = recipientId; + @Override + protected String method() { + return GET; } @Override @@ -398,21 +416,20 @@ protected HttpUrl path() { if (options == null) { options = new ScopedList.Options(); } - return new HttpUrlBuilder(Endpoint.API, "recipients", serializer()) - .segments(recipientId, "schedules") - .params(options) - .build(); + return new HttpUrlBuilder(Endpoint.API, "transfers", serializer()) + .segments("schedules") + .params(options) + .build(); } @Override protected ResponseType> type() { - return new ResponseType<>(new TypeReference>() { - }); + return new ResponseType<>(new TypeReference>() {}); } - public RecipientScheduleListRequestBuilder options(ScopedList.Options options) { + public TransferScheduleListRequestBuilder options(ScopedList.Options options) { this.options = options; return this; } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/ScheduleOn.java b/src/main/java/co/omise/models/schedules/ScheduleOn.java index 39f3ea79..5da71a68 100644 --- a/src/main/java/co/omise/models/schedules/ScheduleOn.java +++ b/src/main/java/co/omise/models/schedules/ScheduleOn.java @@ -1,34 +1,18 @@ package co.omise.models.schedules; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; -// key presence meaningful, must not send nulls or []s public class ScheduleOn implements Serializable { - @JsonInclude(JsonInclude.Include.NON_NULL) - @JsonProperty("weekdays") - private Weekdays[] weekdays; - - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("days_of_month") private int[] daysOfMonth; - - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("weekday_of_month") private String weekdayOfMonth; - - public Weekdays[] getWeekdays() { - return weekdays; - } - - public void setWeekdays(Weekdays[] weekdays) { - this.weekdays = weekdays; - } + private Weekdays[] weekdays; public int[] getDaysOfMonth() { - return daysOfMonth; + return this.daysOfMonth; } public void setDaysOfMonth(int[] daysOfMonth) { @@ -36,57 +20,44 @@ public void setDaysOfMonth(int[] daysOfMonth) { } public String getWeekdayOfMonth() { - return weekdayOfMonth; + return this.weekdayOfMonth; } public void setWeekdayOfMonth(String weekdayOfMonth) { this.weekdayOfMonth = weekdayOfMonth; } + public Weekdays[] getWeekdays() { + return this.weekdays; + } + + public void setWeekdays(Weekdays[] weekdays) { + this.weekdays = weekdays; + } + public static class Params extends co.omise.models.Params { - @JsonProperty("weekdays") - @JsonInclude(JsonInclude.Include.NON_NULL) - private Weekdays[] weekdays; @JsonProperty("days_of_month") - @JsonInclude(JsonInclude.Include.NON_NULL) private int[] daysOfMonth; + @JsonProperty("weekday_of_month") - @JsonInclude(JsonInclude.Include.NON_NULL) private String weekdayOfMonth; - /** - * Specify that a schedule should run only on certain weekdays. - * - * @param weekdays A list of {@link Weekdays} values. - * @return itself, for chaining. - */ - public Params weekdays(Weekdays... weekdays) { - this.weekdays = weekdays; - return this; - } + @JsonProperty + private Weekdays[] weekdays; - /** - * Specify that a schedule should run only on specific date each month. - * - * @param days The month date to run. - * Specify 1 to run every month's start and 28th for every month's end. - * @return itself, for chaining. - */ - public Params daysOfMonth(int... days) { - this.daysOfMonth = days; + public Params daysOfMonth(int... daysOfMonth) { + this.daysOfMonth = daysOfMonth; return this; } - /** - * Specify that a schedule should run only on the ordinalized weekday of each month. - * - * @param weekdayOfMonth Ordinalized weekday of month in underscore form. - * For example `2nd_monday` or `last_friday`. - * @return itself, for chaining. - */ public Params weekdayOfMonth(String weekdayOfMonth) { this.weekdayOfMonth = weekdayOfMonth; return this; } + + public Params weekdays(Weekdays... weekdays) { + this.weekdays = weekdays; + return this; + } } -} +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/SchedulePeriod.java b/src/main/java/co/omise/models/schedules/SchedulePeriod.java index 8329edd6..d4abadab 100644 --- a/src/main/java/co/omise/models/schedules/SchedulePeriod.java +++ b/src/main/java/co/omise/models/schedules/SchedulePeriod.java @@ -3,7 +3,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum SchedulePeriod { - @JsonProperty("day")Day, - @JsonProperty("week")Week, - @JsonProperty("month")Month, + @JsonProperty("day") + Day, + @JsonProperty("month") + Month, + @JsonProperty("week") + Week; } \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/ScheduleStatus.java b/src/main/java/co/omise/models/schedules/ScheduleStatus.java index 9e98b335..c2332de3 100644 --- a/src/main/java/co/omise/models/schedules/ScheduleStatus.java +++ b/src/main/java/co/omise/models/schedules/ScheduleStatus.java @@ -3,9 +3,16 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum ScheduleStatus { - @JsonProperty("running") Running, - @JsonProperty("expiring") Expiring, - @JsonProperty("expired") Expired, - @JsonProperty("deleted") Deleted, - @JsonProperty("suspended") Suspended, -} + @JsonProperty("active") + Active, + @JsonProperty("deleted") + Deleted, + @JsonProperty("expired") + Expired, + @JsonProperty("expiring") + Expiring, + @JsonProperty("running") + Running, + @JsonProperty("suspended") + Suspended; +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/TransferSchedule.java b/src/main/java/co/omise/models/schedules/TransferSchedule.java new file mode 100644 index 00000000..da3be060 --- /dev/null +++ b/src/main/java/co/omise/models/schedules/TransferSchedule.java @@ -0,0 +1,83 @@ +package co.omise.models.schedules; + +import co.omise.models.Model; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Transfer object + * + * @see Transfer API + */ +public class TransferSchedule extends Model { + private long amount; + private String currency; + @JsonProperty("percentage_of_balance") + private Double percentageOfBalance; + private String recipient; + + public long getAmount() { + return this.amount; + } + + public void setAmount(long amount) { + this.amount = amount; + } + + public String getCurrency() { + return this.currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public Double getPercentageOfBalance() { + return this.percentageOfBalance; + } + + public void setPercentageOfBalance(Double percentageOfBalance) { + this.percentageOfBalance = percentageOfBalance; + } + + public String getRecipient() { + return this.recipient; + } + + public void setRecipient(String recipient) { + this.recipient = recipient; + } + + public static class Params extends co.omise.models.Params { + @JsonProperty + private long amount; + + @JsonProperty + private String currency; + + @JsonProperty("percentage_of_balance") + private Double percentageOfBalance; + + @JsonProperty + private String recipient; + + public Params amount(long amount) { + this.amount = amount; + return this; + } + + public Params currency(String currency) { + this.currency = currency; + return this; + } + + public Params percentageOfBalance(Double percentageOfBalance) { + this.percentageOfBalance = percentageOfBalance; + return this; + } + + public Params recipient(String recipient) { + this.recipient = recipient; + return this; + } + } +} \ No newline at end of file diff --git a/src/main/java/co/omise/models/schedules/TransferScheduling.java b/src/main/java/co/omise/models/schedules/TransferScheduling.java deleted file mode 100644 index 07284e62..00000000 --- a/src/main/java/co/omise/models/schedules/TransferScheduling.java +++ /dev/null @@ -1,62 +0,0 @@ -package co.omise.models.schedules; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; - -public class TransferScheduling implements Serializable { - private String recipient; - private long amount; - @JsonProperty("percentage_of_balance") - private float percentageOfBalance; - - public String getRecipient() { - return recipient; - } - - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - public long getAmount() { - return amount; - } - - public void setAmount(long amount) { - this.amount = amount; - } - - public float getPercentageOfBalance() { - return percentageOfBalance; - } - - public void setPercentageOfBalance(float percentageOfBalance) { - this.percentageOfBalance = percentageOfBalance; - } - - public static class Params extends co.omise.models.Params { - @JsonInclude(JsonInclude.Include.NON_NULL) - private Long amount; - @JsonProperty("precentage_of_balance") - @JsonInclude(JsonInclude.Include.NON_NULL) - private Float percentageOfBalance; - @JsonProperty - private String recipient; - - public Params amount(Long amount) { - this.amount = amount; - return this; - } - - public Params percentageOfBalance(Float percent) { - this.percentageOfBalance = percent; - return this; - } - - public Params recipient(String recipient) { - this.recipient = recipient; - return this; - } - } -} diff --git a/src/main/java/co/omise/models/schedules/Weekdays.java b/src/main/java/co/omise/models/schedules/Weekdays.java index c20f63f1..e44544fb 100644 --- a/src/main/java/co/omise/models/schedules/Weekdays.java +++ b/src/main/java/co/omise/models/schedules/Weekdays.java @@ -3,11 +3,18 @@ import com.fasterxml.jackson.annotation.JsonProperty; public enum Weekdays { - @JsonProperty("monday")Monday, - @JsonProperty("tuesday")Tuesday, - @JsonProperty("wednesday")Wednesday, - @JsonProperty("thursday")Thursday, - @JsonProperty("friday")Friday, - @JsonProperty("saturday")Saturday, - @JsonProperty("sunday")Sunday, -} + @JsonProperty("friday") + Friday, + @JsonProperty("monday") + Monday, + @JsonProperty("saturday") + Saturday, + @JsonProperty("sunday") + Sunday, + @JsonProperty("thursday") + Thursday, + @JsonProperty("tuesday") + Tuesday, + @JsonProperty("wednesday") + Wednesday; +} \ No newline at end of file diff --git a/src/test/java/co/omise/live/LiveCardRequestTest.java b/src/test/java/co/omise/live/LiveCardRequestTest.java index ebdde5b7..90ea5e29 100644 --- a/src/test/java/co/omise/live/LiveCardRequestTest.java +++ b/src/test/java/co/omise/live/LiveCardRequestTest.java @@ -28,7 +28,7 @@ public void setup() throws Exception { @Ignore("only hit when test on live.") public void getCard_success() throws Exception { Request request = new Card.GetRequestBuilder( - CARD_ID, CUSTOMER_ID).build(); + CUSTOMER_ID, CARD_ID).build(); Card card = client.sendRequest(request); System.out.println("Card retrieved: " + card.getId()); @@ -42,7 +42,7 @@ public void getCard_success() throws Exception { @Ignore("only hit when test on live.") public void updateCard_success() throws IOException, OmiseException { Request request = new Card.UpdateRequestBuilder( - CARD_ID, CUSTOMER_ID) + CUSTOMER_ID, CARD_ID) .name("JOHN W. DOE") .expirationYear(2022) .expirationMonth(11) @@ -86,7 +86,7 @@ public void getCardList_success() throws IOException, OmiseException { @Ignore("only hit the network when need to.") public void deleteCard_success() throws IOException, OmiseException { Request request = - new Card.DeleteRequestBuilder(CARD_ID, CUSTOMER_ID) + new Card.DeleteRequestBuilder(CUSTOMER_ID, CARD_ID) .build(); Card card = client.sendRequest(request); diff --git a/src/test/java/co/omise/live/LiveScheduleRequestTest.java b/src/test/java/co/omise/live/LiveScheduleRequestTest.java index 685a1ae8..1b217b72 100644 --- a/src/test/java/co/omise/live/LiveScheduleRequestTest.java +++ b/src/test/java/co/omise/live/LiveScheduleRequestTest.java @@ -81,7 +81,7 @@ public void testLiveScheduleGet() throws IOException, OmiseException { .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 99)) - .charge(new ChargeScheduling.Params() + .charge(new ChargeSchedule.Params() .customer(customer.getId()) .amount(2000) .currency("THB") @@ -129,7 +129,7 @@ public void testLiveScheduleCreate() throws IOException, OmiseException { .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 99)) - .charge(new ChargeScheduling.Params() + .charge(new ChargeSchedule.Params() .customer(customer.getId()) .amount(2000) .currency("THB") @@ -172,7 +172,7 @@ public void testLiveScheduleDelete() throws IOException, OmiseException { .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 99)) - .charge(new ChargeScheduling.Params() + .charge(new ChargeSchedule.Params() .customer(customer.getId()) .amount(2000) .currency("THB") @@ -196,7 +196,7 @@ public void testLiveScheduleDelete() throws IOException, OmiseException { @Test @Ignore("only hit the network when we need to.") public void testLiveChargeScheduleListGet() throws IOException, OmiseException { - Request> request = new Schedule.ChargeScheduleListRequestBuilder().build(); + Request> request = new Charge.ListSchedulesRequestBuilder().build(); ScopedList scheduleList = client.sendRequest(request); @@ -214,7 +214,7 @@ public void testLiveListChargeScheduleWithOption() throws IOException, OmiseExce .limit(3) .order(Ordering.Chronological); Request> request = - new Schedule.ChargeScheduleListRequestBuilder() + new Charge.ListSchedulesRequestBuilder() .options(options) .build(); ScopedList transactions = client.sendRequest(request); @@ -249,7 +249,7 @@ public void testLiveCustomerScheduleListGet() throws IOException, OmiseException .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 1)) - .charge(new ChargeScheduling.Params() + .charge(new ChargeSchedule.Params() .customer(customer.getId()) .amount(2000) .currency("THB") @@ -296,7 +296,7 @@ public void testLiveCustomerScheduleListWithOption() throws IOException, OmiseEx .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 1)) - .charge(new ChargeScheduling.Params() + .charge(new ChargeSchedule.Params() .customer(customer.getId()) .amount(2000) .currency("THB") @@ -344,7 +344,7 @@ public void testLiveTransferScheduleList() throws IOException, OmiseException { .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 1)) - .transfer(new TransferScheduling.Params() + .transfer(new TransferSchedule.Params() .amount(2000L) .recipient(recipient.getId()) ) @@ -379,7 +379,7 @@ public void testLiveTransferScheduleListWithOption() throws IOException, OmiseEx .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 1)) - .transfer(new TransferScheduling.Params() + .transfer(new TransferSchedule.Params() .amount(2000L) .recipient(recipient.getId()) ) @@ -422,7 +422,7 @@ public void testLiveRecipientScheduleList() throws IOException, OmiseException { .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 1)) - .transfer(new TransferScheduling.Params() + .transfer(new TransferSchedule.Params() .amount(2000L) .recipient(recipient.getId()) ) @@ -461,7 +461,7 @@ public void testLiveRecipientScheduleListWithOption() throws IOException, OmiseE .period(SchedulePeriod.Week) .on(new ScheduleOn.Params().weekdays(Weekdays.Friday)) .endDate(LocalDate.now().withFieldAdded(DurationFieldType.years(), 1)) - .transfer(new TransferScheduling.Params() + .transfer(new TransferSchedule.Params() .amount(2000L) .recipient(recipient.getId()) ) diff --git a/src/test/java/co/omise/models/SerializationTest.java b/src/test/java/co/omise/models/SerializationTest.java index 67e318df..20babc6e 100644 --- a/src/test/java/co/omise/models/SerializationTest.java +++ b/src/test/java/co/omise/models/SerializationTest.java @@ -83,7 +83,8 @@ private String objectJsonName(Class klass) { } else if (Objects.equal(klass, PaymentMethod.class)) { return "/testdata/objects/payment_method_object.json"; } else { - return "/testdata/objects/" + klass.getSimpleName().toLowerCase() + "_object.json"; + String fileName = klass.getSimpleName().replaceAll("([A-Z])", "_$1").toLowerCase().substring(1); + return "/testdata/objects/" + fileName + "_object.json"; } } } diff --git a/src/test/java/co/omise/requests/CardRequestTest.java b/src/test/java/co/omise/requests/CardRequestTest.java index be27fb71..c01ae718 100644 --- a/src/test/java/co/omise/requests/CardRequestTest.java +++ b/src/test/java/co/omise/requests/CardRequestTest.java @@ -15,7 +15,7 @@ public class CardRequestTest extends RequestTest { @Test public void testGet() throws IOException, OmiseException { - Request request = new Card.GetRequestBuilder(CARD_ID, CUSTOMER_ID).build(); + Request request = new Card.GetRequestBuilder(CUSTOMER_ID, CARD_ID).build(); Card card = getTestRequester().sendRequest(request); assertRequested("GET", "/customers/" + CUSTOMER_ID + "/cards/" + CARD_ID, 200); @@ -29,7 +29,7 @@ public void testGet() throws IOException, OmiseException { @Test public void testUpdate() throws IOException, OmiseException { Request request = new Card.UpdateRequestBuilder( - CARD_ID, CUSTOMER_ID) + CUSTOMER_ID, CARD_ID) .name("JOHN W. DOE") .build(); Card card = getTestRequester().sendRequest(request); @@ -61,7 +61,7 @@ public void testList() throws IOException, OmiseException { @Test public void testDestroy() throws IOException, OmiseException { Request request = - new Card.DeleteRequestBuilder(CARD_ID, CUSTOMER_ID) + new Card.DeleteRequestBuilder(CUSTOMER_ID, CARD_ID) .build(); Card card = getTestRequester().sendRequest(request); diff --git a/src/test/java/co/omise/requests/DisputeRequestTest.java b/src/test/java/co/omise/requests/DisputeRequestTest.java index 2e70b3e2..210ef6ae 100644 --- a/src/test/java/co/omise/requests/DisputeRequestTest.java +++ b/src/test/java/co/omise/requests/DisputeRequestTest.java @@ -67,7 +67,7 @@ public void testGet() throws IOException, OmiseException { DateTimeFormatter formatter = Serializer.defaultSerializer().dateTimeFormatter(); LocalDateTime closedAt = LocalDateTime.parse("2015-03-23T01:24:39Z", formatter); - assertEquals(closedAt, dispute.getClosedDate().toLocalDateTime()); + assertEquals(closedAt, dispute.getClosedAt().toLocalDateTime()); } @Test diff --git a/src/test/java/co/omise/requests/ScheduleRequestTest.java b/src/test/java/co/omise/requests/ScheduleRequestTest.java index e1e06216..b2d0ddae 100644 --- a/src/test/java/co/omise/requests/ScheduleRequestTest.java +++ b/src/test/java/co/omise/requests/ScheduleRequestTest.java @@ -1,5 +1,6 @@ package co.omise.requests; +import co.omise.models.Charge; import co.omise.models.OmiseException; import co.omise.models.ScopedList; import co.omise.models.schedules.*; @@ -32,7 +33,7 @@ public void testGet() throws IOException, OmiseException { assertEquals(ScheduleStatus.Running, schedule.getStatus()); assertEquals(1, schedule.getEvery()); assertEquals(SchedulePeriod.Month, schedule.getPeriod()); - assertEquals(11, schedule.getNextOccurrencesDates().size()); + assertEquals(11, schedule.getNextOccurrencesOn().size()); } @Test @@ -53,7 +54,7 @@ public void testCreate() throws IOException, OmiseException { .on(new ScheduleOn.Params().daysOfMonth(2)) .startDate(LocalDate.parse("2017-04-27")) .endDate(LocalDate.parse("2018-04-27")) - .charge(new ChargeScheduling.Params() + .charge(new ChargeSchedule.Params() .customer("cust_test_55bb3hkywglfyyachha") .amount(88800) .description("Monthly membership fee")) @@ -66,7 +67,7 @@ public void testCreate() throws IOException, OmiseException { assertEquals(SCHEDULE_ID, schedule.getId()); assertEquals(1, schedule.getEvery()); assertEquals(SchedulePeriod.Month, schedule.getPeriod()); - assertEquals(11, schedule.getNextOccurrencesDates().size()); + assertEquals(11, schedule.getNextOccurrencesOn().size()); } @Test @@ -83,7 +84,7 @@ public void testDelete() throws IOException, OmiseException { @Test public void testChargeScheduleList() throws IOException, OmiseException { - Request> request = new Schedule.ChargeScheduleListRequestBuilder().build(); + Request> request = new Charge.ListSchedulesRequestBuilder().build(); ScopedList schedules = requester.sendRequest(request); diff --git a/src/test/resources/testdata/fixtures/api.omise.co/charges/schedules-get.json b/src/test/resources/testdata/fixtures/api.omise.co/charges/schedules-get.json index 558e14b6..c71ac563 100644 --- a/src/test/resources/testdata/fixtures/api.omise.co/charges/schedules-get.json +++ b/src/test/resources/testdata/fixtures/api.omise.co/charges/schedules-get.json @@ -25,6 +25,7 @@ "start_date": "2017-10-20", "end_date": "2116-10-20", "charge": { + "object": "scheduled_charge", "amount": 2000, "currency": "thb", "description": null, @@ -231,6 +232,7 @@ "start_date": "2017-11-09", "end_date": "2116-11-09", "charge": { + "object": "scheduled_charge", "amount": 2000, "currency": "thb", "description": null, @@ -395,6 +397,7 @@ "start_date": "2017-11-09", "end_date": "2116-11-09", "charge": { + "object": "scheduled_charge", "amount": 2000, "currency": "thb", "description": null, @@ -559,6 +562,7 @@ "start_date": "2018-08-21", "end_date": "2019-08-21", "charge": { + "object": "scheduled_charge", "amount": 50000, "currency": "thb", "description": "Test schedule", @@ -627,6 +631,7 @@ "start_date": "2018-08-29", "end_date": "2018-12-29", "charge": { + "object": "scheduled_charge", "amount": 100000, "currency": "thb", "description": "Monthly membership fee", @@ -653,4 +658,4 @@ "created_at": "2018-08-21T08:26:25Z" } ] -} +} \ No newline at end of file diff --git a/src/test/resources/testdata/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/schedules-get.json b/src/test/resources/testdata/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/schedules-get.json index de1becd1..8c278eaf 100644 --- a/src/test/resources/testdata/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/schedules-get.json +++ b/src/test/resources/testdata/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/schedules-get.json @@ -25,6 +25,7 @@ "start_date": "2018-08-21", "end_date": "2019-08-21", "charge": { + "object": "scheduled_charge", "amount": 50000, "currency": "thb", "description": "Test schedule", @@ -93,6 +94,7 @@ "start_date": "2018-08-29", "end_date": "2018-12-29", "charge": { + "object": "scheduled_charge", "amount": 100000, "currency": "thb", "description": "Monthly membership fee", diff --git a/src/test/resources/testdata/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc/schedules-get.json b/src/test/resources/testdata/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc/schedules-get.json index 5d869064..20fa3327 100644 --- a/src/test/resources/testdata/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc/schedules-get.json +++ b/src/test/resources/testdata/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc/schedules-get.json @@ -25,6 +25,7 @@ "start_date": "2018-08-21", "end_date": "2019-08-21", "transfer": { + "object": "scheduled_transfer", "recipient": "recp_test_50894vc13y8z4v51iuc", "amount": 100000, "percentage_of_balance": null, diff --git a/src/test/resources/testdata/fixtures/api.omise.co/schedules-get.json b/src/test/resources/testdata/fixtures/api.omise.co/schedules-get.json index 2d884d05..4a7e112b 100644 --- a/src/test/resources/testdata/fixtures/api.omise.co/schedules-get.json +++ b/src/test/resources/testdata/fixtures/api.omise.co/schedules-get.json @@ -25,6 +25,7 @@ "start_on": "2017-10-20", "end_on": "2116-10-20", "charge": { + "object": "scheduled_charge", "amount": 2000, "currency": "thb", "description": null, @@ -235,7 +236,8 @@ "currency": "thb", "description": null, "customer": "cust_test_59wuazdrsyt6064lih7", - "card": null + "card": null, + "object": "scheduled_charge" }, "occurrences": { "object": "list", @@ -399,7 +401,8 @@ "currency": "thb", "description": null, "customer": "cust_test_59wupnjgzf48bfm0uu0", - "card": null + "card": null, + "object": "scheduled_charge" }, "occurrences": { "object": "list", @@ -563,7 +566,8 @@ "currency": "thb", "description": "Test schedule", "customer": "cust_test_5d071802px8vu1uxvof", - "card": "card_test_5d071cqejxmlzgt1wk0" + "card": "card_test_5d071cqejxmlzgt1wk0", + "object": "scheduled_charge" }, "occurrences": { "object": "list", @@ -631,7 +635,8 @@ "currency": "thb", "description": "Monthly membership fee", "customer": "cust_test_5d071802px8vu1uxvof", - "card": null + "card": null, + "object": "scheduled_charge" }, "occurrences": { "object": "list", @@ -672,7 +677,8 @@ "recipient": "recp_test_59cjdciys3wm0x2ehvw", "amount": 100000, "percentage_of_balance": null, - "currency": "thb" + "currency": "thb", + "object": "scheduled_transfer" }, "occurrences": { "object": "list", @@ -722,7 +728,8 @@ "currency": "thb", "description": "Monthly membership fee", "customer": "cust_test_5d085fcqmskqlbi4470", - "card": null + "card": null, + "object": "scheduled_charge" }, "occurrences": { "object": "list", @@ -790,7 +797,8 @@ "currency": "thb", "description": "Monthly membership fee", "customer": "cust_test_5d085oblrecygubtool", - "card": null + "card": null, + "object": "scheduled_charge" }, "occurrences": { "object": "list", @@ -858,7 +866,8 @@ "currency": "thb", "description": "Monthly membership fee", "customer": "cust_test_5d08c0racxzruddcw5o", - "card": null + "card": null, + "object": "scheduled_charge" }, "occurrences": { "object": "list", @@ -895,7 +904,8 @@ "currency": "thb", "description": "Monthly membership fee", "customer": "cust_test_5d08gm3rhellm7k69rw", - "card": null + "card": null, + "object": "scheduled_charge" }, "occurrences": { "object": "list", @@ -963,7 +973,8 @@ "currency": "thb", "description": "Monthly membership fee", "customer": "cust_test_5d08gq1yhru5he6biyp", - "card": null + "card": null, + "object": "scheduled_charge" }, "occurrences": { "object": "list", diff --git a/src/test/resources/testdata/fixtures/api.omise.co/schedules-post.json b/src/test/resources/testdata/fixtures/api.omise.co/schedules-post.json index a9fae1f0..f8eeda3a 100644 --- a/src/test/resources/testdata/fixtures/api.omise.co/schedules-post.json +++ b/src/test/resources/testdata/fixtures/api.omise.co/schedules-post.json @@ -15,6 +15,7 @@ "start_date":"2017-04-27", "end_date":"2018-04-27", "charge":{ + "object": "scheduled_charge", "amount":88800, "currency":"thb", "description":"Monthly membership fee", diff --git a/src/test/resources/testdata/fixtures/api.omise.co/schedules/schd_test_57s33hm9fg1pzcqihxs-delete.json b/src/test/resources/testdata/fixtures/api.omise.co/schedules/schd_test_57s33hm9fg1pzcqihxs-delete.json index 3c4cc201..04afc434 100644 --- a/src/test/resources/testdata/fixtures/api.omise.co/schedules/schd_test_57s33hm9fg1pzcqihxs-delete.json +++ b/src/test/resources/testdata/fixtures/api.omise.co/schedules/schd_test_57s33hm9fg1pzcqihxs-delete.json @@ -15,6 +15,7 @@ "start_date":"2017-04-27", "end_date":"2018-04-27", "charge":{ + "object": "scheduled_charge", "amount":88800, "currency":"thb", "description":"Monthly membership fee", diff --git a/src/test/resources/testdata/fixtures/api.omise.co/schedules/schd_test_57s33hm9fg1pzcqihxs-get.json b/src/test/resources/testdata/fixtures/api.omise.co/schedules/schd_test_57s33hm9fg1pzcqihxs-get.json index 956d2e1a..0d7d923d 100644 --- a/src/test/resources/testdata/fixtures/api.omise.co/schedules/schd_test_57s33hm9fg1pzcqihxs-get.json +++ b/src/test/resources/testdata/fixtures/api.omise.co/schedules/schd_test_57s33hm9fg1pzcqihxs-get.json @@ -15,6 +15,7 @@ "start_on":"2017-04-27", "end_on":"2018-04-27", "charge":{ + "object": "scheduled_charge", "amount":88800, "currency":"thb", "description":"Monthly membership fee", diff --git a/src/test/resources/testdata/fixtures/api.omise.co/transfers/schedules-get.json b/src/test/resources/testdata/fixtures/api.omise.co/transfers/schedules-get.json index 19f80ffc..1184118d 100644 --- a/src/test/resources/testdata/fixtures/api.omise.co/transfers/schedules-get.json +++ b/src/test/resources/testdata/fixtures/api.omise.co/transfers/schedules-get.json @@ -25,6 +25,7 @@ "start_date": "2018-08-21", "end_date": "2019-08-21", "transfer": { + "object": "scheduled_transfer", "recipient": "recp_test_59cjdciys3wm0x2ehvw", "amount": 100000, "percentage_of_balance": null, diff --git a/src/test/resources/testdata/objects/charge_object.json b/src/test/resources/testdata/objects/charge_object.json index 15b55fa2..ffe02707 100644 --- a/src/test/resources/testdata/objects/charge_object.json +++ b/src/test/resources/testdata/objects/charge_object.json @@ -43,6 +43,10 @@ "security_code_check": true, "created_at": "2015-06-02T05:41:46Z" }, + "platform_fee": { + "fixed": 100, + "percentage": 3.14 + }, "customer": "cust_test_5086xleuh9ft4bn0ac2", "ip": null, "dispute": null, diff --git a/src/test/resources/testdata/objects/charge_schedule_object.json b/src/test/resources/testdata/objects/charge_schedule_object.json new file mode 100644 index 00000000..a0e2ab46 --- /dev/null +++ b/src/test/resources/testdata/objects/charge_schedule_object.json @@ -0,0 +1,15 @@ +{ + "object": "scheduled_charge", + "id": "rchg_test_no1t4tnemucod0e51mo", + "livemode": false, + "currency": "THB", + "amount": 12345, + "default_card": true, + "card": "card_test_no1t4tnemucod0e51mo", + "customer": "cust_test_no1t4tnemucod0e51mo", + "description": "Subscription for coffee beans", + "metadata": { + "answer": 42 + }, + "created_at": "2019-12-31T12:59:59Z" +} \ No newline at end of file diff --git a/src/test/resources/testdata/objects/schedule_object.json b/src/test/resources/testdata/objects/schedule_object.json index b9d5cabc..e853688c 100644 --- a/src/test/resources/testdata/objects/schedule_object.json +++ b/src/test/resources/testdata/objects/schedule_object.json @@ -16,6 +16,7 @@ "start_on": "2017-05-08", "end_on": "2116-05-08", "charge": { + "object": "scheduled_charge", "amount": 2000, "currency": "thb", "customer": "cust_test_57wedy5a1tdt0bf89iy", diff --git a/src/test/resources/testdata/objects/transfer_schedule_object.json b/src/test/resources/testdata/objects/transfer_schedule_object.json new file mode 100644 index 00000000..cde21945 --- /dev/null +++ b/src/test/resources/testdata/objects/transfer_schedule_object.json @@ -0,0 +1,10 @@ +{ + "object": "scheduled_transfer", + "id": "rtrf_test_no1t4tnemucod0e51mo", + "livemode": false, + "amount": 12345, + "currency": "THB", + "percentage_of_balance": null, + "recipient": "recp_test_no1t4tnemucod0e51mo", + "created_at": "2019-12-31T12:59:59Z" +} \ No newline at end of file diff --git a/src/test/resources/testdata/objects/webhook_delivery_object.json b/src/test/resources/testdata/objects/webhook_delivery_object.json new file mode 100644 index 00000000..c924934e --- /dev/null +++ b/src/test/resources/testdata/objects/webhook_delivery_object.json @@ -0,0 +1,6 @@ +{ + "object": "webhook_delivery", + "id": "whdl_test_abc", + "uri": "https://httpbin.org", + "status": 200 +} \ No newline at end of file diff --git a/test.apk b/test.apk deleted file mode 100644 index e69de29b..00000000