Skip to content

Commit 310503d

Browse files
committedMar 7, 2024
improvements on conversions
1 parent 346c0b8 commit 310503d

10 files changed

+357
-162
lines changed
 

‎src/main/java/com/mangopay/core/APIs/ApiBase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ protected MangoPayApi getRoot() {
227227

228228
put("get_conversion_rate", new String[]{"/conversions/rate/%s/%s", RequestType.GET.toString()});
229229
put("create_instant_conversion", new String[]{"/conversions/instant-conversion", RequestType.POST.toString()});
230-
put("get_instant_conversion", new String[]{"/conversions/%s", RequestType.GET.toString()});
230+
put("get_conversion", new String[]{"/conversions/%s", RequestType.GET.toString()});
231231
put("create_conversion_quote", new String[]{"/conversions/quote", RequestType.POST.toString()});
232232
put("get_conversion_quote", new String[]{"/conversions/quote/%s", RequestType.GET.toString()});
233233
put("create_quoted_conversion", new String[]{"/conversions/quoted-conversion", RequestType.POST.toString()});
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.mangopay.core.APIs;
22

3-
import com.mangopay.entities.ConversionQuote;
4-
import com.mangopay.entities.ConversionRate;
5-
import com.mangopay.entities.InstantConversion;
6-
import com.mangopay.entities.QuotedConversion;
3+
import com.mangopay.entities.*;
74

85
public interface ConversionsApi {
96

@@ -22,22 +19,29 @@ public interface ConversionsApi {
2219
* wallets of different currencies instantaneously.
2320
* @return InstantConversion object returned from API
2421
*/
25-
InstantConversion createInstantConversion(InstantConversion conversion, String idempotencyKey) throws Exception;
22+
Conversion createInstantConversion(CreateInstantConversion createInstantConversion, String idempotencyKey) throws Exception;
23+
24+
/**
25+
* This call triggers a conversion, at the rate guaranteed by its quote, of the debited funds to the credited wallet.
26+
*
27+
* @return QuotedConversion
28+
*/
29+
Conversion createQuotedConversion(CreateQuotedConversion quotedConversion, String idempotencyKey) throws Exception;
2630

2731
/**
2832
* This endpoint allows the platform to get
2933
* the details of a conversion which has been carried out.
3034
* @param id The unique identifier of the conversion.
3135
* @return InstantConversion object returned from API
3236
*/
33-
InstantConversion getInstantConversion(String id) throws Exception;
37+
Conversion getConversion(String id) throws Exception;
3438

3539
/**
3640
* This call guarantees a conversion rate to let you Create a Quoted Conversion.
3741
*
3842
* @return Quote object returned from API
3943
*/
40-
ConversionQuote createConversionQuote(ConversionQuote conversionQuote, String idempotencyKey) throws Exception;
44+
ConversionQuote createConversionQuote(CreateConversionQuote createConversionQuote, String idempotencyKey) throws Exception;
4145

4246
/**
4347
* This endpoint allows the platform to get the details of a quote
@@ -47,11 +51,4 @@ public interface ConversionsApi {
4751
*/
4852
ConversionQuote getConversionQuote(String quoteId) throws Exception;
4953

50-
51-
/**
52-
* This call triggers a conversion, at the rate guaranteed by its quote, of the debited funds to the credited wallet.
53-
*
54-
* @return QuotedConversion
55-
*/
56-
QuotedConversion createQuotedConversion(QuotedConversion quotedConversion, String idempotencyKey) throws Exception;
5754
}

‎src/main/java/com/mangopay/core/APIs/implementation/ConversionsApiImpl.java

+11-14
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
import com.mangopay.MangoPayApi;
44
import com.mangopay.core.APIs.ApiBase;
55
import com.mangopay.core.APIs.ConversionsApi;
6-
import com.mangopay.entities.ConversionQuote;
7-
import com.mangopay.entities.ConversionRate;
8-
import com.mangopay.entities.InstantConversion;
9-
import com.mangopay.entities.QuotedConversion;
6+
import com.mangopay.entities.*;
107

118
public class ConversionsApiImpl extends ApiBase implements ConversionsApi {
129

@@ -25,27 +22,27 @@ public ConversionRate getConversionRate(String debitedCurrency, String creditedC
2522
}
2623

2724
@Override
28-
public InstantConversion createInstantConversion(InstantConversion conversion, String idempotencyKey) throws Exception {
29-
return this.createObject(InstantConversion.class, idempotencyKey, "create_instant_conversion", conversion);
25+
public Conversion createInstantConversion(CreateInstantConversion createInstantConversion, String idempotencyKey) throws Exception {
26+
return this.createObject(Conversion.class, idempotencyKey, "create_instant_conversion", createInstantConversion);
3027
}
3128

3229
@Override
33-
public InstantConversion getInstantConversion(String id) throws Exception {
34-
return this.getObject(InstantConversion.class, "get_instant_conversion", id);
30+
public Conversion createQuotedConversion(CreateQuotedConversion quotedConversion, String idempotencyKey) throws Exception {
31+
return this.createObject(Conversion.class, idempotencyKey, "create_quoted_conversion", quotedConversion);
3532
}
3633

3734
@Override
38-
public ConversionQuote createConversionQuote(ConversionQuote conversionQuote, String idempotencyKey) throws Exception {
39-
return this.createObject(ConversionQuote.class, idempotencyKey, "create_conversion_quote", conversionQuote);
35+
public Conversion getConversion(String id) throws Exception {
36+
return this.getObject(Conversion.class, "get_conversion", id);
4037
}
4138

4239
@Override
43-
public ConversionQuote getConversionQuote(String quoteId) throws Exception {
44-
return this.getObject(ConversionQuote.class, "get_conversion_quote", quoteId);
40+
public ConversionQuote createConversionQuote(CreateConversionQuote createConversionQuote, String idempotencyKey) throws Exception {
41+
return this.createObject(ConversionQuote.class, idempotencyKey, "create_conversion_quote", createConversionQuote);
4542
}
4643

4744
@Override
48-
public QuotedConversion createQuotedConversion(QuotedConversion quotedConversion, String idempotencyKey) throws Exception {
49-
return this.createObject(QuotedConversion.class, idempotencyKey, "create_quoted_conversion", quotedConversion);
45+
public ConversionQuote getConversionQuote(String quoteId) throws Exception {
46+
return this.getObject(ConversionQuote.class, "get_conversion_quote", quoteId);
5047
}
5148
}

‎src/main/java/com/mangopay/entities/InstantConversion.java ‎src/main/java/com/mangopay/entities/Conversion.java

+41-28
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,32 @@
99

1010
import java.util.ArrayList;
1111

12-
public class InstantConversion extends EntityBase {
12+
public class Conversion extends EntityBase {
13+
14+
/**
15+
* The unique identifier of the active quote which guaranteed the rate for the conversion.
16+
*/
17+
@SerializedName("QuoteId")
18+
public String quoteId;
19+
20+
/**
21+
* The type of transaction
22+
*/
23+
@SerializedName("Type")
24+
public TransactionType type;
25+
26+
/**
27+
* The nature of the transaction, providing more
28+
* information about the context in which the transaction occurred:
29+
*/
30+
@SerializedName("Nature")
31+
public TransactionNature nature;
32+
33+
/**
34+
* The status of the transaction.
35+
*/
36+
@SerializedName("Status")
37+
public TransactionStatus status;
1338

1439
/**
1540
* The unique identifier of the user at the source of the transaction.
@@ -35,37 +60,18 @@ public class InstantConversion extends EntityBase {
3560
@SerializedName("DebitedFunds")
3661
public Money debitedFunds;
3762

38-
3963
/**
4064
* The buy funds
4165
*/
4266
@SerializedName("CreditedFunds")
4367
public Money creditedFunds;
4468

4569
/**
46-
* Real time indicative market rate of a specific currency pair
47-
*/
48-
@SerializedName("ConversionRate")
49-
public ConversionRate conversionRate;
50-
51-
/**
52-
* The status of the transaction.
53-
*/
54-
@SerializedName("Status")
55-
public TransactionStatus status;
56-
57-
/**
58-
* The type of transaction
59-
*/
60-
@SerializedName("Type")
61-
public TransactionType type;
62-
63-
/**
64-
* The nature of the transaction, providing more
65-
* information about the context in which the transaction occurred:
70+
* Information about the fees taken by the platform for
71+
* this transaction (and hence transferred to the Fees Wallet).
6672
*/
67-
@SerializedName("Nature")
68-
public TransactionNature nature;
73+
@SerializedName("Fees")
74+
public Money fees;
6975

7076
/**
7177
* The code indicates the result of the operation.
@@ -89,11 +95,18 @@ public class InstantConversion extends EntityBase {
8995
public Long executionDate;
9096

9197
/**
92-
* Information about the fees taken by the platform for
93-
* this transaction (and hence transferred to the Fees Wallet).
98+
* Real time indicative market rate of a specific currency pair
9499
*/
95-
@SerializedName("Fees")
96-
public Money fees;
100+
@SerializedName("ConversionRateResponse")
101+
public ConversionRate conversionRate;
102+
103+
public String getQuoteId() {
104+
return quoteId;
105+
}
106+
107+
public void setQuoteId(String quoteId) {
108+
this.quoteId = quoteId;
109+
}
97110

98111
public String getAuthorId() {
99112
return authorId;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.mangopay.entities;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import com.mangopay.core.Dto;
5+
import com.mangopay.core.Money;
6+
7+
public class CreateConversionQuote extends Dto {
8+
@SerializedName("Duration")
9+
private int duration;
10+
@SerializedName("DebitedFunds")
11+
private Money debitedFunds;
12+
@SerializedName("CreditedFunds")
13+
private Money creditedFunds;
14+
@SerializedName("TAG")
15+
private String tag;
16+
17+
public int getDuration() {
18+
return duration;
19+
}
20+
21+
public void setDuration(int duration) {
22+
this.duration = duration;
23+
}
24+
25+
public Money getDebitedFunds() {
26+
return debitedFunds;
27+
}
28+
29+
public void setDebitedFunds(Money debitedFunds) {
30+
this.debitedFunds = debitedFunds;
31+
}
32+
33+
public Money getCreditedFunds() {
34+
return creditedFunds;
35+
}
36+
37+
public void setCreditedFunds(Money creditedFunds) {
38+
this.creditedFunds = creditedFunds;
39+
}
40+
41+
public String getTag() {
42+
return tag;
43+
}
44+
45+
public void setTag(String tag) {
46+
this.tag = tag;
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package com.mangopay.entities;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import com.mangopay.core.Dto;
5+
import com.mangopay.core.Money;
6+
7+
public class CreateInstantConversion extends Dto {
8+
9+
/**
10+
* The unique identifier of the user at the source of the transaction.
11+
*/
12+
@SerializedName("AuthorId")
13+
public String authorId;
14+
15+
/**
16+
* The unique identifier of the debited wallet.
17+
*/
18+
@SerializedName("DebitedWalletId")
19+
public String debitedWalletId;
20+
21+
/**
22+
* The unique identifier of the credited wallet
23+
*/
24+
@SerializedName("CreditedWalletId")
25+
public String creditedWalletId;
26+
27+
/**
28+
* The sell funds
29+
*/
30+
@SerializedName("DebitedFunds")
31+
public Money debitedFunds;
32+
33+
/**
34+
* The buy funds
35+
*/
36+
@SerializedName("CreditedFunds")
37+
public Money creditedFunds;
38+
39+
/**
40+
* Information about the fees taken by the platform for
41+
* this transaction (and hence transferred to the Fees Wallet).
42+
*/
43+
@SerializedName("Fees")
44+
public Money fees;
45+
46+
/**
47+
* Custom data.
48+
*/
49+
@SerializedName("Tag")
50+
private String tag;
51+
52+
public String getAuthorId() {
53+
return authorId;
54+
}
55+
56+
public void setAuthorId(String authorId) {
57+
this.authorId = authorId;
58+
}
59+
60+
public String getDebitedWalletId() {
61+
return debitedWalletId;
62+
}
63+
64+
public void setDebitedWalletId(String debitedWalletId) {
65+
this.debitedWalletId = debitedWalletId;
66+
}
67+
68+
public String getCreditedWalletId() {
69+
return creditedWalletId;
70+
}
71+
72+
public void setCreditedWalletId(String creditedWalletId) {
73+
this.creditedWalletId = creditedWalletId;
74+
}
75+
76+
public Money getDebitedFunds() {
77+
return debitedFunds;
78+
}
79+
80+
public void setDebitedFunds(Money debitedFunds) {
81+
this.debitedFunds = debitedFunds;
82+
}
83+
84+
public Money getCreditedFunds() {
85+
return creditedFunds;
86+
}
87+
88+
public void setCreditedFunds(Money creditedFunds) {
89+
this.creditedFunds = creditedFunds;
90+
}
91+
92+
public Money getFees() {
93+
return fees;
94+
}
95+
96+
public void setFees(Money fees) {
97+
this.fees = fees;
98+
}
99+
100+
public String getTag() {
101+
return tag;
102+
}
103+
104+
public void setTag(String tag) {
105+
this.tag = tag;
106+
}
107+
}

0 commit comments

Comments
 (0)