Skip to content

Commit 381c12b

Browse files
author
Christopher Eteka
committed
Add customer client to spring boot starter with defaults and constant endpoints for lists items with optional params
1 parent 184f6e7 commit 381c12b

16 files changed

Lines changed: 198 additions & 30 deletions

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 ChrisEteka
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

paystack-clients-spring-boot-starter/src/main/java/com/chrisworks/paystackclient/SupportedClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
public enum SupportedClient {
66
APPLE_PAY(Constants.APPLE_PAY_CLIENT),
7+
CUSTOMER(Constants.CUSTOMER_CLIENT),
78
PLAN(Constants.PLAN_CLIENT),
89
PRODUCT(Constants.PRODUCT_CLIENT),
910
SUB_ACCOUNT(Constants.SUB_ACCOUNT_CLIENT),

paystack-clients-spring-boot-starter/src/main/java/com/chrisworks/paystackclient/definitions/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ private Constants() {}
66

77
public static final String PLAN_CLIENT = "plan-client";
88
public static final String APPLE_PAY_CLIENT = "apple-pay-client";
9+
public static final String CUSTOMER_CLIENT = "customer-client";
910
public static final String TRANSACTION_CLIENT = "transaction-client";
1011
public static final String PRODUCT_CLIENT = "product-client";
1112
public static final String SUB_ACCOUNT_CLIENT = "sub-account-client";

paystack-clients-spring-boot-starter/src/main/java/com/chrisworks/paystackclient/definitions/ReactivePaystackClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
public interface ReactivePaystackClient {
1010

1111
ApplePayClient applePay();
12+
CustomerClient customer();
1213
PlanClient plan();
1314
ProductClient product();
1415
SubAccountClient subAccount();
@@ -17,6 +18,6 @@ public interface ReactivePaystackClient {
1718
@Component(value = "reactivePaystackClient")
1819
@Conditional(NoClientIsSelectedToBeActive.class)
1920
@ConditionalOnProperty(prefix = "paystack-client", name = "definition-type", havingValue = "REACTIVE")
20-
record Impl(ApplePayClient applePay, PlanClient plan, ProductClient product,
21+
record Impl(ApplePayClient applePay, CustomerClient customer, PlanClient plan, ProductClient product,
2122
SubAccountClient subAccount, TransactionClient transaction) implements ReactivePaystackClient {}
2223
}

paystack-clients-spring-boot-starter/src/main/java/com/chrisworks/paystackclient/definitions/SimplePaystackClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
public interface SimplePaystackClient {
1010

1111
ApplePayClient applePay();
12+
CustomerClient customer();
1213
PlanClient plan();
1314
ProductClient product();
1415
SubAccountClient subAccount();
@@ -17,6 +18,6 @@ public interface SimplePaystackClient {
1718
@Component(value = "simplePaystackClient")
1819
@Conditional(NoClientIsSelectedToBeActive.class)
1920
@ConditionalOnProperty(prefix = "paystack-client", name = "definition-type", havingValue = "NON_REACTIVE", matchIfMissing = true)
20-
record Impl(ApplePayClient applePay, PlanClient plan, ProductClient product,
21+
record Impl(ApplePayClient applePay, CustomerClient customer, PlanClient plan, ProductClient product,
2122
SubAccountClient subAccount, TransactionClient transaction) implements SimplePaystackClient {}
2223
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.chrisworks.paystackclient.definitions.reactive;
2+
3+
import com.chrisworks.paystackclient.definitions.Constants;
4+
import com.chrisworks.paystackclient.domain.customer.*;
5+
import com.chrisworks.paystackclient.domain.request.QueryParamConstants;
6+
import com.chrisworks.paystackclient.domain.response.EmptyDataResponse;
7+
import com.maciejwalkowiak.spring.http.annotation.HttpClient;
8+
import org.springframework.lang.NonNull;
9+
import org.springframework.web.bind.annotation.PathVariable;
10+
import org.springframework.web.bind.annotation.RequestBody;
11+
import org.springframework.web.bind.annotation.RequestParam;
12+
import org.springframework.web.service.annotation.GetExchange;
13+
import org.springframework.web.service.annotation.PostExchange;
14+
import org.springframework.web.service.annotation.PutExchange;
15+
import reactor.core.publisher.Mono;
16+
17+
import java.math.BigInteger;
18+
import java.time.ZonedDateTime;
19+
20+
@HttpClient(Constants.CUSTOMER_CLIENT)
21+
public interface CustomerClient {
22+
23+
@PostExchange
24+
Mono<CustomerResponse.Single> createCustomer(@RequestBody CreateCustomerRequest body);
25+
26+
@GetExchange
27+
Mono<CustomerResponse.Multiple> listCustomers(
28+
@RequestParam(name = QueryParamConstants.PAGE, required = false, defaultValue = "1") @NonNull BigInteger page,
29+
@RequestParam(name = QueryParamConstants.PER_PAGE, required = false, defaultValue = "50") @NonNull BigInteger perPage,
30+
@RequestParam(name = QueryParamConstants.FROM, required = false) @NonNull ZonedDateTime from,
31+
@RequestParam(name = QueryParamConstants.TO, required = false) @NonNull ZonedDateTime to
32+
);
33+
34+
@GetExchange
35+
Mono<CustomerResponse.Multiple> listCustomers();
36+
37+
@GetExchange("/{customerCode}")
38+
Mono<DetailedCustomerResponse.Single> fetchCustomer(@PathVariable String customerCode);
39+
40+
@PutExchange("/{customerCode}")
41+
Mono<DetailedCustomerResponse.Single> updateCustomer(@PathVariable String customerCode, @RequestBody UpdateCustomerRequest body);
42+
43+
@PostExchange("/{customerCode}/identification")
44+
Mono<EmptyDataResponse> validateCustomer(@PathVariable String customerCode, @RequestBody ValidateCustomerRequest body);
45+
46+
@PostExchange("/set_risk_action")
47+
Mono<CustomerResponse.Single> whiteOrBlackListCustomer(@RequestBody WhiteOrBlackListCustomerRequest body);
48+
49+
@PostExchange("/deactivate_authorization")
50+
Mono<EmptyDataResponse> deactivateAuthorization(@RequestBody DeactivateAuthorizationRequest body);
51+
}

paystack-clients-spring-boot-starter/src/main/java/com/chrisworks/paystackclient/definitions/reactive/PlanClient.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ public interface PlanClient {
2525

2626
@GetExchange
2727
Mono<PlanResponse.Multiple> listPlans(
28-
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
29-
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
28+
@RequestParam(name = QueryParamConstants.PAGE, required = false, defaultValue = "1") @NonNull BigInteger page,
29+
@RequestParam(name = QueryParamConstants.PER_PAGE, required = false, defaultValue = "50") @NonNull BigInteger perPage,
3030
@RequestParam(name = QueryParamConstants.STATUS, required = false) String status,
3131
@RequestParam(name = QueryParamConstants.INTERVAL, required = false) String interval,
3232
@RequestParam(name = QueryParamConstants.AMOUNT, required = false) String amount
3333
);
3434

35+
@GetExchange
36+
Mono<PlanResponse.Multiple> listPlans();
37+
3538
@GetExchange("/{idOrCode}")
3639
Mono<PlanResponse.Single> fetchPlan(@PathVariable String idOrCode);
3740

paystack-clients-spring-boot-starter/src/main/java/com/chrisworks/paystackclient/definitions/reactive/ProductClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ public interface ProductClient {
2525

2626
@GetExchange
2727
Mono<ProductResponse.Multiple> listProducts(
28-
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
29-
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
30-
@RequestParam(name = QueryParamConstants.FROM, required = false)ZonedDateTime from,
31-
@RequestParam(name = QueryParamConstants.TO, required = false)ZonedDateTime to
28+
@RequestParam(name = QueryParamConstants.PAGE, required = false, defaultValue = "1") @NonNull BigInteger page,
29+
@RequestParam(name = QueryParamConstants.PER_PAGE, required = false, defaultValue = "50") @NonNull BigInteger perPage,
30+
@RequestParam(name = QueryParamConstants.FROM, required = false) ZonedDateTime from,
31+
@RequestParam(name = QueryParamConstants.TO, required = false) ZonedDateTime to
3232
);
3333

34+
@GetExchange
35+
Mono<ProductResponse.Multiple> listProducts();
36+
3437
@GetExchange("/{id}")
3538
Mono<ProductResponse.Single> fetchProduct(@PathVariable String id);
3639

paystack-clients-spring-boot-starter/src/main/java/com/chrisworks/paystackclient/definitions/reactive/SubAccountClient.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ public interface SubAccountClient {
2626

2727
@GetExchange
2828
Mono<SubAccountResponse.Multiple> listSubAccounts(
29-
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
30-
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
29+
@RequestParam(name = QueryParamConstants.PAGE, required = false, defaultValue = "1") @NonNull BigInteger page,
30+
@RequestParam(name = QueryParamConstants.PER_PAGE, required = false, defaultValue = "50") @NonNull BigInteger perPage,
3131
@RequestParam(name = QueryParamConstants.FROM, required = false) ZonedDateTime from,
3232
@RequestParam(name = QueryParamConstants.TO, required = false) ZonedDateTime to
3333
);
3434

35+
@GetExchange
36+
Mono<SubAccountResponse.Multiple> listSubAccounts();
37+
3538
@GetExchange("/{idOrCode}")
3639
Mono<SubAccountResponse.Single> fetchSubAccount(@PathVariable String idOrCode);
3740

paystack-clients-spring-boot-starter/src/main/java/com/chrisworks/paystackclient/definitions/reactive/TransactionClient.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public interface TransactionClient {
2626

2727
@GetExchange
2828
Mono<TransactionResponse.Multiple> listTransaction(
29-
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
30-
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
29+
@RequestParam(name = QueryParamConstants.PAGE, required = false, defaultValue = "1") @NonNull BigInteger page,
30+
@RequestParam(name = QueryParamConstants.PER_PAGE, required = false, defaultValue = "50") @NonNull BigInteger perPage,
3131
@RequestParam(name = QueryParamConstants.CUSTOMER, required = false) BigInteger customer,
3232
@RequestParam(name = QueryParamConstants.TERMINAL_ID, required = false) String terminalId,
3333
@RequestParam(name = QueryParamConstants.STATUS, required = false) String status,
@@ -37,6 +37,9 @@ Mono<TransactionResponse.Multiple> listTransaction(
3737

3838
);
3939

40+
@GetExchange
41+
Mono<TransactionResponse.Multiple> listTransaction();
42+
4043
@GetExchange("/{id}")
4144
Mono<TransactionResponse.Single> fetchTransaction(@PathVariable BigInteger id);
4245

@@ -48,16 +51,19 @@ Mono<TransactionResponse.Multiple> listTransaction(
4851

4952
@GetExchange("/totals")
5053
Mono<TransactionTotalResponse.Single> transactionTotals(
51-
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
52-
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
54+
@RequestParam(name = QueryParamConstants.PAGE, required = false, defaultValue = "1") @NonNull BigInteger page,
55+
@RequestParam(name = QueryParamConstants.PER_PAGE, required = false, defaultValue = "50") @NonNull BigInteger perPage,
5356
@RequestParam(name = QueryParamConstants.FROM, required = false) ZonedDateTime from,
5457
@RequestParam(name = QueryParamConstants.TO, required = false) ZonedDateTime to
5558
);
5659

60+
@GetExchange("/totals")
61+
Mono<TransactionTotalResponse.Single> transactionTotals();
62+
5763
@GetExchange("/export")
5864
Mono<ExportTransactionResponse.Single> exportTransactions(
59-
@RequestParam(name = QueryParamConstants.PAGE) @NonNull BigInteger page,
60-
@RequestParam(name = QueryParamConstants.PER_PAGE) @NonNull BigInteger perPage,
65+
@RequestParam(name = QueryParamConstants.PAGE, required = false, defaultValue = "1") @NonNull BigInteger page,
66+
@RequestParam(name = QueryParamConstants.PER_PAGE, required = false, defaultValue = "50") @NonNull BigInteger perPage,
6167
@RequestParam(name = QueryParamConstants.FROM, required = false) ZonedDateTime from,
6268
@RequestParam(name = QueryParamConstants.TO, required = false) ZonedDateTime to,
6369
@RequestParam(name = QueryParamConstants.CUSTOMER, required = false) BigInteger customer,
@@ -70,6 +76,9 @@ Mono<ExportTransactionResponse.Single> exportTransactions(
7076

7177
);
7278

79+
@GetExchange("/export")
80+
Mono<ExportTransactionResponse.Single> exportTransactions();
81+
7382
@PostExchange("/partial_debit")
7483
Mono<TransactionTotalResponse.Single> partialDebit(@RequestBody PartialDebitRequest body);
7584
}

0 commit comments

Comments
 (0)