diff --git a/sdk-generation-log/documentcollector.json b/sdk-generation-log/documentcollector.json new file mode 100644 index 000000000..eb8862897 --- /dev/null +++ b/sdk-generation-log/documentcollector.json @@ -0,0 +1,8 @@ +{ + "service": "documentcollector", + "project": "java", + "generatedAt": "2026-08-21T14:02:13Z", + "openapiCommitSha": "bee086f2cd666ac7cb5b5ba2813a8b5dc943c2d2", + "automationCommitSha": "8d09e0f762f7b00c707748d84d0d002964410c0f", + "libraryCommitSha": "bca8a14bd8bfd031e109bbf12684150f37b17a2b" +} diff --git a/src/main/java/com/adyen/model/documentcollector/AbstractOpenApiSchema.java b/src/main/java/com/adyen/model/documentcollector/AbstractOpenApiSchema.java new file mode 100644 index 000000000..c749246aa --- /dev/null +++ b/src/main/java/com/adyen/model/documentcollector/AbstractOpenApiSchema.java @@ -0,0 +1,142 @@ +/* + * Cross-border Invoices API + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.adyen.model.documentcollector; + +import com.fasterxml.jackson.annotation.JsonValue; +import jakarta.ws.rs.core.GenericType; +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + /** + * @param schemaType the schema type + * @param isNullable whether the instance is nullable + */ + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() { + return instance; + } + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) { + this.instance = instance; + } + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf + * schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) + && Objects.equals(this.isNullable, a.isNullable) + && Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + return Boolean.TRUE.equals(isNullable); + } +} diff --git a/src/main/java/com/adyen/model/documentcollector/DefaultErrorResponseEntity.java b/src/main/java/com/adyen/model/documentcollector/DefaultErrorResponseEntity.java new file mode 100644 index 000000000..7cf4f2c1f --- /dev/null +++ b/src/main/java/com/adyen/model/documentcollector/DefaultErrorResponseEntity.java @@ -0,0 +1,547 @@ +/* + * Cross-border Invoices API + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.adyen.model.documentcollector; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.*; +import java.util.ArrayList; +import java.util.List; + +/** Standardized error response following RFC-7807 format */ +@JsonPropertyOrder({ + DefaultErrorResponseEntity.JSON_PROPERTY_DETAIL, + DefaultErrorResponseEntity.JSON_PROPERTY_ERROR_CODE, + DefaultErrorResponseEntity.JSON_PROPERTY_INSTANCE, + DefaultErrorResponseEntity.JSON_PROPERTY_INVALID_FIELDS, + DefaultErrorResponseEntity.JSON_PROPERTY_REQUEST_ID, + DefaultErrorResponseEntity.JSON_PROPERTY_STATUS, + DefaultErrorResponseEntity.JSON_PROPERTY_TITLE, + DefaultErrorResponseEntity.JSON_PROPERTY_TYPE +}) +public class DefaultErrorResponseEntity { + public static final String JSON_PROPERTY_DETAIL = "detail"; + private String detail; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetDetail = false; + + public static final String JSON_PROPERTY_ERROR_CODE = "errorCode"; + private String errorCode; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetErrorCode = false; + + public static final String JSON_PROPERTY_INSTANCE = "instance"; + private String instance; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetInstance = false; + + public static final String JSON_PROPERTY_INVALID_FIELDS = "invalidFields"; + private List invalidFields; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetInvalidFields = false; + + public static final String JSON_PROPERTY_REQUEST_ID = "requestId"; + private String requestId; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetRequestId = false; + + public static final String JSON_PROPERTY_STATUS = "status"; + private Integer status; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetStatus = false; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetTitle = false; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetType = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public DefaultErrorResponseEntity() {} + + /** + * A human-readable explanation specific to this occurrence of the problem. + * + * @param detail A human-readable explanation specific to this occurrence of the problem. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity detail(String detail) { + this.detail = detail; + isSetDetail = true; // mark as set + return this; + } + + /** + * A human-readable explanation specific to this occurrence of the problem. + * + * @return detail A human-readable explanation specific to this occurrence of the problem. + */ + @JsonProperty(JSON_PROPERTY_DETAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDetail() { + return detail; + } + + /** + * A human-readable explanation specific to this occurrence of the problem. + * + * @param detail A human-readable explanation specific to this occurrence of the problem. + */ + @JsonProperty(JSON_PROPERTY_DETAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDetail(String detail) { + this.detail = detail; + isSetDetail = true; // mark as set + } + + /** + * Unique business error code. + * + * @param errorCode Unique business error code. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity errorCode(String errorCode) { + this.errorCode = errorCode; + isSetErrorCode = true; // mark as set + return this; + } + + /** + * Unique business error code. + * + * @return errorCode Unique business error code. + */ + @JsonProperty(JSON_PROPERTY_ERROR_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getErrorCode() { + return errorCode; + } + + /** + * Unique business error code. + * + * @param errorCode Unique business error code. + */ + @JsonProperty(JSON_PROPERTY_ERROR_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + isSetErrorCode = true; // mark as set + } + + /** + * A URI that identifies the specific occurrence of the problem if applicable. + * + * @param instance A URI that identifies the specific occurrence of the problem if applicable. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity instance(String instance) { + this.instance = instance; + isSetInstance = true; // mark as set + return this; + } + + /** + * A URI that identifies the specific occurrence of the problem if applicable. + * + * @return instance A URI that identifies the specific occurrence of the problem if applicable. + */ + @JsonProperty(JSON_PROPERTY_INSTANCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getInstance() { + return instance; + } + + /** + * A URI that identifies the specific occurrence of the problem if applicable. + * + * @param instance A URI that identifies the specific occurrence of the problem if applicable. + */ + @JsonProperty(JSON_PROPERTY_INSTANCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInstance(String instance) { + this.instance = instance; + isSetInstance = true; // mark as set + } + + /** + * Array of fields with validation errors when applicable. + * + * @param invalidFields Array of fields with validation errors when applicable. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity invalidFields(List invalidFields) { + this.invalidFields = invalidFields; + isSetInvalidFields = true; // mark as set + return this; + } + + public DefaultErrorResponseEntity addInvalidFieldsItem(InvalidField invalidFieldsItem) { + if (this.invalidFields == null) { + this.invalidFields = new ArrayList<>(); + } + this.invalidFields.add(invalidFieldsItem); + return this; + } + + /** + * Array of fields with validation errors when applicable. + * + * @return invalidFields Array of fields with validation errors when applicable. + */ + @JsonProperty(JSON_PROPERTY_INVALID_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getInvalidFields() { + return invalidFields; + } + + /** + * Array of fields with validation errors when applicable. + * + * @param invalidFields Array of fields with validation errors when applicable. + */ + @JsonProperty(JSON_PROPERTY_INVALID_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInvalidFields(List invalidFields) { + this.invalidFields = invalidFields; + isSetInvalidFields = true; // mark as set + } + + /** + * The unique reference for the request. + * + * @param requestId The unique reference for the request. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity requestId(String requestId) { + this.requestId = requestId; + isSetRequestId = true; // mark as set + return this; + } + + /** + * The unique reference for the request. + * + * @return requestId The unique reference for the request. + */ + @JsonProperty(JSON_PROPERTY_REQUEST_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRequestId() { + return requestId; + } + + /** + * The unique reference for the request. + * + * @param requestId The unique reference for the request. + */ + @JsonProperty(JSON_PROPERTY_REQUEST_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRequestId(String requestId) { + this.requestId = requestId; + isSetRequestId = true; // mark as set + } + + /** + * The HTTP status code. + * + * @param status The HTTP status code. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity status(Integer status) { + this.status = status; + isSetStatus = true; // mark as set + return this; + } + + /** + * The HTTP status code. + * + * @return status The HTTP status code. + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getStatus() { + return status; + } + + /** + * The HTTP status code. + * + * @param status The HTTP status code. + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(Integer status) { + this.status = status; + isSetStatus = true; // mark as set + } + + /** + * A short, human-readable summary of the problem type. + * + * @param title A short, human-readable summary of the problem type. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity title(String title) { + this.title = title; + isSetTitle = true; // mark as set + return this; + } + + /** + * A short, human-readable summary of the problem type. + * + * @return title A short, human-readable summary of the problem type. + */ + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTitle() { + return title; + } + + /** + * A short, human-readable summary of the problem type. + * + * @param title A short, human-readable summary of the problem type. + */ + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTitle(String title) { + this.title = title; + isSetTitle = true; // mark as set + } + + /** + * A URI that identifies the validation error type. It points to human-readable documentation for + * the problem type. + * + * @param type A URI that identifies the validation error type. It points to human-readable + * documentation for the problem type. + * @return the current {@code DefaultErrorResponseEntity} instance, allowing for method chaining + */ + public DefaultErrorResponseEntity type(String type) { + this.type = type; + isSetType = true; // mark as set + return this; + } + + /** + * A URI that identifies the validation error type. It points to human-readable documentation for + * the problem type. + * + * @return type A URI that identifies the validation error type. It points to human-readable + * documentation for the problem type. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + /** + * A URI that identifies the validation error type. It points to human-readable documentation for + * the problem type. + * + * @param type A URI that identifies the validation error type. It points to human-readable + * documentation for the problem type. + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + isSetType = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public DefaultErrorResponseEntity includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this DefaultErrorResponseEntity object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DefaultErrorResponseEntity defaultErrorResponseEntity = (DefaultErrorResponseEntity) o; + return Objects.equals(this.detail, defaultErrorResponseEntity.detail) + && Objects.equals(this.isSetDetail, defaultErrorResponseEntity.isSetDetail) + && Objects.equals(this.errorCode, defaultErrorResponseEntity.errorCode) + && Objects.equals(this.isSetErrorCode, defaultErrorResponseEntity.isSetErrorCode) + && Objects.equals(this.instance, defaultErrorResponseEntity.instance) + && Objects.equals(this.isSetInstance, defaultErrorResponseEntity.isSetInstance) + && Objects.equals(this.invalidFields, defaultErrorResponseEntity.invalidFields) + && Objects.equals(this.isSetInvalidFields, defaultErrorResponseEntity.isSetInvalidFields) + && Objects.equals(this.requestId, defaultErrorResponseEntity.requestId) + && Objects.equals(this.isSetRequestId, defaultErrorResponseEntity.isSetRequestId) + && Objects.equals(this.status, defaultErrorResponseEntity.status) + && Objects.equals(this.isSetStatus, defaultErrorResponseEntity.isSetStatus) + && Objects.equals(this.title, defaultErrorResponseEntity.title) + && Objects.equals(this.isSetTitle, defaultErrorResponseEntity.isSetTitle) + && Objects.equals(this.type, defaultErrorResponseEntity.type) + && Objects.equals(this.isSetType, defaultErrorResponseEntity.isSetType); + } + + @Override + public int hashCode() { + return Objects.hash( + detail, + isSetDetail, + errorCode, + isSetErrorCode, + instance, + isSetInstance, + invalidFields, + isSetInvalidFields, + requestId, + isSetRequestId, + status, + isSetStatus, + title, + isSetTitle, + type, + isSetType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DefaultErrorResponseEntity {\n"); + sb.append(" detail: ").append(toIndentedString(detail)).append("\n"); + sb.append(" errorCode: ").append(toIndentedString(errorCode)).append("\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" invalidFields: ").append(toIndentedString(invalidFields)).append("\n"); + sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetDetail) { + addIfNull(nulls, JSON_PROPERTY_DETAIL, this.detail); + } + if (isSetErrorCode) { + addIfNull(nulls, JSON_PROPERTY_ERROR_CODE, this.errorCode); + } + if (isSetInstance) { + addIfNull(nulls, JSON_PROPERTY_INSTANCE, this.instance); + } + if (isSetInvalidFields) { + addIfNull(nulls, JSON_PROPERTY_INVALID_FIELDS, this.invalidFields); + } + if (isSetRequestId) { + addIfNull(nulls, JSON_PROPERTY_REQUEST_ID, this.requestId); + } + if (isSetStatus) { + addIfNull(nulls, JSON_PROPERTY_STATUS, this.status); + } + if (isSetTitle) { + addIfNull(nulls, JSON_PROPERTY_TITLE, this.title); + } + if (isSetType) { + addIfNull(nulls, JSON_PROPERTY_TYPE, this.type); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of DefaultErrorResponseEntity given an JSON string + * + * @param jsonString JSON string + * @return An instance of DefaultErrorResponseEntity + * @throws JsonProcessingException if the JSON string is invalid with respect to + * DefaultErrorResponseEntity + */ + public static DefaultErrorResponseEntity fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, DefaultErrorResponseEntity.class); + } + + /** + * Convert an instance of DefaultErrorResponseEntity to an JSON string + * + * @return JSON string + */ + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); + } +} diff --git a/src/main/java/com/adyen/model/documentcollector/DocumentContext.java b/src/main/java/com/adyen/model/documentcollector/DocumentContext.java new file mode 100644 index 000000000..bf9452aa8 --- /dev/null +++ b/src/main/java/com/adyen/model/documentcollector/DocumentContext.java @@ -0,0 +1,56 @@ +/* + * Cross-border Invoices API + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.adyen.model.documentcollector; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.*; +import java.util.logging.Logger; + +/** The document context indicating the type of document being uploaded */ +public enum DocumentContext { + PACBINVOICE("paCbInvoice"); + + private static final Logger LOG = Logger.getLogger(DocumentContext.class.getName()); + + private String value; + + DocumentContext(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static DocumentContext fromValue(String value) { + for (DocumentContext b : DocumentContext.values()) { + if (b.value.equals(value)) { + return b; + } + } + // handling unexpected value + LOG.warning( + "DocumentContext: unexpected enum value '" + + value + + "' - Supported values are " + + Arrays.toString(DocumentContext.values())); + return null; + } +} diff --git a/src/main/java/com/adyen/model/documentcollector/DocumentUploadResponse.java b/src/main/java/com/adyen/model/documentcollector/DocumentUploadResponse.java new file mode 100644 index 000000000..f9359a046 --- /dev/null +++ b/src/main/java/com/adyen/model/documentcollector/DocumentUploadResponse.java @@ -0,0 +1,330 @@ +/* + * Cross-border Invoices API + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.adyen.model.documentcollector; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.*; + +/** The uploaded document resource */ +@JsonPropertyOrder({ + DocumentUploadResponse.JSON_PROPERTY_CONTEXT, + DocumentUploadResponse.JSON_PROPERTY_FILE_NAME, + DocumentUploadResponse.JSON_PROPERTY_MERCHANT_ACCOUNT, + DocumentUploadResponse.JSON_PROPERTY_PSP_REFERENCE +}) +public class DocumentUploadResponse { + public static final String JSON_PROPERTY_CONTEXT = "context"; + private String context; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetContext = false; + + public static final String JSON_PROPERTY_FILE_NAME = "fileName"; + private String fileName; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetFileName = false; + + public static final String JSON_PROPERTY_MERCHANT_ACCOUNT = "merchantAccount"; + private String merchantAccount; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetMerchantAccount = false; + + public static final String JSON_PROPERTY_PSP_REFERENCE = "pspReference"; + private String pspReference; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetPspReference = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public DocumentUploadResponse() {} + + /** + * The document context indicating the type of document. + * + * @param context The document context indicating the type of document. + * @return the current {@code DocumentUploadResponse} instance, allowing for method chaining + */ + public DocumentUploadResponse context(String context) { + this.context = context; + isSetContext = true; // mark as set + return this; + } + + /** + * The document context indicating the type of document. + * + * @return context The document context indicating the type of document. + */ + @JsonProperty(JSON_PROPERTY_CONTEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getContext() { + return context; + } + + /** + * The document context indicating the type of document. + * + * @param context The document context indicating the type of document. + */ + @JsonProperty(JSON_PROPERTY_CONTEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setContext(String context) { + this.context = context; + isSetContext = true; // mark as set + } + + /** + * The name of the uploaded file. + * + * @param fileName The name of the uploaded file. + * @return the current {@code DocumentUploadResponse} instance, allowing for method chaining + */ + public DocumentUploadResponse fileName(String fileName) { + this.fileName = fileName; + isSetFileName = true; // mark as set + return this; + } + + /** + * The name of the uploaded file. + * + * @return fileName The name of the uploaded file. + */ + @JsonProperty(JSON_PROPERTY_FILE_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFileName() { + return fileName; + } + + /** + * The name of the uploaded file. + * + * @param fileName The name of the uploaded file. + */ + @JsonProperty(JSON_PROPERTY_FILE_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFileName(String fileName) { + this.fileName = fileName; + isSetFileName = true; // mark as set + } + + /** + * The merchant account that the document belongs to. + * + * @param merchantAccount The merchant account that the document belongs to. + * @return the current {@code DocumentUploadResponse} instance, allowing for method chaining + */ + public DocumentUploadResponse merchantAccount(String merchantAccount) { + this.merchantAccount = merchantAccount; + isSetMerchantAccount = true; // mark as set + return this; + } + + /** + * The merchant account that the document belongs to. + * + * @return merchantAccount The merchant account that the document belongs to. + */ + @JsonProperty(JSON_PROPERTY_MERCHANT_ACCOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMerchantAccount() { + return merchantAccount; + } + + /** + * The merchant account that the document belongs to. + * + * @param merchantAccount The merchant account that the document belongs to. + */ + @JsonProperty(JSON_PROPERTY_MERCHANT_ACCOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMerchantAccount(String merchantAccount) { + this.merchantAccount = merchantAccount; + isSetMerchantAccount = true; // mark as set + } + + /** + * The PSP reference extracted from the filename. + * + * @param pspReference The PSP reference extracted from the filename. + * @return the current {@code DocumentUploadResponse} instance, allowing for method chaining + */ + public DocumentUploadResponse pspReference(String pspReference) { + this.pspReference = pspReference; + isSetPspReference = true; // mark as set + return this; + } + + /** + * The PSP reference extracted from the filename. + * + * @return pspReference The PSP reference extracted from the filename. + */ + @JsonProperty(JSON_PROPERTY_PSP_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPspReference() { + return pspReference; + } + + /** + * The PSP reference extracted from the filename. + * + * @param pspReference The PSP reference extracted from the filename. + */ + @JsonProperty(JSON_PROPERTY_PSP_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPspReference(String pspReference) { + this.pspReference = pspReference; + isSetPspReference = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public DocumentUploadResponse includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this DocumentUploadResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DocumentUploadResponse documentUploadResponse = (DocumentUploadResponse) o; + return Objects.equals(this.context, documentUploadResponse.context) + && Objects.equals(this.isSetContext, documentUploadResponse.isSetContext) + && Objects.equals(this.fileName, documentUploadResponse.fileName) + && Objects.equals(this.isSetFileName, documentUploadResponse.isSetFileName) + && Objects.equals(this.merchantAccount, documentUploadResponse.merchantAccount) + && Objects.equals(this.isSetMerchantAccount, documentUploadResponse.isSetMerchantAccount) + && Objects.equals(this.pspReference, documentUploadResponse.pspReference) + && Objects.equals(this.isSetPspReference, documentUploadResponse.isSetPspReference); + } + + @Override + public int hashCode() { + return Objects.hash( + context, + isSetContext, + fileName, + isSetFileName, + merchantAccount, + isSetMerchantAccount, + pspReference, + isSetPspReference); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentUploadResponse {\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" fileName: ").append(toIndentedString(fileName)).append("\n"); + sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n"); + sb.append(" pspReference: ").append(toIndentedString(pspReference)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetContext) { + addIfNull(nulls, JSON_PROPERTY_CONTEXT, this.context); + } + if (isSetFileName) { + addIfNull(nulls, JSON_PROPERTY_FILE_NAME, this.fileName); + } + if (isSetMerchantAccount) { + addIfNull(nulls, JSON_PROPERTY_MERCHANT_ACCOUNT, this.merchantAccount); + } + if (isSetPspReference) { + addIfNull(nulls, JSON_PROPERTY_PSP_REFERENCE, this.pspReference); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of DocumentUploadResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of DocumentUploadResponse + * @throws JsonProcessingException if the JSON string is invalid with respect to + * DocumentUploadResponse + */ + public static DocumentUploadResponse fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, DocumentUploadResponse.class); + } + + /** + * Convert an instance of DocumentUploadResponse to an JSON string + * + * @return JSON string + */ + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); + } +} diff --git a/src/main/java/com/adyen/model/documentcollector/InvalidField.java b/src/main/java/com/adyen/model/documentcollector/InvalidField.java new file mode 100644 index 000000000..c6fa0fb8f --- /dev/null +++ b/src/main/java/com/adyen/model/documentcollector/InvalidField.java @@ -0,0 +1,273 @@ +/* + * Cross-border Invoices API + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.adyen.model.documentcollector; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.*; + +/** InvalidField */ +@JsonPropertyOrder({ + InvalidField.JSON_PROPERTY_MESSAGE, + InvalidField.JSON_PROPERTY_NAME, + InvalidField.JSON_PROPERTY_VALUE +}) +public class InvalidField { + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetMessage = false; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetName = false; + + public static final String JSON_PROPERTY_VALUE = "value"; + private String value; + + /** Mark when the attribute has been explicitly set. */ + private boolean isSetValue = false; + + /** + * Sets whether attributes with null values should be explicitly included in the JSON payload. + * Default is false. + */ + @JsonIgnore private boolean includeNullValues = false; + + public InvalidField() {} + + /** + * Description of the validation error. + * + * @param message Description of the validation error. + * @return the current {@code InvalidField} instance, allowing for method chaining + */ + public InvalidField message(String message) { + this.message = message; + isSetMessage = true; // mark as set + return this; + } + + /** + * Description of the validation error. + * + * @return message Description of the validation error. + */ + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + /** + * Description of the validation error. + * + * @param message Description of the validation error. + */ + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + isSetMessage = true; // mark as set + } + + /** + * The field that has an invalid value. + * + * @param name The field that has an invalid value. + * @return the current {@code InvalidField} instance, allowing for method chaining + */ + public InvalidField name(String name) { + this.name = name; + isSetName = true; // mark as set + return this; + } + + /** + * The field that has an invalid value. + * + * @return name The field that has an invalid value. + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + /** + * The field that has an invalid value. + * + * @param name The field that has an invalid value. + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + isSetName = true; // mark as set + } + + /** + * The invalid value. + * + * @param value The invalid value. + * @return the current {@code InvalidField} instance, allowing for method chaining + */ + public InvalidField value(String value) { + this.value = value; + isSetValue = true; // mark as set + return this; + } + + /** + * The invalid value. + * + * @return value The invalid value. + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getValue() { + return value; + } + + /** + * The invalid value. + * + * @param value The invalid value. + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setValue(String value) { + this.value = value; + isSetValue = true; // mark as set + } + + /** + * Configures whether null values are explicitly serialized in the JSON payload. Default is false. + */ + public InvalidField includeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + return this; + } + + /** Returns whether null values are explicitly serialized in the JSON payload. */ + public boolean isIncludeNullValues() { + return includeNullValues; + } + + /** + * Sets whether null values should be explicitly serialized in the JSON payload. Default is false. + */ + public void setIncludeNullValues(boolean includeNullValues) { + this.includeNullValues = includeNullValues; + } + + /** Return true if this InvalidField object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InvalidField invalidField = (InvalidField) o; + return Objects.equals(this.message, invalidField.message) + && Objects.equals(this.isSetMessage, invalidField.isSetMessage) + && Objects.equals(this.name, invalidField.name) + && Objects.equals(this.isSetName, invalidField.isSetName) + && Objects.equals(this.value, invalidField.value) + && Objects.equals(this.isSetValue, invalidField.isSetValue); + } + + @Override + public int hashCode() { + return Objects.hash(message, isSetMessage, name, isSetName, value, isSetValue); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InvalidField {\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Returns a map of properties to be merged into the JSON payload as explicit null values. */ + @JsonInclude(JsonInclude.Include.ALWAYS) + @JsonAnyGetter + public Map getExplicitNulls() { + if (!this.includeNullValues) { + return Collections.emptyMap(); + } + + Map nulls = new HashMap<>(); + + if (isSetMessage) { + addIfNull(nulls, JSON_PROPERTY_MESSAGE, this.message); + } + if (isSetName) { + addIfNull(nulls, JSON_PROPERTY_NAME, this.name); + } + if (isSetValue) { + addIfNull(nulls, JSON_PROPERTY_VALUE, this.value); + } + + return nulls; + } + + // add to map when value is null + private void addIfNull(Map map, String key, Object value) { + if (value == null) { + map.put(key, null); + } + } + + /** + * Create an instance of InvalidField given an JSON string + * + * @param jsonString JSON string + * @return An instance of InvalidField + * @throws JsonProcessingException if the JSON string is invalid with respect to InvalidField + */ + public static InvalidField fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, InvalidField.class); + } + + /** + * Convert an instance of InvalidField to an JSON string + * + * @return JSON string + */ + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); + } +} diff --git a/src/main/java/com/adyen/model/documentcollector/JSON.java b/src/main/java/com/adyen/model/documentcollector/JSON.java new file mode 100644 index 000000000..96f2141f9 --- /dev/null +++ b/src/main/java/com/adyen/model/documentcollector/JSON.java @@ -0,0 +1,251 @@ +package com.adyen.model.documentcollector; + +import com.adyen.serializer.ByteArrayDeserializer; +import com.adyen.serializer.ByteArraySerializer; +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.ext.ContextResolver; +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class JSON implements ContextResolver { + private static ObjectMapper mapper; + + private JSON() { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, true); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.registerModule(new JavaTimeModule()); + // Custom ByteSerializer + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(byte[].class, new ByteArraySerializer()); + simpleModule.addDeserializer(byte[].class, new ByteArrayDeserializer()); + mapper.registerModule(simpleModule); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + @Override + public ObjectMapper getContext(Class type) { + return mapper; + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public static ObjectMapper getMapper() { + return mapper; + } + + /** + * Returns the target model class that should be used to deserialize the input data. The + * discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet<>()); + } + return null; + } + + /** Helper class to register the discriminator mappings. */ + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap<>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. This + * function can be invoked for anyOf/oneOf composed models with discriminator mappings. The + * discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + *

The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, so + * it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + */ + public static boolean isInstanceOf( + Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (GenericType childType : descendants.values()) { + if (isInstanceOf(childType.getRawType(), inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** A map of discriminators for all model classes. */ + private static final Map, ClassDiscriminatorMapping> modelDiscriminators = + new HashMap, ClassDiscriminatorMapping>(); + + /** A map of oneOf/anyOf descendants for each model class. */ + private static final Map, Map> modelDescendants = new HashMap<>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator( + Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = + new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants( + Class modelClass, Map descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/src/main/java/com/adyen/service/documentcollector/DocumentsApi.java b/src/main/java/com/adyen/service/documentcollector/DocumentsApi.java new file mode 100644 index 000000000..e97c05588 --- /dev/null +++ b/src/main/java/com/adyen/service/documentcollector/DocumentsApi.java @@ -0,0 +1,82 @@ +/* + * Cross-border Invoices API + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.adyen.service.documentcollector; + +import com.adyen.Client; +import com.adyen.Service; +import com.adyen.constants.ApiConstants; +import com.adyen.model.RequestOptions; +import com.adyen.model.documentcollector.DocumentContext; +import com.adyen.model.documentcollector.DocumentUploadResponse; +import com.adyen.service.exception.ApiException; +import com.adyen.service.resource.Resource; +import java.io.File; +import java.io.IOException; + +public class DocumentsApi extends Service { + + public static final String API_VERSION = "1"; + + protected String baseURL; + + /** + * Documents constructor in {@link com.adyen.service.documentcollector package}. + * + * @param client {@link Client } (required) + */ + public DocumentsApi(Client client) { + super(client); + this.baseURL = createBaseURL("https://document-collector-test.adyen.com/v1"); + } + + /** + * Documents constructor in {@link com.adyen.service.documentcollector package}. Please use this + * constructor only if you would like to pass along your own url for routing or testing purposes. + * The latest API version is defined in this class as a constant. + * + * @param client {@link Client } (required) + * @param baseURL {@link String } (required) + */ + public DocumentsApi(Client client, String baseURL) { + super(client); + this.baseURL = baseURL; + } + + /** + * Upload a document + * + * @return {@link DocumentUploadResponse } + * @throws ApiException if fails to make API call + */ + public DocumentUploadResponse uploadCrossBorderInvoice( + DocumentContext context, File _file, String merchantAccount) + throws ApiException, IOException { + return uploadCrossBorderInvoice(null); + } + + /** + * Upload a document + * + * @param requestOptions {@link RequestOptions } Object to store additional HTTP headers such as + * idempotency-keys (optional) + * @return {@link DocumentUploadResponse } + * @throws ApiException if fails to make API call + */ + public DocumentUploadResponse uploadCrossBorderInvoice(RequestOptions requestOptions) + throws ApiException, IOException { + String requestBody = null; + Resource resource = new Resource(this, this.baseURL + "/crossBorderInvoices", null); + String jsonResult = + resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, null); + return DocumentUploadResponse.fromJson(jsonResult); + } +}