|
| 1 | +package com.bunq.sdk.model.generated.endpoint; |
| 2 | + |
| 3 | +import com.bunq.sdk.http.ApiClient; |
| 4 | +import com.bunq.sdk.http.BunqResponse; |
| 5 | +import com.bunq.sdk.http.BunqResponseRaw; |
| 6 | +import com.bunq.sdk.model.core.BunqModel; |
| 7 | +import com.bunq.sdk.model.generated.object.Amount; |
| 8 | +import com.bunq.sdk.model.generated.object.LabelMonetaryAccount; |
| 9 | +import com.google.gson.annotations.Expose; |
| 10 | +import com.google.gson.annotations.SerializedName; |
| 11 | +import com.google.gson.stream.JsonReader; |
| 12 | + |
| 13 | +import java.util.HashMap; |
| 14 | +import java.util.List; |
| 15 | +import java.util.Map; |
| 16 | + |
| 17 | +/** |
| 18 | + * View for requesting Bancontact transactions and polling their status. |
| 19 | + */ |
| 20 | +public class BancontactMerchantTransaction extends BunqModel { |
| 21 | + |
| 22 | + /** |
| 23 | + * Field constants. |
| 24 | + */ |
| 25 | + public static final String FIELD_AMOUNT_REQUESTED = "amount_requested"; |
| 26 | + /** |
| 27 | + * Endpoint constants. |
| 28 | + */ |
| 29 | + protected static final String ENDPOINT_URL_CREATE = "user/%s/monetary-account/%s/bancontact-merchant-transaction"; |
| 30 | + protected static final String ENDPOINT_URL_READ = "user/%s/monetary-account/%s/bancontact-merchant-transaction/%s"; |
| 31 | + protected static final String ENDPOINT_URL_LISTING = "user/%s/monetary-account/%s/bancontact-merchant-transaction"; |
| 32 | + /** |
| 33 | + * Object type. |
| 34 | + */ |
| 35 | + protected static final String OBJECT_TYPE_GET = "BancontactMerchantTransaction"; |
| 36 | + |
| 37 | + /** |
| 38 | + * The id of the monetary account this bancontact merchant transaction links to. |
| 39 | + */ |
| 40 | + @Expose |
| 41 | + @SerializedName("monetary_account_id") |
| 42 | + private Integer monetaryAccountId; |
| 43 | + |
| 44 | + /** |
| 45 | + * The alias of the monetary account to add money to. |
| 46 | + */ |
| 47 | + @Expose |
| 48 | + @SerializedName("alias") |
| 49 | + private LabelMonetaryAccount alias; |
| 50 | + |
| 51 | + /** |
| 52 | + * The requested amount of money to add. |
| 53 | + */ |
| 54 | + @Expose |
| 55 | + @SerializedName("amount_requested") |
| 56 | + private Amount amountRequested; |
| 57 | + |
| 58 | + /** |
| 59 | + * When the transaction will expire. |
| 60 | + */ |
| 61 | + @Expose |
| 62 | + @SerializedName("expiration") |
| 63 | + private String expiration; |
| 64 | + |
| 65 | + /** |
| 66 | + * The URL to visit complete the bancontact transaction. |
| 67 | + */ |
| 68 | + @Expose |
| 69 | + @SerializedName("url_redirect") |
| 70 | + private String urlRedirect; |
| 71 | + |
| 72 | + /** |
| 73 | + * The deep link to visit complete the bancontact transaction. |
| 74 | + */ |
| 75 | + @Expose |
| 76 | + @SerializedName("url_deep_link") |
| 77 | + private String urlDeepLink; |
| 78 | + |
| 79 | + /** |
| 80 | + * The status of the transaction. |
| 81 | + */ |
| 82 | + @Expose |
| 83 | + @SerializedName("status") |
| 84 | + private String status; |
| 85 | + |
| 86 | + /** |
| 87 | + * When the status was last updated. |
| 88 | + */ |
| 89 | + @Expose |
| 90 | + @SerializedName("status_timestamp") |
| 91 | + private String statusTimestamp; |
| 92 | + |
| 93 | + /** |
| 94 | + * The transaction ID of the bancontact transaction. |
| 95 | + */ |
| 96 | + @Expose |
| 97 | + @SerializedName("transaction_id") |
| 98 | + private String transactionId; |
| 99 | + |
| 100 | + /** |
| 101 | + * The requested amount of money to add. |
| 102 | + */ |
| 103 | + @Expose |
| 104 | + @SerializedName("amount_requested_field_for_request") |
| 105 | + private Amount amountRequestedFieldForRequest; |
| 106 | + |
| 107 | + public BancontactMerchantTransaction() { |
| 108 | + this(null); |
| 109 | + } |
| 110 | + |
| 111 | + public BancontactMerchantTransaction(Amount amountRequested) { |
| 112 | + this.amountRequestedFieldForRequest = amountRequested; |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * @param amountRequested The requested amount of money to add. |
| 117 | + */ |
| 118 | + public static BunqResponse<Integer> create(Amount amountRequested, Integer monetaryAccountId, Map<String, String> customHeaders) { |
| 119 | + ApiClient apiClient = new ApiClient(getApiContext()); |
| 120 | + |
| 121 | + if (customHeaders == null) { |
| 122 | + customHeaders = new HashMap<>(); |
| 123 | + } |
| 124 | + |
| 125 | + HashMap<String, Object> requestMap = new HashMap<>(); |
| 126 | + requestMap.put(FIELD_AMOUNT_REQUESTED, amountRequested); |
| 127 | + |
| 128 | + byte[] requestBytes = determineAllRequestByte(requestMap); |
| 129 | + BunqResponseRaw responseRaw = apiClient.post(String.format(ENDPOINT_URL_CREATE, determineUserId(), determineMonetaryAccountId(monetaryAccountId)), requestBytes, customHeaders); |
| 130 | + |
| 131 | + return processForId(responseRaw); |
| 132 | + } |
| 133 | + |
| 134 | + public static BunqResponse<Integer> create() { |
| 135 | + return create(null, null, null); |
| 136 | + } |
| 137 | + |
| 138 | + public static BunqResponse<Integer> create(Amount amountRequested) { |
| 139 | + return create(amountRequested, null, null); |
| 140 | + } |
| 141 | + |
| 142 | + public static BunqResponse<Integer> create(Amount amountRequested, Integer monetaryAccountId) { |
| 143 | + return create(amountRequested, monetaryAccountId, null); |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * |
| 148 | + */ |
| 149 | + public static BunqResponse<BancontactMerchantTransaction> get(Integer bancontactMerchantTransactionId, Integer monetaryAccountId, Map<String, String> params, Map<String, String> customHeaders) { |
| 150 | + ApiClient apiClient = new ApiClient(getApiContext()); |
| 151 | + BunqResponseRaw responseRaw = apiClient.get(String.format(ENDPOINT_URL_READ, determineUserId(), determineMonetaryAccountId(monetaryAccountId), bancontactMerchantTransactionId), params, customHeaders); |
| 152 | + |
| 153 | + return fromJson(BancontactMerchantTransaction.class, responseRaw, OBJECT_TYPE_GET); |
| 154 | + } |
| 155 | + |
| 156 | + public static BunqResponse<BancontactMerchantTransaction> get() { |
| 157 | + return get(null, null, null, null); |
| 158 | + } |
| 159 | + |
| 160 | + public static BunqResponse<BancontactMerchantTransaction> get(Integer bancontactMerchantTransactionId) { |
| 161 | + return get(bancontactMerchantTransactionId, null, null, null); |
| 162 | + } |
| 163 | + |
| 164 | + public static BunqResponse<BancontactMerchantTransaction> get(Integer bancontactMerchantTransactionId, Integer monetaryAccountId) { |
| 165 | + return get(bancontactMerchantTransactionId, monetaryAccountId, null, null); |
| 166 | + } |
| 167 | + |
| 168 | + public static BunqResponse<BancontactMerchantTransaction> get(Integer bancontactMerchantTransactionId, Integer monetaryAccountId, Map<String, String> params) { |
| 169 | + return get(bancontactMerchantTransactionId, monetaryAccountId, params, null); |
| 170 | + } |
| 171 | + |
| 172 | + /** |
| 173 | + * |
| 174 | + */ |
| 175 | + public static BunqResponse<List<BancontactMerchantTransaction>> list(Integer monetaryAccountId, Map<String, String> params, Map<String, String> customHeaders) { |
| 176 | + ApiClient apiClient = new ApiClient(getApiContext()); |
| 177 | + BunqResponseRaw responseRaw = apiClient.get(String.format(ENDPOINT_URL_LISTING, determineUserId(), determineMonetaryAccountId(monetaryAccountId)), params, customHeaders); |
| 178 | + |
| 179 | + return fromJsonList(BancontactMerchantTransaction.class, responseRaw, OBJECT_TYPE_GET); |
| 180 | + } |
| 181 | + |
| 182 | + public static BunqResponse<List<BancontactMerchantTransaction>> list() { |
| 183 | + return list(null, null, null); |
| 184 | + } |
| 185 | + |
| 186 | + public static BunqResponse<List<BancontactMerchantTransaction>> list(Integer monetaryAccountId) { |
| 187 | + return list(monetaryAccountId, null, null); |
| 188 | + } |
| 189 | + |
| 190 | + public static BunqResponse<List<BancontactMerchantTransaction>> list(Integer monetaryAccountId, Map<String, String> params) { |
| 191 | + return list(monetaryAccountId, params, null); |
| 192 | + } |
| 193 | + |
| 194 | + /** |
| 195 | + * |
| 196 | + */ |
| 197 | + public static BancontactMerchantTransaction fromJsonReader(JsonReader reader) { |
| 198 | + return fromJsonReader(BancontactMerchantTransaction.class, reader); |
| 199 | + } |
| 200 | + |
| 201 | + /** |
| 202 | + * The id of the monetary account this bancontact merchant transaction links to. |
| 203 | + */ |
| 204 | + public Integer getMonetaryAccountId() { |
| 205 | + return this.monetaryAccountId; |
| 206 | + } |
| 207 | + |
| 208 | + public void setMonetaryAccountId(Integer monetaryAccountId) { |
| 209 | + this.monetaryAccountId = monetaryAccountId; |
| 210 | + } |
| 211 | + |
| 212 | + /** |
| 213 | + * The alias of the monetary account to add money to. |
| 214 | + */ |
| 215 | + public LabelMonetaryAccount getAlias() { |
| 216 | + return this.alias; |
| 217 | + } |
| 218 | + |
| 219 | + public void setAlias(LabelMonetaryAccount alias) { |
| 220 | + this.alias = alias; |
| 221 | + } |
| 222 | + |
| 223 | + /** |
| 224 | + * The requested amount of money to add. |
| 225 | + */ |
| 226 | + public Amount getAmountRequested() { |
| 227 | + return this.amountRequested; |
| 228 | + } |
| 229 | + |
| 230 | + public void setAmountRequested(Amount amountRequested) { |
| 231 | + this.amountRequested = amountRequested; |
| 232 | + } |
| 233 | + |
| 234 | + /** |
| 235 | + * When the transaction will expire. |
| 236 | + */ |
| 237 | + public String getExpiration() { |
| 238 | + return this.expiration; |
| 239 | + } |
| 240 | + |
| 241 | + public void setExpiration(String expiration) { |
| 242 | + this.expiration = expiration; |
| 243 | + } |
| 244 | + |
| 245 | + /** |
| 246 | + * The URL to visit complete the bancontact transaction. |
| 247 | + */ |
| 248 | + public String getUrlRedirect() { |
| 249 | + return this.urlRedirect; |
| 250 | + } |
| 251 | + |
| 252 | + public void setUrlRedirect(String urlRedirect) { |
| 253 | + this.urlRedirect = urlRedirect; |
| 254 | + } |
| 255 | + |
| 256 | + /** |
| 257 | + * The deep link to visit complete the bancontact transaction. |
| 258 | + */ |
| 259 | + public String getUrlDeepLink() { |
| 260 | + return this.urlDeepLink; |
| 261 | + } |
| 262 | + |
| 263 | + public void setUrlDeepLink(String urlDeepLink) { |
| 264 | + this.urlDeepLink = urlDeepLink; |
| 265 | + } |
| 266 | + |
| 267 | + /** |
| 268 | + * The status of the transaction. |
| 269 | + */ |
| 270 | + public String getStatus() { |
| 271 | + return this.status; |
| 272 | + } |
| 273 | + |
| 274 | + public void setStatus(String status) { |
| 275 | + this.status = status; |
| 276 | + } |
| 277 | + |
| 278 | + /** |
| 279 | + * When the status was last updated. |
| 280 | + */ |
| 281 | + public String getStatusTimestamp() { |
| 282 | + return this.statusTimestamp; |
| 283 | + } |
| 284 | + |
| 285 | + public void setStatusTimestamp(String statusTimestamp) { |
| 286 | + this.statusTimestamp = statusTimestamp; |
| 287 | + } |
| 288 | + |
| 289 | + /** |
| 290 | + * The transaction ID of the bancontact transaction. |
| 291 | + */ |
| 292 | + public String getTransactionId() { |
| 293 | + return this.transactionId; |
| 294 | + } |
| 295 | + |
| 296 | + public void setTransactionId(String transactionId) { |
| 297 | + this.transactionId = transactionId; |
| 298 | + } |
| 299 | + |
| 300 | + /** |
| 301 | + * |
| 302 | + */ |
| 303 | + public boolean isAllFieldNull() { |
| 304 | + if (this.monetaryAccountId != null) { |
| 305 | + return false; |
| 306 | + } |
| 307 | + |
| 308 | + if (this.alias != null) { |
| 309 | + return false; |
| 310 | + } |
| 311 | + |
| 312 | + if (this.amountRequested != null) { |
| 313 | + return false; |
| 314 | + } |
| 315 | + |
| 316 | + if (this.expiration != null) { |
| 317 | + return false; |
| 318 | + } |
| 319 | + |
| 320 | + if (this.urlRedirect != null) { |
| 321 | + return false; |
| 322 | + } |
| 323 | + |
| 324 | + if (this.urlDeepLink != null) { |
| 325 | + return false; |
| 326 | + } |
| 327 | + |
| 328 | + if (this.status != null) { |
| 329 | + return false; |
| 330 | + } |
| 331 | + |
| 332 | + if (this.statusTimestamp != null) { |
| 333 | + return false; |
| 334 | + } |
| 335 | + |
| 336 | + if (this.transactionId != null) { |
| 337 | + return false; |
| 338 | + } |
| 339 | + |
| 340 | + return true; |
| 341 | + } |
| 342 | + |
| 343 | +} |
0 commit comments