Skip to content

Commit

Permalink
Merchant accounts updates (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
tl-luca-baggi authored Oct 30, 2024
1 parent 7b669a0 commit ed12e5c
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 22 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ dependencies {
implementation group: 'org.tinylog', name: 'tinylog-impl', version: tinyLogVersion

// JUnit test framework.
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.11.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.11.3'

// Mocking libraries
testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.14.2'
testImplementation group: 'org.wiremock', name: 'wiremock', version: '3.9.1'
testImplementation group: 'org.wiremock', name: 'wiremock', version: '3.9.2'

// Wait test utility
testImplementation group: 'org.awaitility', name: 'awaitility', version: '4.2.2'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Main properties
group=com.truelayer
archivesBaseName=truelayer-java
version=15.0.0
version=16.0.0

# Artifacts properties
sonatype_repository_url=https://s01.oss.sonatype.org/service/local/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.truelayer.java.merchantaccounts.entities;

import com.truelayer.java.entities.CurrencyCode;
import com.truelayer.java.merchantaccounts.entities.sweeping.Frequency;
import lombok.Builder;
import lombok.EqualsAndHashCode;
Expand All @@ -14,7 +13,5 @@
public class UpdateSweepingRequest {
private int maxAmountInMinor;

private CurrencyCode currency;

private Frequency frequency;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.truelayer.java.merchantaccounts.entities.transactions;

import com.fasterxml.jackson.annotation.JsonGetter;
import com.truelayer.java.entities.CurrencyCode;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import lombok.EqualsAndHashCode;
import lombok.Value;

Expand All @@ -23,4 +26,11 @@ public class MerchantAccountPayment extends Transaction {
PaymentSource paymentSource;

String paymentId;

Map<String, String> metadata;

@JsonGetter
public Optional<Map<String, String>> getMetadata() {
return Optional.ofNullable(metadata);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.truelayer.java.entities.CurrencyCode;
import com.truelayer.java.entities.beneficiary.Beneficiary;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down Expand Up @@ -46,6 +47,13 @@ public class Payout extends Transaction {

String payoutId;

Map<String, String> metadata;

@JsonGetter
public Optional<Map<String, String>> getMetadata() {
return Optional.ofNullable(metadata);
}

@JsonGetter
public Optional<ZonedDateTime> getExecutedAt() {
return Optional.ofNullable(executedAt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.truelayer.java.entities.CurrencyCode;
import com.truelayer.java.entities.beneficiary.PaymentSource;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
import lombok.EqualsAndHashCode;
import lombok.Value;
Expand Down Expand Up @@ -36,6 +37,13 @@ public class Refund extends Transaction {

String paymentId;

Map<String, String> metadata;

@JsonGetter
public Optional<Map<String, String>> getMetadata() {
return Optional.ofNullable(metadata);
}

@JsonGetter
public Optional<ZonedDateTime> getExecutedAt() {
return Optional.ofNullable(executedAt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public void itShouldGetTheSweepingSettings() {
UpdateSweepingRequest updateSweepingRequest = UpdateSweepingRequest.builder()
.maxAmountInMinor(100)
.frequency(Frequency.DAILY)
.currency(CurrencyCode.GBP)
.build();
ApiResponse<SweepingSettings> updateSweepingResponse = tlClient.merchantAccounts()
.updateSweeping(getMerchantAccount(CurrencyCode.GBP).getId(), updateSweepingRequest)
Expand All @@ -83,7 +82,6 @@ public void itShouldUpdateTheSweepingSettings() {
UpdateSweepingRequest updateSweepingRequest = UpdateSweepingRequest.builder()
.maxAmountInMinor(100)
.frequency(Frequency.DAILY)
.currency(CurrencyCode.GBP)
.build();
ApiResponse<SweepingSettings> updateSweepingResponse = tlClient.merchantAccounts()
.updateSweeping(getMerchantAccount(CurrencyCode.GBP).getId(), updateSweepingRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static org.junit.jupiter.api.Assertions.*;

import com.truelayer.java.TestUtils.RequestStub;
import com.truelayer.java.entities.CurrencyCode;
import com.truelayer.java.http.entities.ApiResponse;
import com.truelayer.java.http.entities.Headers;
import com.truelayer.java.merchantaccounts.entities.*;
Expand Down Expand Up @@ -266,7 +265,6 @@ public void shouldUpdateSweepingSetup() {
.build();

UpdateSweepingRequest updateSweepingRequest = UpdateSweepingRequest.builder()
.currency(CurrencyCode.EUR)
.frequency(Frequency.DAILY)
.maxAmountInMinor(100)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import static org.mockito.Mockito.verify;

import com.truelayer.java.Constants;
import com.truelayer.java.entities.CurrencyCode;
import com.truelayer.java.entities.RequestScopes;
import com.truelayer.java.http.entities.Headers;
import com.truelayer.java.merchantaccounts.entities.ListPaymentSourcesQuery;
import com.truelayer.java.merchantaccounts.entities.ListTransactionsQuery;
import com.truelayer.java.merchantaccounts.entities.UpdateSweepingRequest;
import com.truelayer.java.merchantaccounts.entities.sweeping.Frequency;
import com.truelayer.java.merchantaccounts.entities.transactions.TransactionTypeQuery;
import java.time.LocalDate;
import java.time.LocalTime;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void shouldCallListTransactionsEndpoint(ZonedDateTime from, ZonedDateTime
@DisplayName("It should call the update sweeping endpoint with empty headers map")
public void shouldCallUpdateSweepingEndpoint() {
UpdateSweepingRequest request =
UpdateSweepingRequest.builder().currency(CurrencyCode.GBP).build();
UpdateSweepingRequest.builder().frequency(Frequency.DAILY).build();

sut.updateSweeping(A_MERCHANT_ACCOUNT_ID, request);

Expand All @@ -120,7 +120,7 @@ public void shouldCallUpdateSweepingEndpoint() {
public void shouldCallUpdateSweepingEndpointWithCustomHeaders() {
Headers customHeaders = buildTestHeaders();
UpdateSweepingRequest request =
UpdateSweepingRequest.builder().currency(CurrencyCode.GBP).build();
UpdateSweepingRequest.builder().frequency(Frequency.DAILY).build();

sut.updateSweeping(customHeaders, A_MERCHANT_ACCOUNT_ID, request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public void shouldYieldTrueIfMerchantAccountPayment() {
100,
ZonedDateTime.now(Clock.systemUTC()),
new PaymentSource(UUID.randomUUID().toString(), null, null),
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

assertTrue(sut.isMerchantAccountPayment());
}
Expand All @@ -37,7 +38,8 @@ public void shouldConvertToMerchantAccountPayment() {
100,
ZonedDateTime.now(Clock.systemUTC()),
null,
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

assertDoesNotThrow(sut::asMerchantAccountPayment);
}
Expand Down Expand Up @@ -80,7 +82,8 @@ public void shouldNotConvertToExternalPayment() {
100,
ZonedDateTime.now(Clock.systemUTC()),
null,
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

Throwable thrown = assertThrows(TrueLayerException.class, sut::asExternalPayment);

Expand All @@ -99,7 +102,8 @@ public void shouldYieldTrueIfPayout() {
ZonedDateTime.now(Clock.systemUTC()),
null,
Payout.ContextCode.INTERNAL,
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

assertTrue(sut.isPayout());
}
Expand All @@ -116,7 +120,8 @@ public void shouldConvertToPayout() {
ZonedDateTime.now(Clock.systemUTC()),
null,
Payout.ContextCode.INTERNAL,
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

assertDoesNotThrow(sut::asPayout);
}
Expand All @@ -130,7 +135,8 @@ public void shouldNotConvertToPayout() {
100,
ZonedDateTime.now(Clock.systemUTC()),
null,
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

Throwable thrown = assertThrows(TrueLayerException.class, sut::asPayout);

Expand All @@ -150,7 +156,8 @@ public void shouldYieldTrueIfRefund() {
null,
Payout.ContextCode.INTERNAL,
UUID.randomUUID().toString(),
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

assertTrue(sut.isRefund());
}
Expand All @@ -168,7 +175,8 @@ public void shouldConvertToRefund() {
null,
Payout.ContextCode.INTERNAL,
UUID.randomUUID().toString(),
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

assertDoesNotThrow(sut::asRefund);
}
Expand All @@ -182,7 +190,8 @@ public void shouldNotConvertToRefund() {
100,
ZonedDateTime.now(Clock.systemUTC()),
null,
UUID.randomUUID().toString());
UUID.randomUUID().toString(),
null);

Throwable thrown = assertThrows(TrueLayerException.class, sut::asRefund);

Expand Down

0 comments on commit ed12e5c

Please sign in to comment.