diff --git a/src/main/java/io/github/jpdev/asaassdk/doc/Examples.java b/src/main/java/io/github/jpdev/asaassdk/doc/Examples.java index b40d5ff..cdb1e28 100644 --- a/src/main/java/io/github/jpdev/asaassdk/doc/Examples.java +++ b/src/main/java/io/github/jpdev/asaassdk/doc/Examples.java @@ -33,9 +33,7 @@ import io.github.jpdev.asaassdk.rest.subscription.Subscription; import io.github.jpdev.asaassdk.rest.subscription.SubscriptionCycle; import io.github.jpdev.asaassdk.rest.transfer.Transfer; -import io.github.jpdev.asaassdk.rest.transfer.children.BankAccountSetting; -import io.github.jpdev.asaassdk.rest.transfer.children.BankAccountType; -import io.github.jpdev.asaassdk.rest.transfer.children.BankSetting; +import io.github.jpdev.asaassdk.rest.transfer.children.*; import io.github.jpdev.asaassdk.rest.webhook.Event; import io.github.jpdev.asaassdk.rest.webhook.SendType; import io.github.jpdev.asaassdk.rest.webhook.Webhook; @@ -50,6 +48,7 @@ public class Examples { public static void main(String[] args) { Asaas.init(Secret.getAccessToken()); // Initialize the SDK with your access token + recurringTransfer(); } private static void pixTransaction() { @@ -117,6 +116,21 @@ private static void transfer() { .create(); } + private static void recurringTransfer() { + PixRecurring recurring = new PixRecurring() + .setFrequency(PixRecurringFrequency.MONTHLY) + .setQuantity(2); + + Transfer transfer = Transfer.pixAddressKeyCreator() + .setPixAddressKey("47999999999") + .setValue(Money.create(0.01)) + .setDescription("teste") + .setPixAddressKeyType(PixAddressKeyType.PHONE) + .setRecurring(recurring) + .create(); + System.out.println(transfer.getRecurring()); + } + private static void bill() { Bill bill = Bill.creator() .setIdentificationField("25794150099003551916515000211407100000000000000") diff --git a/src/main/java/io/github/jpdev/asaassdk/rest/action/Creator.java b/src/main/java/io/github/jpdev/asaassdk/rest/action/Creator.java index 888e61d..8545bfa 100644 --- a/src/main/java/io/github/jpdev/asaassdk/rest/action/Creator.java +++ b/src/main/java/io/github/jpdev/asaassdk/rest/action/Creator.java @@ -1,5 +1,6 @@ package io.github.jpdev.asaassdk.rest.action; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.github.jpdev.asaassdk.exception.ApiException; import io.github.jpdev.asaassdk.http.Asaas; import io.github.jpdev.asaassdk.rest.ApiResource; @@ -34,7 +35,9 @@ private T parseResponse(AsaasRestClient client, Response response) { } } + @JsonIgnore public abstract String getResourceUrl(); + @JsonIgnore public abstract Class getResourceClass(); } diff --git a/src/main/java/io/github/jpdev/asaassdk/rest/transfer/Transfer.java b/src/main/java/io/github/jpdev/asaassdk/rest/transfer/Transfer.java index 5da0caa..c272585 100644 --- a/src/main/java/io/github/jpdev/asaassdk/rest/transfer/Transfer.java +++ b/src/main/java/io/github/jpdev/asaassdk/rest/transfer/Transfer.java @@ -10,6 +10,8 @@ public class Transfer extends ApiResource { private BigDecimal value; + private String recurring; + public BigDecimal getValue() { return value; } @@ -18,6 +20,14 @@ public void setValue(BigDecimal value) { this.value = value; } + public String getRecurring() { + return recurring; + } + + public void setRecurring(String recurring) { + this.recurring = recurring; + } + public static TransferPixAddressKeyCreator pixAddressKeyCreator() { return new TransferPixAddressKeyCreator(); } diff --git a/src/main/java/io/github/jpdev/asaassdk/rest/transfer/TransferPixAddressKeyCreator.java b/src/main/java/io/github/jpdev/asaassdk/rest/transfer/TransferPixAddressKeyCreator.java index bbb45e4..8bb213d 100644 --- a/src/main/java/io/github/jpdev/asaassdk/rest/transfer/TransferPixAddressKeyCreator.java +++ b/src/main/java/io/github/jpdev/asaassdk/rest/transfer/TransferPixAddressKeyCreator.java @@ -3,6 +3,7 @@ import io.github.jpdev.asaassdk.http.Domain; import io.github.jpdev.asaassdk.rest.action.Creator; import io.github.jpdev.asaassdk.rest.pix.enums.PixAddressKeyType; +import io.github.jpdev.asaassdk.rest.transfer.children.PixRecurring; import java.math.BigDecimal; @@ -12,7 +13,7 @@ public class TransferPixAddressKeyCreator extends Creator { private PixAddressKeyType pixAddressKeyType; private BigDecimal value; private String description; - + private PixRecurring recurring; public TransferPixAddressKeyCreator setPixAddressKey(String pixAddressKey) { this.pixAddressKey = pixAddressKey; @@ -46,6 +47,15 @@ public PixAddressKeyType getPixAddressKeyType() { return pixAddressKeyType; } + public PixRecurring getRecurring() { + return recurring; + } + + public TransferPixAddressKeyCreator setRecurring(PixRecurring recurring) { + this.recurring = recurring; + return this; + } + public String getDescription() { return description; } diff --git a/src/main/java/io/github/jpdev/asaassdk/rest/transfer/children/PixRecurring.java b/src/main/java/io/github/jpdev/asaassdk/rest/transfer/children/PixRecurring.java new file mode 100644 index 0000000..ec0a60d --- /dev/null +++ b/src/main/java/io/github/jpdev/asaassdk/rest/transfer/children/PixRecurring.java @@ -0,0 +1,25 @@ +package io.github.jpdev.asaassdk.rest.transfer.children; + +public class PixRecurring { + + PixRecurringFrequency frequency; + int quantity; + + public PixRecurringFrequency getFrequency() { + return frequency; + } + + public PixRecurring setFrequency(PixRecurringFrequency frequency) { + this.frequency = frequency; + return this; + } + + public int getQuantity() { + return quantity; + } + + public PixRecurring setQuantity(int quantity) { + this.quantity = quantity; + return this; + } +} diff --git a/src/main/java/io/github/jpdev/asaassdk/rest/transfer/children/PixRecurringFrequency.java b/src/main/java/io/github/jpdev/asaassdk/rest/transfer/children/PixRecurringFrequency.java new file mode 100644 index 0000000..7a8e8f7 --- /dev/null +++ b/src/main/java/io/github/jpdev/asaassdk/rest/transfer/children/PixRecurringFrequency.java @@ -0,0 +1,6 @@ +package io.github.jpdev.asaassdk.rest.transfer.children; + +public enum PixRecurringFrequency { + + WEEKLY,MONTHLY +}