Skip to content

Commit

Permalink
Merge pull request #287 from Backbase/PAYM-5230-use-payment-order-cli…
Browse files Browse the repository at this point in the history
…ent-api-v3

PAYM-5230: Use payments v3 spec
  • Loading branch information
polarfish authored Apr 23, 2024
2 parents 3904447 + 6e80039 commit fefbcbf
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 99 deletions.
86 changes: 58 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
<common-types.version>1.0.5</common-types.version>

<!-- Products Specs Versions -->
<arrangement-client-api.version>2.11.1</arrangement-client-api.version>
<arrangement-integration-outbound-link-account-api.version>2.1.1</arrangement-integration-outbound-link-account-api.version>
<arrangement-integration-outbound-origination-api.version>1.0.3</arrangement-integration-outbound-origination-api.version>
<arrangement-integration-inbound-api.version>2.7.2</arrangement-integration-inbound-api.version>
<contentservices-client-api.version>2.6.0</contentservices-client-api.version>
<contact-manager-integration-inbound-api.version>2.9.5</contact-manager-integration-inbound-api.version>
<payment-order-client-api.version>3.9.0</payment-order-client-api.version>

</properties>

Expand Down Expand Up @@ -413,6 +415,18 @@
</execution>

<!-- Products Specs -->
<execution>
<id>download-arrangement-client-api-spec</id>
<goals>
<goal>download-single</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<url>https://repo.backbase.com/specs/arrangement-manager</url>
<fromFile>arrangement-client-api-v${arrangement-client-api.version}.yaml</fromFile>
</configuration>
</execution>

<execution>
<id>download-arrangement-outbound-origination-api-spec</id>
<goals>
Expand Down Expand Up @@ -472,6 +486,18 @@
<fromFile>contact-manager-integration-inbound-api-v${contact-manager-integration-inbound-api.version}.yaml</fromFile>
</configuration>
</execution>

<execution>
<id>download-payment-order-client-api-spec</id>
<goals>
<goal>download-single</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<url>https://repo.backbase.com/specs/payment</url>
<fromFile>payment-order-client-api-v${payment-order-client-api.version}.yaml</fromFile>
</configuration>
</execution>
</executions>
</plugin>

Expand Down Expand Up @@ -642,6 +668,7 @@
</configOptions>
</configuration>
</execution>

</executions>
</plugin>

Expand All @@ -668,6 +695,21 @@

<executions>

<execution>
<id>generate-arrangement-client-api</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${api.target}/arrangement-client-api-v${arrangement-client-api.version}.yaml</inputSpec>
<configOptions>
<apiPackage>com.backbase.dbs.arrangement.client.api.v2</apiPackage>
<modelPackage>com.backbase.dbs.arrangement.client.api.v2.model</modelPackage>
</configOptions>
</configuration>
</execution>

<execution>
<id>generate-arrangement-outbound-origination-client-code</id>
<goals>
Expand Down Expand Up @@ -710,6 +752,22 @@
</configOptions>
</configuration>
</execution>

<execution>
<id>generate-payment-order-client-api</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${api.target}/payment-order-client-api-v${payment-order-client-api.version}.yaml</inputSpec>
<configOptions>
<apiPackage>com.backbase.dbs.paymentorder.client.api.v3</apiPackage>
<modelPackage>com.backbase.dbs.paymentorder.client.api.v3.model</modelPackage>
</configOptions>
</configuration>
</execution>

</executions>
</plugin>

Expand Down Expand Up @@ -767,14 +825,6 @@
</outputDirectory>
</artifactItem>

<artifactItem>
<groupId>com.backbase.dbs.paymentorder</groupId>
<artifactId>payment-order-presentation-spec</artifactId>
<outputDirectory>
${project.build.directory}/payment-order-presentation-spec
</outputDirectory>
</artifactItem>

<artifactItem>
<groupId>com.backbase.dbs.user</groupId>
<artifactId>user-manager-spec</artifactId>
Expand Down Expand Up @@ -892,26 +942,6 @@
</configuration>
</execution>

<execution>
<id>generate-payment-order-presentation-spec</id>
<phase>generate-sources</phase>
<goals>
<goal>raml-api-generator</goal>
</goals>
<configuration>
<serviceId>payment-order-presentation-spec</serviceId>
<packageName>dbs.payments</packageName>
<inputFiles>
<inputFile>
${project.build.directory}/payment-order-presentation-spec/service-api.raml
</inputFile>
<inputFile>
${project.build.directory}/payment-order-presentation-spec/api.raml
</inputFile>
</inputFiles>
<requestHeaders>false</requestHeaders>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.backbase.ct.bbfuel.client.common.RestClient;
import com.backbase.ct.bbfuel.config.BbFuelConfiguration;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiatePaymentOrder;
import com.backbase.dbs.paymentorder.client.api.v3.model.InitiatePaymentOrderWithId;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import javax.annotation.PostConstruct;
Expand All @@ -15,7 +15,7 @@ public class PaymentOrderPresentationRestClient extends RestClient {

private final BbFuelConfiguration config;

private static final String SERVICE_VERSION = "v2";
private static final String SERVICE_VERSION = "v3";
private static final String ENDPOINT_PAYMENT_ORDERS = "/payment-orders";

@PostConstruct
Expand All @@ -25,7 +25,7 @@ public void init() {
setInitialPath(config.getDbsServiceNames().getPayments() + "/" + CLIENT_API);
}

public Response initiatePaymentOrder(InitiatePaymentOrder body) {
public Response initiatePaymentOrder(InitiatePaymentOrderWithId body) {
return requestSpec()
.contentType(ContentType.JSON)
.body(body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.backbase.ct.bbfuel.client.common.RestClient;
import com.backbase.ct.bbfuel.config.BbFuelConfiguration;
import com.backbase.ct.bbfuel.dto.ProductSummaryQueryParameters;
import com.backbase.dbs.productsummary.presentation.rest.spec.v2.productsummary.ArrangementsByBusinessFunctionGetResponseBody;
import com.backbase.dbs.arrangement.client.api.v2.model.ProductSummaryItem;
import io.restassured.response.Response;
import java.util.Arrays;
import java.util.List;
Expand All @@ -40,7 +40,7 @@ public void init() {
setInitialPath(config.getDbsServiceNames().getProducts() + "/" + CLIENT_API);
}

public List<ArrangementsByBusinessFunctionGetResponseBody> getProductSummaryArrangements() {
public List<ProductSummaryItem> getProductSummaryArrangements() {
return Arrays.asList(getProductSummaryContextArrangements(new ProductSummaryQueryParameters()
.withBusinessFunction(PRODUCT_SUMMARY_FUNCTION_NAME)
.withResourceName(PRODUCT_SUMMARY_RESOURCE_NAME)
Expand All @@ -50,11 +50,11 @@ public List<ArrangementsByBusinessFunctionGetResponseBody> getProductSummaryArra
.then()
.statusCode(SC_OK)
.extract()
.as(ArrangementsByBusinessFunctionGetResponseBody[].class));
.as(ProductSummaryItem[].class));
}

public List<ArrangementsByBusinessFunctionGetResponseBody> getSepaCtArrangements() {
ArrangementsByBusinessFunctionGetResponseBody[] arrangements = getProductSummaryContextArrangements(
public List<ProductSummaryItem> getSepaCtArrangements() {
ProductSummaryItem[] arrangements = getProductSummaryContextArrangements(
new ProductSummaryQueryParameters()
.withBusinessFunction(SEPA_CT_FUNCTION_NAME)
.withResourceName(PAYMENTS_RESOURCE_NAME)
Expand All @@ -66,7 +66,7 @@ public List<ArrangementsByBusinessFunctionGetResponseBody> getSepaCtArrangements
.then()
.statusCode(SC_OK)
.extract()
.as(ArrangementsByBusinessFunctionGetResponseBody[].class);
.as(ProductSummaryItem[].class);

// Make sure the Regex is in sync with payment-order-presentation-service/src/main/resources/application.yml (property: sepacountries)
return Arrays.stream(arrangements)
Expand All @@ -78,7 +78,7 @@ public List<ArrangementsByBusinessFunctionGetResponseBody> getSepaCtArrangements
.collect(Collectors.toList());
}

public List<ArrangementsByBusinessFunctionGetResponseBody> getUsDomesticWireArrangements() {
public List<ProductSummaryItem> getUsDomesticWireArrangements() {
return Arrays.asList(getProductSummaryContextArrangements(new ProductSummaryQueryParameters()
.withBusinessFunction(US_DOMESTIC_WIRE_FUNCTION_NAME)
.withResourceName(PAYMENTS_RESOURCE_NAME)
Expand All @@ -90,10 +90,10 @@ public List<ArrangementsByBusinessFunctionGetResponseBody> getUsDomesticWireArra
.then()
.statusCode(SC_OK)
.extract()
.as(ArrangementsByBusinessFunctionGetResponseBody[].class));
.as(ProductSummaryItem[].class));
}

public List<ArrangementsByBusinessFunctionGetResponseBody> getAchDebitArrangements() {
public List<ProductSummaryItem> getAchDebitArrangements() {
return Arrays.stream(getProductSummaryContextArrangements(new ProductSummaryQueryParameters()
.withBusinessFunction(ACH_DEBIT_FUNCTION_NAME)
.withResourceName(PAYMENTS_RESOURCE_NAME)
Expand All @@ -105,15 +105,15 @@ public List<ArrangementsByBusinessFunctionGetResponseBody> getAchDebitArrangemen
.then()
.statusCode(SC_OK)
.extract()
.as(ArrangementsByBusinessFunctionGetResponseBody[].class))
.as(ProductSummaryItem[].class))
.filter(arrangement -> isValidCurrencyForAchDebit(arrangement.getCurrency())).collect(Collectors.toList());
}

private static boolean isValidCurrencyForAchDebit(String currency) {
return currency.equals("USD") || currency.equals("CAD");
}

public List<ArrangementsByBusinessFunctionGetResponseBody> getUSForeignWireArrangements() {
public List<ProductSummaryItem> getUSForeignWireArrangements() {
return Arrays.asList(getProductSummaryContextArrangements(new ProductSummaryQueryParameters()
.withBusinessFunction(US_FOREIGN_WIRE_FUNCTION_NAME)
.withResourceName(PAYMENTS_RESOURCE_NAME)
Expand All @@ -125,7 +125,7 @@ public List<ArrangementsByBusinessFunctionGetResponseBody> getUSForeignWireArran
.then()
.statusCode(SC_OK)
.extract()
.as(ArrangementsByBusinessFunctionGetResponseBody[].class));
.as(ProductSummaryItem[].class));
}

private Response getProductSummaryContextArrangements(ProductSummaryQueryParameters queryParameters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.backbase.ct.bbfuel.client.user.UserProfileRestClient;
import com.backbase.ct.bbfuel.dto.accountStatement.EStatementPreferencesRequest;
import com.backbase.ct.bbfuel.util.GlobalProperties;
import com.backbase.dbs.productsummary.presentation.rest.spec.v2.productsummary.ArrangementsByBusinessFunctionGetResponseBody;
import com.backbase.dbs.arrangement.client.api.v2.model.ProductSummaryItem;
import io.restassured.response.Response;
import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -48,7 +48,7 @@ public void ingestAccountStatements(String externalUserId) {
int randomAmount = generateRandomNumberInRange(globalProperties.getInt(PROPERTY_ACCOUNTSTATEMENTS_MIN),
globalProperties.getInt(PROPERTY_ACCOUNTSTATEMENTS_MAX));

Consumer<ArrangementsByBusinessFunctionGetResponseBody> consumer = arrangement -> {
Consumer<ProductSummaryItem> consumer = arrangement -> {
String internalArrangementId = arrangement.getId();
String accountName = arrangement.getName();
String accountIBAN = arrangement.getIBAN();
Expand All @@ -69,7 +69,7 @@ public void ingestAccountStatements(String externalUserId) {
public void ingestAccountStatementPreferences(String externalUserId) {
final Random booleanGenerator = new Random(System.currentTimeMillis());

Function<ArrangementsByBusinessFunctionGetResponseBody, EStatementPreferencesRequest> mapper =
Function<ProductSummaryItem, EStatementPreferencesRequest> mapper =
arrangement -> new EStatementPreferencesRequest(
arrangement.getId(), externalUserId,
booleanGenerator.nextBoolean(), booleanGenerator.nextBoolean());
Expand Down Expand Up @@ -117,7 +117,7 @@ public void ingestUserProfile(String externalUserId) {
}
}

private List<ArrangementsByBusinessFunctionGetResponseBody> fetchUserArrangements(String externalUserId) {
private List<ProductSummaryItem> fetchUserArrangements(String externalUserId) {
loginRestClient.login(externalUserId, externalUserId);
userContextPresentationRestClient.selectContextBasedOnMasterServiceAgreement();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.backbase.ct.bbfuel.client.productsummary.ProductSummaryPresentationRestClient;
import com.backbase.ct.bbfuel.util.GlobalProperties;
import com.backbase.dbs.action.client.v2.model.ActionRecipesPostRequestBodyParent;
import com.backbase.dbs.productsummary.presentation.rest.spec.v2.productsummary.ArrangementsByBusinessFunctionGetResponseBody;
import com.backbase.dbs.arrangement.client.api.v2.model.ProductSummaryItem;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
Expand All @@ -34,7 +34,7 @@ public class ActionsConfigurator {
private final ActionRecipesPresentationRestClient actionRecipesPresentationRestClient;

public void ingestActions(String externalUserId) {
List<ArrangementsByBusinessFunctionGetResponseBody> arrangements = new ArrayList<>();
List<ProductSummaryItem> arrangements = new ArrayList<>();
int randomAmount = generateRandomNumberInRange(globalProperties.getInt(PROPERTY_ACTIONS_MIN),
globalProperties.getInt(PROPERTY_ACTIONS_MAX));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import com.backbase.ct.bbfuel.data.PaymentsDataGenerator;
import com.backbase.ct.bbfuel.util.CommonHelpers;
import com.backbase.ct.bbfuel.util.GlobalProperties;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiatePaymentOrder;
import com.backbase.dbs.productsummary.presentation.rest.spec.v2.productsummary.ArrangementsByBusinessFunctionGetResponseBody;
import com.backbase.dbs.paymentorder.client.api.v3.model.InitiatePaymentOrderWithId;
import com.backbase.dbs.arrangement.client.api.v2.model.ProductSummaryItem;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -43,13 +43,13 @@ public void ingestPaymentOrders(String externalUserId) {

loginRestClient.login(externalUserId, externalUserId);
userContextPresentationRestClient.selectContextBasedOnMasterServiceAgreement();
List<ArrangementsByBusinessFunctionGetResponseBody> sepaCtArrangements = productSummaryPresentationRestClient
List<ProductSummaryItem> sepaCtArrangements = productSummaryPresentationRestClient
.getSepaCtArrangements();
List<ArrangementsByBusinessFunctionGetResponseBody> usDomesticWireArrangements = productSummaryPresentationRestClient
List<ProductSummaryItem> usDomesticWireArrangements = productSummaryPresentationRestClient
.getUsDomesticWireArrangements();
List<ArrangementsByBusinessFunctionGetResponseBody> achDebitArrangements = productSummaryPresentationRestClient
List<ProductSummaryItem> achDebitArrangements = productSummaryPresentationRestClient
.getAchDebitArrangements();
List<ArrangementsByBusinessFunctionGetResponseBody> usForeignWireArrangements = productSummaryPresentationRestClient
List<com.backbase.dbs.arrangement.client.api.v2.model.ProductSummaryItem> usForeignWireArrangements = productSummaryPresentationRestClient
.getUSForeignWireArrangements();

int randomAmount = CommonHelpers
Expand All @@ -61,7 +61,7 @@ public void ingestPaymentOrders(String externalUserId) {

IntStream.range(0, randomAmount).parallel().forEach(randomNumber -> {
String paymentType = getRandomFromList(ootbPaymentTypes);
ArrangementsByBusinessFunctionGetResponseBody randomArrangement;
ProductSummaryItem randomArrangement;

if (PAYMENT_TYPE_SEPA_CREDIT_TRANSFER.equals(paymentType)) {
randomArrangement = getRandomFromList(sepaCtArrangements);
Expand All @@ -75,7 +75,7 @@ public void ingestPaymentOrders(String externalUserId) {
throw new IllegalArgumentException("Unknown payment type " + paymentType);
}

InitiatePaymentOrder initiatePaymentOrder = PaymentsDataGenerator
InitiatePaymentOrderWithId initiatePaymentOrder = PaymentsDataGenerator
.generateInitiatePaymentOrder(randomArrangement.getId(), randomArrangement.getCurrency(), paymentType);
paymentOrderPresentationRestClient.initiatePaymentOrder(initiatePaymentOrder)
.then()
Expand Down
Loading

0 comments on commit fefbcbf

Please sign in to comment.