Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>ai.pluggy</groupId>
<artifactId>pluggy-java</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -86,6 +86,24 @@
</dependencies>

<build>
<!-- Filter pluggy.properties so ${project.version} is replaced at build time; the
Version helper reads it to keep the User-Agent in sync with the pom version. -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>pluggy.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>pluggy.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- Test Surefire Plugin -->
<plugin>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ai/pluggy/client/PluggyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ai.pluggy.client.response.ErrorResponse;
import ai.pluggy.exception.PluggyException;
import ai.pluggy.utils.Utils;
import ai.pluggy.utils.Version;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -292,7 +293,7 @@ public String authenticate() throws IOException, PluggyException {
.post(body)
.addHeader("content-type", "application/json")
.addHeader("cache-control", "no-cache")
.addHeader("User-Agent", "PluggyJava/0.16.2")
.addHeader("User-Agent", Version.userAgent())
.build();

String apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static ai.pluggy.utils.Asserts.assertNotNull;

import ai.pluggy.utils.Version;
import com.google.gson.Gson;

import java.io.IOException;
Expand Down Expand Up @@ -114,8 +115,7 @@ private Request requestWithAuth(Request originalRequest, String apiKey) {
// override the apiKey of the original request with the new one
return originalRequest.newBuilder()
.header(X_API_KEY_HEADER, apiKey)
// TOOD: add dynamic version
.header("User-Agent", "PluggyJava/0.16.2")
.header("User-Agent", Version.userAgent())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ai.pluggy.client.response;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
public enum CreditCardAccountFeeType {
@SerializedName("ANNUAL_FEE")
ANNUAL_FEE("ANNUAL_FEE"),
@SerializedName("ATM_WITHDRAWAL_DOMESTIC")
ATM_WITHDRAWAL_DOMESTIC("ATM_WITHDRAWAL_DOMESTIC"),
@SerializedName("ATM_WITHDRAWAL_INTERNATIONAL")
ATM_WITHDRAWAL_INTERNATIONAL("ATM_WITHDRAWAL_INTERNATIONAL"),
@SerializedName("EMERGENCY_CREDIT_EVALUATION")
EMERGENCY_CREDIT_EVALUATION("EMERGENCY_CREDIT_EVALUATION"),
@SerializedName("CARD_REISSUE")
CARD_REISSUE("CARD_REISSUE"),
@SerializedName("BILL_PAYMENT_FEE")
BILL_PAYMENT_FEE("BILL_PAYMENT_FEE"),
@SerializedName("SMS")
SMS("SMS"),
@SerializedName("OTHER")
OTHER("OTHER");

@Getter
private String value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ai.pluggy.client.response;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
public enum CreditCardAccountOtherCreditType {
@SerializedName("REVOLVING_CREDIT")
REVOLVING_CREDIT("REVOLVING_CREDIT"),
@SerializedName("BILL_INSTALLMENT")
BILL_INSTALLMENT("BILL_INSTALLMENT"),
@SerializedName("LOAN")
LOAN("LOAN"),
@SerializedName("OTHER")
OTHER("OTHER");

@Getter
private String value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ai.pluggy.client.response;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
public enum CreditCardLimitLineName {
@SerializedName("CREDITO_A_VISTA")
CREDITO_A_VISTA("CREDITO_A_VISTA"),
@SerializedName("CREDITO_PARCELADO")
CREDITO_PARCELADO("CREDITO_PARCELADO"),
@SerializedName("SAQUE_CREDITO_BRASIL")
SAQUE_CREDITO_BRASIL("SAQUE_CREDITO_BRASIL"),
@SerializedName("SAQUE_CREDITO_EXTERIOR")
SAQUE_CREDITO_EXTERIOR("SAQUE_CREDITO_EXTERIOR"),
@SerializedName("EMPRESTIMO_CARTAO_CONSIGNADO")
EMPRESTIMO_CARTAO_CONSIGNADO("EMPRESTIMO_CARTAO_CONSIGNADO"),
@SerializedName("OUTROS")
OUTROS("OUTROS");

@Getter
private String value;
}
4 changes: 4 additions & 0 deletions src/main/java/ai/pluggy/client/response/CreditData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
public class CreditData {

String level;
String brand;
String brandAdditionalInfo;
String balanceCloseDate;
String balanceDueDate;
Double availableCreditLimit;
Expand All @@ -17,4 +20,5 @@ public class CreditData {
Double creditLimit;
HolderType holderType;
CreditCardStatus status;
List<DisaggregatedCreditLimit> disaggregatedCreditLimits;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ai.pluggy.client.response;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class DisaggregatedCreditLimit {

CreditCardLimitLineName lineName;
String limitAmountReason;
Double customizedLimitAmount;
String customizedLimitAmountCurrencyCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ public class TransactionCreditCardMetadata {
Date purchaseDate;
String cardNumber;
String billId;
CreditCardAccountFeeType feeType;
String feeTypeAdditionalInfo;
CreditCardAccountOtherCreditType otherCreditsType;
String otherCreditsAdditionalInfo;
}
46 changes: 46 additions & 0 deletions src/main/java/ai/pluggy/utils/Version.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ai.pluggy.utils;

import java.io.InputStream;
import java.util.Properties;

/**
* Exposes the SDK version, derived from the Maven {@code project.version} at build time via
* resource filtering of {@code pluggy.properties}. Used to build the {@code User-Agent} header so it
* stays in sync with {@code pom.xml} automatically.
*/
public final class Version {

private static final String UNKNOWN = "unknown";
private static final String VERSION = load();

private Version() {
}

/** SDK version (e.g. {@code "1.11.0"}), or {@code "unknown"} if it can't be resolved. */
public static String get() {
return VERSION;
}

/** {@code User-Agent} header value, e.g. {@code "PluggyJava/1.11.0"}. */
public static String userAgent() {
return "PluggyJava/" + VERSION;
}

private static String load() {
try (InputStream in = Version.class.getResourceAsStream("/pluggy.properties")) {
if (in == null) {
return UNKNOWN;
}
Properties props = new Properties();
props.load(in);
String version = props.getProperty("version");
// Guard against an unfiltered placeholder (e.g. if resource filtering didn't run).
if (version == null || version.isEmpty() || version.startsWith("${")) {
return UNKNOWN;
}
return version;
} catch (Exception e) {
return UNKNOWN;
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/pluggy.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${project.version}
24 changes: 24 additions & 0 deletions src/test/java/ai/pluggy/utils/VersionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ai.pluggy.utils;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

public class VersionTest {

@Test
public void version_isResolvedFromFilteredProperties() {
// Resource filtering replaces ${project.version} at build time. If the filtering config
// is removed, Version falls back to "unknown" and these assertions fail.
String version = Version.get();
assertFalse(version.isEmpty(), "version should not be empty");
assertFalse("unknown".equals(version), "version should resolve from pluggy.properties");
assertFalse(version.startsWith("${"), "version placeholder should be filtered");
}

@Test
public void userAgent_hasExpectedPrefix() {
assertTrue(Version.userAgent().startsWith("PluggyJava/"));
}
}
Loading