001
002package com.commercetools.api.models.payment;
003
004import java.time.*;
005import java.time.ZonedDateTime;
006import java.util.*;
007import java.util.function.Function;
008import java.util.stream.Collectors;
009
010import javax.annotation.Nullable;
011import javax.validation.Valid;
012import javax.validation.constraints.NotNull;
013
014import com.commercetools.api.models.common.BaseResource;
015import com.commercetools.api.models.common.CentPrecisionMoney;
016import com.commercetools.api.models.common.CreatedBy;
017import com.commercetools.api.models.common.LastModifiedBy;
018import com.commercetools.api.models.customer.CustomerReference;
019import com.commercetools.api.models.type.CustomFields;
020import com.fasterxml.jackson.annotation.*;
021import com.fasterxml.jackson.databind.annotation.*;
022
023import io.vrap.rmf.base.client.utils.Generated;
024
025/**
026 * Payment
027 *
028 * <hr>
029 * Example to create an instance using the builder pattern
030 * <div class=code-example>
031 * <pre><code class='java'>
032 *     Payment payment = Payment.builder()
033 *             .id("{id}")
034 *             .version(0.3)
035 *             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
036 *             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
037 *             .amountPlanned(amountPlannedBuilder -> amountPlannedBuilder)
038 *             .paymentMethodInfo(paymentMethodInfoBuilder -> paymentMethodInfoBuilder)
039 *             .paymentStatus(paymentStatusBuilder -> paymentStatusBuilder)
040 *             .plusTransactions(transactionsBuilder -> transactionsBuilder)
041 *             .plusInterfaceInteractions(interfaceInteractionsBuilder -> interfaceInteractionsBuilder)
042 *             .build()
043 * </code></pre>
044 * </div>
045 */
046@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
047@JsonDeserialize(as = PaymentImpl.class)
048public interface Payment extends BaseResource, PaymentMixin, com.commercetools.api.models.DomainResource<Payment>,
049        com.commercetools.api.models.Referencable<Payment>, com.commercetools.api.models.ResourceIdentifiable<Payment>,
050        com.commercetools.api.models.Customizable<Payment>, com.commercetools.api.models.WithKey {
051
052    /**
053     *  <p>Unique identifier of the Payment.</p>
054     * @return id
055     */
056    @NotNull
057    @JsonProperty("id")
058    public String getId();
059
060    /**
061     *  <p>Current version of the Payment.</p>
062     * @return version
063     */
064    @NotNull
065    @JsonProperty("version")
066    public Long getVersion();
067
068    /**
069     *  <p>Date and time (UTC) the Payment was initially created.</p>
070     * @return createdAt
071     */
072    @NotNull
073    @JsonProperty("createdAt")
074    public ZonedDateTime getCreatedAt();
075
076    /**
077     *  <p>Date and time (UTC) the Payment was last updated.</p>
078     * @return lastModifiedAt
079     */
080    @NotNull
081    @JsonProperty("lastModifiedAt")
082    public ZonedDateTime getLastModifiedAt();
083
084    /**
085     *  <p>Present on resources created after 1 February 2019 except for events not tracked.</p>
086     * @return lastModifiedBy
087     */
088    @Valid
089    @JsonProperty("lastModifiedBy")
090    public LastModifiedBy getLastModifiedBy();
091
092    /**
093     *  <p>Present on resources created after 1 February 2019 except for events not tracked.</p>
094     * @return createdBy
095     */
096    @Valid
097    @JsonProperty("createdBy")
098    public CreatedBy getCreatedBy();
099
100    /**
101     *  <p>Reference to a Customer associated with the Payment.</p>
102     * @return customer
103     */
104    @Valid
105    @JsonProperty("customer")
106    public CustomerReference getCustomer();
107
108    /**
109     *  <p>Anonymous session associated with the Payment.</p>
110     * @return anonymousId
111     */
112
113    @JsonProperty("anonymousId")
114    public String getAnonymousId();
115
116    /**
117     *  <p>Identifier used by the payment service that processes the Payment (for example, a PSP). The combination of <code>interfaceId</code> and the <code>paymentInterface</code> field on PaymentMethodInfo must be unique.</p>
118     * @return interfaceId
119     */
120
121    @JsonProperty("interfaceId")
122    public String getInterfaceId();
123
124    /**
125     *  <p>Money value the Payment intends to receive from the customer. The value typically matches the Cart or Order gross total.</p>
126     * @return amountPlanned
127     */
128    @NotNull
129    @Valid
130    @JsonProperty("amountPlanned")
131    public CentPrecisionMoney getAmountPlanned();
132
133    /**
134     *  <p>Information regarding the payment interface (for example, a PSP), and the specific payment method used.</p>
135     * @return paymentMethodInfo
136     */
137    @NotNull
138    @Valid
139    @JsonProperty("paymentMethodInfo")
140    public PaymentMethodInfo getPaymentMethodInfo();
141
142    /**
143     *  <p>Current status of the Payment.</p>
144     * @return paymentStatus
145     */
146    @NotNull
147    @Valid
148    @JsonProperty("paymentStatus")
149    public PaymentStatus getPaymentStatus();
150
151    /**
152     *  <p>Financial transactions of the Payment. Each Transaction has a TransactionType and a TransactionState.</p>
153     * @return transactions
154     */
155    @NotNull
156    @Valid
157    @JsonProperty("transactions")
158    public List<Transaction> getTransactions();
159
160    /**
161     *  <p>Represents information exchange with the payment service, for example, a PSP. An interaction may be a request sent, or a response or notification received from the payment service.</p>
162     * @return interfaceInteractions
163     */
164    @NotNull
165    @Valid
166    @JsonProperty("interfaceInteractions")
167    public List<CustomFields> getInterfaceInteractions();
168
169    /**
170     *  <p>Custom Fields for the Payment.</p>
171     * @return custom
172     */
173    @Valid
174    @JsonProperty("custom")
175    public CustomFields getCustom();
176
177    /**
178     *  <p>User-defined unique identifier of the Payment.</p>
179     * @return key
180     */
181
182    @JsonProperty("key")
183    public String getKey();
184
185    /**
186     *  <p>Unique identifier of the Payment.</p>
187     * @param id value to be set
188     */
189
190    public void setId(final String id);
191
192    /**
193     *  <p>Current version of the Payment.</p>
194     * @param version value to be set
195     */
196
197    public void setVersion(final Long version);
198
199    /**
200     *  <p>Date and time (UTC) the Payment was initially created.</p>
201     * @param createdAt value to be set
202     */
203
204    public void setCreatedAt(final ZonedDateTime createdAt);
205
206    /**
207     *  <p>Date and time (UTC) the Payment was last updated.</p>
208     * @param lastModifiedAt value to be set
209     */
210
211    public void setLastModifiedAt(final ZonedDateTime lastModifiedAt);
212
213    /**
214     *  <p>Present on resources created after 1 February 2019 except for events not tracked.</p>
215     * @param lastModifiedBy value to be set
216     */
217
218    public void setLastModifiedBy(final LastModifiedBy lastModifiedBy);
219
220    /**
221     *  <p>Present on resources created after 1 February 2019 except for events not tracked.</p>
222     * @param createdBy value to be set
223     */
224
225    public void setCreatedBy(final CreatedBy createdBy);
226
227    /**
228     *  <p>Reference to a Customer associated with the Payment.</p>
229     * @param customer value to be set
230     */
231
232    public void setCustomer(final CustomerReference customer);
233
234    /**
235     *  <p>Anonymous session associated with the Payment.</p>
236     * @param anonymousId value to be set
237     */
238
239    public void setAnonymousId(final String anonymousId);
240
241    /**
242     *  <p>Identifier used by the payment service that processes the Payment (for example, a PSP). The combination of <code>interfaceId</code> and the <code>paymentInterface</code> field on PaymentMethodInfo must be unique.</p>
243     * @param interfaceId value to be set
244     */
245
246    public void setInterfaceId(final String interfaceId);
247
248    /**
249     *  <p>Money value the Payment intends to receive from the customer. The value typically matches the Cart or Order gross total.</p>
250     * @param amountPlanned value to be set
251     */
252
253    public void setAmountPlanned(final CentPrecisionMoney amountPlanned);
254
255    /**
256     *  <p>Information regarding the payment interface (for example, a PSP), and the specific payment method used.</p>
257     * @param paymentMethodInfo value to be set
258     */
259
260    public void setPaymentMethodInfo(final PaymentMethodInfo paymentMethodInfo);
261
262    /**
263     *  <p>Current status of the Payment.</p>
264     * @param paymentStatus value to be set
265     */
266
267    public void setPaymentStatus(final PaymentStatus paymentStatus);
268
269    /**
270     *  <p>Financial transactions of the Payment. Each Transaction has a TransactionType and a TransactionState.</p>
271     * @param transactions values to be set
272     */
273
274    @JsonIgnore
275    public void setTransactions(final Transaction... transactions);
276
277    /**
278     *  <p>Financial transactions of the Payment. Each Transaction has a TransactionType and a TransactionState.</p>
279     * @param transactions values to be set
280     */
281
282    public void setTransactions(final List<Transaction> transactions);
283
284    /**
285     *  <p>Represents information exchange with the payment service, for example, a PSP. An interaction may be a request sent, or a response or notification received from the payment service.</p>
286     * @param interfaceInteractions values to be set
287     */
288
289    @JsonIgnore
290    public void setInterfaceInteractions(final CustomFields... interfaceInteractions);
291
292    /**
293     *  <p>Represents information exchange with the payment service, for example, a PSP. An interaction may be a request sent, or a response or notification received from the payment service.</p>
294     * @param interfaceInteractions values to be set
295     */
296
297    public void setInterfaceInteractions(final List<CustomFields> interfaceInteractions);
298
299    /**
300     *  <p>Custom Fields for the Payment.</p>
301     * @param custom value to be set
302     */
303
304    public void setCustom(final CustomFields custom);
305
306    /**
307     *  <p>User-defined unique identifier of the Payment.</p>
308     * @param key value to be set
309     */
310
311    public void setKey(final String key);
312
313    /**
314     * factory method
315     * @return instance of Payment
316     */
317    public static Payment of() {
318        return new PaymentImpl();
319    }
320
321    /**
322     * factory method to create a shallow copy Payment
323     * @param template instance to be copied
324     * @return copy instance
325     */
326    public static Payment of(final Payment template) {
327        PaymentImpl instance = new PaymentImpl();
328        instance.setId(template.getId());
329        instance.setVersion(template.getVersion());
330        instance.setCreatedAt(template.getCreatedAt());
331        instance.setLastModifiedAt(template.getLastModifiedAt());
332        instance.setLastModifiedBy(template.getLastModifiedBy());
333        instance.setCreatedBy(template.getCreatedBy());
334        instance.setCustomer(template.getCustomer());
335        instance.setAnonymousId(template.getAnonymousId());
336        instance.setInterfaceId(template.getInterfaceId());
337        instance.setAmountPlanned(template.getAmountPlanned());
338        instance.setPaymentMethodInfo(template.getPaymentMethodInfo());
339        instance.setPaymentStatus(template.getPaymentStatus());
340        instance.setTransactions(template.getTransactions());
341        instance.setInterfaceInteractions(template.getInterfaceInteractions());
342        instance.setCustom(template.getCustom());
343        instance.setKey(template.getKey());
344        return instance;
345    }
346
347    /**
348     * factory method to create a deep copy of Payment
349     * @param template instance to be copied
350     * @return copy instance
351     */
352    @Nullable
353    public static Payment deepCopy(@Nullable final Payment template) {
354        if (template == null) {
355            return null;
356        }
357        PaymentImpl instance = new PaymentImpl();
358        instance.setId(template.getId());
359        instance.setVersion(template.getVersion());
360        instance.setCreatedAt(template.getCreatedAt());
361        instance.setLastModifiedAt(template.getLastModifiedAt());
362        instance.setLastModifiedBy(
363            com.commercetools.api.models.common.LastModifiedBy.deepCopy(template.getLastModifiedBy()));
364        instance.setCreatedBy(com.commercetools.api.models.common.CreatedBy.deepCopy(template.getCreatedBy()));
365        instance.setCustomer(com.commercetools.api.models.customer.CustomerReference.deepCopy(template.getCustomer()));
366        instance.setAnonymousId(template.getAnonymousId());
367        instance.setInterfaceId(template.getInterfaceId());
368        instance.setAmountPlanned(
369            com.commercetools.api.models.common.CentPrecisionMoney.deepCopy(template.getAmountPlanned()));
370        instance.setPaymentMethodInfo(
371            com.commercetools.api.models.payment.PaymentMethodInfo.deepCopy(template.getPaymentMethodInfo()));
372        instance.setPaymentStatus(
373            com.commercetools.api.models.payment.PaymentStatus.deepCopy(template.getPaymentStatus()));
374        instance.setTransactions(Optional.ofNullable(template.getTransactions())
375                .map(t -> t.stream()
376                        .map(com.commercetools.api.models.payment.Transaction::deepCopy)
377                        .collect(Collectors.toList()))
378                .orElse(null));
379        instance.setInterfaceInteractions(Optional.ofNullable(template.getInterfaceInteractions())
380                .map(t -> t.stream()
381                        .map(com.commercetools.api.models.type.CustomFields::deepCopy)
382                        .collect(Collectors.toList()))
383                .orElse(null));
384        instance.setCustom(com.commercetools.api.models.type.CustomFields.deepCopy(template.getCustom()));
385        instance.setKey(template.getKey());
386        return instance;
387    }
388
389    /**
390     * builder factory method for Payment
391     * @return builder
392     */
393    public static PaymentBuilder builder() {
394        return PaymentBuilder.of();
395    }
396
397    /**
398     * create builder for Payment instance
399     * @param template instance with prefilled values for the builder
400     * @return builder
401     */
402    public static PaymentBuilder builder(final Payment template) {
403        return PaymentBuilder.of(template);
404    }
405
406    /**
407     * accessor map function
408     * @param <T> mapped type
409     * @param helper function to map the object
410     * @return mapped value
411     */
412    default <T> T withPayment(Function<Payment, T> helper) {
413        return helper.apply(this);
414    }
415
416    public static com.commercetools.api.models.common.ReferenceTypeId referenceTypeId() {
417        return com.commercetools.api.models.common.ReferenceTypeId.PAYMENT;
418    }
419
420    /**
421     * gives a TypeReference for usage with Jackson DataBind
422     * @return TypeReference
423     */
424    public static com.fasterxml.jackson.core.type.TypeReference<Payment> typeReference() {
425        return new com.fasterxml.jackson.core.type.TypeReference<Payment>() {
426            @Override
427            public String toString() {
428                return "TypeReference<Payment>";
429            }
430        };
431    }
432}