-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes for handling transfer refund in v4 endpoint #62
Changes from 10 commits
df364dd
908e724
0e6f1d8
14becde
ed5888f
04f77a8
9a9dcd2
7c14cc3
2691667
d91a15c
1906c2f
d1ff3dd
281745b
4a00061
af4f238
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1016,6 +1016,73 @@ public HyperwalletStatusTransition createTransferStatusTransition(String transfe | |
return apiClient.post(url + "/transfers/" + transferToken + "/status-transitions", transition, HyperwalletStatusTransition.class); | ||
} | ||
|
||
//-------------------------------------- | ||
// Transfer refunds | ||
//-------------------------------------- | ||
|
||
/** | ||
* Create Transfer Refund | ||
* | ||
* @param transferToken Transfer token assigned | ||
* @param transferRefund Transfer Refund object to create | ||
* @return Created Transfer Refund | ||
*/ | ||
public HyperwalletTransferRefund createTransferRefund(String transferToken, HyperwalletTransferRefund transferRefund) { | ||
if (transferRefund == null) { | ||
throw new HyperwalletException("Transfer Refund is required"); | ||
} | ||
if (StringUtils.isEmpty(transferToken)) { | ||
throw new HyperwalletException("Transfer token is required"); | ||
} | ||
if (StringUtils.isEmpty(transferRefund.getClientRefundId())) { | ||
throw new HyperwalletException("ClientRefundId is required"); | ||
} | ||
|
||
transferRefund = copy(transferRefund); | ||
transferRefund.setStatus(null); | ||
transferRefund.setCreatedOn(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed as suggested. |
||
return apiClient.post(url + "/transfers/" + transferToken + "/refunds", transferRefund, HyperwalletTransferRefund.class); | ||
} | ||
|
||
/** | ||
* Get Transfer Refund | ||
* | ||
* @param transferToken Transfer token assigned | ||
* @param transferRefundToken Transfer Refund token assigned | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pls remove extra spaces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
* @return Transfer Refund object | ||
*/ | ||
public HyperwalletTransferRefund getTransferRefund(String transferToken, String transferRefundToken) { | ||
if (StringUtils.isEmpty(transferToken)) { | ||
throw new HyperwalletException("Transfer token is required"); | ||
} | ||
if (StringUtils.isEmpty(transferRefundToken)) { | ||
throw new HyperwalletException("Transfer Refund token is required"); | ||
} | ||
|
||
return apiClient.get(url + "/transfers/" + transferToken + "/refunds/" + transferRefundToken, HyperwalletTransferRefund.class); | ||
} | ||
|
||
/** | ||
* List Transfer Refund Requests | ||
* | ||
* @param options List filter option | ||
* @return HyperwalletList of HyperwalletTransferRefund | ||
*/ | ||
public HyperwalletList<HyperwalletTransferRefund> listTransferRefunds(String transferToken, HyperwalletTransferRefundListOptions options) { | ||
if (StringUtils.isEmpty(transferToken)) { | ||
throw new HyperwalletException("Transfer token is required"); | ||
} | ||
|
||
String url = paginate(this.url + "/transfers/" + transferToken + "/refunds", options); | ||
if (options != null) { | ||
url = addParameter(url, "clientRefundId", options.getClientRefundId()); | ||
url = addParameter(url, "sourceToken", options.getSourceToken()); | ||
url = addParameter(url, "status", options.getStatus()); | ||
} | ||
return apiClient.get(url, new TypeReference<HyperwalletList<HyperwalletTransferRefund>>() { | ||
}); | ||
} | ||
|
||
//-------------------------------------- | ||
// PayPal Accounts | ||
//-------------------------------------- | ||
|
@@ -2228,8 +2295,11 @@ private HyperwalletPayPalAccount copy(HyperwalletPayPalAccount payPalAccount) { | |
return payPalAccount; | ||
} | ||
|
||
private HyperwalletTransferRefund copy(HyperwalletTransferRefund transferRefund) { | ||
return HyperwalletJsonUtil.fromJson(HyperwalletJsonUtil.toJson(transferRefund), HyperwalletTransferRefund.class); | ||
} | ||
|
||
private HyperwalletVenmoAccount copy(HyperwalletVenmoAccount venmoAccount) { | ||
return HyperwalletJsonUtil.fromJson(HyperwalletJsonUtil.toJson(venmoAccount), HyperwalletVenmoAccount.class); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be changed to: return HyperwalletJsonUtil.fromJson(HyperwalletJsonUtil.toJson(transferRefund), HyperwalletTransferRefund.class); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,305 @@ | ||
package com.hyperwallet.clientsdk.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFilter; | ||
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER) | ||
@XmlRootElement | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
public class HyperwalletTransferRefund extends HyperwalletBaseMonitor { | ||
|
||
public static enum Status {PENDING, FAILED, COMPLETED} | ||
|
||
private String token; | ||
private Status status; | ||
private String clientRefundId; | ||
private String sourceToken; | ||
private Double sourceAmount; | ||
private String sourceCurrency; | ||
private String destinationToken; | ||
private Double destinationAmount; | ||
private String destinationCurrency; | ||
private Date createdOn; | ||
private String notes; | ||
private String memo; | ||
private List<HyperwalletLink> links; | ||
|
||
public String getToken() { | ||
return token; | ||
} | ||
|
||
public void setToken(String token) { | ||
addField("token", token); | ||
this.token = token; | ||
} | ||
|
||
public HyperwalletTransferRefund token(String token) { | ||
addField("token", token); | ||
this.token = token; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearToken() { | ||
clearField("token"); | ||
this.token = null; | ||
return this; | ||
} | ||
|
||
public Status getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(Status status) { | ||
addField("status", status); | ||
this.status = status; | ||
} | ||
|
||
public HyperwalletTransferRefund status(Status status) { | ||
addField("status", status); | ||
this.status = status; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearStatus() { | ||
clearField("status"); | ||
this.status = null; | ||
return this; | ||
} | ||
|
||
public String getClientRefundId() { | ||
return clientRefundId; | ||
} | ||
|
||
public void setClientRefundId(String clientRefundId) { | ||
addField("clientRefundId", clientRefundId); | ||
this.clientRefundId = clientRefundId; | ||
} | ||
|
||
public HyperwalletTransferRefund clientRefundId(String clientRefundId) { | ||
addField("clientRefundId", clientRefundId); | ||
this.clientRefundId = clientRefundId; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearClientRefundId() { | ||
clearField("clientRefundId"); | ||
this.clientRefundId = null; | ||
return this; | ||
} | ||
|
||
public String getSourceToken() { | ||
return sourceToken; | ||
} | ||
|
||
public void setSourceToken(String sourceToken) { | ||
addField("sourceToken", sourceToken); | ||
this.sourceToken = sourceToken; | ||
} | ||
|
||
public HyperwalletTransferRefund sourceToken(String sourceToken) { | ||
addField("sourceToken", sourceToken); | ||
this.sourceToken = sourceToken; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearSourceToken() { | ||
clearField("sourceToken"); | ||
this.sourceToken = null; | ||
return this; | ||
} | ||
|
||
public Double getSourceAmount() { | ||
return sourceAmount; | ||
} | ||
|
||
public void setSourceAmount(Double sourceAmount) { | ||
addField("sourceAmount", sourceAmount); | ||
this.sourceAmount = sourceAmount; | ||
} | ||
|
||
public HyperwalletTransferRefund sourceAmount(Double sourceAmount) { | ||
addField("sourceAmount", sourceAmount); | ||
this.sourceAmount = sourceAmount; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearSourceAmount() { | ||
clearField("sourceAmount"); | ||
this.sourceAmount = null; | ||
return this; | ||
} | ||
|
||
public String getSourceCurrency() { | ||
return sourceCurrency; | ||
} | ||
|
||
public void setSourceCurrency(String sourceCurrency) { | ||
addField("sourceCurrency", sourceCurrency); | ||
this.sourceCurrency = sourceCurrency; | ||
} | ||
|
||
public HyperwalletTransferRefund sourceCurrency(String sourceCurrency) { | ||
addField("sourceCurrency", sourceCurrency); | ||
this.sourceCurrency = sourceCurrency; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearSourceCurrency() { | ||
clearField("sourceCurrency"); | ||
this.sourceCurrency = null; | ||
return this; | ||
} | ||
|
||
public String getDestinationToken() { | ||
return destinationToken; | ||
} | ||
|
||
public void setDestinationToken(String destinationToken) { | ||
addField("destinationToken", destinationToken); | ||
this.destinationToken = destinationToken; | ||
} | ||
|
||
public HyperwalletTransferRefund destinationToken(String destinationToken) { | ||
addField("destinationToken", destinationToken); | ||
this.destinationToken = destinationToken; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearDestinationToken() { | ||
clearField("destinationToken"); | ||
this.destinationToken = null; | ||
return this; | ||
} | ||
|
||
public Double getDestinationAmount() { | ||
return destinationAmount; | ||
} | ||
|
||
public void setDestinationAmount(Double destinationAmount) { | ||
addField("destinationAmount", destinationAmount); | ||
this.destinationAmount = destinationAmount; | ||
} | ||
|
||
public HyperwalletTransferRefund destinationAmount(Double destinationAmount) { | ||
addField("destinationAmount", destinationAmount); | ||
this.destinationAmount = destinationAmount; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearDestinationAmount() { | ||
clearField("destinationAmount"); | ||
this.destinationAmount = null; | ||
return this; | ||
} | ||
|
||
public String getDestinationCurrency() { | ||
return destinationCurrency; | ||
} | ||
|
||
public void setDestinationCurrency(String destinationCurrency) { | ||
addField("destinationCurrency", destinationCurrency); | ||
this.destinationCurrency = destinationCurrency; | ||
} | ||
|
||
public HyperwalletTransferRefund destinationCurrency(String destinationCurrency) { | ||
addField("destinationCurrency", destinationCurrency); | ||
this.destinationCurrency = destinationCurrency; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearDestinationCurrency() { | ||
clearField("destinationCurrency"); | ||
this.destinationCurrency = null; | ||
return this; | ||
} | ||
|
||
public Date getCreatedOn() { | ||
return createdOn; | ||
} | ||
|
||
public void setCreatedOn(Date createdOn) { | ||
addField("createdOn", createdOn); | ||
this.createdOn = createdOn; | ||
} | ||
|
||
public HyperwalletTransferRefund createdOn(Date createdOn) { | ||
addField("createdOn", createdOn); | ||
this.createdOn = createdOn; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearCreatedOn() { | ||
clearField("createdOn"); | ||
this.createdOn = null; | ||
return this; | ||
} | ||
|
||
public String getNotes() { | ||
return notes; | ||
} | ||
|
||
public void setNotes(String notes) { | ||
addField("notes", notes); | ||
this.notes = notes; | ||
} | ||
|
||
public HyperwalletTransferRefund notes(String notes) { | ||
addField("notes", notes); | ||
this.notes = notes; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearNotes() { | ||
clearField("notes"); | ||
this.notes = null; | ||
return this; | ||
} | ||
|
||
public String getMemo() { | ||
return memo; | ||
} | ||
|
||
public void setMemo(String memo) { | ||
addField("memo", memo); | ||
this.memo = memo; | ||
} | ||
|
||
public HyperwalletTransferRefund memo(String memo) { | ||
addField("memo", memo); | ||
this.memo = memo; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearMemo() { | ||
clearField("memo"); | ||
this.memo = null; | ||
return this; | ||
} | ||
|
||
public List<HyperwalletLink> getLinks() { | ||
return links; | ||
} | ||
|
||
public void setLinks(List<HyperwalletLink> links) { | ||
addField("links", links); | ||
this.links = links; | ||
} | ||
|
||
public HyperwalletTransferRefund links(List<HyperwalletLink> links) { | ||
addField("links", links); | ||
this.links = links; | ||
return this; | ||
} | ||
|
||
public HyperwalletTransferRefund clearLinks() { | ||
clearField("links"); | ||
this.links = null; | ||
return this; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use the clearStatus() method here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed as suggested.