Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,74 @@ 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);
return apiClient.post(url + "/transfers/" + transferToken + "/refunds", transferRefund, HyperwalletTransferRefund.class);
}


/**
* Get Transfer Refund
*
* @param transferToken Transfer token assigned
* @param transferRefundToken Transfer Refund token assigned
* @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
//--------------------------------------
Expand Down Expand Up @@ -1919,6 +1987,11 @@ private HyperwalletTransfer copy(HyperwalletTransfer transfer) {
return transfer;
}

private HyperwalletTransferRefund copy(HyperwalletTransferRefund transferRefund) {
transferRefund = HyperwalletJsonUtil.fromJson(HyperwalletJsonUtil.toJson(transferRefund), HyperwalletTransferRefund.class);
return transferRefund;
}

private HyperwalletPayPalAccount copy(HyperwalletPayPalAccount payPalAccount) {
payPalAccount = HyperwalletJsonUtil.fromJson(HyperwalletJsonUtil.toJson(payPalAccount), HyperwalletPayPalAccount.class);
return payPalAccount;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
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;

@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;

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;
}
}
Loading