|
| 1 | +package com.bunq.sdk.model.generated.endpoint; |
| 2 | + |
| 3 | +import com.bunq.sdk.context.ApiContext; |
| 4 | +import com.bunq.sdk.http.ApiClient; |
| 5 | +import com.bunq.sdk.http.BunqResponse; |
| 6 | +import com.bunq.sdk.http.BunqResponseRaw; |
| 7 | +import com.bunq.sdk.model.core.BunqModel; |
| 8 | +import com.bunq.sdk.model.core.MonetaryAccountReference; |
| 9 | +import com.bunq.sdk.security.SecurityUtils; |
| 10 | +import com.google.gson.annotations.Expose; |
| 11 | +import com.google.gson.annotations.SerializedName; |
| 12 | +import java.math.BigDecimal; |
| 13 | +import java.util.ArrayList; |
| 14 | +import java.util.HashMap; |
| 15 | +import java.util.List; |
| 16 | +import java.util.Map; |
| 17 | +import javax.lang.model.type.NullType; |
| 18 | + |
| 19 | +/** |
| 20 | + * Endpoint for generating and retrieving a new CVC2 code. |
| 21 | + */ |
| 22 | +public class CardGeneratedCvc2 extends BunqModel { |
| 23 | + |
| 24 | + /** |
| 25 | + * Endpoint constants. |
| 26 | + */ |
| 27 | + private static final String ENDPOINT_URL_CREATE = "user/%s/card/%s/generated-cvc2"; |
| 28 | + private static final String ENDPOINT_URL_READ = "user/%s/card/%s/generated-cvc2/%s"; |
| 29 | + private static final String ENDPOINT_URL_LISTING = "user/%s/card/%s/generated-cvc2"; |
| 30 | + |
| 31 | + /** |
| 32 | + * Object type. |
| 33 | + */ |
| 34 | + private static final String OBJECT_TYPE = "CardGeneratedCvc2"; |
| 35 | + |
| 36 | + /** |
| 37 | + * The cvc2 code. |
| 38 | + */ |
| 39 | + @Expose |
| 40 | + @SerializedName("cvc2") |
| 41 | + private String cvc2; |
| 42 | + |
| 43 | + /** |
| 44 | + * The status of the cvc2. Can be AVAILABLE, USED, EXPIRED, BLOCKED. |
| 45 | + */ |
| 46 | + @Expose |
| 47 | + @SerializedName("status") |
| 48 | + private String status; |
| 49 | + |
| 50 | + /** |
| 51 | + * Expiry time of the cvc2. |
| 52 | + */ |
| 53 | + @Expose |
| 54 | + @SerializedName("expiry_time") |
| 55 | + private String expiryTime; |
| 56 | + |
| 57 | + public static BunqResponse<CardGeneratedCvc2> create(ApiContext apiContext, Map<String, Object> requestMap, Integer userId, Integer cardId) { |
| 58 | + return create(apiContext, requestMap, userId, cardId, new HashMap<>()); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Generate a new CVC2 code for a card. |
| 63 | + */ |
| 64 | + public static BunqResponse<CardGeneratedCvc2> create(ApiContext apiContext, Map<String, Object> requestMap, Integer userId, Integer cardId, Map<String, String> customHeaders) { |
| 65 | + ApiClient apiClient = new ApiClient(apiContext); |
| 66 | + byte[] requestBytes = gson.toJson(requestMap).getBytes(); |
| 67 | + requestBytes = SecurityUtils.encrypt(apiContext, requestBytes, customHeaders); |
| 68 | + BunqResponseRaw responseRaw = apiClient.post(String.format(ENDPOINT_URL_CREATE, userId, cardId), requestBytes, customHeaders); |
| 69 | + |
| 70 | + return fromJson(CardGeneratedCvc2.class, responseRaw, OBJECT_TYPE); |
| 71 | + } |
| 72 | + |
| 73 | + public static BunqResponse<CardGeneratedCvc2> get(ApiContext apiContext, Integer userId, Integer cardId, Integer cardGeneratedCvc2Id) { |
| 74 | + return get(apiContext, userId, cardId, cardGeneratedCvc2Id, new HashMap<>()); |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Get the details for a specific generated CVC2 code. |
| 79 | + */ |
| 80 | + public static BunqResponse<CardGeneratedCvc2> get(ApiContext apiContext, Integer userId, Integer cardId, Integer cardGeneratedCvc2Id, Map<String, String> customHeaders) { |
| 81 | + ApiClient apiClient = new ApiClient(apiContext); |
| 82 | + BunqResponseRaw responseRaw = apiClient.get(String.format(ENDPOINT_URL_READ, userId, cardId, cardGeneratedCvc2Id), new HashMap<>(), customHeaders); |
| 83 | + |
| 84 | + return fromJson(CardGeneratedCvc2.class, responseRaw, OBJECT_TYPE); |
| 85 | + } |
| 86 | + |
| 87 | + public static BunqResponse<List<CardGeneratedCvc2>> list(ApiContext apiContext, Integer userId, Integer cardId) { |
| 88 | + return list(apiContext, userId, cardId, new HashMap<>()); |
| 89 | + } |
| 90 | + |
| 91 | + public static BunqResponse<List<CardGeneratedCvc2>> list(ApiContext apiContext, Integer userId, Integer cardId, Map<String, String> params) { |
| 92 | + return list(apiContext, userId, cardId, params, new HashMap<>()); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * Get all generated CVC2 codes for a card. |
| 97 | + */ |
| 98 | + public static BunqResponse<List<CardGeneratedCvc2>> list(ApiContext apiContext, Integer userId, Integer cardId, Map<String, String> params, Map<String, String> customHeaders) { |
| 99 | + ApiClient apiClient = new ApiClient(apiContext); |
| 100 | + BunqResponseRaw responseRaw = apiClient.get(String.format(ENDPOINT_URL_LISTING, userId, cardId), params, customHeaders); |
| 101 | + |
| 102 | + return fromJsonList(CardGeneratedCvc2.class, responseRaw, OBJECT_TYPE); |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * The cvc2 code. |
| 107 | + */ |
| 108 | + public String getCvc2() { |
| 109 | + return this.cvc2; |
| 110 | + } |
| 111 | + |
| 112 | + public void setCvc2(String cvc2) { |
| 113 | + this.cvc2 = cvc2; |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * The status of the cvc2. Can be AVAILABLE, USED, EXPIRED, BLOCKED. |
| 118 | + */ |
| 119 | + public String getStatus() { |
| 120 | + return this.status; |
| 121 | + } |
| 122 | + |
| 123 | + public void setStatus(String status) { |
| 124 | + this.status = status; |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Expiry time of the cvc2. |
| 129 | + */ |
| 130 | + public String getExpiryTime() { |
| 131 | + return this.expiryTime; |
| 132 | + } |
| 133 | + |
| 134 | + public void setExpiryTime(String expiryTime) { |
| 135 | + this.expiryTime = expiryTime; |
| 136 | + } |
| 137 | + |
| 138 | +} |
0 commit comments