diff --git a/codegen/internal/generator/model.go b/codegen/internal/generator/model.go index 385c198..d3dd841 100644 --- a/codegen/internal/generator/model.go +++ b/codegen/internal/generator/model.go @@ -21,13 +21,13 @@ type sdkModel struct { // clientModel encapsulates the data necessary to render a Java API client. type clientModel struct { - TagName string + TagName string TagDescriptionLines []string - ClassName string - AccessorName string - FieldName string - Package string - Methods []operationModel + ClassName string + AccessorName string + FieldName string + Package string + Methods []operationModel } // operationModel stores the derived metadata for one OpenAPI operation. @@ -242,9 +242,9 @@ func convertOperation(method, path string, item *v3.PathItem, op *v3.Operation, } params := collectParameters(item, op) - model.PathParams = filterParams(params, parameterInPath, resolver) + model.PathParams = filterParams(params, parameterInPath, resolver, sanitizedID) - queryParams := filterParams(params, parameterInQuery, resolver) + queryParams := filterParams(params, parameterInQuery, resolver, sanitizedID) model.RequiredQueryParams, model.OptionalQueryParams = splitParams(queryParams) if len(model.OptionalQueryParams) > 0 { model.QueryStruct = ¶meterGroupModel{ @@ -260,7 +260,7 @@ func convertOperation(method, path string, item *v3.PathItem, op *v3.Operation, } model.HasQueryParams = len(model.RequiredQueryParams) > 0 || len(model.OptionalQueryParams) > 0 - headerParams := filterParams(params, parameterInHeader, resolver) + headerParams := filterParams(params, parameterInHeader, resolver, sanitizedID) model.RequiredHeaderParams, model.OptionalHeaderParams = splitParams(headerParams) if len(model.OptionalHeaderParams) > 0 { model.HeaderStruct = ¶meterGroupModel{ @@ -356,7 +356,7 @@ func collectParameters(item *v3.PathItem, op *v3.Operation) []*v3.Parameter { // filterParams keeps parameters that match the requested location and converts // them into parameterModel values. -func filterParams(params []*v3.Parameter, location string, resolver *typeResolver) []parameterModel { +func filterParams(params []*v3.Parameter, location string, resolver *typeResolver, operationContext string) []parameterModel { var filtered []parameterModel seen := map[string]struct{}{} for _, param := range params { @@ -375,7 +375,7 @@ func filterParams(params []*v3.Parameter, location string, resolver *typeResolve } seen[name] = struct{}{} schemaRef := parameterSchema(param) - javaType := resolver.javaType(schemaRef, name) + javaType := resolver.parameterJavaType(schemaRef, operationContext, name) required := param.Required != nil && *param.Required filtered = append(filtered, parameterModel{ Name: name, @@ -568,6 +568,7 @@ func buildSchemas(doc *v3.Document, params Params, resolver *typeResolver) []sch imports := sortedImports(map[string]struct{}{ "com.fasterxml.jackson.annotation.JsonCreator": {}, "com.fasterxml.jackson.annotation.JsonValue": {}, + "java.util.Objects": {}, }) result = append(result, schemaModel{ Name: name, @@ -630,7 +631,7 @@ func buildSchemaFields(name string, ref *base.SchemaProxy, resolver *typeResolve if schema == nil { return []schemaField{{Name: "value", Type: "Object"}}, nil, nil, false } - if schemaHasType(schema, "object") { + if schemaDefinesModelFields(schema) { props := collectProperties(schema) if len(props) == 0 { return []schemaField{{Name: "value", Type: "java.util.Map"}}, nil, []string{"java.util.Map"}, false @@ -695,6 +696,31 @@ func buildSchemaFields(name string, ref *base.SchemaProxy, resolver *typeResolve return fields, additionalProps, sortedImports(imports), hasRequired } +func schemaDefinesModelFields(schema *base.Schema) bool { + if schema == nil { + return false + } + return schemaHasType(schema, "object") || schemaHasFlattenableProperties(schema) +} + +func schemaHasFlattenableProperties(schema *base.Schema) bool { + if schema == nil { + return false + } + if schema.Properties != nil && schema.Properties.Len() > 0 { + return true + } + for _, item := range schema.AllOf { + if item == nil { + continue + } + if schemaHasFlattenableProperties(item.Schema()) { + return true + } + } + return false +} + // resolveAdditionalProperties returns metadata for schemas that allow // additional fields alongside declared properties. func resolveAdditionalProperties(schema *base.Schema, resolver *typeResolver, context ...string) *additionalPropertiesModel { diff --git a/codegen/internal/generator/model_naming_test.go b/codegen/internal/generator/model_naming_test.go new file mode 100644 index 0000000..4b69a44 --- /dev/null +++ b/codegen/internal/generator/model_naming_test.go @@ -0,0 +1,177 @@ +package generator + +import ( + "context" + "os" + "path/filepath" + "testing" +) + +func TestGenerateModelFlattensAllOfIntoComponent(t *testing.T) { + t.Parallel() + + tmp := t.TempDir() + specPath := filepath.Join(tmp, "openapi.json") + outputDir := filepath.Join(tmp, "src", "main", "java") + resourceDir := filepath.Join(tmp, "src", "main", "resources") + + spec := `{ + "openapi": "3.0.3", + "info": { + "title": "test", + "version": "1.0.0" + }, + "paths": {}, + "components": { + "schemas": { + "Merchant": { + "allOf": [ + { + "type": "object", + "required": ["merchant_code"], + "properties": { + "merchant_code": { "type": "string" } + } + }, + { + "$ref": "#/components/schemas/Timestamps" + } + ], + "title": "Merchant" + }, + "Timestamps": { + "type": "object", + "properties": { + "created_at": { "type": "string", "format": "date-time", "readOnly": true } + } + } + } + } +}` + if err := os.WriteFile(specPath, []byte(spec), 0o644); err != nil { + t.Fatalf("write spec: %v", err) + } + + params := Params{ + SpecPath: specPath, + OutputDir: outputDir, + ResourceDir: resourceDir, + BasePackage: "com.test.sdk", + } + if err := Run(context.Background(), params); err != nil { + t.Fatalf("run generator: %v", err) + } + + merchantPath := filepath.Join(outputDir, "com", "test", "sdk", "models", "Merchant.java") + content, err := os.ReadFile(merchantPath) + if err != nil { + t.Fatalf("read generated Merchant model: %v", err) + } + generated := string(content) + + assertContains(t, generated, "public record Merchant(") + assertContains(t, generated, "String merchantCode") + assertContains(t, generated, "java.time.OffsetDateTime createdAt") + assertNotContains(t, generated, "Merchant2") + assertFileDoesNotExist(t, filepath.Join(outputDir, "com", "test", "sdk", "models", "Merchant2.java")) +} + +func TestGenerateClientUsesOpenEnumsForInlineParameterEnums(t *testing.T) { + t.Parallel() + + tmp := t.TempDir() + specPath := filepath.Join(tmp, "openapi.json") + outputDir := filepath.Join(tmp, "src", "main", "java") + resourceDir := filepath.Join(tmp, "src", "main", "resources") + + spec := `{ + "openapi": "3.0.3", + "info": { + "title": "test", + "version": "1.0.0" + }, + "paths": { + "/v1/transactions": { + "get": { + "operationId": "ListTransactions", + "parameters": [ + { + "name": "order", + "in": "query", + "schema": { + "type": "string", + "enum": ["ascending", "descending"] + } + }, + { + "name": "types", + "in": "query", + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": ["PAYMENT", "REFUND"] + } + } + } + ], + "responses": { + "204": { + "description": "No content" + } + }, + "tags": ["Transactions"] + } + } + } +}` + if err := os.WriteFile(specPath, []byte(spec), 0o644); err != nil { + t.Fatalf("write spec: %v", err) + } + + params := Params{ + SpecPath: specPath, + OutputDir: outputDir, + ResourceDir: resourceDir, + BasePackage: "com.test.sdk", + } + if err := Run(context.Background(), params); err != nil { + t.Fatalf("run generator: %v", err) + } + + clientPath := filepath.Join(outputDir, "com", "test", "sdk", "clients", "TransactionsClient.java") + content, err := os.ReadFile(clientPath) + if err != nil { + t.Fatalf("read generated Transactions client: %v", err) + } + generated := string(content) + + assertContains(t, generated, "public ListTransactionsQueryParams order(com.test.sdk.models.ListTransactionsOrder value)") + assertContains(t, generated, "public ListTransactionsQueryParams types(java.util.List value)") + assertContains(t, generated, "com.test.sdk.models.ListTransactionsOrder") + assertContains(t, generated, "com.test.sdk.models.ListTransactionsTypesItem") + assertFileDoesNotExist(t, filepath.Join(outputDir, "com", "test", "sdk", "models", "Order.java")) + assertFileDoesNotExist(t, filepath.Join(outputDir, "com", "test", "sdk", "models", "TypesItem.java")) + + orderPath := filepath.Join(outputDir, "com", "test", "sdk", "models", "ListTransactionsOrder.java") + orderContent, err := os.ReadFile(orderPath) + if err != nil { + t.Fatalf("read generated ListTransactionsOrder model: %v", err) + } + orderGenerated := string(orderContent) + + assertContains(t, orderGenerated, "public final class ListTransactionsOrder") + assertContains(t, orderGenerated, `public static final ListTransactionsOrder ASCENDING = new ListTransactionsOrder("ascending");`) + assertContains(t, orderGenerated, "public static ListTransactionsOrder of(String value)") + assertContains(t, orderGenerated, "return value == null ? null : new ListTransactionsOrder(value);") + assertNotContains(t, orderGenerated, "public enum ListTransactionsOrder") +} + +func assertFileDoesNotExist(t *testing.T, path string) { + t.Helper() + if _, err := os.Stat(path); err == nil { + t.Fatalf("expected %s to not exist", path) + } else if !os.IsNotExist(err) { + t.Fatalf("stat %s: %v", path, err) + } +} diff --git a/codegen/internal/generator/templates/model.tmpl b/codegen/internal/generator/templates/model.tmpl index c714d30..2273568 100644 --- a/codegen/internal/generator/templates/model.tmpl +++ b/codegen/internal/generator/templates/model.tmpl @@ -13,14 +13,25 @@ package {{ .Package }}; */ {{- end }} {{- if .IsEnum }} -public enum {{ .ClassName }} { -{{- range $index, $value := .EnumValues }}{{ if $index }}, -{{ end }} {{ $value.Name }}({{ quote $value.WireValue }}){{ end }}; +public final class {{ .ClassName }} { +{{- range .EnumValues }} + public static final {{ $.ClassName }} {{ .Name }} = new {{ $.ClassName }}({{ quote .WireValue }}); +{{- end }} private final String value; - {{ .ClassName }}(String value) { - this.value = value; + private {{ .ClassName }}(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a {{ .ClassName }} for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static {{ .ClassName }} of(String value) { + return new {{ .ClassName }}(value); } @JsonValue @@ -35,15 +46,17 @@ public enum {{ .ClassName }} { @JsonCreator public static {{ .ClassName }} fromValue(String value) { - if (value == null) { - return null; - } - for ({{ .ClassName }} entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown {{ .ClassName }} value: " + value); + return value == null ? null : new {{ .ClassName }}(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof {{ .ClassName }} that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } {{- else }} diff --git a/codegen/internal/generator/types.go b/codegen/internal/generator/types.go index fa6379e..5bb2d93 100644 --- a/codegen/internal/generator/types.go +++ b/codegen/internal/generator/types.go @@ -146,13 +146,8 @@ func (r *typeResolver) javaType(ref *base.SchemaProxy, context ...string) javaTy if schema.Properties != nil && schema.Properties.Len() > 0 { return r.inlineObjectType(schema, context) } - if len(schema.AllOf) > 0 { - for _, item := range schema.AllOf { - if item == nil { - continue - } - return r.javaType(item, context...) - } + if schemaHasFlattenableProperties(schema) { + return r.inlineObjectType(schema, context) } if len(schema.OneOf) > 0 { for _, item := range schema.OneOf { @@ -173,6 +168,10 @@ func (r *typeResolver) javaType(ref *base.SchemaProxy, context ...string) javaTy return r.genericMap() } +func (r *typeResolver) parameterJavaType(ref *base.SchemaProxy, context ...string) javaType { + return r.javaType(ref, context...) +} + // objectType handles schemas that look like objects by either emitting inline // models or falling back to generic map types. func (r *typeResolver) objectType(schema *base.Schema, context []string) javaType { @@ -331,6 +330,7 @@ func (r *typeResolver) inlineSchemaModels(params Params) []schemaModel { imports := sortedImports(map[string]struct{}{ "com.fasterxml.jackson.annotation.JsonCreator": {}, "com.fasterxml.jackson.annotation.JsonValue": {}, + "java.util.Objects": {}, }) models = append(models, schemaModel{ Name: info.className, diff --git a/src/main/java/com/sumup/sdk/clients/MembershipsAsyncClient.java b/src/main/java/com/sumup/sdk/clients/MembershipsAsyncClient.java index ff27079..2769db1 100644 --- a/src/main/java/com/sumup/sdk/clients/MembershipsAsyncClient.java +++ b/src/main/java/com/sumup/sdk/clients/MembershipsAsyncClient.java @@ -182,7 +182,7 @@ public ListMembershipsQueryParams resourceParentId(String value) { * Pass explicit null to filter for resources without a parent. * @return This ListMembershipsQueryParams instance. */ - public ListMembershipsQueryParams resourceParentType(com.sumup.sdk.models.ResourceType value) { + public ListMembershipsQueryParams resourceParentType(java.util.Map value) { this.values.put("resource.parent.type", Objects.requireNonNull(value, "resourceParentType")); return this; } diff --git a/src/main/java/com/sumup/sdk/clients/MembershipsClient.java b/src/main/java/com/sumup/sdk/clients/MembershipsClient.java index 6260d96..16a0283 100644 --- a/src/main/java/com/sumup/sdk/clients/MembershipsClient.java +++ b/src/main/java/com/sumup/sdk/clients/MembershipsClient.java @@ -177,7 +177,7 @@ public ListMembershipsQueryParams resourceParentId(String value) { * Pass explicit null to filter for resources without a parent. * @return This ListMembershipsQueryParams instance. */ - public ListMembershipsQueryParams resourceParentType(com.sumup.sdk.models.ResourceType value) { + public ListMembershipsQueryParams resourceParentType(java.util.Map value) { this.values.put("resource.parent.type", Objects.requireNonNull(value, "resourceParentType")); return this; } diff --git a/src/main/java/com/sumup/sdk/clients/PayoutsAsyncClient.java b/src/main/java/com/sumup/sdk/clients/PayoutsAsyncClient.java index 153a88d..fd916d0 100644 --- a/src/main/java/com/sumup/sdk/clients/PayoutsAsyncClient.java +++ b/src/main/java/com/sumup/sdk/clients/PayoutsAsyncClient.java @@ -216,7 +216,7 @@ public static final class ListPayoutsV1QueryParams { * @param value Response format for the payout list. * @return This ListPayoutsV1QueryParams instance. */ - public ListPayoutsV1QueryParams format(com.sumup.sdk.models.Format value) { + public ListPayoutsV1QueryParams format(com.sumup.sdk.models.ListPayoutsV1Format value) { this.values.put("format", Objects.requireNonNull(value, "format")); return this; } @@ -238,7 +238,7 @@ public ListPayoutsV1QueryParams limit(Long value) { * @param value Sort direction for the returned payouts. * @return This ListPayoutsV1QueryParams instance. */ - public ListPayoutsV1QueryParams order(com.sumup.sdk.models.Order2 value) { + public ListPayoutsV1QueryParams order(com.sumup.sdk.models.ListPayoutsV1Order value) { this.values.put("order", Objects.requireNonNull(value, "order")); return this; } @@ -263,7 +263,7 @@ public static final class ListPayoutsQueryParams { * @param value Response format for the payout list. * @return This ListPayoutsQueryParams instance. */ - public ListPayoutsQueryParams format(com.sumup.sdk.models.Format2 value) { + public ListPayoutsQueryParams format(com.sumup.sdk.models.ListPayoutsFormat value) { this.values.put("format", Objects.requireNonNull(value, "format")); return this; } @@ -285,7 +285,7 @@ public ListPayoutsQueryParams limit(Long value) { * @param value Sort direction for the returned payouts. * @return This ListPayoutsQueryParams instance. */ - public ListPayoutsQueryParams order(com.sumup.sdk.models.Order2 value) { + public ListPayoutsQueryParams order(com.sumup.sdk.models.ListPayoutsOrder value) { this.values.put("order", Objects.requireNonNull(value, "order")); return this; } diff --git a/src/main/java/com/sumup/sdk/clients/PayoutsClient.java b/src/main/java/com/sumup/sdk/clients/PayoutsClient.java index 33c94ad..57d9bf3 100644 --- a/src/main/java/com/sumup/sdk/clients/PayoutsClient.java +++ b/src/main/java/com/sumup/sdk/clients/PayoutsClient.java @@ -215,7 +215,7 @@ public static final class ListPayoutsV1QueryParams { * @param value Response format for the payout list. * @return This ListPayoutsV1QueryParams instance. */ - public ListPayoutsV1QueryParams format(com.sumup.sdk.models.Format value) { + public ListPayoutsV1QueryParams format(com.sumup.sdk.models.ListPayoutsV1Format value) { this.values.put("format", Objects.requireNonNull(value, "format")); return this; } @@ -237,7 +237,7 @@ public ListPayoutsV1QueryParams limit(Long value) { * @param value Sort direction for the returned payouts. * @return This ListPayoutsV1QueryParams instance. */ - public ListPayoutsV1QueryParams order(com.sumup.sdk.models.Order2 value) { + public ListPayoutsV1QueryParams order(com.sumup.sdk.models.ListPayoutsV1Order value) { this.values.put("order", Objects.requireNonNull(value, "order")); return this; } @@ -262,7 +262,7 @@ public static final class ListPayoutsQueryParams { * @param value Response format for the payout list. * @return This ListPayoutsQueryParams instance. */ - public ListPayoutsQueryParams format(com.sumup.sdk.models.Format2 value) { + public ListPayoutsQueryParams format(com.sumup.sdk.models.ListPayoutsFormat value) { this.values.put("format", Objects.requireNonNull(value, "format")); return this; } @@ -284,7 +284,7 @@ public ListPayoutsQueryParams limit(Long value) { * @param value Sort direction for the returned payouts. * @return This ListPayoutsQueryParams instance. */ - public ListPayoutsQueryParams order(com.sumup.sdk.models.Order2 value) { + public ListPayoutsQueryParams order(com.sumup.sdk.models.ListPayoutsOrder value) { this.values.put("order", Objects.requireNonNull(value, "order")); return this; } diff --git a/src/main/java/com/sumup/sdk/clients/TransactionsAsyncClient.java b/src/main/java/com/sumup/sdk/clients/TransactionsAsyncClient.java index d7a4d09..2eea9ee 100644 --- a/src/main/java/com/sumup/sdk/clients/TransactionsAsyncClient.java +++ b/src/main/java/com/sumup/sdk/clients/TransactionsAsyncClient.java @@ -591,7 +591,8 @@ public ListTransactionsV21QueryParams oldestTime(java.time.OffsetDateTime value) * @param value Specifies the order in which the returned results are displayed. * @return This ListTransactionsV21QueryParams instance. */ - public ListTransactionsV21QueryParams order(com.sumup.sdk.models.Order value) { + public ListTransactionsV21QueryParams order( + com.sumup.sdk.models.ListTransactionsV21Order value) { this.values.put("order", Objects.requireNonNull(value, "order")); return this; } @@ -617,7 +618,7 @@ public ListTransactionsV21QueryParams paymentTypes( * @return This ListTransactionsV21QueryParams instance. */ public ListTransactionsV21QueryParams statuses( - java.util.List value) { + java.util.List value) { this.values.put("statuses[]", Objects.requireNonNull(value, "statuses")); return this; } @@ -640,7 +641,7 @@ public ListTransactionsV21QueryParams transactionCode(String value) { * @return This ListTransactionsV21QueryParams instance. */ public ListTransactionsV21QueryParams types( - java.util.List value) { + java.util.List value) { this.values.put("types", Objects.requireNonNull(value, "types")); return this; } @@ -753,7 +754,7 @@ public ListTransactionsQueryParams oldestTime(java.time.OffsetDateTime value) { * @param value Specifies the order in which the returned results are displayed. * @return This ListTransactionsQueryParams instance. */ - public ListTransactionsQueryParams order(com.sumup.sdk.models.Order2 value) { + public ListTransactionsQueryParams order(com.sumup.sdk.models.ListTransactionsOrder value) { this.values.put("order", Objects.requireNonNull(value, "order")); return this; } @@ -779,7 +780,7 @@ public ListTransactionsQueryParams paymentTypes( * @return This ListTransactionsQueryParams instance. */ public ListTransactionsQueryParams statuses( - java.util.List value) { + java.util.List value) { this.values.put("statuses[]", Objects.requireNonNull(value, "statuses")); return this; } @@ -802,7 +803,7 @@ public ListTransactionsQueryParams transactionCode(String value) { * @return This ListTransactionsQueryParams instance. */ public ListTransactionsQueryParams types( - java.util.List value) { + java.util.List value) { this.values.put("types", Objects.requireNonNull(value, "types")); return this; } diff --git a/src/main/java/com/sumup/sdk/clients/TransactionsClient.java b/src/main/java/com/sumup/sdk/clients/TransactionsClient.java index 4be6623..ca0ead2 100644 --- a/src/main/java/com/sumup/sdk/clients/TransactionsClient.java +++ b/src/main/java/com/sumup/sdk/clients/TransactionsClient.java @@ -578,7 +578,8 @@ public ListTransactionsV21QueryParams oldestTime(java.time.OffsetDateTime value) * @param value Specifies the order in which the returned results are displayed. * @return This ListTransactionsV21QueryParams instance. */ - public ListTransactionsV21QueryParams order(com.sumup.sdk.models.Order value) { + public ListTransactionsV21QueryParams order( + com.sumup.sdk.models.ListTransactionsV21Order value) { this.values.put("order", Objects.requireNonNull(value, "order")); return this; } @@ -604,7 +605,7 @@ public ListTransactionsV21QueryParams paymentTypes( * @return This ListTransactionsV21QueryParams instance. */ public ListTransactionsV21QueryParams statuses( - java.util.List value) { + java.util.List value) { this.values.put("statuses[]", Objects.requireNonNull(value, "statuses")); return this; } @@ -627,7 +628,7 @@ public ListTransactionsV21QueryParams transactionCode(String value) { * @return This ListTransactionsV21QueryParams instance. */ public ListTransactionsV21QueryParams types( - java.util.List value) { + java.util.List value) { this.values.put("types", Objects.requireNonNull(value, "types")); return this; } @@ -740,7 +741,7 @@ public ListTransactionsQueryParams oldestTime(java.time.OffsetDateTime value) { * @param value Specifies the order in which the returned results are displayed. * @return This ListTransactionsQueryParams instance. */ - public ListTransactionsQueryParams order(com.sumup.sdk.models.Order2 value) { + public ListTransactionsQueryParams order(com.sumup.sdk.models.ListTransactionsOrder value) { this.values.put("order", Objects.requireNonNull(value, "order")); return this; } @@ -766,7 +767,7 @@ public ListTransactionsQueryParams paymentTypes( * @return This ListTransactionsQueryParams instance. */ public ListTransactionsQueryParams statuses( - java.util.List value) { + java.util.List value) { this.values.put("statuses[]", Objects.requireNonNull(value, "statuses")); return this; } @@ -789,7 +790,7 @@ public ListTransactionsQueryParams transactionCode(String value) { * @return This ListTransactionsQueryParams instance. */ public ListTransactionsQueryParams types( - java.util.List value) { + java.util.List value) { this.values.put("types", Objects.requireNonNull(value, "types")); return this; } diff --git a/src/main/java/com/sumup/sdk/core/ApiClient.java b/src/main/java/com/sumup/sdk/core/ApiClient.java index 9d7bcbf..f420304 100644 --- a/src/main/java/com/sumup/sdk/core/ApiClient.java +++ b/src/main/java/com/sumup/sdk/core/ApiClient.java @@ -260,11 +260,7 @@ private String serializeQueryValue(Object value) { if (value instanceof OffsetDateTime) { return ((OffsetDateTime) value).toString(); } - try { - return objectMapper.writeValueAsString(value); - } catch (JsonProcessingException e) { - return value.toString(); - } + return parameterValue(value); } private String writeBody(Object body) { diff --git a/src/main/java/com/sumup/sdk/models/BadRequestErrorsType.java b/src/main/java/com/sumup/sdk/models/BadRequestErrorsType.java index 3a654d3..a421bbc 100644 --- a/src/main/java/com/sumup/sdk/models/BadRequestErrorsType.java +++ b/src/main/java/com/sumup/sdk/models/BadRequestErrorsType.java @@ -3,18 +3,33 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Key indicating type of error */ -public enum BadRequestErrorsType { - INVALID_BEARER_TOKEN("INVALID_BEARER_TOKEN"), - INVALID_USER_AGENT("INVALID_USER_AGENT"), - NOT_ENOUGH_UNPAID_PAYOUTS("NOT_ENOUGH_UNPAID_PAYOUTS"), - DUPLICATE_HEADERS("DUPLICATE_HEADERS"); +public final class BadRequestErrorsType { + public static final BadRequestErrorsType INVALID_BEARER_TOKEN = + new BadRequestErrorsType("INVALID_BEARER_TOKEN"); + public static final BadRequestErrorsType INVALID_USER_AGENT = + new BadRequestErrorsType("INVALID_USER_AGENT"); + public static final BadRequestErrorsType NOT_ENOUGH_UNPAID_PAYOUTS = + new BadRequestErrorsType("NOT_ENOUGH_UNPAID_PAYOUTS"); + public static final BadRequestErrorsType DUPLICATE_HEADERS = + new BadRequestErrorsType("DUPLICATE_HEADERS"); private final String value; - BadRequestErrorsType(String value) { - this.value = value; + private BadRequestErrorsType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a BadRequestErrorsType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static BadRequestErrorsType of(String value) { + return new BadRequestErrorsType(value); } @JsonValue @@ -29,14 +44,17 @@ public String toString() { @JsonCreator public static BadRequestErrorsType fromValue(String value) { - if (value == null) { - return null; - } - for (BadRequestErrorsType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown BadRequestErrorsType value: " + value); + return value == null ? null : new BadRequestErrorsType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof BadRequestErrorsType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/CardExpiryMonth.java b/src/main/java/com/sumup/sdk/models/CardExpiryMonth.java index 8a5cb85..6fdd43f 100644 --- a/src/main/java/com/sumup/sdk/models/CardExpiryMonth.java +++ b/src/main/java/com/sumup/sdk/models/CardExpiryMonth.java @@ -3,26 +3,37 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Month from the expiration time of the payment card. Accepted format is `MM`. */ -public enum CardExpiryMonth { - VALUE_01("01"), - VALUE_02("02"), - VALUE_03("03"), - VALUE_04("04"), - VALUE_05("05"), - VALUE_06("06"), - VALUE_07("07"), - VALUE_08("08"), - VALUE_09("09"), - VALUE_10("10"), - VALUE_11("11"), - VALUE_12("12"); +public final class CardExpiryMonth { + public static final CardExpiryMonth VALUE_01 = new CardExpiryMonth("01"); + public static final CardExpiryMonth VALUE_02 = new CardExpiryMonth("02"); + public static final CardExpiryMonth VALUE_03 = new CardExpiryMonth("03"); + public static final CardExpiryMonth VALUE_04 = new CardExpiryMonth("04"); + public static final CardExpiryMonth VALUE_05 = new CardExpiryMonth("05"); + public static final CardExpiryMonth VALUE_06 = new CardExpiryMonth("06"); + public static final CardExpiryMonth VALUE_07 = new CardExpiryMonth("07"); + public static final CardExpiryMonth VALUE_08 = new CardExpiryMonth("08"); + public static final CardExpiryMonth VALUE_09 = new CardExpiryMonth("09"); + public static final CardExpiryMonth VALUE_10 = new CardExpiryMonth("10"); + public static final CardExpiryMonth VALUE_11 = new CardExpiryMonth("11"); + public static final CardExpiryMonth VALUE_12 = new CardExpiryMonth("12"); private final String value; - CardExpiryMonth(String value) { - this.value = value; + private CardExpiryMonth(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a CardExpiryMonth for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static CardExpiryMonth of(String value) { + return new CardExpiryMonth(value); } @JsonValue @@ -37,14 +48,17 @@ public String toString() { @JsonCreator public static CardExpiryMonth fromValue(String value) { - if (value == null) { - return null; - } - for (CardExpiryMonth entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown CardExpiryMonth value: " + value); + return value == null ? null : new CardExpiryMonth(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof CardExpiryMonth that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/CardType.java b/src/main/java/com/sumup/sdk/models/CardType.java index 40159d5..8776125 100644 --- a/src/main/java/com/sumup/sdk/models/CardType.java +++ b/src/main/java/com/sumup/sdk/models/CardType.java @@ -3,38 +3,49 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Issuing card network of the payment card used for the transaction. */ -public enum CardType { - ALELO("ALELO"), - AMEX("AMEX"), - CONECS("CONECS"), - CUP("CUP"), - DINERS("DINERS"), - DISCOVER("DISCOVER"), - EFTPOS("EFTPOS"), - ELO("ELO"), - ELV("ELV"), - GIROCARD("GIROCARD"), - HIPERCARD("HIPERCARD"), - INTERAC("INTERAC"), - JCB("JCB"), - MAESTRO("MAESTRO"), - MASTERCARD("MASTERCARD"), - PLUXEE("PLUXEE"), - SWILE("SWILE"), - TICKET("TICKET"), - VISA("VISA"), - VISA_ELECTRON("VISA_ELECTRON"), - VISA_VPAY("VISA_VPAY"), - VPAY("VPAY"), - VR("VR"), - UNKNOWN("UNKNOWN"); +public final class CardType { + public static final CardType ALELO = new CardType("ALELO"); + public static final CardType AMEX = new CardType("AMEX"); + public static final CardType CONECS = new CardType("CONECS"); + public static final CardType CUP = new CardType("CUP"); + public static final CardType DINERS = new CardType("DINERS"); + public static final CardType DISCOVER = new CardType("DISCOVER"); + public static final CardType EFTPOS = new CardType("EFTPOS"); + public static final CardType ELO = new CardType("ELO"); + public static final CardType ELV = new CardType("ELV"); + public static final CardType GIROCARD = new CardType("GIROCARD"); + public static final CardType HIPERCARD = new CardType("HIPERCARD"); + public static final CardType INTERAC = new CardType("INTERAC"); + public static final CardType JCB = new CardType("JCB"); + public static final CardType MAESTRO = new CardType("MAESTRO"); + public static final CardType MASTERCARD = new CardType("MASTERCARD"); + public static final CardType PLUXEE = new CardType("PLUXEE"); + public static final CardType SWILE = new CardType("SWILE"); + public static final CardType TICKET = new CardType("TICKET"); + public static final CardType VISA = new CardType("VISA"); + public static final CardType VISA_ELECTRON = new CardType("VISA_ELECTRON"); + public static final CardType VISA_VPAY = new CardType("VISA_VPAY"); + public static final CardType VPAY = new CardType("VPAY"); + public static final CardType VR = new CardType("VR"); + public static final CardType UNKNOWN = new CardType("UNKNOWN"); private final String value; - CardType(String value) { - this.value = value; + private CardType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a CardType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static CardType of(String value) { + return new CardType(value); } @JsonValue @@ -49,14 +60,16 @@ public String toString() { @JsonCreator public static CardType fromValue(String value) { - if (value == null) { - return null; - } - for (CardType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown CardType value: " + value); + return value == null ? null : new CardType(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof CardType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/Checkout.java b/src/main/java/com/sumup/sdk/models/Checkout.java index 38807b5..8b0ad5b 100644 --- a/src/main/java/com/sumup/sdk/models/Checkout.java +++ b/src/main/java/com/sumup/sdk/models/Checkout.java @@ -67,7 +67,7 @@ public record Checkout( * Payment attempts and resulting transaction records linked to this checkout. Use the * Transactions endpoints when you need the authoritative payment result and event history. */ - java.util.List transactions, + java.util.List transactions, /** * Optional expiration timestamp. The checkout must be processed before this moment, otherwise @@ -95,7 +95,7 @@ public static final class Builder { private String merchantCode; private String returnUrl; private com.sumup.sdk.models.CheckoutStatus status; - private java.util.List transactions; + private java.util.List transactions; private java.time.OffsetDateTime validUntil; private Builder() {} @@ -229,7 +229,8 @@ public Builder status(com.sumup.sdk.models.CheckoutStatus status) { * and event history. * @return This builder instance. */ - public Builder transactions(java.util.List transactions) { + public Builder transactions( + java.util.List transactions) { this.transactions = transactions; return this; } diff --git a/src/main/java/com/sumup/sdk/models/CheckoutAcceptedNextStepMechanismItem.java b/src/main/java/com/sumup/sdk/models/CheckoutAcceptedNextStepMechanismItem.java index 03d8fc0..fe4c819 100644 --- a/src/main/java/com/sumup/sdk/models/CheckoutAcceptedNextStepMechanismItem.java +++ b/src/main/java/com/sumup/sdk/models/CheckoutAcceptedNextStepMechanismItem.java @@ -3,15 +3,28 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; -public enum CheckoutAcceptedNextStepMechanismItem { - IFRAME("iframe"), - BROWSER("browser"); +public final class CheckoutAcceptedNextStepMechanismItem { + public static final CheckoutAcceptedNextStepMechanismItem IFRAME = + new CheckoutAcceptedNextStepMechanismItem("iframe"); + public static final CheckoutAcceptedNextStepMechanismItem BROWSER = + new CheckoutAcceptedNextStepMechanismItem("browser"); private final String value; - CheckoutAcceptedNextStepMechanismItem(String value) { - this.value = value; + private CheckoutAcceptedNextStepMechanismItem(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a CheckoutAcceptedNextStepMechanismItem for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static CheckoutAcceptedNextStepMechanismItem of(String value) { + return new CheckoutAcceptedNextStepMechanismItem(value); } @JsonValue @@ -26,15 +39,18 @@ public String toString() { @JsonCreator public static CheckoutAcceptedNextStepMechanismItem fromValue(String value) { - if (value == null) { - return null; - } - for (CheckoutAcceptedNextStepMechanismItem entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException( - "Unknown CheckoutAcceptedNextStepMechanismItem value: " + value); + return value == null ? null : new CheckoutAcceptedNextStepMechanismItem(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof CheckoutAcceptedNextStepMechanismItem that + && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/CheckoutCreateRequestPurpose.java b/src/main/java/com/sumup/sdk/models/CheckoutCreateRequestPurpose.java index 70848ee..5be42c7 100644 --- a/src/main/java/com/sumup/sdk/models/CheckoutCreateRequestPurpose.java +++ b/src/main/java/com/sumup/sdk/models/CheckoutCreateRequestPurpose.java @@ -3,20 +3,33 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** * Business purpose of the checkout. Use `CHECKOUT` for a standard payment and * `SETUP_RECURRING_PAYMENT` when collecting consent and payment details for future recurring * charges. */ -public enum CheckoutCreateRequestPurpose { - CHECKOUT("CHECKOUT"), - SETUP_RECURRING_PAYMENT("SETUP_RECURRING_PAYMENT"); +public final class CheckoutCreateRequestPurpose { + public static final CheckoutCreateRequestPurpose CHECKOUT = + new CheckoutCreateRequestPurpose("CHECKOUT"); + public static final CheckoutCreateRequestPurpose SETUP_RECURRING_PAYMENT = + new CheckoutCreateRequestPurpose("SETUP_RECURRING_PAYMENT"); private final String value; - CheckoutCreateRequestPurpose(String value) { - this.value = value; + private CheckoutCreateRequestPurpose(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a CheckoutCreateRequestPurpose for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static CheckoutCreateRequestPurpose of(String value) { + return new CheckoutCreateRequestPurpose(value); } @JsonValue @@ -31,14 +44,17 @@ public String toString() { @JsonCreator public static CheckoutCreateRequestPurpose fromValue(String value) { - if (value == null) { - return null; - } - for (CheckoutCreateRequestPurpose entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown CheckoutCreateRequestPurpose value: " + value); + return value == null ? null : new CheckoutCreateRequestPurpose(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof CheckoutCreateRequestPurpose that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/CheckoutStatus.java b/src/main/java/com/sumup/sdk/models/CheckoutStatus.java index ebf000a..3c0942a 100644 --- a/src/main/java/com/sumup/sdk/models/CheckoutStatus.java +++ b/src/main/java/com/sumup/sdk/models/CheckoutStatus.java @@ -3,22 +3,33 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** * Current high-level state of the checkout. `PENDING` means the checkout exists but is not yet * completed, `PAID` means a payment succeeded, `FAILED` means the latest processing attempt failed, * and `EXPIRED` means the checkout can no longer be processed. */ -public enum CheckoutStatus { - PENDING("PENDING"), - FAILED("FAILED"), - PAID("PAID"), - EXPIRED("EXPIRED"); +public final class CheckoutStatus { + public static final CheckoutStatus PENDING = new CheckoutStatus("PENDING"); + public static final CheckoutStatus FAILED = new CheckoutStatus("FAILED"); + public static final CheckoutStatus PAID = new CheckoutStatus("PAID"); + public static final CheckoutStatus EXPIRED = new CheckoutStatus("EXPIRED"); private final String value; - CheckoutStatus(String value) { - this.value = value; + private CheckoutStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a CheckoutStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static CheckoutStatus of(String value) { + return new CheckoutStatus(value); } @JsonValue @@ -33,14 +44,16 @@ public String toString() { @JsonCreator public static CheckoutStatus fromValue(String value) { - if (value == null) { - return null; - } - for (CheckoutStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown CheckoutStatus value: " + value); + return value == null ? null : new CheckoutStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof CheckoutStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/CheckoutSuccess.java b/src/main/java/com/sumup/sdk/models/CheckoutSuccess.java index 2003297..c340ce9 100644 --- a/src/main/java/com/sumup/sdk/models/CheckoutSuccess.java +++ b/src/main/java/com/sumup/sdk/models/CheckoutSuccess.java @@ -6,4 +6,333 @@ * checkout fields, it can include the resulting transaction identifiers and any newly created * payment instrument token. */ -public record CheckoutSuccess(com.sumup.sdk.models.Checkout value) {} +public record CheckoutSuccess( + /** Amount to be charged to the payer, expressed in major units. */ + Float amount, + + /** + * Merchant-defined reference for the checkout. Use it to correlate the SumUp checkout with your + * own order, cart, subscription, or payment attempt in your systems. + */ + String checkoutReference, + + /** + * Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the + * amount. Currently supported currency values are enumerated above. + */ + com.sumup.sdk.models.Currency currency, + + /** + * Merchant-scoped identifier of the customer associated with the checkout. Use it when storing + * payment instruments or reusing saved customer context for recurring and returning-payer + * flows. + */ + String customerId, + + /** + * Date and time of the creation of the payment checkout. Response format expressed according to + * [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + */ + java.time.OffsetDateTime date, + + /** + * Short merchant-defined description shown in SumUp tools and reporting. Use it to make the + * checkout easier to recognize in dashboards, support workflows, and reconciliation. + */ + String description, + + /** Unique SumUp identifier of the checkout resource. */ + String id, + + /** Details of the mandate linked to the saved payment instrument. */ + com.sumup.sdk.models.MandateResponse mandate, + + /** Merchant account that receives the payment. */ + String merchantCode, + + /** Name of the merchant */ + String merchantName, + + /** Details of the saved payment instrument created or reused during checkout processing. */ + com.sumup.sdk.models.CheckoutSuccessPaymentInstrument paymentInstrument, + + /** URL where the payer is redirected after a redirect-based payment or SCA flow completes. */ + String redirectUrl, + + /** + * Optional backend callback URL used by SumUp to notify your platform about processing updates + * for the checkout. + */ + String returnUrl, + + /** + * Current high-level state of the checkout. `PENDING` means the checkout exists but is not yet + * completed, `PAID` means a payment succeeded, `FAILED` means the latest processing attempt + * failed, and `EXPIRED` means the checkout can no longer be processed. + */ + com.sumup.sdk.models.CheckoutSuccessStatus status, + + /** + * Transaction code of the successful transaction with which the payment for the checkout is + * completed. + */ + String transactionCode, + + /** + * Transaction ID of the successful transaction with which the payment for the checkout is + * completed. + */ + String transactionId, + + /** + * Payment attempts and resulting transaction records linked to this checkout. Use the + * Transactions endpoints when you need the authoritative payment result and event history. + */ + java.util.List transactions, + + /** + * Optional expiration timestamp. The checkout must be processed before this moment, otherwise + * it becomes unusable. If omitted, the checkout does not have an explicit expiry time. + */ + java.time.OffsetDateTime validUntil) { + /** + * Creates a builder for CheckoutSuccess. + * + * @return Builder that constructs immutable CheckoutSuccess instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for CheckoutSuccess instances. */ + public static final class Builder { + private Float amount; + private String checkoutReference; + private com.sumup.sdk.models.Currency currency; + private String customerId; + private java.time.OffsetDateTime date; + private String description; + private com.sumup.sdk.models.MandateResponse mandate; + private String merchantCode; + private String merchantName; + private com.sumup.sdk.models.CheckoutSuccessPaymentInstrument paymentInstrument; + private String redirectUrl; + private String returnUrl; + private com.sumup.sdk.models.CheckoutSuccessStatus status; + private java.util.List transactions; + private java.time.OffsetDateTime validUntil; + + private Builder() {} + + /** + * Sets the value for {@code amount}. + * + * @param amount Amount to be charged to the payer, expressed in major units. + * @return This builder instance. + */ + public Builder amount(Float amount) { + this.amount = amount; + return this; + } + + /** + * Sets the value for {@code checkoutReference}. + * + * @param checkoutReference Merchant-defined reference for the checkout. Use it to correlate the + * SumUp checkout with your own order, cart, subscription, or payment attempt in your + * systems. + * @return This builder instance. + */ + public Builder checkoutReference(String checkoutReference) { + this.checkoutReference = checkoutReference; + return this; + } + + /** + * Sets the value for {@code currency}. + * + * @param currency Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the + * currency for the amount. Currently supported currency values are enumerated above. + * @return This builder instance. + */ + public Builder currency(com.sumup.sdk.models.Currency currency) { + this.currency = currency; + return this; + } + + /** + * Sets the value for {@code customerId}. + * + * @param customerId Merchant-scoped identifier of the customer associated with the checkout. + * Use it when storing payment instruments or reusing saved customer context for recurring + * and returning-payer flows. + * @return This builder instance. + */ + public Builder customerId(String customerId) { + this.customerId = customerId; + return this; + } + + /** + * Sets the value for {@code date}. + * + * @param date Date and time of the creation of the payment checkout. Response format expressed + * according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + * @return This builder instance. + */ + public Builder date(java.time.OffsetDateTime date) { + this.date = date; + return this; + } + + /** + * Sets the value for {@code description}. + * + * @param description Short merchant-defined description shown in SumUp tools and reporting. Use + * it to make the checkout easier to recognize in dashboards, support workflows, and + * reconciliation. + * @return This builder instance. + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Sets the value for {@code mandate}. + * + * @param mandate Details of the mandate linked to the saved payment instrument. + * @return This builder instance. + */ + public Builder mandate(com.sumup.sdk.models.MandateResponse mandate) { + this.mandate = mandate; + return this; + } + + /** + * Sets the value for {@code merchantCode}. + * + * @param merchantCode Merchant account that receives the payment. + * @return This builder instance. + */ + public Builder merchantCode(String merchantCode) { + this.merchantCode = merchantCode; + return this; + } + + /** + * Sets the value for {@code merchantName}. + * + * @param merchantName Name of the merchant + * @return This builder instance. + */ + public Builder merchantName(String merchantName) { + this.merchantName = merchantName; + return this; + } + + /** + * Sets the value for {@code paymentInstrument}. + * + * @param paymentInstrument Details of the saved payment instrument created or reused during + * checkout processing. + * @return This builder instance. + */ + public Builder paymentInstrument( + com.sumup.sdk.models.CheckoutSuccessPaymentInstrument paymentInstrument) { + this.paymentInstrument = paymentInstrument; + return this; + } + + /** + * Sets the value for {@code redirectUrl}. + * + * @param redirectUrl URL where the payer is redirected after a redirect-based payment or SCA + * flow completes. + * @return This builder instance. + */ + public Builder redirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + return this; + } + + /** + * Sets the value for {@code returnUrl}. + * + * @param returnUrl Optional backend callback URL used by SumUp to notify your platform about + * processing updates for the checkout. + * @return This builder instance. + */ + public Builder returnUrl(String returnUrl) { + this.returnUrl = returnUrl; + return this; + } + + /** + * Sets the value for {@code status}. + * + * @param status Current high-level state of the checkout. `PENDING` means the checkout exists + * but is not yet completed, `PAID` means a payment succeeded, `FAILED` means the latest + * processing attempt failed, and `EXPIRED` means the checkout can no longer be processed. + * @return This builder instance. + */ + public Builder status(com.sumup.sdk.models.CheckoutSuccessStatus status) { + this.status = status; + return this; + } + + /** + * Sets the value for {@code transactions}. + * + * @param transactions Payment attempts and resulting transaction records linked to this + * checkout. Use the Transactions endpoints when you need the authoritative payment result + * and event history. + * @return This builder instance. + */ + public Builder transactions( + java.util.List transactions) { + this.transactions = transactions; + return this; + } + + /** + * Sets the value for {@code validUntil}. + * + * @param validUntil Optional expiration timestamp. The checkout must be processed before this + * moment, otherwise it becomes unusable. If omitted, the checkout does not have an explicit + * expiry time. + * @return This builder instance. + */ + public Builder validUntil(java.time.OffsetDateTime validUntil) { + this.validUntil = validUntil; + return this; + } + + /** + * Builds an immutable CheckoutSuccess instance. + * + * @return Immutable CheckoutSuccess. + */ + public CheckoutSuccess build() { + return new CheckoutSuccess( + amount, + checkoutReference, + currency, + customerId, + date, + description, + null, + mandate, + merchantCode, + merchantName, + paymentInstrument, + redirectUrl, + returnUrl, + status, + null, + null, + transactions, + validUntil); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/CheckoutSuccessPaymentInstrument.java b/src/main/java/com/sumup/sdk/models/CheckoutSuccessPaymentInstrument.java new file mode 100644 index 0000000..6f88a46 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/CheckoutSuccessPaymentInstrument.java @@ -0,0 +1,43 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +/** Details of the saved payment instrument created or reused during checkout processing. */ +public record CheckoutSuccessPaymentInstrument( + /** Token value */ + String token) { + /** + * Creates a builder for CheckoutSuccessPaymentInstrument. + * + * @return Builder that constructs immutable CheckoutSuccessPaymentInstrument instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for CheckoutSuccessPaymentInstrument instances. */ + public static final class Builder { + private String token; + + private Builder() {} + + /** + * Sets the value for {@code token}. + * + * @param token Token value + * @return This builder instance. + */ + public Builder token(String token) { + this.token = token; + return this; + } + + /** + * Builds an immutable CheckoutSuccessPaymentInstrument instance. + * + * @return Immutable CheckoutSuccessPaymentInstrument. + */ + public CheckoutSuccessPaymentInstrument build() { + return new CheckoutSuccessPaymentInstrument(token); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/CheckoutSuccessStatus.java b/src/main/java/com/sumup/sdk/models/CheckoutSuccessStatus.java new file mode 100644 index 0000000..a6591e6 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/CheckoutSuccessStatus.java @@ -0,0 +1,60 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** + * Current high-level state of the checkout. `PENDING` means the checkout exists but is not yet + * completed, `PAID` means a payment succeeded, `FAILED` means the latest processing attempt failed, + * and `EXPIRED` means the checkout can no longer be processed. + */ +public final class CheckoutSuccessStatus { + public static final CheckoutSuccessStatus PENDING = new CheckoutSuccessStatus("PENDING"); + public static final CheckoutSuccessStatus FAILED = new CheckoutSuccessStatus("FAILED"); + public static final CheckoutSuccessStatus PAID = new CheckoutSuccessStatus("PAID"); + public static final CheckoutSuccessStatus EXPIRED = new CheckoutSuccessStatus("EXPIRED"); + + private final String value; + + private CheckoutSuccessStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a CheckoutSuccessStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static CheckoutSuccessStatus of(String value) { + return new CheckoutSuccessStatus(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static CheckoutSuccessStatus fromValue(String value) { + return value == null ? null : new CheckoutSuccessStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof CheckoutSuccessStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/CheckoutSuccessTransactionsItem.java b/src/main/java/com/sumup/sdk/models/CheckoutSuccessTransactionsItem.java new file mode 100644 index 0000000..6f92f64 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/CheckoutSuccessTransactionsItem.java @@ -0,0 +1,250 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +public record CheckoutSuccessTransactionsItem( + /** Total amount of the transaction. */ + Float amount, + + /** + * Authorization code for the transaction sent by the payment card issuer or bank. Applicable + * only to card payments. + */ + String authCode, + + /** + * Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the + * amount. Currently supported currency values are enumerated above. + */ + com.sumup.sdk.models.Currency currency, + + /** Entry mode of the payment details. */ + com.sumup.sdk.models.EntryMode entryMode, + + /** Unique ID of the transaction. */ + String id, + + /** Current number of the installment for deferred payments. */ + Long installmentsCount, + + /** Unique code of the registered merchant to whom the payment is made. */ + String merchantCode, + + /** Payment type used for the transaction. */ + com.sumup.sdk.models.PaymentType paymentType, + + /** Current status of the transaction. */ + com.sumup.sdk.models.TransactionFullStatus status, + + /** + * Date and time of the creation of the transaction. Response format expressed according to + * [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + */ + java.time.OffsetDateTime timestamp, + + /** Amount of the tip (out of the total transaction amount). */ + Float tipAmount, + + /** + * Transaction code returned by the acquirer/processing entity after processing the transaction. + */ + String transactionCode, + + /** Amount of the applicable VAT (out of the total transaction amount). */ + Float vatAmount) { + /** + * Creates a builder for CheckoutSuccessTransactionsItem. + * + * @return Builder that constructs immutable CheckoutSuccessTransactionsItem instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for CheckoutSuccessTransactionsItem instances. */ + public static final class Builder { + private Float amount; + private String authCode; + private com.sumup.sdk.models.Currency currency; + private com.sumup.sdk.models.EntryMode entryMode; + private String id; + private Long installmentsCount; + private String merchantCode; + private com.sumup.sdk.models.PaymentType paymentType; + private com.sumup.sdk.models.TransactionFullStatus status; + private java.time.OffsetDateTime timestamp; + private Float tipAmount; + private String transactionCode; + private Float vatAmount; + + private Builder() {} + + /** + * Sets the value for {@code amount}. + * + * @param amount Total amount of the transaction. + * @return This builder instance. + */ + public Builder amount(Float amount) { + this.amount = amount; + return this; + } + + /** + * Sets the value for {@code authCode}. + * + * @param authCode Authorization code for the transaction sent by the payment card issuer or + * bank. Applicable only to card payments. + * @return This builder instance. + */ + public Builder authCode(String authCode) { + this.authCode = authCode; + return this; + } + + /** + * Sets the value for {@code currency}. + * + * @param currency Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the + * currency for the amount. Currently supported currency values are enumerated above. + * @return This builder instance. + */ + public Builder currency(com.sumup.sdk.models.Currency currency) { + this.currency = currency; + return this; + } + + /** + * Sets the value for {@code entryMode}. + * + * @param entryMode Entry mode of the payment details. + * @return This builder instance. + */ + public Builder entryMode(com.sumup.sdk.models.EntryMode entryMode) { + this.entryMode = entryMode; + return this; + } + + /** + * Sets the value for {@code id}. + * + * @param id Unique ID of the transaction. + * @return This builder instance. + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Sets the value for {@code installmentsCount}. + * + * @param installmentsCount Current number of the installment for deferred payments. + * @return This builder instance. + */ + public Builder installmentsCount(Long installmentsCount) { + this.installmentsCount = installmentsCount; + return this; + } + + /** + * Sets the value for {@code merchantCode}. + * + * @param merchantCode Unique code of the registered merchant to whom the payment is made. + * @return This builder instance. + */ + public Builder merchantCode(String merchantCode) { + this.merchantCode = merchantCode; + return this; + } + + /** + * Sets the value for {@code paymentType}. + * + * @param paymentType Payment type used for the transaction. + * @return This builder instance. + */ + public Builder paymentType(com.sumup.sdk.models.PaymentType paymentType) { + this.paymentType = paymentType; + return this; + } + + /** + * Sets the value for {@code status}. + * + * @param status Current status of the transaction. + * @return This builder instance. + */ + public Builder status(com.sumup.sdk.models.TransactionFullStatus status) { + this.status = status; + return this; + } + + /** + * Sets the value for {@code timestamp}. + * + * @param timestamp Date and time of the creation of the transaction. Response format expressed + * according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + * @return This builder instance. + */ + public Builder timestamp(java.time.OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Sets the value for {@code tipAmount}. + * + * @param tipAmount Amount of the tip (out of the total transaction amount). + * @return This builder instance. + */ + public Builder tipAmount(Float tipAmount) { + this.tipAmount = tipAmount; + return this; + } + + /** + * Sets the value for {@code transactionCode}. + * + * @param transactionCode Transaction code returned by the acquirer/processing entity after + * processing the transaction. + * @return This builder instance. + */ + public Builder transactionCode(String transactionCode) { + this.transactionCode = transactionCode; + return this; + } + + /** + * Sets the value for {@code vatAmount}. + * + * @param vatAmount Amount of the applicable VAT (out of the total transaction amount). + * @return This builder instance. + */ + public Builder vatAmount(Float vatAmount) { + this.vatAmount = vatAmount; + return this; + } + + /** + * Builds an immutable CheckoutSuccessTransactionsItem instance. + * + * @return Immutable CheckoutSuccessTransactionsItem. + */ + public CheckoutSuccessTransactionsItem build() { + return new CheckoutSuccessTransactionsItem( + amount, + authCode, + currency, + entryMode, + id, + installmentsCount, + merchantCode, + paymentType, + status, + timestamp, + tipAmount, + transactionCode, + vatAmount); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/CheckoutTransactionsItem.java b/src/main/java/com/sumup/sdk/models/CheckoutTransactionsItem.java new file mode 100644 index 0000000..ff7655e --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/CheckoutTransactionsItem.java @@ -0,0 +1,250 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +public record CheckoutTransactionsItem( + /** Total amount of the transaction. */ + Float amount, + + /** + * Authorization code for the transaction sent by the payment card issuer or bank. Applicable + * only to card payments. + */ + String authCode, + + /** + * Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the + * amount. Currently supported currency values are enumerated above. + */ + com.sumup.sdk.models.Currency currency, + + /** Entry mode of the payment details. */ + com.sumup.sdk.models.EntryMode entryMode, + + /** Unique ID of the transaction. */ + String id, + + /** Current number of the installment for deferred payments. */ + Long installmentsCount, + + /** Unique code of the registered merchant to whom the payment is made. */ + String merchantCode, + + /** Payment type used for the transaction. */ + com.sumup.sdk.models.PaymentType paymentType, + + /** Current status of the transaction. */ + com.sumup.sdk.models.TransactionFullStatus status, + + /** + * Date and time of the creation of the transaction. Response format expressed according to + * [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + */ + java.time.OffsetDateTime timestamp, + + /** Amount of the tip (out of the total transaction amount). */ + Float tipAmount, + + /** + * Transaction code returned by the acquirer/processing entity after processing the transaction. + */ + String transactionCode, + + /** Amount of the applicable VAT (out of the total transaction amount). */ + Float vatAmount) { + /** + * Creates a builder for CheckoutTransactionsItem. + * + * @return Builder that constructs immutable CheckoutTransactionsItem instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for CheckoutTransactionsItem instances. */ + public static final class Builder { + private Float amount; + private String authCode; + private com.sumup.sdk.models.Currency currency; + private com.sumup.sdk.models.EntryMode entryMode; + private String id; + private Long installmentsCount; + private String merchantCode; + private com.sumup.sdk.models.PaymentType paymentType; + private com.sumup.sdk.models.TransactionFullStatus status; + private java.time.OffsetDateTime timestamp; + private Float tipAmount; + private String transactionCode; + private Float vatAmount; + + private Builder() {} + + /** + * Sets the value for {@code amount}. + * + * @param amount Total amount of the transaction. + * @return This builder instance. + */ + public Builder amount(Float amount) { + this.amount = amount; + return this; + } + + /** + * Sets the value for {@code authCode}. + * + * @param authCode Authorization code for the transaction sent by the payment card issuer or + * bank. Applicable only to card payments. + * @return This builder instance. + */ + public Builder authCode(String authCode) { + this.authCode = authCode; + return this; + } + + /** + * Sets the value for {@code currency}. + * + * @param currency Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the + * currency for the amount. Currently supported currency values are enumerated above. + * @return This builder instance. + */ + public Builder currency(com.sumup.sdk.models.Currency currency) { + this.currency = currency; + return this; + } + + /** + * Sets the value for {@code entryMode}. + * + * @param entryMode Entry mode of the payment details. + * @return This builder instance. + */ + public Builder entryMode(com.sumup.sdk.models.EntryMode entryMode) { + this.entryMode = entryMode; + return this; + } + + /** + * Sets the value for {@code id}. + * + * @param id Unique ID of the transaction. + * @return This builder instance. + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Sets the value for {@code installmentsCount}. + * + * @param installmentsCount Current number of the installment for deferred payments. + * @return This builder instance. + */ + public Builder installmentsCount(Long installmentsCount) { + this.installmentsCount = installmentsCount; + return this; + } + + /** + * Sets the value for {@code merchantCode}. + * + * @param merchantCode Unique code of the registered merchant to whom the payment is made. + * @return This builder instance. + */ + public Builder merchantCode(String merchantCode) { + this.merchantCode = merchantCode; + return this; + } + + /** + * Sets the value for {@code paymentType}. + * + * @param paymentType Payment type used for the transaction. + * @return This builder instance. + */ + public Builder paymentType(com.sumup.sdk.models.PaymentType paymentType) { + this.paymentType = paymentType; + return this; + } + + /** + * Sets the value for {@code status}. + * + * @param status Current status of the transaction. + * @return This builder instance. + */ + public Builder status(com.sumup.sdk.models.TransactionFullStatus status) { + this.status = status; + return this; + } + + /** + * Sets the value for {@code timestamp}. + * + * @param timestamp Date and time of the creation of the transaction. Response format expressed + * according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + * @return This builder instance. + */ + public Builder timestamp(java.time.OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Sets the value for {@code tipAmount}. + * + * @param tipAmount Amount of the tip (out of the total transaction amount). + * @return This builder instance. + */ + public Builder tipAmount(Float tipAmount) { + this.tipAmount = tipAmount; + return this; + } + + /** + * Sets the value for {@code transactionCode}. + * + * @param transactionCode Transaction code returned by the acquirer/processing entity after + * processing the transaction. + * @return This builder instance. + */ + public Builder transactionCode(String transactionCode) { + this.transactionCode = transactionCode; + return this; + } + + /** + * Sets the value for {@code vatAmount}. + * + * @param vatAmount Amount of the applicable VAT (out of the total transaction amount). + * @return This builder instance. + */ + public Builder vatAmount(Float vatAmount) { + this.vatAmount = vatAmount; + return this; + } + + /** + * Builds an immutable CheckoutTransactionsItem instance. + * + * @return Immutable CheckoutTransactionsItem. + */ + public CheckoutTransactionsItem build() { + return new CheckoutTransactionsItem( + amount, + authCode, + currency, + entryMode, + id, + installmentsCount, + merchantCode, + paymentType, + status, + timestamp, + tipAmount, + transactionCode, + vatAmount); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/CreateReaderCheckoutRequestCardType.java b/src/main/java/com/sumup/sdk/models/CreateReaderCheckoutRequestCardType.java index 4ca98d2..f0af7d9 100644 --- a/src/main/java/com/sumup/sdk/models/CreateReaderCheckoutRequestCardType.java +++ b/src/main/java/com/sumup/sdk/models/CreateReaderCheckoutRequestCardType.java @@ -3,19 +3,32 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** * The card type of the card used for the transaction. Is is required only for some countries (e.g: * Brazil). */ -public enum CreateReaderCheckoutRequestCardType { - CREDIT("credit"), - DEBIT("debit"); +public final class CreateReaderCheckoutRequestCardType { + public static final CreateReaderCheckoutRequestCardType CREDIT = + new CreateReaderCheckoutRequestCardType("credit"); + public static final CreateReaderCheckoutRequestCardType DEBIT = + new CreateReaderCheckoutRequestCardType("debit"); private final String value; - CreateReaderCheckoutRequestCardType(String value) { - this.value = value; + private CreateReaderCheckoutRequestCardType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a CreateReaderCheckoutRequestCardType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static CreateReaderCheckoutRequestCardType of(String value) { + return new CreateReaderCheckoutRequestCardType(value); } @JsonValue @@ -30,15 +43,18 @@ public String toString() { @JsonCreator public static CreateReaderCheckoutRequestCardType fromValue(String value) { - if (value == null) { - return null; - } - for (CreateReaderCheckoutRequestCardType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException( - "Unknown CreateReaderCheckoutRequestCardType value: " + value); + return value == null ? null : new CreateReaderCheckoutRequestCardType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof CreateReaderCheckoutRequestCardType that + && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/Currency.java b/src/main/java/com/sumup/sdk/models/Currency.java index 876283e..6d03a37 100644 --- a/src/main/java/com/sumup/sdk/models/Currency.java +++ b/src/main/java/com/sumup/sdk/models/Currency.java @@ -3,33 +3,44 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** * Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the * amount. Currently supported currency values are enumerated above. */ -public enum Currency { - BGN("BGN"), - BRL("BRL"), - CHF("CHF"), - CLP("CLP"), - COP("COP"), - CZK("CZK"), - DKK("DKK"), - EUR("EUR"), - GBP("GBP"), - HRK("HRK"), - HUF("HUF"), - NOK("NOK"), - PLN("PLN"), - RON("RON"), - SEK("SEK"), - USD("USD"); +public final class Currency { + public static final Currency BGN = new Currency("BGN"); + public static final Currency BRL = new Currency("BRL"); + public static final Currency CHF = new Currency("CHF"); + public static final Currency CLP = new Currency("CLP"); + public static final Currency COP = new Currency("COP"); + public static final Currency CZK = new Currency("CZK"); + public static final Currency DKK = new Currency("DKK"); + public static final Currency EUR = new Currency("EUR"); + public static final Currency GBP = new Currency("GBP"); + public static final Currency HRK = new Currency("HRK"); + public static final Currency HUF = new Currency("HUF"); + public static final Currency NOK = new Currency("NOK"); + public static final Currency PLN = new Currency("PLN"); + public static final Currency RON = new Currency("RON"); + public static final Currency SEK = new Currency("SEK"); + public static final Currency USD = new Currency("USD"); private final String value; - Currency(String value) { - this.value = value; + private Currency(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a Currency for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static Currency of(String value) { + return new Currency(value); } @JsonValue @@ -44,14 +55,16 @@ public String toString() { @JsonCreator public static Currency fromValue(String value) { - if (value == null) { - return null; - } - for (Currency entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown Currency value: " + value); + return value == null ? null : new Currency(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof Currency that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/EntryMode.java b/src/main/java/com/sumup/sdk/models/EntryMode.java index 71a9faa..9d57595 100644 --- a/src/main/java/com/sumup/sdk/models/EntryMode.java +++ b/src/main/java/com/sumup/sdk/models/EntryMode.java @@ -3,41 +3,52 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Entry mode of the payment details. */ -public enum EntryMode { - BOLETO("BOLETO"), - SOFORT("SOFORT"), - IDEAL("IDEAL"), - BANCONTACT("BANCONTACT"), - EPS("EPS"), - MYBANK("MYBANK"), - SATISPAY("SATISPAY"), - BLIK("BLIK"), - P24("P24"), - GIROPAY("GIROPAY"), - PIX("PIX"), - QR_CODE_PIX("QR_CODE_PIX"), - APPLE_PAY("APPLE_PAY"), - GOOGLE_PAY("GOOGLE_PAY"), - PAYPAL("PAYPAL"), - TWINT("TWINT"), - NONE("NONE"), - CHIP("CHIP"), - MANUAL_ENTRY("MANUAL_ENTRY"), - CUSTOMER_ENTRY("CUSTOMER_ENTRY"), - MAGSTRIPE_FALLBACK("MAGSTRIPE_FALLBACK"), - MAGSTRIPE("MAGSTRIPE"), - DIRECT_DEBIT("DIRECT_DEBIT"), - CONTACTLESS("CONTACTLESS"), - MOTO("MOTO"), - CONTACTLESS_MAGSTRIPE("CONTACTLESS_MAGSTRIPE"), - N_A("N/A"); +public final class EntryMode { + public static final EntryMode BOLETO = new EntryMode("BOLETO"); + public static final EntryMode SOFORT = new EntryMode("SOFORT"); + public static final EntryMode IDEAL = new EntryMode("IDEAL"); + public static final EntryMode BANCONTACT = new EntryMode("BANCONTACT"); + public static final EntryMode EPS = new EntryMode("EPS"); + public static final EntryMode MYBANK = new EntryMode("MYBANK"); + public static final EntryMode SATISPAY = new EntryMode("SATISPAY"); + public static final EntryMode BLIK = new EntryMode("BLIK"); + public static final EntryMode P24 = new EntryMode("P24"); + public static final EntryMode GIROPAY = new EntryMode("GIROPAY"); + public static final EntryMode PIX = new EntryMode("PIX"); + public static final EntryMode QR_CODE_PIX = new EntryMode("QR_CODE_PIX"); + public static final EntryMode APPLE_PAY = new EntryMode("APPLE_PAY"); + public static final EntryMode GOOGLE_PAY = new EntryMode("GOOGLE_PAY"); + public static final EntryMode PAYPAL = new EntryMode("PAYPAL"); + public static final EntryMode TWINT = new EntryMode("TWINT"); + public static final EntryMode NONE = new EntryMode("NONE"); + public static final EntryMode CHIP = new EntryMode("CHIP"); + public static final EntryMode MANUAL_ENTRY = new EntryMode("MANUAL_ENTRY"); + public static final EntryMode CUSTOMER_ENTRY = new EntryMode("CUSTOMER_ENTRY"); + public static final EntryMode MAGSTRIPE_FALLBACK = new EntryMode("MAGSTRIPE_FALLBACK"); + public static final EntryMode MAGSTRIPE = new EntryMode("MAGSTRIPE"); + public static final EntryMode DIRECT_DEBIT = new EntryMode("DIRECT_DEBIT"); + public static final EntryMode CONTACTLESS = new EntryMode("CONTACTLESS"); + public static final EntryMode MOTO = new EntryMode("MOTO"); + public static final EntryMode CONTACTLESS_MAGSTRIPE = new EntryMode("CONTACTLESS_MAGSTRIPE"); + public static final EntryMode N_A = new EntryMode("N/A"); private final String value; - EntryMode(String value) { - this.value = value; + private EntryMode(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a EntryMode for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static EntryMode of(String value) { + return new EntryMode(value); } @JsonValue @@ -52,14 +63,16 @@ public String toString() { @JsonCreator public static EntryMode fromValue(String value) { - if (value == null) { - return null; - } - for (EntryMode entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown EntryMode value: " + value); + return value == null ? null : new EntryMode(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof EntryMode that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/ErrorExtended.java b/src/main/java/com/sumup/sdk/models/ErrorExtended.java index ba279a6..da63e68 100644 --- a/src/main/java/com/sumup/sdk/models/ErrorExtended.java +++ b/src/main/java/com/sumup/sdk/models/ErrorExtended.java @@ -2,4 +2,78 @@ package com.sumup.sdk.models; /** Error payload with the invalid parameter reference. */ -public record ErrorExtended(com.sumup.sdk.models.Error value) {} +public record ErrorExtended( + /** Platform code for the error. */ + String errorCode, + + /** Short description of the error. */ + String message, + + /** + * Parameter name (with relative location) to which the error applies. Parameters from embedded + * resources are displayed using dot notation. For example, `card.name` refers to the `name` + * parameter embedded in the `card` object. + */ + String param) { + /** + * Creates a builder for ErrorExtended. + * + * @return Builder that constructs immutable ErrorExtended instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for ErrorExtended instances. */ + public static final class Builder { + private String errorCode; + private String message; + private String param; + + private Builder() {} + + /** + * Sets the value for {@code errorCode}. + * + * @param errorCode Platform code for the error. + * @return This builder instance. + */ + public Builder errorCode(String errorCode) { + this.errorCode = errorCode; + return this; + } + + /** + * Sets the value for {@code message}. + * + * @param message Short description of the error. + * @return This builder instance. + */ + public Builder message(String message) { + this.message = message; + return this; + } + + /** + * Sets the value for {@code param}. + * + * @param param Parameter name (with relative location) to which the error applies. Parameters + * from embedded resources are displayed using dot notation. For example, `card.name` refers + * to the `name` parameter embedded in the `card` object. + * @return This builder instance. + */ + public Builder param(String param) { + this.param = param; + return this; + } + + /** + * Builds an immutable ErrorExtended instance. + * + * @return Immutable ErrorExtended. + */ + public ErrorExtended build() { + return new ErrorExtended(errorCode, message, param); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/EventStatus.java b/src/main/java/com/sumup/sdk/models/EventStatus.java index c8f521b..4ce3ecd 100644 --- a/src/main/java/com/sumup/sdk/models/EventStatus.java +++ b/src/main/java/com/sumup/sdk/models/EventStatus.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** * Status of the transaction event. Not every value is used for every event type. - `PENDING`: The @@ -19,19 +20,29 @@ * as `PAID_OUT` or `REFUNDED`. - `FAILED`: The event could not be completed. Typical examples are a * payout that could not be executed or an event that was rejected during processing. */ -public enum EventStatus { - FAILED("FAILED"), - PAID_OUT("PAID_OUT"), - PENDING("PENDING"), - RECONCILED("RECONCILED"), - REFUNDED("REFUNDED"), - SCHEDULED("SCHEDULED"), - SUCCESSFUL("SUCCESSFUL"); +public final class EventStatus { + public static final EventStatus FAILED = new EventStatus("FAILED"); + public static final EventStatus PAID_OUT = new EventStatus("PAID_OUT"); + public static final EventStatus PENDING = new EventStatus("PENDING"); + public static final EventStatus RECONCILED = new EventStatus("RECONCILED"); + public static final EventStatus REFUNDED = new EventStatus("REFUNDED"); + public static final EventStatus SCHEDULED = new EventStatus("SCHEDULED"); + public static final EventStatus SUCCESSFUL = new EventStatus("SUCCESSFUL"); private final String value; - EventStatus(String value) { - this.value = value; + private EventStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a EventStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static EventStatus of(String value) { + return new EventStatus(value); } @JsonValue @@ -46,14 +57,16 @@ public String toString() { @JsonCreator public static EventStatus fromValue(String value) { - if (value == null) { - return null; - } - for (EventStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown EventStatus value: " + value); + return value == null ? null : new EventStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof EventStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/EventType.java b/src/main/java/com/sumup/sdk/models/EventType.java index 4748543..aca3c47 100644 --- a/src/main/java/com/sumup/sdk/models/EventType.java +++ b/src/main/java/com/sumup/sdk/models/EventType.java @@ -3,18 +3,29 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Type of the transaction event. */ -public enum EventType { - PAYOUT("PAYOUT"), - CHARGE_BACK("CHARGE_BACK"), - REFUND("REFUND"), - PAYOUT_DEDUCTION("PAYOUT_DEDUCTION"); +public final class EventType { + public static final EventType PAYOUT = new EventType("PAYOUT"); + public static final EventType CHARGE_BACK = new EventType("CHARGE_BACK"); + public static final EventType REFUND = new EventType("REFUND"); + public static final EventType PAYOUT_DEDUCTION = new EventType("PAYOUT_DEDUCTION"); private final String value; - EventType(String value) { - this.value = value; + private EventType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a EventType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static EventType of(String value) { + return new EventType(value); } @JsonValue @@ -29,14 +40,16 @@ public String toString() { @JsonCreator public static EventType fromValue(String value) { - if (value == null) { - return null; - } - for (EventType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown EventType value: " + value); + return value == null ? null : new EventType(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof EventType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/FinancialPayoutsItemStatus.java b/src/main/java/com/sumup/sdk/models/FinancialPayoutsItemStatus.java index 60b5ee8..dda78cb 100644 --- a/src/main/java/com/sumup/sdk/models/FinancialPayoutsItemStatus.java +++ b/src/main/java/com/sumup/sdk/models/FinancialPayoutsItemStatus.java @@ -3,15 +3,27 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; -public enum FinancialPayoutsItemStatus { - SUCCESSFUL("SUCCESSFUL"), - FAILED("FAILED"); +public final class FinancialPayoutsItemStatus { + public static final FinancialPayoutsItemStatus SUCCESSFUL = + new FinancialPayoutsItemStatus("SUCCESSFUL"); + public static final FinancialPayoutsItemStatus FAILED = new FinancialPayoutsItemStatus("FAILED"); private final String value; - FinancialPayoutsItemStatus(String value) { - this.value = value; + private FinancialPayoutsItemStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a FinancialPayoutsItemStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static FinancialPayoutsItemStatus of(String value) { + return new FinancialPayoutsItemStatus(value); } @JsonValue @@ -26,14 +38,17 @@ public String toString() { @JsonCreator public static FinancialPayoutsItemStatus fromValue(String value) { - if (value == null) { - return null; - } - for (FinancialPayoutsItemStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown FinancialPayoutsItemStatus value: " + value); + return value == null ? null : new FinancialPayoutsItemStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof FinancialPayoutsItemStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/FinancialPayoutsItemType.java b/src/main/java/com/sumup/sdk/models/FinancialPayoutsItemType.java index 76697de..baeaab6 100644 --- a/src/main/java/com/sumup/sdk/models/FinancialPayoutsItemType.java +++ b/src/main/java/com/sumup/sdk/models/FinancialPayoutsItemType.java @@ -3,18 +3,33 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; -public enum FinancialPayoutsItemType { - PAYOUT("PAYOUT"), - CHARGE_BACK_DEDUCTION("CHARGE_BACK_DEDUCTION"), - REFUND_DEDUCTION("REFUND_DEDUCTION"), - DD_RETURN_DEDUCTION("DD_RETURN_DEDUCTION"), - BALANCE_DEDUCTION("BALANCE_DEDUCTION"); +public final class FinancialPayoutsItemType { + public static final FinancialPayoutsItemType PAYOUT = new FinancialPayoutsItemType("PAYOUT"); + public static final FinancialPayoutsItemType CHARGE_BACK_DEDUCTION = + new FinancialPayoutsItemType("CHARGE_BACK_DEDUCTION"); + public static final FinancialPayoutsItemType REFUND_DEDUCTION = + new FinancialPayoutsItemType("REFUND_DEDUCTION"); + public static final FinancialPayoutsItemType DD_RETURN_DEDUCTION = + new FinancialPayoutsItemType("DD_RETURN_DEDUCTION"); + public static final FinancialPayoutsItemType BALANCE_DEDUCTION = + new FinancialPayoutsItemType("BALANCE_DEDUCTION"); private final String value; - FinancialPayoutsItemType(String value) { - this.value = value; + private FinancialPayoutsItemType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a FinancialPayoutsItemType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static FinancialPayoutsItemType of(String value) { + return new FinancialPayoutsItemType(value); } @JsonValue @@ -29,14 +44,17 @@ public String toString() { @JsonCreator public static FinancialPayoutsItemType fromValue(String value) { - if (value == null) { - return null; - } - for (FinancialPayoutsItemType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown FinancialPayoutsItemType value: " + value); + return value == null ? null : new FinancialPayoutsItemType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof FinancialPayoutsItemType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/Format.java b/src/main/java/com/sumup/sdk/models/Format.java deleted file mode 100644 index 5a88767..0000000 --- a/src/main/java/com/sumup/sdk/models/Format.java +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum Format { - JSON("json"), - CSV("csv"); - - private final String value; - - Format(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - - @JsonCreator - public static Format fromValue(String value) { - if (value == null) { - return null; - } - for (Format entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown Format value: " + value); - } -} diff --git a/src/main/java/com/sumup/sdk/models/Format2.java b/src/main/java/com/sumup/sdk/models/Format2.java deleted file mode 100644 index f90553f..0000000 --- a/src/main/java/com/sumup/sdk/models/Format2.java +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum Format2 { - JSON("json"), - CSV("csv"); - - private final String value; - - Format2(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - - @JsonCreator - public static Format2 fromValue(String value) { - if (value == null) { - return null; - } - for (Format2 entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown Format2 value: " + value); - } -} diff --git a/src/main/java/com/sumup/sdk/models/ListPayoutsFormat.java b/src/main/java/com/sumup/sdk/models/ListPayoutsFormat.java new file mode 100644 index 0000000..74586ba --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListPayoutsFormat.java @@ -0,0 +1,53 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListPayoutsFormat { + public static final ListPayoutsFormat JSON = new ListPayoutsFormat("json"); + public static final ListPayoutsFormat CSV = new ListPayoutsFormat("csv"); + + private final String value; + + private ListPayoutsFormat(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListPayoutsFormat for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListPayoutsFormat of(String value) { + return new ListPayoutsFormat(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListPayoutsFormat fromValue(String value) { + return value == null ? null : new ListPayoutsFormat(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListPayoutsFormat that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListPayoutsOrder.java b/src/main/java/com/sumup/sdk/models/ListPayoutsOrder.java new file mode 100644 index 0000000..23c0da2 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListPayoutsOrder.java @@ -0,0 +1,53 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListPayoutsOrder { + public static final ListPayoutsOrder DESC = new ListPayoutsOrder("desc"); + public static final ListPayoutsOrder ASC = new ListPayoutsOrder("asc"); + + private final String value; + + private ListPayoutsOrder(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListPayoutsOrder for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListPayoutsOrder of(String value) { + return new ListPayoutsOrder(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListPayoutsOrder fromValue(String value) { + return value == null ? null : new ListPayoutsOrder(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListPayoutsOrder that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListPayoutsV1Format.java b/src/main/java/com/sumup/sdk/models/ListPayoutsV1Format.java new file mode 100644 index 0000000..8c19436 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListPayoutsV1Format.java @@ -0,0 +1,53 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListPayoutsV1Format { + public static final ListPayoutsV1Format JSON = new ListPayoutsV1Format("json"); + public static final ListPayoutsV1Format CSV = new ListPayoutsV1Format("csv"); + + private final String value; + + private ListPayoutsV1Format(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListPayoutsV1Format for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListPayoutsV1Format of(String value) { + return new ListPayoutsV1Format(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListPayoutsV1Format fromValue(String value) { + return value == null ? null : new ListPayoutsV1Format(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListPayoutsV1Format that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListPayoutsV1Order.java b/src/main/java/com/sumup/sdk/models/ListPayoutsV1Order.java new file mode 100644 index 0000000..f120ea8 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListPayoutsV1Order.java @@ -0,0 +1,53 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListPayoutsV1Order { + public static final ListPayoutsV1Order DESC = new ListPayoutsV1Order("desc"); + public static final ListPayoutsV1Order ASC = new ListPayoutsV1Order("asc"); + + private final String value; + + private ListPayoutsV1Order(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListPayoutsV1Order for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListPayoutsV1Order of(String value) { + return new ListPayoutsV1Order(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListPayoutsV1Order fromValue(String value) { + return value == null ? null : new ListPayoutsV1Order(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListPayoutsV1Order that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListTransactionsOrder.java b/src/main/java/com/sumup/sdk/models/ListTransactionsOrder.java new file mode 100644 index 0000000..0f5c889 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListTransactionsOrder.java @@ -0,0 +1,53 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListTransactionsOrder { + public static final ListTransactionsOrder ASCENDING = new ListTransactionsOrder("ascending"); + public static final ListTransactionsOrder DESCENDING = new ListTransactionsOrder("descending"); + + private final String value; + + private ListTransactionsOrder(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListTransactionsOrder for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListTransactionsOrder of(String value) { + return new ListTransactionsOrder(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListTransactionsOrder fromValue(String value) { + return value == null ? null : new ListTransactionsOrder(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListTransactionsOrder that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListTransactionsStatusesItem.java b/src/main/java/com/sumup/sdk/models/ListTransactionsStatusesItem.java new file mode 100644 index 0000000..b2af6c0 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListTransactionsStatusesItem.java @@ -0,0 +1,61 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListTransactionsStatusesItem { + public static final ListTransactionsStatusesItem SUCCESSFUL = + new ListTransactionsStatusesItem("SUCCESSFUL"); + public static final ListTransactionsStatusesItem CANCELLED = + new ListTransactionsStatusesItem("CANCELLED"); + public static final ListTransactionsStatusesItem FAILED = + new ListTransactionsStatusesItem("FAILED"); + public static final ListTransactionsStatusesItem REFUNDED = + new ListTransactionsStatusesItem("REFUNDED"); + public static final ListTransactionsStatusesItem CHARGE_BACK = + new ListTransactionsStatusesItem("CHARGE_BACK"); + + private final String value; + + private ListTransactionsStatusesItem(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListTransactionsStatusesItem for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListTransactionsStatusesItem of(String value) { + return new ListTransactionsStatusesItem(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListTransactionsStatusesItem fromValue(String value) { + return value == null ? null : new ListTransactionsStatusesItem(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListTransactionsStatusesItem that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListTransactionsTypesItem.java b/src/main/java/com/sumup/sdk/models/ListTransactionsTypesItem.java new file mode 100644 index 0000000..6ece86c --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListTransactionsTypesItem.java @@ -0,0 +1,55 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListTransactionsTypesItem { + public static final ListTransactionsTypesItem PAYMENT = new ListTransactionsTypesItem("PAYMENT"); + public static final ListTransactionsTypesItem REFUND = new ListTransactionsTypesItem("REFUND"); + public static final ListTransactionsTypesItem CHARGE_BACK = + new ListTransactionsTypesItem("CHARGE_BACK"); + + private final String value; + + private ListTransactionsTypesItem(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListTransactionsTypesItem for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListTransactionsTypesItem of(String value) { + return new ListTransactionsTypesItem(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListTransactionsTypesItem fromValue(String value) { + return value == null ? null : new ListTransactionsTypesItem(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListTransactionsTypesItem that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListTransactionsV21Order.java b/src/main/java/com/sumup/sdk/models/ListTransactionsV21Order.java new file mode 100644 index 0000000..997a61c --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListTransactionsV21Order.java @@ -0,0 +1,55 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListTransactionsV21Order { + public static final ListTransactionsV21Order ASCENDING = + new ListTransactionsV21Order("ascending"); + public static final ListTransactionsV21Order DESCENDING = + new ListTransactionsV21Order("descending"); + + private final String value; + + private ListTransactionsV21Order(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListTransactionsV21Order for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListTransactionsV21Order of(String value) { + return new ListTransactionsV21Order(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListTransactionsV21Order fromValue(String value) { + return value == null ? null : new ListTransactionsV21Order(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListTransactionsV21Order that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListTransactionsV21StatusesItem.java b/src/main/java/com/sumup/sdk/models/ListTransactionsV21StatusesItem.java new file mode 100644 index 0000000..e034709 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListTransactionsV21StatusesItem.java @@ -0,0 +1,61 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListTransactionsV21StatusesItem { + public static final ListTransactionsV21StatusesItem SUCCESSFUL = + new ListTransactionsV21StatusesItem("SUCCESSFUL"); + public static final ListTransactionsV21StatusesItem CANCELLED = + new ListTransactionsV21StatusesItem("CANCELLED"); + public static final ListTransactionsV21StatusesItem FAILED = + new ListTransactionsV21StatusesItem("FAILED"); + public static final ListTransactionsV21StatusesItem REFUNDED = + new ListTransactionsV21StatusesItem("REFUNDED"); + public static final ListTransactionsV21StatusesItem CHARGE_BACK = + new ListTransactionsV21StatusesItem("CHARGE_BACK"); + + private final String value; + + private ListTransactionsV21StatusesItem(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListTransactionsV21StatusesItem for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListTransactionsV21StatusesItem of(String value) { + return new ListTransactionsV21StatusesItem(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListTransactionsV21StatusesItem fromValue(String value) { + return value == null ? null : new ListTransactionsV21StatusesItem(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListTransactionsV21StatusesItem that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/ListTransactionsV21TypesItem.java b/src/main/java/com/sumup/sdk/models/ListTransactionsV21TypesItem.java new file mode 100644 index 0000000..e6e3c67 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/ListTransactionsV21TypesItem.java @@ -0,0 +1,57 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +public final class ListTransactionsV21TypesItem { + public static final ListTransactionsV21TypesItem PAYMENT = + new ListTransactionsV21TypesItem("PAYMENT"); + public static final ListTransactionsV21TypesItem REFUND = + new ListTransactionsV21TypesItem("REFUND"); + public static final ListTransactionsV21TypesItem CHARGE_BACK = + new ListTransactionsV21TypesItem("CHARGE_BACK"); + + private final String value; + + private ListTransactionsV21TypesItem(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ListTransactionsV21TypesItem for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ListTransactionsV21TypesItem of(String value) { + return new ListTransactionsV21TypesItem(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static ListTransactionsV21TypesItem fromValue(String value) { + return value == null ? null : new ListTransactionsV21TypesItem(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ListTransactionsV21TypesItem that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/MandatePayloadType.java b/src/main/java/com/sumup/sdk/models/MandatePayloadType.java index d546763..6ea55a9 100644 --- a/src/main/java/com/sumup/sdk/models/MandatePayloadType.java +++ b/src/main/java/com/sumup/sdk/models/MandatePayloadType.java @@ -3,15 +3,26 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Type of mandate to create for the saved payment instrument. */ -public enum MandatePayloadType { - RECURRENT("recurrent"); +public final class MandatePayloadType { + public static final MandatePayloadType RECURRENT = new MandatePayloadType("recurrent"); private final String value; - MandatePayloadType(String value) { - this.value = value; + private MandatePayloadType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a MandatePayloadType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static MandatePayloadType of(String value) { + return new MandatePayloadType(value); } @JsonValue @@ -26,14 +37,17 @@ public String toString() { @JsonCreator public static MandatePayloadType fromValue(String value) { - if (value == null) { - return null; - } - for (MandatePayloadType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown MandatePayloadType value: " + value); + return value == null ? null : new MandatePayloadType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof MandatePayloadType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/MandateResponseStatus.java b/src/main/java/com/sumup/sdk/models/MandateResponseStatus.java index e43f38c..9a9064b 100644 --- a/src/main/java/com/sumup/sdk/models/MandateResponseStatus.java +++ b/src/main/java/com/sumup/sdk/models/MandateResponseStatus.java @@ -3,16 +3,27 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Current lifecycle status of the mandate. */ -public enum MandateResponseStatus { - ACTIVE("active"), - INACTIVE("inactive"); +public final class MandateResponseStatus { + public static final MandateResponseStatus ACTIVE = new MandateResponseStatus("active"); + public static final MandateResponseStatus INACTIVE = new MandateResponseStatus("inactive"); private final String value; - MandateResponseStatus(String value) { - this.value = value; + private MandateResponseStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a MandateResponseStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static MandateResponseStatus of(String value) { + return new MandateResponseStatus(value); } @JsonValue @@ -27,14 +38,17 @@ public String toString() { @JsonCreator public static MandateResponseStatus fromValue(String value) { - if (value == null) { - return null; - } - for (MandateResponseStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown MandateResponseStatus value: " + value); + return value == null ? null : new MandateResponseStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof MandateResponseStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/MembershipStatus.java b/src/main/java/com/sumup/sdk/models/MembershipStatus.java index 59a8626..7a80cf4 100644 --- a/src/main/java/com/sumup/sdk/models/MembershipStatus.java +++ b/src/main/java/com/sumup/sdk/models/MembershipStatus.java @@ -3,19 +3,30 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** The status of the membership. */ -public enum MembershipStatus { - ACCEPTED("accepted"), - PENDING("pending"), - EXPIRED("expired"), - DISABLED("disabled"), - UNKNOWN("unknown"); +public final class MembershipStatus { + public static final MembershipStatus ACCEPTED = new MembershipStatus("accepted"); + public static final MembershipStatus PENDING = new MembershipStatus("pending"); + public static final MembershipStatus EXPIRED = new MembershipStatus("expired"); + public static final MembershipStatus DISABLED = new MembershipStatus("disabled"); + public static final MembershipStatus UNKNOWN = new MembershipStatus("unknown"); private final String value; - MembershipStatus(String value) { - this.value = value; + private MembershipStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a MembershipStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static MembershipStatus of(String value) { + return new MembershipStatus(value); } @JsonValue @@ -30,14 +41,17 @@ public String toString() { @JsonCreator public static MembershipStatus fromValue(String value) { - if (value == null) { - return null; - } - for (MembershipStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown MembershipStatus value: " + value); + return value == null ? null : new MembershipStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof MembershipStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/Merchant.java b/src/main/java/com/sumup/sdk/models/Merchant.java index 1456acb..ee9d77a 100644 --- a/src/main/java/com/sumup/sdk/models/Merchant.java +++ b/src/main/java/com/sumup/sdk/models/Merchant.java @@ -1,4 +1,314 @@ // Code generated by sumup-java/codegen. DO NOT EDIT. package com.sumup.sdk.models; -public record Merchant(com.sumup.sdk.models.Merchant2 value) {} +import java.util.Objects; + +public record Merchant( + /** + * A user-facing name of the merchant account for use in dashboards and other user-facing + * applications. For customer-facing business name see `merchant.business_profile`. + */ + String alias, + + /** + * A user-facing small-format logo for use in dashboards and other user-facing applications. For + * customer-facing branding see `merchant.business_profile.branding`. + */ + String avatar, + + /** + * Business information about the merchant. This information will be visible to the merchant's + * customers. + */ + com.sumup.sdk.models.BusinessProfile businessProfile, + + /** + * The business type. * `sole_trader`: The business is run by an self-employed individual. * + * `company`: The business is run as a company with one or more shareholders * `partnership`: + * The business is run as a company with two or more shareholders that can be also other legal + * entities * `non_profit`: The business is run as a nonprofit organization that operates for + * public or social benefit * `government_entity`: The business is state owned and operated + */ + String businessType, + + /** + * Reflects the status of changes submitted through the `PATCH` endpoints for the merchant or + * persons. If some changes have not been applied yet, the status will be `pending`. If all + * changes have been applied, the status `done`. The status is only returned after write + * operations or on read endpoints when the `version` query parameter is provided. + */ + com.sumup.sdk.models.ChangeStatus changeStatus, + com.sumup.sdk.models.ClassicMerchantIdentifiers classic, + + /** + * Information about the company or business. This is legal information that is used for + * verification. + */ + com.sumup.sdk.models.Company company, + + /** + * An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. This + * definition users `oneOf` with a two-character string type to allow for support of future + * countries in client code. + */ + com.sumup.sdk.models.CountryCode country, + + /** + * The date and time when the resource was created. This is a string as defined in [RFC 3339, + * section 5.6](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6). + */ + java.time.OffsetDateTime createdAt, + + /** + * Three-letter [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217) representing the + * default currency for the account. + */ + String defaultCurrency, + + /** + * Merchant's default locale, represented as a BCP47 + * [RFC5646](https://datatracker.ietf.org/doc/html/rfc5646) language tag. This is typically an + * ISO 639-1 Alpha-2 [ISO639‑1](https://www.iso.org/iso-639-language-code) language code in + * lowercase and an ISO 3166-1 Alpha-2 + * [ISO3166‑1](https://www.iso.org/iso-3166-country-codes.html) country code in uppercase, + * separated by a dash. For example, en-US or fr-CA. In multilingual countries this is the + * merchant's preferred locale out of those, that are officially spoken in the country. In a + * countries with a single official language this will match the official language. + */ + String defaultLocale, + + /** Short unique identifier for the merchant. */ + String merchantCode, + + /** + * A set of key-value pairs that you can attach to an object. This can be useful for storing + * additional information about the object in a structured format. **Warning**: Updating Meta + * will overwrite the existing data. Make sure to always include the complete JSON object. + */ + com.sumup.sdk.models.Meta meta, + + /** ID of the organization the merchant belongs to (if any). */ + String organizationId, + + /** True if the merchant is a sandbox for testing. */ + Boolean sandbox, + + /** + * The date and time when the resource was last updated. This is a string as defined in [RFC + * 3339, section 5.6](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6). + */ + java.time.OffsetDateTime updatedAt, + + /** + * The version of the resource. The version reflects a specific change submitted to the API via + * one of the `PATCH` endpoints. + */ + com.sumup.sdk.models.Version version) { + /** + * Creates a builder for Merchant. + * + * @return Builder that constructs immutable Merchant instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for Merchant instances. */ + public static final class Builder { + private String alias; + private String avatar; + private com.sumup.sdk.models.BusinessProfile businessProfile; + private String businessType; + private com.sumup.sdk.models.ClassicMerchantIdentifiers classic; + private com.sumup.sdk.models.Company company; + private com.sumup.sdk.models.CountryCode country; + private String defaultLocale; + private com.sumup.sdk.models.Meta meta; + private String organizationId; + private Boolean sandbox; + private com.sumup.sdk.models.Version version; + + private Builder() {} + + /** + * Sets the value for {@code alias}. + * + * @param alias A user-facing name of the merchant account for use in dashboards and other + * user-facing applications. For customer-facing business name see + * `merchant.business_profile`. + * @return This builder instance. + */ + public Builder alias(String alias) { + this.alias = alias; + return this; + } + + /** + * Sets the value for {@code avatar}. + * + * @param avatar A user-facing small-format logo for use in dashboards and other user-facing + * applications. For customer-facing branding see `merchant.business_profile.branding`. + * @return This builder instance. + */ + public Builder avatar(String avatar) { + this.avatar = avatar; + return this; + } + + /** + * Sets the value for {@code businessProfile}. + * + * @param businessProfile Business information about the merchant. This information will be + * visible to the merchant's customers. + * @return This builder instance. + */ + public Builder businessProfile(com.sumup.sdk.models.BusinessProfile businessProfile) { + this.businessProfile = businessProfile; + return this; + } + + /** + * Sets the value for {@code businessType}. + * + * @param businessType The business type. * `sole_trader`: The business is run by an + * self-employed individual. * `company`: The business is run as a company with one or more + * shareholders * `partnership`: The business is run as a company with two or more + * shareholders that can be also other legal entities * `non_profit`: The business is run as + * a nonprofit organization that operates for public or social benefit * + * `government_entity`: The business is state owned and operated + * @return This builder instance. + */ + public Builder businessType(String businessType) { + this.businessType = businessType; + return this; + } + + /** + * Sets the value for {@code classic}. + * + * @param classic Value for the classic field. + * @return This builder instance. + */ + public Builder classic(com.sumup.sdk.models.ClassicMerchantIdentifiers classic) { + this.classic = classic; + return this; + } + + /** + * Sets the value for {@code company}. + * + * @param company Information about the company or business. This is legal information that is + * used for verification. + * @return This builder instance. + */ + public Builder company(com.sumup.sdk.models.Company company) { + this.company = company; + return this; + } + + /** + * Sets the value for {@code country}. + * + * @param country An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * country code. This definition users `oneOf` with a two-character string type to allow for + * support of future countries in client code. + * @return This builder instance. + */ + public Builder country(com.sumup.sdk.models.CountryCode country) { + this.country = country; + return this; + } + + /** + * Sets the value for {@code defaultLocale}. + * + * @param defaultLocale Merchant's default locale, represented as a BCP47 + * [RFC5646](https://datatracker.ietf.org/doc/html/rfc5646) language tag. This is typically + * an ISO 639-1 Alpha-2 [ISO639‑1](https://www.iso.org/iso-639-language-code) language code + * in lowercase and an ISO 3166-1 Alpha-2 + * [ISO3166‑1](https://www.iso.org/iso-3166-country-codes.html) country code in uppercase, + * separated by a dash. For example, en-US or fr-CA. In multilingual countries this is the + * merchant's preferred locale out of those, that are officially spoken in the country. In a + * countries with a single official language this will match the official language. + * @return This builder instance. + */ + public Builder defaultLocale(String defaultLocale) { + this.defaultLocale = defaultLocale; + return this; + } + + /** + * Sets the value for {@code meta}. + * + * @param meta A set of key-value pairs that you can attach to an object. This can be useful for + * storing additional information about the object in a structured format. **Warning**: + * Updating Meta will overwrite the existing data. Make sure to always include the complete + * JSON object. + * @return This builder instance. + */ + public Builder meta(com.sumup.sdk.models.Meta meta) { + this.meta = meta; + return this; + } + + /** + * Sets the value for {@code organizationId}. + * + * @param organizationId ID of the organization the merchant belongs to (if any). + * @return This builder instance. + */ + public Builder organizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + /** + * Sets the value for {@code sandbox}. + * + * @param sandbox True if the merchant is a sandbox for testing. + * @return This builder instance. + */ + public Builder sandbox(Boolean sandbox) { + this.sandbox = sandbox; + return this; + } + + /** + * Sets the value for {@code version}. + * + * @param version The version of the resource. The version reflects a specific change submitted + * to the API via one of the `PATCH` endpoints. + * @return This builder instance. + */ + public Builder version(com.sumup.sdk.models.Version version) { + this.version = version; + return this; + } + + /** + * Builds an immutable Merchant instance. + * + * @return Immutable Merchant. + */ + public Merchant build() { + return new Merchant( + alias, + avatar, + businessProfile, + businessType, + null, + classic, + company, + Objects.requireNonNull(country, "country"), + null, + null, + Objects.requireNonNull(defaultLocale, "defaultLocale"), + null, + meta, + organizationId, + sandbox, + null, + version); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/Merchant2.java b/src/main/java/com/sumup/sdk/models/Merchant2.java deleted file mode 100644 index 4e2d0a9..0000000 --- a/src/main/java/com/sumup/sdk/models/Merchant2.java +++ /dev/null @@ -1,300 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import java.util.Objects; - -public record Merchant2( - /** - * A user-facing name of the merchant account for use in dashboards and other user-facing - * applications. For customer-facing business name see `merchant.business_profile`. - */ - String alias, - - /** - * A user-facing small-format logo for use in dashboards and other user-facing applications. For - * customer-facing branding see `merchant.business_profile.branding`. - */ - String avatar, - - /** - * Business information about the merchant. This information will be visible to the merchant's - * customers. - */ - com.sumup.sdk.models.BusinessProfile businessProfile, - - /** - * The business type. * `sole_trader`: The business is run by an self-employed individual. * - * `company`: The business is run as a company with one or more shareholders * `partnership`: - * The business is run as a company with two or more shareholders that can be also other legal - * entities * `non_profit`: The business is run as a nonprofit organization that operates for - * public or social benefit * `government_entity`: The business is state owned and operated - */ - String businessType, - - /** - * Reflects the status of changes submitted through the `PATCH` endpoints for the merchant or - * persons. If some changes have not been applied yet, the status will be `pending`. If all - * changes have been applied, the status `done`. The status is only returned after write - * operations or on read endpoints when the `version` query parameter is provided. - */ - com.sumup.sdk.models.ChangeStatus changeStatus, - com.sumup.sdk.models.ClassicMerchantIdentifiers classic, - - /** - * Information about the company or business. This is legal information that is used for - * verification. - */ - com.sumup.sdk.models.Company company, - - /** - * An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. This - * definition users `oneOf` with a two-character string type to allow for support of future - * countries in client code. - */ - com.sumup.sdk.models.CountryCode country, - - /** - * Three-letter [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217) representing the - * default currency for the account. - */ - String defaultCurrency, - - /** - * Merchant's default locale, represented as a BCP47 - * [RFC5646](https://datatracker.ietf.org/doc/html/rfc5646) language tag. This is typically an - * ISO 639-1 Alpha-2 [ISO639‑1](https://www.iso.org/iso-639-language-code) language code in - * lowercase and an ISO 3166-1 Alpha-2 - * [ISO3166‑1](https://www.iso.org/iso-3166-country-codes.html) country code in uppercase, - * separated by a dash. For example, en-US or fr-CA. In multilingual countries this is the - * merchant's preferred locale out of those, that are officially spoken in the country. In a - * countries with a single official language this will match the official language. - */ - String defaultLocale, - - /** Short unique identifier for the merchant. */ - String merchantCode, - - /** - * A set of key-value pairs that you can attach to an object. This can be useful for storing - * additional information about the object in a structured format. **Warning**: Updating Meta - * will overwrite the existing data. Make sure to always include the complete JSON object. - */ - com.sumup.sdk.models.Meta meta, - - /** ID of the organization the merchant belongs to (if any). */ - String organizationId, - - /** True if the merchant is a sandbox for testing. */ - Boolean sandbox, - - /** - * The version of the resource. The version reflects a specific change submitted to the API via - * one of the `PATCH` endpoints. - */ - com.sumup.sdk.models.Version version) { - /** - * Creates a builder for Merchant2. - * - * @return Builder that constructs immutable Merchant2 instances. - */ - public static Builder builder() { - return new Builder(); - } - - /** Builder for Merchant2 instances. */ - public static final class Builder { - private String alias; - private String avatar; - private com.sumup.sdk.models.BusinessProfile businessProfile; - private String businessType; - private com.sumup.sdk.models.ClassicMerchantIdentifiers classic; - private com.sumup.sdk.models.Company company; - private com.sumup.sdk.models.CountryCode country; - private String defaultLocale; - private com.sumup.sdk.models.Meta meta; - private String organizationId; - private Boolean sandbox; - private com.sumup.sdk.models.Version version; - - private Builder() {} - - /** - * Sets the value for {@code alias}. - * - * @param alias A user-facing name of the merchant account for use in dashboards and other - * user-facing applications. For customer-facing business name see - * `merchant.business_profile`. - * @return This builder instance. - */ - public Builder alias(String alias) { - this.alias = alias; - return this; - } - - /** - * Sets the value for {@code avatar}. - * - * @param avatar A user-facing small-format logo for use in dashboards and other user-facing - * applications. For customer-facing branding see `merchant.business_profile.branding`. - * @return This builder instance. - */ - public Builder avatar(String avatar) { - this.avatar = avatar; - return this; - } - - /** - * Sets the value for {@code businessProfile}. - * - * @param businessProfile Business information about the merchant. This information will be - * visible to the merchant's customers. - * @return This builder instance. - */ - public Builder businessProfile(com.sumup.sdk.models.BusinessProfile businessProfile) { - this.businessProfile = businessProfile; - return this; - } - - /** - * Sets the value for {@code businessType}. - * - * @param businessType The business type. * `sole_trader`: The business is run by an - * self-employed individual. * `company`: The business is run as a company with one or more - * shareholders * `partnership`: The business is run as a company with two or more - * shareholders that can be also other legal entities * `non_profit`: The business is run as - * a nonprofit organization that operates for public or social benefit * - * `government_entity`: The business is state owned and operated - * @return This builder instance. - */ - public Builder businessType(String businessType) { - this.businessType = businessType; - return this; - } - - /** - * Sets the value for {@code classic}. - * - * @param classic Value for the classic field. - * @return This builder instance. - */ - public Builder classic(com.sumup.sdk.models.ClassicMerchantIdentifiers classic) { - this.classic = classic; - return this; - } - - /** - * Sets the value for {@code company}. - * - * @param company Information about the company or business. This is legal information that is - * used for verification. - * @return This builder instance. - */ - public Builder company(com.sumup.sdk.models.Company company) { - this.company = company; - return this; - } - - /** - * Sets the value for {@code country}. - * - * @param country An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) - * country code. This definition users `oneOf` with a two-character string type to allow for - * support of future countries in client code. - * @return This builder instance. - */ - public Builder country(com.sumup.sdk.models.CountryCode country) { - this.country = country; - return this; - } - - /** - * Sets the value for {@code defaultLocale}. - * - * @param defaultLocale Merchant's default locale, represented as a BCP47 - * [RFC5646](https://datatracker.ietf.org/doc/html/rfc5646) language tag. This is typically - * an ISO 639-1 Alpha-2 [ISO639‑1](https://www.iso.org/iso-639-language-code) language code - * in lowercase and an ISO 3166-1 Alpha-2 - * [ISO3166‑1](https://www.iso.org/iso-3166-country-codes.html) country code in uppercase, - * separated by a dash. For example, en-US or fr-CA. In multilingual countries this is the - * merchant's preferred locale out of those, that are officially spoken in the country. In a - * countries with a single official language this will match the official language. - * @return This builder instance. - */ - public Builder defaultLocale(String defaultLocale) { - this.defaultLocale = defaultLocale; - return this; - } - - /** - * Sets the value for {@code meta}. - * - * @param meta A set of key-value pairs that you can attach to an object. This can be useful for - * storing additional information about the object in a structured format. **Warning**: - * Updating Meta will overwrite the existing data. Make sure to always include the complete - * JSON object. - * @return This builder instance. - */ - public Builder meta(com.sumup.sdk.models.Meta meta) { - this.meta = meta; - return this; - } - - /** - * Sets the value for {@code organizationId}. - * - * @param organizationId ID of the organization the merchant belongs to (if any). - * @return This builder instance. - */ - public Builder organizationId(String organizationId) { - this.organizationId = organizationId; - return this; - } - - /** - * Sets the value for {@code sandbox}. - * - * @param sandbox True if the merchant is a sandbox for testing. - * @return This builder instance. - */ - public Builder sandbox(Boolean sandbox) { - this.sandbox = sandbox; - return this; - } - - /** - * Sets the value for {@code version}. - * - * @param version The version of the resource. The version reflects a specific change submitted - * to the API via one of the `PATCH` endpoints. - * @return This builder instance. - */ - public Builder version(com.sumup.sdk.models.Version version) { - this.version = version; - return this; - } - - /** - * Builds an immutable Merchant2 instance. - * - * @return Immutable Merchant2. - */ - public Merchant2 build() { - return new Merchant2( - alias, - avatar, - businessProfile, - businessType, - null, - classic, - company, - Objects.requireNonNull(country, "country"), - null, - Objects.requireNonNull(defaultLocale, "defaultLocale"), - null, - meta, - organizationId, - sandbox, - version); - } - } -} diff --git a/src/main/java/com/sumup/sdk/models/OperatorAccountType.java b/src/main/java/com/sumup/sdk/models/OperatorAccountType.java index e3094ce..b7cf2ab 100644 --- a/src/main/java/com/sumup/sdk/models/OperatorAccountType.java +++ b/src/main/java/com/sumup/sdk/models/OperatorAccountType.java @@ -3,15 +3,26 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; -public enum OperatorAccountType { - OPERATOR("operator"), - NORMAL("normal"); +public final class OperatorAccountType { + public static final OperatorAccountType OPERATOR = new OperatorAccountType("operator"); + public static final OperatorAccountType NORMAL = new OperatorAccountType("normal"); private final String value; - OperatorAccountType(String value) { - this.value = value; + private OperatorAccountType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a OperatorAccountType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static OperatorAccountType of(String value) { + return new OperatorAccountType(value); } @JsonValue @@ -26,14 +37,17 @@ public String toString() { @JsonCreator public static OperatorAccountType fromValue(String value) { - if (value == null) { - return null; - } - for (OperatorAccountType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown OperatorAccountType value: " + value); + return value == null ? null : new OperatorAccountType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof OperatorAccountType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/Order.java b/src/main/java/com/sumup/sdk/models/Order.java deleted file mode 100644 index 90cfb2e..0000000 --- a/src/main/java/com/sumup/sdk/models/Order.java +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum Order { - ASCENDING("ascending"), - DESCENDING("descending"); - - private final String value; - - Order(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - - @JsonCreator - public static Order fromValue(String value) { - if (value == null) { - return null; - } - for (Order entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown Order value: " + value); - } -} diff --git a/src/main/java/com/sumup/sdk/models/Order2.java b/src/main/java/com/sumup/sdk/models/Order2.java deleted file mode 100644 index 168cae3..0000000 --- a/src/main/java/com/sumup/sdk/models/Order2.java +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum Order2 { - DESC("desc"), - ASC("asc"); - - private final String value; - - Order2(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - - @JsonCreator - public static Order2 fromValue(String value) { - if (value == null) { - return null; - } - for (Order2 entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown Order2 value: " + value); - } -} diff --git a/src/main/java/com/sumup/sdk/models/PaymentInstrumentResponseType.java b/src/main/java/com/sumup/sdk/models/PaymentInstrumentResponseType.java index 2115b54..ab99d9a 100644 --- a/src/main/java/com/sumup/sdk/models/PaymentInstrumentResponseType.java +++ b/src/main/java/com/sumup/sdk/models/PaymentInstrumentResponseType.java @@ -3,15 +3,27 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Type of the payment instrument. */ -public enum PaymentInstrumentResponseType { - CARD("card"); +public final class PaymentInstrumentResponseType { + public static final PaymentInstrumentResponseType CARD = + new PaymentInstrumentResponseType("card"); private final String value; - PaymentInstrumentResponseType(String value) { - this.value = value; + private PaymentInstrumentResponseType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a PaymentInstrumentResponseType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static PaymentInstrumentResponseType of(String value) { + return new PaymentInstrumentResponseType(value); } @JsonValue @@ -26,14 +38,17 @@ public String toString() { @JsonCreator public static PaymentInstrumentResponseType fromValue(String value) { - if (value == null) { - return null; - } - for (PaymentInstrumentResponseType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown PaymentInstrumentResponseType value: " + value); + return value == null ? null : new PaymentInstrumentResponseType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof PaymentInstrumentResponseType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/PaymentType.java b/src/main/java/com/sumup/sdk/models/PaymentType.java index 2a4a3b9..accb48a 100644 --- a/src/main/java/com/sumup/sdk/models/PaymentType.java +++ b/src/main/java/com/sumup/sdk/models/PaymentType.java @@ -3,25 +3,36 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Payment type used for the transaction. */ -public enum PaymentType { - CASH("CASH"), - POS("POS"), - ECOM("ECOM"), - RECURRING("RECURRING"), - BITCOIN("BITCOIN"), - BALANCE("BALANCE"), - MOTO("MOTO"), - BOLETO("BOLETO"), - DIRECT_DEBIT("DIRECT_DEBIT"), - APM("APM"), - UNKNOWN("UNKNOWN"); +public final class PaymentType { + public static final PaymentType CASH = new PaymentType("CASH"); + public static final PaymentType POS = new PaymentType("POS"); + public static final PaymentType ECOM = new PaymentType("ECOM"); + public static final PaymentType RECURRING = new PaymentType("RECURRING"); + public static final PaymentType BITCOIN = new PaymentType("BITCOIN"); + public static final PaymentType BALANCE = new PaymentType("BALANCE"); + public static final PaymentType MOTO = new PaymentType("MOTO"); + public static final PaymentType BOLETO = new PaymentType("BOLETO"); + public static final PaymentType DIRECT_DEBIT = new PaymentType("DIRECT_DEBIT"); + public static final PaymentType APM = new PaymentType("APM"); + public static final PaymentType UNKNOWN = new PaymentType("UNKNOWN"); private final String value; - PaymentType(String value) { - this.value = value; + private PaymentType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a PaymentType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static PaymentType of(String value) { + return new PaymentType(value); } @JsonValue @@ -36,14 +47,16 @@ public String toString() { @JsonCreator public static PaymentType fromValue(String value) { - if (value == null) { - return null; - } - for (PaymentType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown PaymentType value: " + value); + return value == null ? null : new PaymentType(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof PaymentType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/Person.java b/src/main/java/com/sumup/sdk/models/Person.java index 671779b..3e3982c 100644 --- a/src/main/java/com/sumup/sdk/models/Person.java +++ b/src/main/java/com/sumup/sdk/models/Person.java @@ -1,4 +1,311 @@ // Code generated by sumup-java/codegen. DO NOT EDIT. package com.sumup.sdk.models; -public record Person(com.sumup.sdk.models.BasePerson value) {} +public record Person( + /** + * An address somewhere in the world. The address fields used depend on the country conventions. + * For example, in Great Britain, `city` is `post_town`. In the United States, the top-level + * administrative unit used in addresses is `state`, whereas in Chile it's `region`. Whether an + * address is valid or not depends on whether the locally required fields are present. Fields + * not supported in a country will be ignored. + */ + com.sumup.sdk.models.Address address, + + /** + * The date of birth of the individual, represented as an ISO 8601:2004 [ISO8601‑2004] + * YYYY-MM-DD format. + */ + java.time.LocalDate birthdate, + + /** + * Reflects the status of changes submitted through the `PATCH` endpoints for the merchant or + * persons. If some changes have not been applied yet, the status will be `pending`. If all + * changes have been applied, the status `done`. The status is only returned after write + * operations or on read endpoints when the `version` query parameter is provided. + */ + com.sumup.sdk.models.ChangeStatus changeStatus, + + /** + * An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. This + * definition users `oneOf` with a two-character string type to allow for support of future + * countries in client code. + */ + com.sumup.sdk.models.CountryCode citizenship, + + /** + * An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code + * representing the country where the person resides. + */ + String countryOfResidence, + + /** The last name(s) of the individual. */ + String familyName, + + /** The first name(s) of the individual. */ + String givenName, + + /** + * The unique identifier for the person. This is a [typeid](https://github.com/sumup/typeid). + */ + String id, + + /** A list of country-specific personal identifiers. */ + java.util.List identifiers, + + /** + * Middle name(s) of the End-User. Note that in some cultures, people can have multiple middle + * names; all can be present, with the names being separated by space characters. Also note that + * in some cultures, middle names are not used. + */ + String middleName, + + /** + * The persons nationality. May be an [ISO3166-1 + * alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code, but legacy data may + * not conform to this standard. + */ + String nationality, + com.sumup.sdk.models.Ownership ownership, + + /** A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format. */ + com.sumup.sdk.models.PhoneNumber phoneNumber, + + /** + * A list of roles the person has in the merchant or towards SumUp. A merchant must have at + * least one person with the relationship `representative`. + */ + java.util.List relationships, + + /** A corresponding identity user ID for the person, if they have a user account. */ + String userId, + + /** + * The version of the resource. The version reflects a specific change submitted to the API via + * one of the `PATCH` endpoints. + */ + com.sumup.sdk.models.Version version) { + /** + * Creates a builder for Person. + * + * @return Builder that constructs immutable Person instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for Person instances. */ + public static final class Builder { + private com.sumup.sdk.models.Address address; + private java.time.LocalDate birthdate; + private com.sumup.sdk.models.CountryCode citizenship; + private String countryOfResidence; + private String familyName; + private String givenName; + private java.util.List identifiers; + private String middleName; + private String nationality; + private com.sumup.sdk.models.Ownership ownership; + private com.sumup.sdk.models.PhoneNumber phoneNumber; + private java.util.List relationships; + private String userId; + private com.sumup.sdk.models.Version version; + + private Builder() {} + + /** + * Sets the value for {@code address}. + * + * @param address An address somewhere in the world. The address fields used depend on the + * country conventions. For example, in Great Britain, `city` is `post_town`. In the United + * States, the top-level administrative unit used in addresses is `state`, whereas in Chile + * it's `region`. Whether an address is valid or not depends on whether the locally required + * fields are present. Fields not supported in a country will be ignored. + * @return This builder instance. + */ + public Builder address(com.sumup.sdk.models.Address address) { + this.address = address; + return this; + } + + /** + * Sets the value for {@code birthdate}. + * + * @param birthdate The date of birth of the individual, represented as an ISO 8601:2004 + * [ISO8601‑2004] YYYY-MM-DD format. + * @return This builder instance. + */ + public Builder birthdate(java.time.LocalDate birthdate) { + this.birthdate = birthdate; + return this; + } + + /** + * Sets the value for {@code citizenship}. + * + * @param citizenship An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) + * country code. This definition users `oneOf` with a two-character string type to allow for + * support of future countries in client code. + * @return This builder instance. + */ + public Builder citizenship(com.sumup.sdk.models.CountryCode citizenship) { + this.citizenship = citizenship; + return this; + } + + /** + * Sets the value for {@code countryOfResidence}. + * + * @param countryOfResidence An [ISO3166-1 + * alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code representing the + * country where the person resides. + * @return This builder instance. + */ + public Builder countryOfResidence(String countryOfResidence) { + this.countryOfResidence = countryOfResidence; + return this; + } + + /** + * Sets the value for {@code familyName}. + * + * @param familyName The last name(s) of the individual. + * @return This builder instance. + */ + public Builder familyName(String familyName) { + this.familyName = familyName; + return this; + } + + /** + * Sets the value for {@code givenName}. + * + * @param givenName The first name(s) of the individual. + * @return This builder instance. + */ + public Builder givenName(String givenName) { + this.givenName = givenName; + return this; + } + + /** + * Sets the value for {@code identifiers}. + * + * @param identifiers A list of country-specific personal identifiers. + * @return This builder instance. + */ + public Builder identifiers( + java.util.List identifiers) { + this.identifiers = identifiers; + return this; + } + + /** + * Sets the value for {@code middleName}. + * + * @param middleName Middle name(s) of the End-User. Note that in some cultures, people can have + * multiple middle names; all can be present, with the names being separated by space + * characters. Also note that in some cultures, middle names are not used. + * @return This builder instance. + */ + public Builder middleName(String middleName) { + this.middleName = middleName; + return this; + } + + /** + * Sets the value for {@code nationality}. + * + * @param nationality The persons nationality. May be an [ISO3166-1 + * alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code, but legacy data + * may not conform to this standard. + * @return This builder instance. + */ + public Builder nationality(String nationality) { + this.nationality = nationality; + return this; + } + + /** + * Sets the value for {@code ownership}. + * + * @param ownership Value for the ownership field. + * @return This builder instance. + */ + public Builder ownership(com.sumup.sdk.models.Ownership ownership) { + this.ownership = ownership; + return this; + } + + /** + * Sets the value for {@code phoneNumber}. + * + * @param phoneNumber A publicly available phone number in + * [E.164](https://en.wikipedia.org/wiki/E.164) format. + * @return This builder instance. + */ + public Builder phoneNumber(com.sumup.sdk.models.PhoneNumber phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + /** + * Sets the value for {@code relationships}. + * + * @param relationships A list of roles the person has in the merchant or towards SumUp. A + * merchant must have at least one person with the relationship `representative`. + * @return This builder instance. + */ + public Builder relationships(java.util.List relationships) { + this.relationships = relationships; + return this; + } + + /** + * Sets the value for {@code userId}. + * + * @param userId A corresponding identity user ID for the person, if they have a user account. + * @return This builder instance. + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + + /** + * Sets the value for {@code version}. + * + * @param version The version of the resource. The version reflects a specific change submitted + * to the API via one of the `PATCH` endpoints. + * @return This builder instance. + */ + public Builder version(com.sumup.sdk.models.Version version) { + this.version = version; + return this; + } + + /** + * Builds an immutable Person instance. + * + * @return Immutable Person. + */ + public Person build() { + return new Person( + address, + birthdate, + null, + citizenship, + countryOfResidence, + familyName, + givenName, + null, + identifiers, + middleName, + nationality, + ownership, + phoneNumber, + relationships, + userId, + version); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/ProcessCheckoutPaymentType.java b/src/main/java/com/sumup/sdk/models/ProcessCheckoutPaymentType.java index 8a1e680..5d2713d 100644 --- a/src/main/java/com/sumup/sdk/models/ProcessCheckoutPaymentType.java +++ b/src/main/java/com/sumup/sdk/models/ProcessCheckoutPaymentType.java @@ -3,24 +3,38 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** * Payment method used for this processing attempt. It determines which additional request fields * are required. */ -public enum ProcessCheckoutPaymentType { - CARD("card"), - BOLETO("boleto"), - IDEAL("ideal"), - BLIK("blik"), - BANCONTACT("bancontact"), - GOOGLE_PAY("google_pay"), - APPLE_PAY("apple_pay"); +public final class ProcessCheckoutPaymentType { + public static final ProcessCheckoutPaymentType CARD = new ProcessCheckoutPaymentType("card"); + public static final ProcessCheckoutPaymentType BOLETO = new ProcessCheckoutPaymentType("boleto"); + public static final ProcessCheckoutPaymentType IDEAL = new ProcessCheckoutPaymentType("ideal"); + public static final ProcessCheckoutPaymentType BLIK = new ProcessCheckoutPaymentType("blik"); + public static final ProcessCheckoutPaymentType BANCONTACT = + new ProcessCheckoutPaymentType("bancontact"); + public static final ProcessCheckoutPaymentType GOOGLE_PAY = + new ProcessCheckoutPaymentType("google_pay"); + public static final ProcessCheckoutPaymentType APPLE_PAY = + new ProcessCheckoutPaymentType("apple_pay"); private final String value; - ProcessCheckoutPaymentType(String value) { - this.value = value; + private ProcessCheckoutPaymentType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ProcessCheckoutPaymentType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ProcessCheckoutPaymentType of(String value) { + return new ProcessCheckoutPaymentType(value); } @JsonValue @@ -35,14 +49,17 @@ public String toString() { @JsonCreator public static ProcessCheckoutPaymentType fromValue(String value) { - if (value == null) { - return null; - } - for (ProcessCheckoutPaymentType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown ProcessCheckoutPaymentType value: " + value); + return value == null ? null : new ProcessCheckoutPaymentType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ProcessCheckoutPaymentType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/ReaderCheckoutStatusChangePayloadStatus.java b/src/main/java/com/sumup/sdk/models/ReaderCheckoutStatusChangePayloadStatus.java index b26c0d9..fe0e21c 100644 --- a/src/main/java/com/sumup/sdk/models/ReaderCheckoutStatusChangePayloadStatus.java +++ b/src/main/java/com/sumup/sdk/models/ReaderCheckoutStatusChangePayloadStatus.java @@ -3,16 +3,30 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** The current status of the transaction. */ -public enum ReaderCheckoutStatusChangePayloadStatus { - SUCCESSFUL("successful"), - FAILED("failed"); +public final class ReaderCheckoutStatusChangePayloadStatus { + public static final ReaderCheckoutStatusChangePayloadStatus SUCCESSFUL = + new ReaderCheckoutStatusChangePayloadStatus("successful"); + public static final ReaderCheckoutStatusChangePayloadStatus FAILED = + new ReaderCheckoutStatusChangePayloadStatus("failed"); private final String value; - ReaderCheckoutStatusChangePayloadStatus(String value) { - this.value = value; + private ReaderCheckoutStatusChangePayloadStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ReaderCheckoutStatusChangePayloadStatus for a value not yet known to this SDK + * version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ReaderCheckoutStatusChangePayloadStatus of(String value) { + return new ReaderCheckoutStatusChangePayloadStatus(value); } @JsonValue @@ -27,15 +41,18 @@ public String toString() { @JsonCreator public static ReaderCheckoutStatusChangePayloadStatus fromValue(String value) { - if (value == null) { - return null; - } - for (ReaderCheckoutStatusChangePayloadStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException( - "Unknown ReaderCheckoutStatusChangePayloadStatus value: " + value); + return value == null ? null : new ReaderCheckoutStatusChangePayloadStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ReaderCheckoutStatusChangePayloadStatus that + && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/ReaderDeviceModel.java b/src/main/java/com/sumup/sdk/models/ReaderDeviceModel.java index dd83b36..b00d5eb 100644 --- a/src/main/java/com/sumup/sdk/models/ReaderDeviceModel.java +++ b/src/main/java/com/sumup/sdk/models/ReaderDeviceModel.java @@ -3,16 +3,27 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Identifier of the model of the device. */ -public enum ReaderDeviceModel { - SOLO("solo"), - VIRTUAL_SOLO("virtual-solo"); +public final class ReaderDeviceModel { + public static final ReaderDeviceModel SOLO = new ReaderDeviceModel("solo"); + public static final ReaderDeviceModel VIRTUAL_SOLO = new ReaderDeviceModel("virtual-solo"); private final String value; - ReaderDeviceModel(String value) { - this.value = value; + private ReaderDeviceModel(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ReaderDeviceModel for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ReaderDeviceModel of(String value) { + return new ReaderDeviceModel(value); } @JsonValue @@ -27,14 +38,17 @@ public String toString() { @JsonCreator public static ReaderDeviceModel fromValue(String value) { - if (value == null) { - return null; - } - for (ReaderDeviceModel entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown ReaderDeviceModel value: " + value); + return value == null ? null : new ReaderDeviceModel(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ReaderDeviceModel that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/ReaderStatus.java b/src/main/java/com/sumup/sdk/models/ReaderStatus.java index bd0728e..48326da 100644 --- a/src/main/java/com/sumup/sdk/models/ReaderStatus.java +++ b/src/main/java/com/sumup/sdk/models/ReaderStatus.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** * The status of the reader object gives information about the current state of the reader. Possible @@ -11,16 +12,26 @@ * merchant account and can be used with SumUp APIs. - `expired` - The pairing is expired and no * longer usable with the account. The resource needs to get recreated. */ -public enum ReaderStatus { - UNKNOWN("unknown"), - PROCESSING("processing"), - PAIRED("paired"), - EXPIRED("expired"); +public final class ReaderStatus { + public static final ReaderStatus UNKNOWN = new ReaderStatus("unknown"); + public static final ReaderStatus PROCESSING = new ReaderStatus("processing"); + public static final ReaderStatus PAIRED = new ReaderStatus("paired"); + public static final ReaderStatus EXPIRED = new ReaderStatus("expired"); private final String value; - ReaderStatus(String value) { - this.value = value; + private ReaderStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ReaderStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ReaderStatus of(String value) { + return new ReaderStatus(value); } @JsonValue @@ -35,14 +46,16 @@ public String toString() { @JsonCreator public static ReaderStatus fromValue(String value) { - if (value == null) { - return null; - } - for (ReaderStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown ReaderStatus value: " + value); + return value == null ? null : new ReaderStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other || (other instanceof ReaderStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/ReceiptTransactionProcessAs.java b/src/main/java/com/sumup/sdk/models/ReceiptTransactionProcessAs.java index 237499f..5b20f11 100644 --- a/src/main/java/com/sumup/sdk/models/ReceiptTransactionProcessAs.java +++ b/src/main/java/com/sumup/sdk/models/ReceiptTransactionProcessAs.java @@ -3,16 +3,28 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Debit/Credit. */ -public enum ReceiptTransactionProcessAs { - CREDIT("CREDIT"), - DEBIT("DEBIT"); +public final class ReceiptTransactionProcessAs { + public static final ReceiptTransactionProcessAs CREDIT = + new ReceiptTransactionProcessAs("CREDIT"); + public static final ReceiptTransactionProcessAs DEBIT = new ReceiptTransactionProcessAs("DEBIT"); private final String value; - ReceiptTransactionProcessAs(String value) { - this.value = value; + private ReceiptTransactionProcessAs(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a ReceiptTransactionProcessAs for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static ReceiptTransactionProcessAs of(String value) { + return new ReceiptTransactionProcessAs(value); } @JsonValue @@ -27,14 +39,17 @@ public String toString() { @JsonCreator public static ReceiptTransactionProcessAs fromValue(String value) { - if (value == null) { - return null; - } - for (ReceiptTransactionProcessAs entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown ReceiptTransactionProcessAs value: " + value); + return value == null ? null : new ReceiptTransactionProcessAs(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof ReceiptTransactionProcessAs that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/StatusResponseDataConnectionType.java b/src/main/java/com/sumup/sdk/models/StatusResponseDataConnectionType.java index 263c00d..21330fb 100644 --- a/src/main/java/com/sumup/sdk/models/StatusResponseDataConnectionType.java +++ b/src/main/java/com/sumup/sdk/models/StatusResponseDataConnectionType.java @@ -3,21 +3,39 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Type of connection used by the device */ -public enum StatusResponseDataConnectionType { - BTLE("btle"), - EDGE("edge"), - GPRS("gprs"), - LTE("lte"), - UMTS("umts"), - USB("usb"), - WI_FI("Wi-Fi"); +public final class StatusResponseDataConnectionType { + public static final StatusResponseDataConnectionType BTLE = + new StatusResponseDataConnectionType("btle"); + public static final StatusResponseDataConnectionType EDGE = + new StatusResponseDataConnectionType("edge"); + public static final StatusResponseDataConnectionType GPRS = + new StatusResponseDataConnectionType("gprs"); + public static final StatusResponseDataConnectionType LTE = + new StatusResponseDataConnectionType("lte"); + public static final StatusResponseDataConnectionType UMTS = + new StatusResponseDataConnectionType("umts"); + public static final StatusResponseDataConnectionType USB = + new StatusResponseDataConnectionType("usb"); + public static final StatusResponseDataConnectionType WI_FI = + new StatusResponseDataConnectionType("Wi-Fi"); private final String value; - StatusResponseDataConnectionType(String value) { - this.value = value; + private StatusResponseDataConnectionType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a StatusResponseDataConnectionType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static StatusResponseDataConnectionType of(String value) { + return new StatusResponseDataConnectionType(value); } @JsonValue @@ -32,14 +50,18 @@ public String toString() { @JsonCreator public static StatusResponseDataConnectionType fromValue(String value) { - if (value == null) { - return null; - } - for (StatusResponseDataConnectionType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown StatusResponseDataConnectionType value: " + value); + return value == null ? null : new StatusResponseDataConnectionType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof StatusResponseDataConnectionType that + && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/StatusResponseDataState.java b/src/main/java/com/sumup/sdk/models/StatusResponseDataState.java index 491d370..436d82a 100644 --- a/src/main/java/com/sumup/sdk/models/StatusResponseDataState.java +++ b/src/main/java/com/sumup/sdk/models/StatusResponseDataState.java @@ -3,20 +3,36 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Latest state of the device */ -public enum StatusResponseDataState { - IDLE("IDLE"), - SELECTING_TIP("SELECTING_TIP"), - WAITING_FOR_CARD("WAITING_FOR_CARD"), - WAITING_FOR_PIN("WAITING_FOR_PIN"), - WAITING_FOR_SIGNATURE("WAITING_FOR_SIGNATURE"), - UPDATING_FIRMWARE("UPDATING_FIRMWARE"); +public final class StatusResponseDataState { + public static final StatusResponseDataState IDLE = new StatusResponseDataState("IDLE"); + public static final StatusResponseDataState SELECTING_TIP = + new StatusResponseDataState("SELECTING_TIP"); + public static final StatusResponseDataState WAITING_FOR_CARD = + new StatusResponseDataState("WAITING_FOR_CARD"); + public static final StatusResponseDataState WAITING_FOR_PIN = + new StatusResponseDataState("WAITING_FOR_PIN"); + public static final StatusResponseDataState WAITING_FOR_SIGNATURE = + new StatusResponseDataState("WAITING_FOR_SIGNATURE"); + public static final StatusResponseDataState UPDATING_FIRMWARE = + new StatusResponseDataState("UPDATING_FIRMWARE"); private final String value; - StatusResponseDataState(String value) { - this.value = value; + private StatusResponseDataState(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a StatusResponseDataState for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static StatusResponseDataState of(String value) { + return new StatusResponseDataState(value); } @JsonValue @@ -31,14 +47,17 @@ public String toString() { @JsonCreator public static StatusResponseDataState fromValue(String value) { - if (value == null) { - return null; - } - for (StatusResponseDataState entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown StatusResponseDataState value: " + value); + return value == null ? null : new StatusResponseDataState(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof StatusResponseDataState that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/StatusResponseDataStatus.java b/src/main/java/com/sumup/sdk/models/StatusResponseDataStatus.java index 76daa76..7b8387b 100644 --- a/src/main/java/com/sumup/sdk/models/StatusResponseDataStatus.java +++ b/src/main/java/com/sumup/sdk/models/StatusResponseDataStatus.java @@ -3,16 +3,27 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Status of a device */ -public enum StatusResponseDataStatus { - ONLINE("ONLINE"), - OFFLINE("OFFLINE"); +public final class StatusResponseDataStatus { + public static final StatusResponseDataStatus ONLINE = new StatusResponseDataStatus("ONLINE"); + public static final StatusResponseDataStatus OFFLINE = new StatusResponseDataStatus("OFFLINE"); private final String value; - StatusResponseDataStatus(String value) { - this.value = value; + private StatusResponseDataStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a StatusResponseDataStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static StatusResponseDataStatus of(String value) { + return new StatusResponseDataStatus(value); } @JsonValue @@ -27,14 +38,17 @@ public String toString() { @JsonCreator public static StatusResponseDataStatus fromValue(String value) { - if (value == null) { - return null; - } - for (StatusResponseDataStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown StatusResponseDataStatus value: " + value); + return value == null ? null : new StatusResponseDataStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof StatusResponseDataStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/StatusesItem.java b/src/main/java/com/sumup/sdk/models/StatusesItem.java deleted file mode 100644 index 1328611..0000000 --- a/src/main/java/com/sumup/sdk/models/StatusesItem.java +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum StatusesItem { - SUCCESSFUL("SUCCESSFUL"), - CANCELLED("CANCELLED"), - FAILED("FAILED"), - REFUNDED("REFUNDED"), - CHARGE_BACK("CHARGE_BACK"); - - private final String value; - - StatusesItem(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - - @JsonCreator - public static StatusesItem fromValue(String value) { - if (value == null) { - return null; - } - for (StatusesItem entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown StatusesItem value: " + value); - } -} diff --git a/src/main/java/com/sumup/sdk/models/StatusesItem2.java b/src/main/java/com/sumup/sdk/models/StatusesItem2.java deleted file mode 100644 index c40dc97..0000000 --- a/src/main/java/com/sumup/sdk/models/StatusesItem2.java +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum StatusesItem2 { - SUCCESSFUL("SUCCESSFUL"), - CANCELLED("CANCELLED"), - FAILED("FAILED"), - REFUNDED("REFUNDED"), - CHARGE_BACK("CHARGE_BACK"); - - private final String value; - - StatusesItem2(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - - @JsonCreator - public static StatusesItem2 fromValue(String value) { - if (value == null) { - return null; - } - for (StatusesItem2 entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown StatusesItem2 value: " + value); - } -} diff --git a/src/main/java/com/sumup/sdk/models/TransactionBaseStatus.java b/src/main/java/com/sumup/sdk/models/TransactionBaseStatus.java index 9b19c51..020d5c5 100644 --- a/src/main/java/com/sumup/sdk/models/TransactionBaseStatus.java +++ b/src/main/java/com/sumup/sdk/models/TransactionBaseStatus.java @@ -3,18 +3,29 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Current status of the transaction. */ -public enum TransactionBaseStatus { - SUCCESSFUL("SUCCESSFUL"), - CANCELLED("CANCELLED"), - FAILED("FAILED"), - PENDING("PENDING"); +public final class TransactionBaseStatus { + public static final TransactionBaseStatus SUCCESSFUL = new TransactionBaseStatus("SUCCESSFUL"); + public static final TransactionBaseStatus CANCELLED = new TransactionBaseStatus("CANCELLED"); + public static final TransactionBaseStatus FAILED = new TransactionBaseStatus("FAILED"); + public static final TransactionBaseStatus PENDING = new TransactionBaseStatus("PENDING"); private final String value; - TransactionBaseStatus(String value) { - this.value = value; + private TransactionBaseStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionBaseStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionBaseStatus of(String value) { + return new TransactionBaseStatus(value); } @JsonValue @@ -29,14 +40,17 @@ public String toString() { @JsonCreator public static TransactionBaseStatus fromValue(String value) { - if (value == null) { - return null; - } - for (TransactionBaseStatus entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown TransactionBaseStatus value: " + value); + return value == null ? null : new TransactionBaseStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionBaseStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/TransactionFull.java b/src/main/java/com/sumup/sdk/models/TransactionFull.java index cc2b736..d5c16d3 100644 --- a/src/main/java/com/sumup/sdk/models/TransactionFull.java +++ b/src/main/java/com/sumup/sdk/models/TransactionFull.java @@ -2,4 +2,762 @@ package com.sumup.sdk.models; /** Full transaction resource with checkout, payout, and event details. */ -public record TransactionFull(com.sumup.sdk.models.TransactionBase value) {} +public record TransactionFull( + /** Total amount of the transaction. */ + Float amount, + + /** + * Authorization code for the transaction sent by the payment card issuer or bank. Applicable + * only to card payments. + */ + String authCode, + + /** Details of the payment card. */ + com.sumup.sdk.models.CardResponse card, + + /** Client transaction id. */ + String clientTransactionId, + + /** + * Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the + * amount. Currently supported currency values are enumerated above. + */ + com.sumup.sdk.models.Currency currency, + + /** Details of the device used to create the transaction. */ + com.sumup.sdk.models.Device deviceInfo, + + /** Details of the ELV card account associated with the transaction. */ + com.sumup.sdk.models.ElvCardAccount elvAccount, + + /** Entry mode of the payment details. */ + com.sumup.sdk.models.EntryMode entryMode, + + /** Compact list of events related to the transaction. */ + java.util.List events, + + /** Transaction SumUp total fee amount. */ + Double feeAmount, + + /** External/foreign transaction id (passed by clients). */ + String foreignTransactionId, + + /** + * Indication of the precision of the geographical position received from the payment terminal. + */ + com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy, + + /** Unique ID of the transaction. */ + String id, + + /** Current number of the installment for deferred payments. */ + Long installmentsCount, + + /** + * Latitude value from the coordinates of the payment location (as received from the payment + * terminal reader). + */ + com.sumup.sdk.models.Lat lat, + + /** List of hyperlinks for accessing related resources. */ + java.util.List links, + + /** Local date and time of the creation of the transaction. */ + java.time.OffsetDateTime localTime, + + /** Details of the payment location as received from the payment terminal. */ + com.sumup.sdk.models.TransactionFullLocation location, + + /** + * Longitude value from the coordinates of the payment location (as received from the payment + * terminal reader). + */ + com.sumup.sdk.models.Lon lon, + + /** Unique code of the registered merchant to whom the payment is made. */ + String merchantCode, + + /** SumUp merchant internal Id. */ + Long merchantId, + + /** Payment type used for the transaction. */ + com.sumup.sdk.models.PaymentType paymentType, + + /** The date of the payout. */ + java.time.LocalDate payoutDate, + + /** Payout plan of the registered user at the time when the transaction was made. */ + com.sumup.sdk.models.TransactionFullPayoutPlan payoutPlan, + + /** Payout type for the transaction. */ + com.sumup.sdk.models.TransactionFullPayoutType payoutType, + + /** Number of payouts that are made to the registered user specified in the `user` property. */ + Long payoutsReceived, + + /** Total number of payouts to the registered user specified in the `user` property. */ + Long payoutsTotal, + + /** Debit/Credit. */ + com.sumup.sdk.models.TransactionFullProcessAs processAs, + + /** + * Short description of the payment. The value is taken from the `description` property of the + * related checkout resource. + */ + String productSummary, + + /** + * List of products from the merchant's catalogue for which the transaction serves as a payment. + */ + java.util.List products, + + /** Simple name of the payment type. */ + com.sumup.sdk.models.TransactionFullSimplePaymentType simplePaymentType, + + /** + * High-level status of the transaction from the merchant's perspective. - `PENDING`: The + * payment has been initiated and is still being processed. A final outcome is not available + * yet. - `SUCCESSFUL`: The payment was completed successfully. - `PAID_OUT`: The payment was + * completed successfully and the funds have already been included in a payout to the merchant. + * - `FAILED`: The payment did not complete successfully. - `CANCELLED`: The payment was + * cancelled or reversed and is no longer payable or payable to the merchant. - `CANCEL_FAILED`: + * An attempt to cancel or reverse the payment was not completed successfully. - `REFUNDED`: The + * payment was refunded in full or in part. - `REFUND_FAILED`: An attempt to refund the payment + * was not completed successfully. - `CHARGEBACK`: The payment was subject to a chargeback. - + * `NON_COLLECTION`: The amount could not be collected from the merchant after a chargeback or + * related adjustment. + */ + com.sumup.sdk.models.TransactionFullSimpleStatus simpleStatus, + + /** Current status of the transaction. */ + com.sumup.sdk.models.TransactionFullStatus status, + + /** Indicates whether tax deduction is enabled for the transaction. */ + Boolean taxEnabled, + + /** + * Date and time of the creation of the transaction. Response format expressed according to + * [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + */ + java.time.OffsetDateTime timestamp, + + /** Amount of the tip (out of the total transaction amount). */ + Float tipAmount, + + /** + * Transaction code returned by the acquirer/processing entity after processing the transaction. + */ + String transactionCode, + + /** Detailed list of events related to the transaction. */ + java.util.List transactionEvents, + + /** Email address of the registered user (merchant) to whom the payment is made. */ + String username, + + /** Amount of the applicable VAT (out of the total transaction amount). */ + Float vatAmount, + + /** List of VAT rates applicable to the transaction. */ + java.util.List vatRates, + + /** Verification method used for the transaction. */ + com.sumup.sdk.models.TransactionFullVerificationMethod verificationMethod) { + /** + * Creates a builder for TransactionFull. + * + * @return Builder that constructs immutable TransactionFull instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for TransactionFull instances. */ + public static final class Builder { + private Float amount; + private String authCode; + private com.sumup.sdk.models.CardResponse card; + private String clientTransactionId; + private com.sumup.sdk.models.Currency currency; + private com.sumup.sdk.models.Device deviceInfo; + private com.sumup.sdk.models.ElvCardAccount elvAccount; + private com.sumup.sdk.models.EntryMode entryMode; + private java.util.List events; + private Double feeAmount; + private String foreignTransactionId; + private com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy; + private String id; + private Long installmentsCount; + private com.sumup.sdk.models.Lat lat; + private java.util.List links; + private java.time.OffsetDateTime localTime; + private com.sumup.sdk.models.TransactionFullLocation location; + private com.sumup.sdk.models.Lon lon; + private String merchantCode; + private Long merchantId; + private com.sumup.sdk.models.PaymentType paymentType; + private java.time.LocalDate payoutDate; + private com.sumup.sdk.models.TransactionFullPayoutPlan payoutPlan; + private com.sumup.sdk.models.TransactionFullPayoutType payoutType; + private Long payoutsReceived; + private Long payoutsTotal; + private com.sumup.sdk.models.TransactionFullProcessAs processAs; + private String productSummary; + private java.util.List products; + private com.sumup.sdk.models.TransactionFullSimplePaymentType simplePaymentType; + private com.sumup.sdk.models.TransactionFullSimpleStatus simpleStatus; + private com.sumup.sdk.models.TransactionFullStatus status; + private Boolean taxEnabled; + private java.time.OffsetDateTime timestamp; + private Float tipAmount; + private String transactionCode; + private java.util.List transactionEvents; + private String username; + private Float vatAmount; + private java.util.List vatRates; + private com.sumup.sdk.models.TransactionFullVerificationMethod verificationMethod; + + private Builder() {} + + /** + * Sets the value for {@code amount}. + * + * @param amount Total amount of the transaction. + * @return This builder instance. + */ + public Builder amount(Float amount) { + this.amount = amount; + return this; + } + + /** + * Sets the value for {@code authCode}. + * + * @param authCode Authorization code for the transaction sent by the payment card issuer or + * bank. Applicable only to card payments. + * @return This builder instance. + */ + public Builder authCode(String authCode) { + this.authCode = authCode; + return this; + } + + /** + * Sets the value for {@code card}. + * + * @param card Details of the payment card. + * @return This builder instance. + */ + public Builder card(com.sumup.sdk.models.CardResponse card) { + this.card = card; + return this; + } + + /** + * Sets the value for {@code clientTransactionId}. + * + * @param clientTransactionId Client transaction id. + * @return This builder instance. + */ + public Builder clientTransactionId(String clientTransactionId) { + this.clientTransactionId = clientTransactionId; + return this; + } + + /** + * Sets the value for {@code currency}. + * + * @param currency Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the + * currency for the amount. Currently supported currency values are enumerated above. + * @return This builder instance. + */ + public Builder currency(com.sumup.sdk.models.Currency currency) { + this.currency = currency; + return this; + } + + /** + * Sets the value for {@code deviceInfo}. + * + * @param deviceInfo Details of the device used to create the transaction. + * @return This builder instance. + */ + public Builder deviceInfo(com.sumup.sdk.models.Device deviceInfo) { + this.deviceInfo = deviceInfo; + return this; + } + + /** + * Sets the value for {@code elvAccount}. + * + * @param elvAccount Details of the ELV card account associated with the transaction. + * @return This builder instance. + */ + public Builder elvAccount(com.sumup.sdk.models.ElvCardAccount elvAccount) { + this.elvAccount = elvAccount; + return this; + } + + /** + * Sets the value for {@code entryMode}. + * + * @param entryMode Entry mode of the payment details. + * @return This builder instance. + */ + public Builder entryMode(com.sumup.sdk.models.EntryMode entryMode) { + this.entryMode = entryMode; + return this; + } + + /** + * Sets the value for {@code events}. + * + * @param events Compact list of events related to the transaction. + * @return This builder instance. + */ + public Builder events(java.util.List events) { + this.events = events; + return this; + } + + /** + * Sets the value for {@code feeAmount}. + * + * @param feeAmount Transaction SumUp total fee amount. + * @return This builder instance. + */ + public Builder feeAmount(Double feeAmount) { + this.feeAmount = feeAmount; + return this; + } + + /** + * Sets the value for {@code foreignTransactionId}. + * + * @param foreignTransactionId External/foreign transaction id (passed by clients). + * @return This builder instance. + */ + public Builder foreignTransactionId(String foreignTransactionId) { + this.foreignTransactionId = foreignTransactionId; + return this; + } + + /** + * Sets the value for {@code horizontalAccuracy}. + * + * @param horizontalAccuracy Indication of the precision of the geographical position received + * from the payment terminal. + * @return This builder instance. + */ + public Builder horizontalAccuracy(com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy) { + this.horizontalAccuracy = horizontalAccuracy; + return this; + } + + /** + * Sets the value for {@code id}. + * + * @param id Unique ID of the transaction. + * @return This builder instance. + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Sets the value for {@code installmentsCount}. + * + * @param installmentsCount Current number of the installment for deferred payments. + * @return This builder instance. + */ + public Builder installmentsCount(Long installmentsCount) { + this.installmentsCount = installmentsCount; + return this; + } + + /** + * Sets the value for {@code lat}. + * + * @param lat Latitude value from the coordinates of the payment location (as received from the + * payment terminal reader). + * @return This builder instance. + */ + public Builder lat(com.sumup.sdk.models.Lat lat) { + this.lat = lat; + return this; + } + + /** + * Sets the value for {@code links}. + * + * @param links List of hyperlinks for accessing related resources. + * @return This builder instance. + */ + public Builder links(java.util.List links) { + this.links = links; + return this; + } + + /** + * Sets the value for {@code localTime}. + * + * @param localTime Local date and time of the creation of the transaction. + * @return This builder instance. + */ + public Builder localTime(java.time.OffsetDateTime localTime) { + this.localTime = localTime; + return this; + } + + /** + * Sets the value for {@code location}. + * + * @param location Details of the payment location as received from the payment terminal. + * @return This builder instance. + */ + public Builder location(com.sumup.sdk.models.TransactionFullLocation location) { + this.location = location; + return this; + } + + /** + * Sets the value for {@code lon}. + * + * @param lon Longitude value from the coordinates of the payment location (as received from the + * payment terminal reader). + * @return This builder instance. + */ + public Builder lon(com.sumup.sdk.models.Lon lon) { + this.lon = lon; + return this; + } + + /** + * Sets the value for {@code merchantCode}. + * + * @param merchantCode Unique code of the registered merchant to whom the payment is made. + * @return This builder instance. + */ + public Builder merchantCode(String merchantCode) { + this.merchantCode = merchantCode; + return this; + } + + /** + * Sets the value for {@code merchantId}. + * + * @param merchantId SumUp merchant internal Id. + * @return This builder instance. + */ + public Builder merchantId(Long merchantId) { + this.merchantId = merchantId; + return this; + } + + /** + * Sets the value for {@code paymentType}. + * + * @param paymentType Payment type used for the transaction. + * @return This builder instance. + */ + public Builder paymentType(com.sumup.sdk.models.PaymentType paymentType) { + this.paymentType = paymentType; + return this; + } + + /** + * Sets the value for {@code payoutDate}. + * + * @param payoutDate The date of the payout. + * @return This builder instance. + */ + public Builder payoutDate(java.time.LocalDate payoutDate) { + this.payoutDate = payoutDate; + return this; + } + + /** + * Sets the value for {@code payoutPlan}. + * + * @param payoutPlan Payout plan of the registered user at the time when the transaction was + * made. + * @return This builder instance. + */ + public Builder payoutPlan(com.sumup.sdk.models.TransactionFullPayoutPlan payoutPlan) { + this.payoutPlan = payoutPlan; + return this; + } + + /** + * Sets the value for {@code payoutType}. + * + * @param payoutType Payout type for the transaction. + * @return This builder instance. + */ + public Builder payoutType(com.sumup.sdk.models.TransactionFullPayoutType payoutType) { + this.payoutType = payoutType; + return this; + } + + /** + * Sets the value for {@code payoutsReceived}. + * + * @param payoutsReceived Number of payouts that are made to the registered user specified in + * the `user` property. + * @return This builder instance. + */ + public Builder payoutsReceived(Long payoutsReceived) { + this.payoutsReceived = payoutsReceived; + return this; + } + + /** + * Sets the value for {@code payoutsTotal}. + * + * @param payoutsTotal Total number of payouts to the registered user specified in the `user` + * property. + * @return This builder instance. + */ + public Builder payoutsTotal(Long payoutsTotal) { + this.payoutsTotal = payoutsTotal; + return this; + } + + /** + * Sets the value for {@code processAs}. + * + * @param processAs Debit/Credit. + * @return This builder instance. + */ + public Builder processAs(com.sumup.sdk.models.TransactionFullProcessAs processAs) { + this.processAs = processAs; + return this; + } + + /** + * Sets the value for {@code productSummary}. + * + * @param productSummary Short description of the payment. The value is taken from the + * `description` property of the related checkout resource. + * @return This builder instance. + */ + public Builder productSummary(String productSummary) { + this.productSummary = productSummary; + return this; + } + + /** + * Sets the value for {@code products}. + * + * @param products List of products from the merchant's catalogue for which the transaction + * serves as a payment. + * @return This builder instance. + */ + public Builder products(java.util.List products) { + this.products = products; + return this; + } + + /** + * Sets the value for {@code simplePaymentType}. + * + * @param simplePaymentType Simple name of the payment type. + * @return This builder instance. + */ + public Builder simplePaymentType( + com.sumup.sdk.models.TransactionFullSimplePaymentType simplePaymentType) { + this.simplePaymentType = simplePaymentType; + return this; + } + + /** + * Sets the value for {@code simpleStatus}. + * + * @param simpleStatus High-level status of the transaction from the merchant's perspective. - + * `PENDING`: The payment has been initiated and is still being processed. A final outcome + * is not available yet. - `SUCCESSFUL`: The payment was completed successfully. - + * `PAID_OUT`: The payment was completed successfully and the funds have already been + * included in a payout to the merchant. - `FAILED`: The payment did not complete + * successfully. - `CANCELLED`: The payment was cancelled or reversed and is no longer + * payable or payable to the merchant. - `CANCEL_FAILED`: An attempt to cancel or reverse + * the payment was not completed successfully. - `REFUNDED`: The payment was refunded in + * full or in part. - `REFUND_FAILED`: An attempt to refund the payment was not completed + * successfully. - `CHARGEBACK`: The payment was subject to a chargeback. - + * `NON_COLLECTION`: The amount could not be collected from the merchant after a chargeback + * or related adjustment. + * @return This builder instance. + */ + public Builder simpleStatus(com.sumup.sdk.models.TransactionFullSimpleStatus simpleStatus) { + this.simpleStatus = simpleStatus; + return this; + } + + /** + * Sets the value for {@code status}. + * + * @param status Current status of the transaction. + * @return This builder instance. + */ + public Builder status(com.sumup.sdk.models.TransactionFullStatus status) { + this.status = status; + return this; + } + + /** + * Sets the value for {@code taxEnabled}. + * + * @param taxEnabled Indicates whether tax deduction is enabled for the transaction. + * @return This builder instance. + */ + public Builder taxEnabled(Boolean taxEnabled) { + this.taxEnabled = taxEnabled; + return this; + } + + /** + * Sets the value for {@code timestamp}. + * + * @param timestamp Date and time of the creation of the transaction. Response format expressed + * according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + * @return This builder instance. + */ + public Builder timestamp(java.time.OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Sets the value for {@code tipAmount}. + * + * @param tipAmount Amount of the tip (out of the total transaction amount). + * @return This builder instance. + */ + public Builder tipAmount(Float tipAmount) { + this.tipAmount = tipAmount; + return this; + } + + /** + * Sets the value for {@code transactionCode}. + * + * @param transactionCode Transaction code returned by the acquirer/processing entity after + * processing the transaction. + * @return This builder instance. + */ + public Builder transactionCode(String transactionCode) { + this.transactionCode = transactionCode; + return this; + } + + /** + * Sets the value for {@code transactionEvents}. + * + * @param transactionEvents Detailed list of events related to the transaction. + * @return This builder instance. + */ + public Builder transactionEvents( + java.util.List transactionEvents) { + this.transactionEvents = transactionEvents; + return this; + } + + /** + * Sets the value for {@code username}. + * + * @param username Email address of the registered user (merchant) to whom the payment is made. + * @return This builder instance. + */ + public Builder username(String username) { + this.username = username; + return this; + } + + /** + * Sets the value for {@code vatAmount}. + * + * @param vatAmount Amount of the applicable VAT (out of the total transaction amount). + * @return This builder instance. + */ + public Builder vatAmount(Float vatAmount) { + this.vatAmount = vatAmount; + return this; + } + + /** + * Sets the value for {@code vatRates}. + * + * @param vatRates List of VAT rates applicable to the transaction. + * @return This builder instance. + */ + public Builder vatRates( + java.util.List vatRates) { + this.vatRates = vatRates; + return this; + } + + /** + * Sets the value for {@code verificationMethod}. + * + * @param verificationMethod Verification method used for the transaction. + * @return This builder instance. + */ + public Builder verificationMethod( + com.sumup.sdk.models.TransactionFullVerificationMethod verificationMethod) { + this.verificationMethod = verificationMethod; + return this; + } + + /** + * Builds an immutable TransactionFull instance. + * + * @return Immutable TransactionFull. + */ + public TransactionFull build() { + return new TransactionFull( + amount, + authCode, + card, + clientTransactionId, + currency, + deviceInfo, + elvAccount, + entryMode, + events, + feeAmount, + foreignTransactionId, + horizontalAccuracy, + id, + installmentsCount, + lat, + links, + localTime, + location, + lon, + merchantCode, + merchantId, + paymentType, + payoutDate, + payoutPlan, + payoutType, + payoutsReceived, + payoutsTotal, + processAs, + productSummary, + products, + simplePaymentType, + simpleStatus, + status, + taxEnabled, + timestamp, + tipAmount, + transactionCode, + transactionEvents, + username, + vatAmount, + vatRates, + verificationMethod); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullLocation.java b/src/main/java/com/sumup/sdk/models/TransactionFullLocation.java new file mode 100644 index 0000000..a344a21 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullLocation.java @@ -0,0 +1,84 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +/** Details of the payment location as received from the payment terminal. */ +public record TransactionFullLocation( + /** + * Indication of the precision of the geographical position received from the payment terminal. + */ + com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy, + + /** + * Latitude value from the coordinates of the payment location (as received from the payment + * terminal reader). + */ + com.sumup.sdk.models.Lat lat, + + /** + * Longitude value from the coordinates of the payment location (as received from the payment + * terminal reader). + */ + com.sumup.sdk.models.Lon lon) { + /** + * Creates a builder for TransactionFullLocation. + * + * @return Builder that constructs immutable TransactionFullLocation instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for TransactionFullLocation instances. */ + public static final class Builder { + private com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy; + private com.sumup.sdk.models.Lat lat; + private com.sumup.sdk.models.Lon lon; + + private Builder() {} + + /** + * Sets the value for {@code horizontalAccuracy}. + * + * @param horizontalAccuracy Indication of the precision of the geographical position received + * from the payment terminal. + * @return This builder instance. + */ + public Builder horizontalAccuracy(com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy) { + this.horizontalAccuracy = horizontalAccuracy; + return this; + } + + /** + * Sets the value for {@code lat}. + * + * @param lat Latitude value from the coordinates of the payment location (as received from the + * payment terminal reader). + * @return This builder instance. + */ + public Builder lat(com.sumup.sdk.models.Lat lat) { + this.lat = lat; + return this; + } + + /** + * Sets the value for {@code lon}. + * + * @param lon Longitude value from the coordinates of the payment location (as received from the + * payment terminal reader). + * @return This builder instance. + */ + public Builder lon(com.sumup.sdk.models.Lon lon) { + this.lon = lon; + return this; + } + + /** + * Builds an immutable TransactionFullLocation instance. + * + * @return Immutable TransactionFullLocation. + */ + public TransactionFullLocation build() { + return new TransactionFullLocation(horizontalAccuracy, lat, lon); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullPayoutPlan.java b/src/main/java/com/sumup/sdk/models/TransactionFullPayoutPlan.java new file mode 100644 index 0000000..6e38ea3 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullPayoutPlan.java @@ -0,0 +1,58 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** Payout plan of the registered user at the time when the transaction was made. */ +public final class TransactionFullPayoutPlan { + public static final TransactionFullPayoutPlan SINGLE_PAYMENT = + new TransactionFullPayoutPlan("SINGLE_PAYMENT"); + public static final TransactionFullPayoutPlan TRUE_INSTALLMENT = + new TransactionFullPayoutPlan("TRUE_INSTALLMENT"); + public static final TransactionFullPayoutPlan ACCELERATED_INSTALLMENT = + new TransactionFullPayoutPlan("ACCELERATED_INSTALLMENT"); + + private final String value; + + private TransactionFullPayoutPlan(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionFullPayoutPlan for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionFullPayoutPlan of(String value) { + return new TransactionFullPayoutPlan(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionFullPayoutPlan fromValue(String value) { + return value == null ? null : new TransactionFullPayoutPlan(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionFullPayoutPlan that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullPayoutType.java b/src/main/java/com/sumup/sdk/models/TransactionFullPayoutType.java new file mode 100644 index 0000000..33d81f4 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullPayoutType.java @@ -0,0 +1,56 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** Payout type for the transaction. */ +public final class TransactionFullPayoutType { + public static final TransactionFullPayoutType BANK_ACCOUNT = + new TransactionFullPayoutType("BANK_ACCOUNT"); + public static final TransactionFullPayoutType PREPAID_CARD = + new TransactionFullPayoutType("PREPAID_CARD"); + + private final String value; + + private TransactionFullPayoutType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionFullPayoutType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionFullPayoutType of(String value) { + return new TransactionFullPayoutType(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionFullPayoutType fromValue(String value) { + return value == null ? null : new TransactionFullPayoutType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionFullPayoutType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullProcessAs.java b/src/main/java/com/sumup/sdk/models/TransactionFullProcessAs.java new file mode 100644 index 0000000..e4312f9 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullProcessAs.java @@ -0,0 +1,54 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** Debit/Credit. */ +public final class TransactionFullProcessAs { + public static final TransactionFullProcessAs CREDIT = new TransactionFullProcessAs("CREDIT"); + public static final TransactionFullProcessAs DEBIT = new TransactionFullProcessAs("DEBIT"); + + private final String value; + + private TransactionFullProcessAs(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionFullProcessAs for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionFullProcessAs of(String value) { + return new TransactionFullProcessAs(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionFullProcessAs fromValue(String value) { + return value == null ? null : new TransactionFullProcessAs(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionFullProcessAs that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullSimplePaymentType.java b/src/main/java/com/sumup/sdk/models/TransactionFullSimplePaymentType.java new file mode 100644 index 0000000..a4896de --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullSimplePaymentType.java @@ -0,0 +1,81 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** Simple name of the payment type. */ +public final class TransactionFullSimplePaymentType { + public static final TransactionFullSimplePaymentType CASH = + new TransactionFullSimplePaymentType("CASH"); + public static final TransactionFullSimplePaymentType CC_SIGNATURE = + new TransactionFullSimplePaymentType("CC_SIGNATURE"); + public static final TransactionFullSimplePaymentType ELV = + new TransactionFullSimplePaymentType("ELV"); + public static final TransactionFullSimplePaymentType ELV_WITHOUT_SIGNATURE = + new TransactionFullSimplePaymentType("ELV_WITHOUT_SIGNATURE"); + public static final TransactionFullSimplePaymentType CC_CUSTOMER_ENTERED = + new TransactionFullSimplePaymentType("CC_CUSTOMER_ENTERED"); + public static final TransactionFullSimplePaymentType MANUAL_ENTRY = + new TransactionFullSimplePaymentType("MANUAL_ENTRY"); + public static final TransactionFullSimplePaymentType EMV = + new TransactionFullSimplePaymentType("EMV"); + public static final TransactionFullSimplePaymentType RECURRING = + new TransactionFullSimplePaymentType("RECURRING"); + public static final TransactionFullSimplePaymentType BALANCE = + new TransactionFullSimplePaymentType("BALANCE"); + public static final TransactionFullSimplePaymentType MOTO = + new TransactionFullSimplePaymentType("MOTO"); + public static final TransactionFullSimplePaymentType BOLETO = + new TransactionFullSimplePaymentType("BOLETO"); + public static final TransactionFullSimplePaymentType APM = + new TransactionFullSimplePaymentType("APM"); + public static final TransactionFullSimplePaymentType BITCOIN = + new TransactionFullSimplePaymentType("BITCOIN"); + public static final TransactionFullSimplePaymentType CARD = + new TransactionFullSimplePaymentType("CARD"); + + private final String value; + + private TransactionFullSimplePaymentType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionFullSimplePaymentType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionFullSimplePaymentType of(String value) { + return new TransactionFullSimplePaymentType(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionFullSimplePaymentType fromValue(String value) { + return value == null ? null : new TransactionFullSimplePaymentType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionFullSimplePaymentType that + && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullSimpleStatus.java b/src/main/java/com/sumup/sdk/models/TransactionFullSimpleStatus.java new file mode 100644 index 0000000..6832cb9 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullSimpleStatus.java @@ -0,0 +1,83 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** + * High-level status of the transaction from the merchant's perspective. - `PENDING`: The payment + * has been initiated and is still being processed. A final outcome is not available yet. - + * `SUCCESSFUL`: The payment was completed successfully. - `PAID_OUT`: The payment was completed + * successfully and the funds have already been included in a payout to the merchant. - `FAILED`: + * The payment did not complete successfully. - `CANCELLED`: The payment was cancelled or reversed + * and is no longer payable or payable to the merchant. - `CANCEL_FAILED`: An attempt to cancel or + * reverse the payment was not completed successfully. - `REFUNDED`: The payment was refunded in + * full or in part. - `REFUND_FAILED`: An attempt to refund the payment was not completed + * successfully. - `CHARGEBACK`: The payment was subject to a chargeback. - `NON_COLLECTION`: The + * amount could not be collected from the merchant after a chargeback or related adjustment. + */ +public final class TransactionFullSimpleStatus { + public static final TransactionFullSimpleStatus SUCCESSFUL = + new TransactionFullSimpleStatus("SUCCESSFUL"); + public static final TransactionFullSimpleStatus PAID_OUT = + new TransactionFullSimpleStatus("PAID_OUT"); + public static final TransactionFullSimpleStatus CANCEL_FAILED = + new TransactionFullSimpleStatus("CANCEL_FAILED"); + public static final TransactionFullSimpleStatus CANCELLED = + new TransactionFullSimpleStatus("CANCELLED"); + public static final TransactionFullSimpleStatus CHARGEBACK = + new TransactionFullSimpleStatus("CHARGEBACK"); + public static final TransactionFullSimpleStatus FAILED = + new TransactionFullSimpleStatus("FAILED"); + public static final TransactionFullSimpleStatus REFUND_FAILED = + new TransactionFullSimpleStatus("REFUND_FAILED"); + public static final TransactionFullSimpleStatus REFUNDED = + new TransactionFullSimpleStatus("REFUNDED"); + public static final TransactionFullSimpleStatus NON_COLLECTION = + new TransactionFullSimpleStatus("NON_COLLECTION"); + public static final TransactionFullSimpleStatus PENDING = + new TransactionFullSimpleStatus("PENDING"); + + private final String value; + + private TransactionFullSimpleStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionFullSimpleStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionFullSimpleStatus of(String value) { + return new TransactionFullSimpleStatus(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionFullSimpleStatus fromValue(String value) { + return value == null ? null : new TransactionFullSimpleStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionFullSimpleStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullStatus.java b/src/main/java/com/sumup/sdk/models/TransactionFullStatus.java new file mode 100644 index 0000000..73a4db5 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullStatus.java @@ -0,0 +1,56 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** Current status of the transaction. */ +public final class TransactionFullStatus { + public static final TransactionFullStatus SUCCESSFUL = new TransactionFullStatus("SUCCESSFUL"); + public static final TransactionFullStatus CANCELLED = new TransactionFullStatus("CANCELLED"); + public static final TransactionFullStatus FAILED = new TransactionFullStatus("FAILED"); + public static final TransactionFullStatus PENDING = new TransactionFullStatus("PENDING"); + + private final String value; + + private TransactionFullStatus(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionFullStatus for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionFullStatus of(String value) { + return new TransactionFullStatus(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionFullStatus fromValue(String value) { + return value == null ? null : new TransactionFullStatus(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionFullStatus that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullVatRatesItem.java b/src/main/java/com/sumup/sdk/models/TransactionFullVatRatesItem.java new file mode 100644 index 0000000..370ac40 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullVatRatesItem.java @@ -0,0 +1,87 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +public record TransactionFullVatRatesItem( + /** Gross amount of products having this VAT rate applied. */ + Double gross, + + /** NET amount of products having this VAT rate applied. */ + Double net, + + /** VAT rate. */ + Double rate, + + /** VAT amount of this rate applied. */ + Double vat) { + /** + * Creates a builder for TransactionFullVatRatesItem. + * + * @return Builder that constructs immutable TransactionFullVatRatesItem instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for TransactionFullVatRatesItem instances. */ + public static final class Builder { + private Double gross; + private Double net; + private Double rate; + private Double vat; + + private Builder() {} + + /** + * Sets the value for {@code gross}. + * + * @param gross Gross amount of products having this VAT rate applied. + * @return This builder instance. + */ + public Builder gross(Double gross) { + this.gross = gross; + return this; + } + + /** + * Sets the value for {@code net}. + * + * @param net NET amount of products having this VAT rate applied. + * @return This builder instance. + */ + public Builder net(Double net) { + this.net = net; + return this; + } + + /** + * Sets the value for {@code rate}. + * + * @param rate VAT rate. + * @return This builder instance. + */ + public Builder rate(Double rate) { + this.rate = rate; + return this; + } + + /** + * Sets the value for {@code vat}. + * + * @param vat VAT amount of this rate applied. + * @return This builder instance. + */ + public Builder vat(Double vat) { + this.vat = vat; + return this; + } + + /** + * Builds an immutable TransactionFullVatRatesItem instance. + * + * @return Immutable TransactionFullVatRatesItem. + */ + public TransactionFullVatRatesItem build() { + return new TransactionFullVatRatesItem(gross, net, rate, vat); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullVerificationMethod.java b/src/main/java/com/sumup/sdk/models/TransactionFullVerificationMethod.java new file mode 100644 index 0000000..7b6ed6f --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionFullVerificationMethod.java @@ -0,0 +1,65 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** Verification method used for the transaction. */ +public final class TransactionFullVerificationMethod { + public static final TransactionFullVerificationMethod NONE = + new TransactionFullVerificationMethod("none"); + public static final TransactionFullVerificationMethod SIGNATURE = + new TransactionFullVerificationMethod("signature"); + public static final TransactionFullVerificationMethod OFFLINE_PIN = + new TransactionFullVerificationMethod("offline PIN"); + public static final TransactionFullVerificationMethod ONLINE_PIN = + new TransactionFullVerificationMethod("online PIN"); + public static final TransactionFullVerificationMethod OFFLINE_PIN_SIGNATURE = + new TransactionFullVerificationMethod("offline PIN + signature"); + public static final TransactionFullVerificationMethod NA = + new TransactionFullVerificationMethod("na"); + + private final String value; + + private TransactionFullVerificationMethod(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionFullVerificationMethod for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionFullVerificationMethod of(String value) { + return new TransactionFullVerificationMethod(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionFullVerificationMethod fromValue(String value) { + return value == null ? null : new TransactionFullVerificationMethod(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionFullVerificationMethod that + && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionHistory.java b/src/main/java/com/sumup/sdk/models/TransactionHistory.java index 5a6be3a..8ab3db8 100644 --- a/src/main/java/com/sumup/sdk/models/TransactionHistory.java +++ b/src/main/java/com/sumup/sdk/models/TransactionHistory.java @@ -2,4 +2,365 @@ package com.sumup.sdk.models; /** Transaction entry returned in history listing responses. */ -public record TransactionHistory(com.sumup.sdk.models.TransactionBase value) {} +public record TransactionHistory( + /** Total amount of the transaction. */ + Float amount, + + /** Issuing card network of the payment card used for the transaction. */ + com.sumup.sdk.models.CardType cardType, + + /** Client-specific ID of the transaction. */ + String clientTransactionId, + + /** + * Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the + * amount. Currently supported currency values are enumerated above. + */ + com.sumup.sdk.models.Currency currency, + + /** Unique ID of the transaction. */ + String id, + + /** Current number of the installment for deferred payments. */ + Long installmentsCount, + + /** Payment type used for the transaction. */ + com.sumup.sdk.models.PaymentType paymentType, + + /** Payout date (if paid out at once). */ + java.time.LocalDate payoutDate, + + /** Payout plan of the registered user at the time when the transaction was made. */ + com.sumup.sdk.models.TransactionFullPayoutPlan payoutPlan, + + /** Payout type. */ + com.sumup.sdk.models.TransactionHistoryPayoutType payoutType, + + /** Number of payouts that are made to the registered user specified in the `user` property. */ + Long payoutsReceived, + + /** Total number of payouts to the registered user specified in the `user` property. */ + Long payoutsTotal, + + /** + * Short description of the payment. The value is taken from the `description` property of the + * related checkout resource. + */ + String productSummary, + + /** Total refunded amount. */ + Double refundedAmount, + + /** Current status of the transaction. */ + com.sumup.sdk.models.TransactionFullStatus status, + + /** + * Date and time of the creation of the transaction. Response format expressed according to + * [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + */ + java.time.OffsetDateTime timestamp, + + /** + * Transaction code returned by the acquirer/processing entity after processing the transaction. + */ + String transactionCode, + + /** Unique ID of the transaction. */ + com.sumup.sdk.models.TransactionId transactionId, + + /** Type of the transaction for the registered user specified in the `user` property. */ + com.sumup.sdk.models.TransactionHistoryType type, + + /** Email address of the registered user (merchant) to whom the payment is made. */ + String user) { + /** + * Creates a builder for TransactionHistory. + * + * @return Builder that constructs immutable TransactionHistory instances. + */ + public static Builder builder() { + return new Builder(); + } + + /** Builder for TransactionHistory instances. */ + public static final class Builder { + private Float amount; + private com.sumup.sdk.models.CardType cardType; + private String clientTransactionId; + private com.sumup.sdk.models.Currency currency; + private String id; + private Long installmentsCount; + private com.sumup.sdk.models.PaymentType paymentType; + private java.time.LocalDate payoutDate; + private com.sumup.sdk.models.TransactionFullPayoutPlan payoutPlan; + private com.sumup.sdk.models.TransactionHistoryPayoutType payoutType; + private Long payoutsReceived; + private Long payoutsTotal; + private String productSummary; + private Double refundedAmount; + private com.sumup.sdk.models.TransactionFullStatus status; + private java.time.OffsetDateTime timestamp; + private String transactionCode; + private com.sumup.sdk.models.TransactionId transactionId; + private com.sumup.sdk.models.TransactionHistoryType type; + private String user; + + private Builder() {} + + /** + * Sets the value for {@code amount}. + * + * @param amount Total amount of the transaction. + * @return This builder instance. + */ + public Builder amount(Float amount) { + this.amount = amount; + return this; + } + + /** + * Sets the value for {@code cardType}. + * + * @param cardType Issuing card network of the payment card used for the transaction. + * @return This builder instance. + */ + public Builder cardType(com.sumup.sdk.models.CardType cardType) { + this.cardType = cardType; + return this; + } + + /** + * Sets the value for {@code clientTransactionId}. + * + * @param clientTransactionId Client-specific ID of the transaction. + * @return This builder instance. + */ + public Builder clientTransactionId(String clientTransactionId) { + this.clientTransactionId = clientTransactionId; + return this; + } + + /** + * Sets the value for {@code currency}. + * + * @param currency Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the + * currency for the amount. Currently supported currency values are enumerated above. + * @return This builder instance. + */ + public Builder currency(com.sumup.sdk.models.Currency currency) { + this.currency = currency; + return this; + } + + /** + * Sets the value for {@code id}. + * + * @param id Unique ID of the transaction. + * @return This builder instance. + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Sets the value for {@code installmentsCount}. + * + * @param installmentsCount Current number of the installment for deferred payments. + * @return This builder instance. + */ + public Builder installmentsCount(Long installmentsCount) { + this.installmentsCount = installmentsCount; + return this; + } + + /** + * Sets the value for {@code paymentType}. + * + * @param paymentType Payment type used for the transaction. + * @return This builder instance. + */ + public Builder paymentType(com.sumup.sdk.models.PaymentType paymentType) { + this.paymentType = paymentType; + return this; + } + + /** + * Sets the value for {@code payoutDate}. + * + * @param payoutDate Payout date (if paid out at once). + * @return This builder instance. + */ + public Builder payoutDate(java.time.LocalDate payoutDate) { + this.payoutDate = payoutDate; + return this; + } + + /** + * Sets the value for {@code payoutPlan}. + * + * @param payoutPlan Payout plan of the registered user at the time when the transaction was + * made. + * @return This builder instance. + */ + public Builder payoutPlan(com.sumup.sdk.models.TransactionFullPayoutPlan payoutPlan) { + this.payoutPlan = payoutPlan; + return this; + } + + /** + * Sets the value for {@code payoutType}. + * + * @param payoutType Payout type. + * @return This builder instance. + */ + public Builder payoutType(com.sumup.sdk.models.TransactionHistoryPayoutType payoutType) { + this.payoutType = payoutType; + return this; + } + + /** + * Sets the value for {@code payoutsReceived}. + * + * @param payoutsReceived Number of payouts that are made to the registered user specified in + * the `user` property. + * @return This builder instance. + */ + public Builder payoutsReceived(Long payoutsReceived) { + this.payoutsReceived = payoutsReceived; + return this; + } + + /** + * Sets the value for {@code payoutsTotal}. + * + * @param payoutsTotal Total number of payouts to the registered user specified in the `user` + * property. + * @return This builder instance. + */ + public Builder payoutsTotal(Long payoutsTotal) { + this.payoutsTotal = payoutsTotal; + return this; + } + + /** + * Sets the value for {@code productSummary}. + * + * @param productSummary Short description of the payment. The value is taken from the + * `description` property of the related checkout resource. + * @return This builder instance. + */ + public Builder productSummary(String productSummary) { + this.productSummary = productSummary; + return this; + } + + /** + * Sets the value for {@code refundedAmount}. + * + * @param refundedAmount Total refunded amount. + * @return This builder instance. + */ + public Builder refundedAmount(Double refundedAmount) { + this.refundedAmount = refundedAmount; + return this; + } + + /** + * Sets the value for {@code status}. + * + * @param status Current status of the transaction. + * @return This builder instance. + */ + public Builder status(com.sumup.sdk.models.TransactionFullStatus status) { + this.status = status; + return this; + } + + /** + * Sets the value for {@code timestamp}. + * + * @param timestamp Date and time of the creation of the transaction. Response format expressed + * according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code. + * @return This builder instance. + */ + public Builder timestamp(java.time.OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Sets the value for {@code transactionCode}. + * + * @param transactionCode Transaction code returned by the acquirer/processing entity after + * processing the transaction. + * @return This builder instance. + */ + public Builder transactionCode(String transactionCode) { + this.transactionCode = transactionCode; + return this; + } + + /** + * Sets the value for {@code transactionId}. + * + * @param transactionId Unique ID of the transaction. + * @return This builder instance. + */ + public Builder transactionId(com.sumup.sdk.models.TransactionId transactionId) { + this.transactionId = transactionId; + return this; + } + + /** + * Sets the value for {@code type}. + * + * @param type Type of the transaction for the registered user specified in the `user` property. + * @return This builder instance. + */ + public Builder type(com.sumup.sdk.models.TransactionHistoryType type) { + this.type = type; + return this; + } + + /** + * Sets the value for {@code user}. + * + * @param user Email address of the registered user (merchant) to whom the payment is made. + * @return This builder instance. + */ + public Builder user(String user) { + this.user = user; + return this; + } + + /** + * Builds an immutable TransactionHistory instance. + * + * @return Immutable TransactionHistory. + */ + public TransactionHistory build() { + return new TransactionHistory( + amount, + cardType, + clientTransactionId, + currency, + id, + installmentsCount, + paymentType, + payoutDate, + payoutPlan, + payoutType, + payoutsReceived, + payoutsTotal, + productSummary, + refundedAmount, + status, + timestamp, + transactionCode, + transactionId, + type, + user); + } + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionHistoryPayoutType.java b/src/main/java/com/sumup/sdk/models/TransactionHistoryPayoutType.java new file mode 100644 index 0000000..05994bd --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionHistoryPayoutType.java @@ -0,0 +1,56 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** Payout type. */ +public final class TransactionHistoryPayoutType { + public static final TransactionHistoryPayoutType BANK_ACCOUNT = + new TransactionHistoryPayoutType("BANK_ACCOUNT"); + public static final TransactionHistoryPayoutType PREPAID_CARD = + new TransactionHistoryPayoutType("PREPAID_CARD"); + + private final String value; + + private TransactionHistoryPayoutType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionHistoryPayoutType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionHistoryPayoutType of(String value) { + return new TransactionHistoryPayoutType(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionHistoryPayoutType fromValue(String value) { + return value == null ? null : new TransactionHistoryPayoutType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionHistoryPayoutType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionHistoryType.java b/src/main/java/com/sumup/sdk/models/TransactionHistoryType.java new file mode 100644 index 0000000..e8158c9 --- /dev/null +++ b/src/main/java/com/sumup/sdk/models/TransactionHistoryType.java @@ -0,0 +1,56 @@ +// Code generated by sumup-java/codegen. DO NOT EDIT. +package com.sumup.sdk.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; + +/** Type of the transaction for the registered user specified in the `user` property. */ +public final class TransactionHistoryType { + public static final TransactionHistoryType PAYMENT = new TransactionHistoryType("PAYMENT"); + public static final TransactionHistoryType REFUND = new TransactionHistoryType("REFUND"); + public static final TransactionHistoryType CHARGE_BACK = + new TransactionHistoryType("CHARGE_BACK"); + + private final String value; + + private TransactionHistoryType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionHistoryType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionHistoryType of(String value) { + return new TransactionHistoryType(value); + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + + @JsonCreator + public static TransactionHistoryType fromValue(String value) { + return value == null ? null : new TransactionHistoryType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionHistoryType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/com/sumup/sdk/models/TransactionMixinHistoryPayoutPlan.java b/src/main/java/com/sumup/sdk/models/TransactionMixinHistoryPayoutPlan.java index d1012d1..7fe6a8b 100644 --- a/src/main/java/com/sumup/sdk/models/TransactionMixinHistoryPayoutPlan.java +++ b/src/main/java/com/sumup/sdk/models/TransactionMixinHistoryPayoutPlan.java @@ -3,17 +3,31 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** Payout plan of the registered user at the time when the transaction was made. */ -public enum TransactionMixinHistoryPayoutPlan { - SINGLE_PAYMENT("SINGLE_PAYMENT"), - TRUE_INSTALLMENT("TRUE_INSTALLMENT"), - ACCELERATED_INSTALLMENT("ACCELERATED_INSTALLMENT"); +public final class TransactionMixinHistoryPayoutPlan { + public static final TransactionMixinHistoryPayoutPlan SINGLE_PAYMENT = + new TransactionMixinHistoryPayoutPlan("SINGLE_PAYMENT"); + public static final TransactionMixinHistoryPayoutPlan TRUE_INSTALLMENT = + new TransactionMixinHistoryPayoutPlan("TRUE_INSTALLMENT"); + public static final TransactionMixinHistoryPayoutPlan ACCELERATED_INSTALLMENT = + new TransactionMixinHistoryPayoutPlan("ACCELERATED_INSTALLMENT"); private final String value; - TransactionMixinHistoryPayoutPlan(String value) { - this.value = value; + private TransactionMixinHistoryPayoutPlan(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a TransactionMixinHistoryPayoutPlan for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static TransactionMixinHistoryPayoutPlan of(String value) { + return new TransactionMixinHistoryPayoutPlan(value); } @JsonValue @@ -28,14 +42,18 @@ public String toString() { @JsonCreator public static TransactionMixinHistoryPayoutPlan fromValue(String value) { - if (value == null) { - return null; - } - for (TransactionMixinHistoryPayoutPlan entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown TransactionMixinHistoryPayoutPlan value: " + value); + return value == null ? null : new TransactionMixinHistoryPayoutPlan(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof TransactionMixinHistoryPayoutPlan that + && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } } diff --git a/src/main/java/com/sumup/sdk/models/TypesItem.java b/src/main/java/com/sumup/sdk/models/TypesItem.java deleted file mode 100644 index 8654234..0000000 --- a/src/main/java/com/sumup/sdk/models/TypesItem.java +++ /dev/null @@ -1,40 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TypesItem { - PAYMENT("PAYMENT"), - REFUND("REFUND"), - CHARGE_BACK("CHARGE_BACK"); - - private final String value; - - TypesItem(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - - @JsonCreator - public static TypesItem fromValue(String value) { - if (value == null) { - return null; - } - for (TypesItem entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown TypesItem value: " + value); - } -} diff --git a/src/main/java/com/sumup/sdk/models/TypesItem2.java b/src/main/java/com/sumup/sdk/models/TypesItem2.java deleted file mode 100644 index 15a2b2a..0000000 --- a/src/main/java/com/sumup/sdk/models/TypesItem2.java +++ /dev/null @@ -1,40 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TypesItem2 { - PAYMENT("PAYMENT"), - REFUND("REFUND"), - CHARGE_BACK("CHARGE_BACK"); - - private final String value; - - TypesItem2(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - - @JsonCreator - public static TypesItem2 fromValue(String value) { - if (value == null) { - return null; - } - for (TypesItem2 entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown TypesItem2 value: " + value); - } -} diff --git a/src/main/java/com/sumup/sdk/models/UnauthorizedErrorsType.java b/src/main/java/com/sumup/sdk/models/UnauthorizedErrorsType.java index ae9ac14..ed2059f 100644 --- a/src/main/java/com/sumup/sdk/models/UnauthorizedErrorsType.java +++ b/src/main/java/com/sumup/sdk/models/UnauthorizedErrorsType.java @@ -3,19 +3,32 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; /** * Key indicating type of error. Present only for typed 401 responses (e.g. invalid token, invalid * password). Absent for generic unauthorized responses. */ -public enum UnauthorizedErrorsType { - INVALID_ACCESS_TOKEN("INVALID_ACCESS_TOKEN"), - INVALID_PASSWORD("INVALID_PASSWORD"); +public final class UnauthorizedErrorsType { + public static final UnauthorizedErrorsType INVALID_ACCESS_TOKEN = + new UnauthorizedErrorsType("INVALID_ACCESS_TOKEN"); + public static final UnauthorizedErrorsType INVALID_PASSWORD = + new UnauthorizedErrorsType("INVALID_PASSWORD"); private final String value; - UnauthorizedErrorsType(String value) { - this.value = value; + private UnauthorizedErrorsType(String value) { + this.value = Objects.requireNonNull(value, "value"); + } + + /** + * Creates a UnauthorizedErrorsType for a value not yet known to this SDK version. + * + * @param value Wire value sent to or received from the API. + * @return Open enum value wrapping {@code value}. + */ + public static UnauthorizedErrorsType of(String value) { + return new UnauthorizedErrorsType(value); } @JsonValue @@ -30,14 +43,17 @@ public String toString() { @JsonCreator public static UnauthorizedErrorsType fromValue(String value) { - if (value == null) { - return null; - } - for (UnauthorizedErrorsType entry : values()) { - if (entry.value.equals(value)) { - return entry; - } - } - throw new IllegalArgumentException("Unknown UnauthorizedErrorsType value: " + value); + return value == null ? null : new UnauthorizedErrorsType(value); + } + + @Override + public boolean equals(Object other) { + return this == other + || (other instanceof UnauthorizedErrorsType that && this.value.equals(that.value)); + } + + @Override + public int hashCode() { + return value.hashCode(); } }