Skip to content

Commit

Permalink
feat: Pix Recurring
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdev01 committed Nov 17, 2024
1 parent 6df6183 commit 5ac8d01
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/main/java/io/github/jpdev/asaassdk/doc/Examples.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -34,7 +35,9 @@ private T parseResponse(AsaasRestClient client, Response response) {
}
}

@JsonIgnore
public abstract String getResourceUrl();

@JsonIgnore
public abstract Class<T> getResourceClass();
}
10 changes: 10 additions & 0 deletions src/main/java/io/github/jpdev/asaassdk/rest/transfer/Transfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class Transfer extends ApiResource {

private BigDecimal value;

private String recurring;

public BigDecimal getValue() {
return value;
}
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -12,7 +13,7 @@ public class TransferPixAddressKeyCreator extends Creator<Transfer> {
private PixAddressKeyType pixAddressKeyType;
private BigDecimal value;
private String description;

private PixRecurring recurring;

public TransferPixAddressKeyCreator setPixAddressKey(String pixAddressKey) {
this.pixAddressKey = pixAddressKey;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.jpdev.asaassdk.rest.transfer.children;

public enum PixRecurringFrequency {

WEEKLY,MONTHLY
}

0 comments on commit 5ac8d01

Please sign in to comment.