/buttonmanagersdk/src/main/java/urn/ebay/api/PayPalAPI/MassPayRequestType.java

https://gitlab.com/CORP-RESELLER/buttonmanager-sdk-java · Java · 164 lines · 82 code · 23 blank · 59 comment · 13 complexity · a0625b62e67a422cfadd5ea855edf7fb MD5 · raw file

  1. package urn.ebay.api.PayPalAPI;
  2. import urn.ebay.apis.eBLBaseComponents.ReceiverInfoCodeType;
  3. import java.util.List;
  4. import java.util.ArrayList;
  5. import urn.ebay.api.PayPalAPI.MassPayRequestItemType;
  6. import urn.ebay.apis.eBLBaseComponents.AbstractRequestType;
  7. import com.paypal.core.SDKUtil;
  8. /**
  9. * Subject line of the email sent to all recipients. This
  10. * subject is not contained in the input file; you must create
  11. * it with your application. Optional Character length and
  12. * limitations: 255 single-byte alphanumeric characters
  13. */
  14. public class MassPayRequestType extends AbstractRequestType {
  15. private static final String nameSpace="urn:ebay:api:PayPalAPI";
  16. private static final String preferredPrefix="ns";
  17. /**
  18. * Subject line of the email sent to all recipients. This
  19. * subject is not contained in the input file; you must create
  20. * it with your application. Optional Character length and
  21. * limitations: 255 single-byte alphanumeric characters
  22. */
  23. private String emailSubject;
  24. /**
  25. * Indicates how you identify the recipients of payments in all
  26. * MassPayItems: either by EmailAddress (ReceiverEmail in
  27. * MassPayItem), PhoneNumber (ReceiverPhone in MassPayItem), or
  28. * by UserID (ReceiverID in MassPayItem). Required. You must
  29. * specify one or the other of EmailAddress or UserID.
  30. */
  31. private ReceiverInfoCodeType receiverType;
  32. /**
  33. * Known as BN code, to track the partner referred merchant
  34. * transactions. OptionalCharacter length and limitations: 32
  35. * single-byte alphanumeric characters
  36. */
  37. private String buttonSource = "PayPal_SDK";
  38. /**
  39. * Details of each payment. A single MassPayRequest can include
  40. * up to 250 MassPayItems. Required
  41. *@Required
  42. */
  43. private List<MassPayRequestItemType> massPayItem = new ArrayList<MassPayRequestItemType>();
  44. /**
  45. * Constructor with arguments
  46. */
  47. public MassPayRequestType (List<MassPayRequestItemType> massPayItem){
  48. this.massPayItem = massPayItem;
  49. }
  50. /**
  51. * Default Constructor
  52. */
  53. public MassPayRequestType (){
  54. }
  55. /**
  56. * Getter for emailSubject
  57. */
  58. public String getEmailSubject() {
  59. return emailSubject;
  60. }
  61. /**
  62. * Setter for emailSubject
  63. */
  64. public void setEmailSubject(String emailSubject) {
  65. this.emailSubject = emailSubject;
  66. }
  67. /**
  68. * Getter for receiverType
  69. */
  70. public ReceiverInfoCodeType getReceiverType() {
  71. return receiverType;
  72. }
  73. /**
  74. * Setter for receiverType
  75. */
  76. public void setReceiverType(ReceiverInfoCodeType receiverType) {
  77. this.receiverType = receiverType;
  78. }
  79. /**
  80. * Getter for buttonSource
  81. */
  82. public String getButtonSource() {
  83. return buttonSource;
  84. }
  85. /**
  86. * Setter for buttonSource
  87. */
  88. public void setButtonSource(String buttonSource) {
  89. this.buttonSource = buttonSource;
  90. }
  91. /**
  92. * Getter for massPayItem
  93. */
  94. public List<MassPayRequestItemType> getMassPayItem() {
  95. return massPayItem;
  96. }
  97. /**
  98. * Setter for massPayItem
  99. */
  100. public void setMassPayItem(List<MassPayRequestItemType> massPayItem) {
  101. this.massPayItem = massPayItem;
  102. }
  103. public String toXMLString(String prefix, String name) {
  104. StringBuilder sb = new StringBuilder();
  105. if(name!=null){
  106. if(prefix!=null){
  107. sb.append("<").append(prefix).append(":").append(name).append(">");
  108. }
  109. else{
  110. sb.append("<").append(preferredPrefix).append(":").append(name).append(">");
  111. }
  112. }
  113. sb.append(super.toXMLString(prefix, null));
  114. if(emailSubject != null) {
  115. sb.append("<").append(preferredPrefix).append(":EmailSubject>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.emailSubject));
  116. sb.append("</").append(preferredPrefix).append(":EmailSubject>");
  117. }
  118. if(receiverType != null) {
  119. sb.append("<").append(preferredPrefix).append(":ReceiverType>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.receiverType.getValue()));
  120. sb.append("</").append(preferredPrefix).append(":ReceiverType>");
  121. }
  122. if(buttonSource != null) {
  123. sb.append("<").append(preferredPrefix).append(":ButtonSource>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.buttonSource));
  124. sb.append("</").append(preferredPrefix).append(":ButtonSource>");
  125. }
  126. if(massPayItem != null) {
  127. for(int i=0; i < massPayItem.size(); i++) {
  128. sb.append(massPayItem.get(i).toXMLString(preferredPrefix,"MassPayItem"));
  129. }
  130. }
  131. if(name!=null){
  132. if(prefix!=null){
  133. sb.append("</").append(prefix).append(":").append(name).append(">");
  134. }
  135. else{
  136. sb.append("</").append(preferredPrefix).append(":").append(name).append(">");
  137. }
  138. }
  139. return sb.toString();
  140. }
  141. }