Skip to content

Commit 1691805

Browse files
committed
Add paymentdraft mixin
1 parent 13fd705 commit 1691805

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

api-java-mixin.raml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@ types:
424424
return com.commercetools.api.models.common.ReferenceTypeId.PAYMENT;
425425
}
426426
PaymentDraft:
427-
(java-extends): 'com.commercetools.api.models.CustomizableDraft<PaymentDraft>, com.commercetools.api.models.WithKey'
427+
(java-extends): 'PaymentDraftMixin, com.commercetools.api.models.CustomizableDraft<PaymentDraft>, com.commercetools.api.models.WithKey'
428+
PaymentMethodInfo:
429+
(java-extends): 'PaymentMethodInfoMixin'
428430
PaymentPagedQueryResponse:
429431
(java-extends): 'com.commercetools.api.models.ResourcePagedQueryResponse<Payment>'
430432
PaymentReference:

commercetools/commercetools-sdk-java-api/src/main/java-generated/com/commercetools/api/models/payment/PaymentDraft.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
3636
@JsonDeserialize(as = PaymentDraftImpl.class)
37-
public interface PaymentDraft extends com.commercetools.api.models.CustomizableDraft<PaymentDraft>,
37+
public interface PaymentDraft extends PaymentDraftMixin, com.commercetools.api.models.CustomizableDraft<PaymentDraft>,
3838
com.commercetools.api.models.WithKey, io.vrap.rmf.base.client.Draft<PaymentDraft> {
3939

4040
/**

commercetools/commercetools-sdk-java-api/src/main/java-generated/com/commercetools/api/models/payment/PaymentMethodInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
3333
@JsonDeserialize(as = PaymentMethodInfoImpl.class)
34-
public interface PaymentMethodInfo {
34+
public interface PaymentMethodInfo extends PaymentMethodInfoMixin {
3535

3636
/**
3737
* <p>Payment service that processes the Payment—for example, a PSP. The combination of <code>paymentInterface</code> and the <code>interfaceId</code> of a Payment is unique.</p>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
package com.commercetools.api.models.payment;
3+
4+
import com.commercetools.api.models.WithKey;
5+
import com.commercetools.api.models.type.CustomFields;
6+
import com.commercetools.api.models.type.CustomFieldsDraft;
7+
8+
public interface PaymentDraftMixin extends WithKey {
9+
10+
public default PaymentResourceIdentifier toResourceIdentifier() {
11+
if (getKey() != null)
12+
return PaymentResourceIdentifier.builder().key(getKey()).build();
13+
return null;
14+
}
15+
16+
public void setCustom(final CustomFieldsDraft custom);
17+
18+
public default void setCustom(final CustomFields custom) {
19+
this.setCustom(custom.toDraft());
20+
}
21+
22+
public void setPaymentMethodInfo(final PaymentMethodInfoDraft paymentMethodInfo);
23+
24+
public default void setPaymentMethodInfo(final PaymentMethodInfo paymentMethodInfo) {
25+
this.setPaymentMethodInfo(paymentMethodInfo.toDraft());
26+
}
27+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
package com.commercetools.api.models.payment;
3+
4+
import com.commercetools.api.models.common.LocalizedString;
5+
import com.commercetools.api.models.payment_method.PaymentMethodToken;
6+
import com.commercetools.api.models.type.CustomFields;
7+
8+
public interface PaymentMethodInfoMixin {
9+
10+
public String getPaymentInterface();
11+
12+
public String getMethod();
13+
14+
public LocalizedString getName();
15+
16+
public PaymentMethodToken getToken();
17+
18+
public String getInterfaceAccount();
19+
20+
public CustomFields getCustom();
21+
22+
public default PaymentMethodInfoDraft toDraft() {
23+
return PaymentMethodInfoDraft.builder()
24+
.name(getName())
25+
.method(getMethod())
26+
.paymentInterface(getPaymentInterface())
27+
.token(getToken())
28+
.interfaceAccount(getInterfaceAccount())
29+
.custom(getCustom().toDraft())
30+
.build();
31+
}
32+
}

0 commit comments

Comments
 (0)