001
002package com.commercetools.history.models.common;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007
008import javax.annotation.Nullable;
009import javax.validation.Valid;
010import javax.validation.constraints.NotNull;
011
012import com.fasterxml.jackson.annotation.*;
013import com.fasterxml.jackson.databind.annotation.*;
014
015import io.vrap.rmf.base.client.utils.Generated;
016
017/**
018 * Transaction
019 *
020 * <hr>
021 * Example to create an instance using the builder pattern
022 * <div class=code-example>
023 * <pre><code class='java'>
024 *     Transaction transaction = Transaction.builder()
025 *             .id("{id}")
026 *             .timestamp("{timestamp}")
027 *             .type(TransactionType.AUTHORIZATION)
028 *             .amount(amountBuilder -> amountBuilder)
029 *             .interactionId("{interactionId}")
030 *             .state(TransactionState.INITIAL)
031 *             .build()
032 * </code></pre>
033 * </div>
034 */
035@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
036@JsonDeserialize(as = TransactionImpl.class)
037public interface Transaction {
038
039    /**
040     *  <p>Unique identifier of the Transaction.</p>
041     * @return id
042     */
043    @NotNull
044    @JsonProperty("id")
045    public String getId();
046
047    /**
048     *  <p>Time at which the transaction took place.</p>
049     * @return timestamp
050     */
051    @NotNull
052    @JsonProperty("timestamp")
053    public String getTimestamp();
054
055    /**
056     *
057     * @return type
058     */
059    @NotNull
060    @JsonProperty("type")
061    public TransactionType getType();
062
063    /**
064     *
065     * @return amount
066     */
067    @NotNull
068    @Valid
069    @JsonProperty("amount")
070    public Money getAmount();
071
072    /**
073     *  <p>Identifier used by the interface that manages the transaction (usually the PSP). If a matching interaction was logged in the <code>interfaceInteractions</code> array, the corresponding interaction should be findable with this ID.</p>
074     * @return interactionId
075     */
076    @NotNull
077    @JsonProperty("interactionId")
078    public String getInteractionId();
079
080    /**
081     *
082     * @return state
083     */
084    @NotNull
085    @JsonProperty("state")
086    public TransactionState getState();
087
088    /**
089     *  <p>Unique identifier of the Transaction.</p>
090     * @param id value to be set
091     */
092
093    public void setId(final String id);
094
095    /**
096     *  <p>Time at which the transaction took place.</p>
097     * @param timestamp value to be set
098     */
099
100    public void setTimestamp(final String timestamp);
101
102    /**
103     * set type
104     * @param type value to be set
105     */
106
107    public void setType(final TransactionType type);
108
109    /**
110     * set amount
111     * @param amount value to be set
112     */
113
114    public void setAmount(final Money amount);
115
116    /**
117     *  <p>Identifier used by the interface that manages the transaction (usually the PSP). If a matching interaction was logged in the <code>interfaceInteractions</code> array, the corresponding interaction should be findable with this ID.</p>
118     * @param interactionId value to be set
119     */
120
121    public void setInteractionId(final String interactionId);
122
123    /**
124     * set state
125     * @param state value to be set
126     */
127
128    public void setState(final TransactionState state);
129
130    /**
131     * factory method
132     * @return instance of Transaction
133     */
134    public static Transaction of() {
135        return new TransactionImpl();
136    }
137
138    /**
139     * factory method to create a shallow copy Transaction
140     * @param template instance to be copied
141     * @return copy instance
142     */
143    public static Transaction of(final Transaction template) {
144        TransactionImpl instance = new TransactionImpl();
145        instance.setId(template.getId());
146        instance.setTimestamp(template.getTimestamp());
147        instance.setType(template.getType());
148        instance.setAmount(template.getAmount());
149        instance.setInteractionId(template.getInteractionId());
150        instance.setState(template.getState());
151        return instance;
152    }
153
154    /**
155     * factory method to create a deep copy of Transaction
156     * @param template instance to be copied
157     * @return copy instance
158     */
159    @Nullable
160    public static Transaction deepCopy(@Nullable final Transaction template) {
161        if (template == null) {
162            return null;
163        }
164        TransactionImpl instance = new TransactionImpl();
165        instance.setId(template.getId());
166        instance.setTimestamp(template.getTimestamp());
167        instance.setType(template.getType());
168        instance.setAmount(com.commercetools.history.models.common.Money.deepCopy(template.getAmount()));
169        instance.setInteractionId(template.getInteractionId());
170        instance.setState(template.getState());
171        return instance;
172    }
173
174    /**
175     * builder factory method for Transaction
176     * @return builder
177     */
178    public static TransactionBuilder builder() {
179        return TransactionBuilder.of();
180    }
181
182    /**
183     * create builder for Transaction instance
184     * @param template instance with prefilled values for the builder
185     * @return builder
186     */
187    public static TransactionBuilder builder(final Transaction template) {
188        return TransactionBuilder.of(template);
189    }
190
191    /**
192     * accessor map function
193     * @param <T> mapped type
194     * @param helper function to map the object
195     * @return mapped value
196     */
197    default <T> T withTransaction(Function<Transaction, T> helper) {
198        return helper.apply(this);
199    }
200
201    /**
202     * gives a TypeReference for usage with Jackson DataBind
203     * @return TypeReference
204     */
205    public static com.fasterxml.jackson.core.type.TypeReference<Transaction> typeReference() {
206        return new com.fasterxml.jackson.core.type.TypeReference<Transaction>() {
207            @Override
208            public String toString() {
209                return "TypeReference<Transaction>";
210            }
211        };
212    }
213}