From c68acf27dc1c92569faebe781cc7feefdf107f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Dzivjak?= Date: Fri, 11 Sep 2026 15:43:05 +0200 Subject: [PATCH] fix(codegen)!: use Java types for scalar schemas Named scalar schemas required wrapper records and produced inconsistent APIs. Resolve them to the same Java types as inline scalars, preserving enums, formats, and nullability. Regenerate the SDK and update examples and regression tests. BREAKING CHANGE: Scalar wrapper classes are removed. Pass and read their underlying Java values directly. --- README.md | 4 +- codegen/README.md | 6 + .../generator/additional_properties_test.go | 11 +- codegen/internal/generator/model.go | 4 +- codegen/internal/generator/render.go | 3 - codegen/internal/generator/scalars_test.go | 115 ++++++++++++++++++ codegen/internal/generator/types.go | 31 ++++- .../cardreader/CardReaderCheckoutExample.java | 4 +- .../sdk/clients/MembershipsAsyncClient.java | 4 +- .../sumup/sdk/clients/MembershipsClient.java | 4 +- .../sumup/sdk/clients/ReadersAsyncClient.java | 27 ++-- .../com/sumup/sdk/clients/ReadersClient.java | 26 ++-- .../java/com/sumup/sdk/models/Address.java | 6 +- .../java/com/sumup/sdk/models/BasePerson.java | 20 +-- .../com/sumup/sdk/models/BusinessProfile.java | 6 +- .../com/sumup/sdk/models/ChangeStatus.java | 10 -- .../java/com/sumup/sdk/models/Company.java | 12 +- .../com/sumup/sdk/models/CountryCode.java | 9 -- .../sumup/sdk/models/CreateReaderRequest.java | 12 +- src/main/java/com/sumup/sdk/models/Event.java | 12 +- .../sumup/sdk/models/HorizontalAccuracy.java | 5 - src/main/java/com/sumup/sdk/models/Lat.java | 8 -- .../java/com/sumup/sdk/models/LegalType.java | 9 -- src/main/java/com/sumup/sdk/models/Lon.java | 8 -- .../java/com/sumup/sdk/models/Membership.java | 6 +- .../sumup/sdk/models/MembershipResource.java | 6 +- .../java/com/sumup/sdk/models/Merchant.java | 14 +-- .../java/com/sumup/sdk/models/Person.java | 20 +-- .../com/sumup/sdk/models/PhoneNumber.java | 5 - .../java/com/sumup/sdk/models/Reader.java | 12 +- .../java/com/sumup/sdk/models/ReaderId.java | 5 - .../java/com/sumup/sdk/models/ReaderName.java | 5 - .../sumup/sdk/models/ReaderPairingCode.java | 8 -- .../com/sumup/sdk/models/ReceiptEvent.java | 12 +- .../sumup/sdk/models/ReceiptTransaction.java | 6 +- .../com/sumup/sdk/models/ResourceType.java | 8 -- .../sumup/sdk/models/TransactionEvent.java | 6 +- .../sumup/sdk/models/TransactionEventId.java | 5 - .../com/sumup/sdk/models/TransactionFull.java | 18 +-- .../sdk/models/TransactionFullLocation.java | 18 +-- .../sumup/sdk/models/TransactionHistory.java | 6 +- .../com/sumup/sdk/models/TransactionId.java | 5 - .../sumup/sdk/models/UpdateReaderRequest.java | 6 +- .../java/com/sumup/sdk/models/Version.java | 8 -- .../com/sumup/sdk/core/ApiClientTest.java | 5 +- .../sumup/sdk/models/ScalarModelsTest.java | 27 ++++ 46 files changed, 306 insertions(+), 261 deletions(-) create mode 100644 codegen/internal/generator/scalars_test.go delete mode 100644 src/main/java/com/sumup/sdk/models/ChangeStatus.java delete mode 100644 src/main/java/com/sumup/sdk/models/CountryCode.java delete mode 100644 src/main/java/com/sumup/sdk/models/HorizontalAccuracy.java delete mode 100644 src/main/java/com/sumup/sdk/models/Lat.java delete mode 100644 src/main/java/com/sumup/sdk/models/LegalType.java delete mode 100644 src/main/java/com/sumup/sdk/models/Lon.java delete mode 100644 src/main/java/com/sumup/sdk/models/PhoneNumber.java delete mode 100644 src/main/java/com/sumup/sdk/models/ReaderId.java delete mode 100644 src/main/java/com/sumup/sdk/models/ReaderName.java delete mode 100644 src/main/java/com/sumup/sdk/models/ReaderPairingCode.java delete mode 100644 src/main/java/com/sumup/sdk/models/ResourceType.java delete mode 100644 src/main/java/com/sumup/sdk/models/TransactionEventId.java delete mode 100644 src/main/java/com/sumup/sdk/models/TransactionId.java delete mode 100644 src/main/java/com/sumup/sdk/models/Version.java create mode 100644 src/test/java/com/sumup/sdk/models/ScalarModelsTest.java diff --git a/README.md b/README.md index c93a340..d070ac7 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ String readerId = () -> client.readers().list(merchantCode).items().stream() .findFirst() - .map(reader -> reader.id().value()) + .map(reader -> reader.id()) .orElseThrow(() -> new IllegalStateException("No paired readers found."))); CreateReaderCheckoutRequest request = @@ -224,7 +224,7 @@ CompletableFuture readerIdFuture = response -> response.items().stream() .findFirst() - .map(reader -> reader.id().value()) + .map(reader -> reader.id()) .orElseThrow( () -> new IllegalStateException("No paired readers found.")))); diff --git a/codegen/README.md b/codegen/README.md index 168365c..b3cc7f5 100644 --- a/codegen/README.md +++ b/codegen/README.md @@ -22,6 +22,12 @@ just generate The command is idempotent; rerunning it rewrites the generated clients in-place. Continuous Integration runs the same invocation and fails when the working tree is dirty afterward. +Named scalar schemas use the same Java types as inline schemas: `String`, boxed +numbers and booleans, or the existing date/time and UUID format mappings. They do +not generate wrapper records. Enum schemas retain their open enum classes, and +structured schemas retain their models. This applies to parameters, request and +response fields, and code samples. + ## Java Code Samples The `samples` command generates a deterministic, versioned JSON catalog of Java examples from the same intermediate representation used to generate the SDK. Each catalog entry contains a complete Java program. Named OpenAPI request examples produce separate entries. diff --git a/codegen/internal/generator/additional_properties_test.go b/codegen/internal/generator/additional_properties_test.go index 37c4e6c..2debf8b 100644 --- a/codegen/internal/generator/additional_properties_test.go +++ b/codegen/internal/generator/additional_properties_test.go @@ -107,16 +107,7 @@ func TestGenerateModelWithoutBuilderForTypeAliases(t *testing.T) { } lonPath := filepath.Join(outputDir, "com", "test", "sdk", "models", "Lon.java") - lonContent, err := os.ReadFile(lonPath) - if err != nil { - t.Fatalf("read generated Lon model: %v", err) - } - lonGenerated := string(lonContent) - - assertContains(t, lonGenerated, "public record Lon(") - assertContains(t, lonGenerated, "Float value") - assertNotContains(t, lonGenerated, "public static Builder builder()") - assertNotContains(t, lonGenerated, "public static final class Builder") + assertFileDoesNotExist(t, lonPath) metaPath := filepath.Join(outputDir, "com", "test", "sdk", "models", "Meta.java") metaContent, err := os.ReadFile(metaPath) diff --git a/codegen/internal/generator/model.go b/codegen/internal/generator/model.go index ccb3f3c..d4004af 100644 --- a/codegen/internal/generator/model.go +++ b/codegen/internal/generator/model.go @@ -571,7 +571,7 @@ func buildSchemas(doc *v3.Document, params Params, resolver *typeResolver) []sch result := make([]schemaModel, 0, len(names)) for _, name := range names { ref := doc.Components.Schemas.GetOrZero(name) - if ref == nil { + if ref == nil || isPlainScalarSchema(ref.Schema()) { continue } description := schemaDescription(ref) @@ -617,7 +617,7 @@ func buildSchemas(doc *v3.Document, params Params, resolver *typeResolver) []sch } // shouldGenerateBuilder reports whether the model should expose a builder. -// Single-field wrapper records (for example Lon/Lat/Meta-style aliases) don't +// Single-field wrapper records (for example map aliases) don't // benefit from a builder and should use the canonical record constructor. func shouldGenerateBuilder(fields []schemaField, additionalProps *additionalPropertiesModel) bool { if additionalProps != nil { diff --git a/codegen/internal/generator/render.go b/codegen/internal/generator/render.go index f2b9bb8..a8c5f90 100644 --- a/codegen/internal/generator/render.go +++ b/codegen/internal/generator/render.go @@ -90,9 +90,6 @@ func renderSumUpClient(model sdkModel, params Params) error { // renderModels generates POJO classes that mirror OpenAPI schemas. func renderModels(model sdkModel, params Params) error { - if len(model.Schemas) == 0 { - return nil - } dir := filepath.Join(params.OutputDir, params.modelPackagePath()) if err := os.RemoveAll(dir); err != nil { return fmt.Errorf("remove models directory: %w", err) diff --git a/codegen/internal/generator/scalars_test.go b/codegen/internal/generator/scalars_test.go new file mode 100644 index 0000000..472c003 --- /dev/null +++ b/codegen/internal/generator/scalars_test.go @@ -0,0 +1,115 @@ +package generator + +import ( + "os" + "path/filepath" + "testing" +) + +func TestGenerateScalarReferences(t *testing.T) { + t.Parallel() + + tmp := t.TempDir() + specPath := filepath.Join(tmp, "openapi.yaml") + spec := `openapi: 3.1.0 +info: {title: Scalars, version: '1'} +paths: + /readers/{id}: + post: + operationId: createReader + x-codegen: {method_name: create} + tags: [Readers] + parameters: + - name: id + in: path + required: true + schema: {$ref: '#/components/schemas/Name'} + requestBody: + required: true + content: + application/json: + schema: {$ref: '#/components/schemas/Request'} + responses: + '200': + description: Name + content: + application/json: + schema: {$ref: '#/components/schemas/Name'} +components: + schemas: + Name: {type: string, description: Reader display name., example: Counter 1} + Count: {type: integer, format: int32} + Total: {type: integer, format: int64} + Latitude: {type: number, format: float} + Amount: {type: number, format: double} + Enabled: {type: boolean} + Date: {type: string, format: date} + Timestamp: {type: string, format: date-time} + Identifier: {type: string, format: uuid} + NullableName: {type: [string, 'null']} + Status: {type: string, enum: [active, inactive]} + Request: + type: object + required: [name, nullableName] + properties: + name: {$ref: '#/components/schemas/Name'} + nullableName: {$ref: '#/components/schemas/NullableName'} + count: {$ref: '#/components/schemas/Count'} + total: {$ref: '#/components/schemas/Total'} + latitude: {$ref: '#/components/schemas/Latitude'} + amount: {$ref: '#/components/schemas/Amount'} + enabled: {$ref: '#/components/schemas/Enabled'} + date: {$ref: '#/components/schemas/Date'} + timestamp: {$ref: '#/components/schemas/Timestamp'} + identifier: {$ref: '#/components/schemas/Identifier'} + status: {$ref: '#/components/schemas/Status'} + names: + type: array + items: {$ref: '#/components/schemas/Name'} + counts: + type: object + additionalProperties: {$ref: '#/components/schemas/Count'} +` + if err := os.WriteFile(specPath, []byte(spec), 0o600); err != nil { + t.Fatal(err) + } + params := Params{SpecPath: specPath, OutputDir: filepath.Join(tmp, "java"), ResourceDir: filepath.Join(tmp, "resources")} + if err := Run(t.Context(), params); err != nil { + t.Fatal(err) + } + read := func(path string) string { + t.Helper() + data, err := os.ReadFile(filepath.Join(params.OutputDir, "com/sumup/sdk", path)) + if err != nil { + t.Fatal(err) + } + return string(data) + } + request := read("models/Request.java") + for _, field := range []string{ + "String name", "String nullableName", "Integer count", "Long total", "Float latitude", "Double amount", + "Boolean enabled", "java.time.LocalDate date", "java.time.OffsetDateTime timestamp", "java.util.UUID identifier", + "com.sumup.sdk.models.Status status", "java.util.List names", "java.util.Map counts", + "Reader display name.", `Objects.requireNonNull(name, "name")`, + } { + assertContains(t, request, field) + } + assertNotContains(t, request, `Objects.requireNonNull(nullableName`) + for _, name := range []string{"Name", "NullableName", "Count", "Total", "Latitude", "Amount", "Enabled", "Date", "Timestamp", "Identifier"} { + assertFileDoesNotExist(t, filepath.Join(params.OutputDir, "com/sumup/sdk/models", name+".java")) + } + assertContains(t, read("models/Status.java"), "public static final Status ACTIVE") + assertContains(t, read("clients/ReadersClient.java"), "public String create(") + assertContains(t, read("clients/ReadersClient.java"), "String id") + assertContains(t, read("clients/ReadersAsyncClient.java"), "CompletableFuture create(") + + catalog, err := BuildSamples(params, "test") + if err != nil { + t.Fatal(err) + } + if len(catalog.Samples) != 1 { + t.Fatalf("expected one sample, got %d", len(catalog.Samples)) + } + assertContains(t, catalog.Samples[0].Source, `.name("Counter 1")`) + assertNotContains(t, catalog.Samples[0].Source, "new com.sumup.sdk.models.Name") +} diff --git a/codegen/internal/generator/types.go b/codegen/internal/generator/types.go index 5bb2d93..09879c2 100644 --- a/codegen/internal/generator/types.go +++ b/codegen/internal/generator/types.go @@ -40,7 +40,10 @@ func newTypeResolver(doc *v3.Document, params Params) *typeResolver { inlineNameUsage: make(map[string]int), } if doc.Components != nil && doc.Components.Schemas != nil && doc.Components.Schemas.Len() > 0 { - for name := range doc.Components.Schemas.KeysFromOldest() { + for name, ref := range doc.Components.Schemas.FromOldest() { + if isPlainScalarSchema(schemaFromProxy(ref)) { + continue + } className := pascalCase(name, "") resolver.schemaTypes[name] = params.modelPackage() + "." + className resolver.inlineNameUsage[className]++ @@ -76,7 +79,7 @@ func (r *typeResolver) javaType(ref *base.SchemaProxy, context ...string) javaTy if ref == nil { return r.genericMap() } - if ref.IsReference() { + if ref.IsReference() && !isPlainScalarSchema(ref.Schema()) { name := componentNameFromRef(ref.GetReference()) if name != "" { fqn := r.schemaClassName(name) @@ -172,6 +175,28 @@ func (r *typeResolver) parameterJavaType(ref *base.SchemaProxy, context ...strin return r.javaType(ref, context...) } +// isPlainScalarSchema identifies schemas that use Java's scalar types even when +// named as components. Enums and composed schemas retain their model handling. +func isPlainScalarSchema(schema *base.Schema) bool { + if schema == nil || len(schema.Enum) > 0 || len(schema.AllOf) > 0 || len(schema.OneOf) > 0 || len(schema.AnyOf) > 0 { + return false + } + scalar := false + for _, kind := range schema.Type { + switch kind { + case "string", "integer", "number", "boolean": + if scalar { + return false + } + scalar = true + case "null": + default: + return false + } + } + return scalar +} + // 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 { @@ -330,7 +355,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": {}, + "java.util.Objects": {}, }) models = append(models, schemaModel{ Name: info.className, diff --git a/examples/card-reader-checkout/src/main/java/com/sumup/examples/cardreader/CardReaderCheckoutExample.java b/examples/card-reader-checkout/src/main/java/com/sumup/examples/cardreader/CardReaderCheckoutExample.java index d155b61..15cf31b 100644 --- a/examples/card-reader-checkout/src/main/java/com/sumup/examples/cardreader/CardReaderCheckoutExample.java +++ b/examples/card-reader-checkout/src/main/java/com/sumup/examples/cardreader/CardReaderCheckoutExample.java @@ -18,9 +18,7 @@ public static void main(String[] args) { SumUpClient client = new SumUpClient(); Optional readerId = - client.readers().list(merchantCode).items().stream() - .findFirst() - .map(reader -> reader.id().value()); + client.readers().list(merchantCode).items().stream().findFirst().map(reader -> reader.id()); if (readerId.isEmpty()) { System.err.println("Merchant has no paired readers."); return; diff --git a/src/main/java/com/sumup/sdk/clients/MembershipsAsyncClient.java b/src/main/java/com/sumup/sdk/clients/MembershipsAsyncClient.java index 2769db1..3fbf31d 100644 --- a/src/main/java/com/sumup/sdk/clients/MembershipsAsyncClient.java +++ b/src/main/java/com/sumup/sdk/clients/MembershipsAsyncClient.java @@ -110,7 +110,7 @@ public static final class ListMembershipsQueryParams { * @param value Filter memberships by resource kind. * @return This ListMembershipsQueryParams instance. */ - public ListMembershipsQueryParams kind(com.sumup.sdk.models.ResourceType value) { + public ListMembershipsQueryParams kind(String value) { this.values.put("kind", Objects.requireNonNull(value, "kind")); return this; } @@ -193,7 +193,7 @@ public ListMembershipsQueryParams resourceParentType(java.util.Map crea * @throws ApiException if the SumUp API returns an error. */ public CompletableFuture createGoCheckout( - String merchantCode, - com.sumup.sdk.models.ReaderId readerId, - com.sumup.sdk.models.ReaderPaymentRequestParams request) + String merchantCode, String readerId, com.sumup.sdk.models.ReaderPaymentRequestParams request) throws ApiException { return createGoCheckout(merchantCode, readerId, request, null); } @@ -205,7 +203,7 @@ public CompletableFuture createGoChe */ public CompletableFuture createGoCheckout( String merchantCode, - com.sumup.sdk.models.ReaderId readerId, + String readerId, com.sumup.sdk.models.ReaderPaymentRequestParams request, RequestOptions requestOptions) throws ApiException { @@ -242,8 +240,7 @@ public CompletableFuture createGoChe * @return CompletableFuture completed when the request finishes. * @throws ApiException if the SumUp API returns an error. */ - public CompletableFuture delete(String merchantCode, com.sumup.sdk.models.ReaderId readerId) - throws ApiException { + public CompletableFuture delete(String merchantCode, String readerId) throws ApiException { return delete(merchantCode, readerId, null); } @@ -262,8 +259,7 @@ public CompletableFuture delete(String merchantCode, com.sumup.sdk.models. * @throws ApiException if the SumUp API returns an error. */ public CompletableFuture delete( - String merchantCode, com.sumup.sdk.models.ReaderId readerId, RequestOptions requestOptions) - throws ApiException { + String merchantCode, String readerId, RequestOptions requestOptions) throws ApiException { Objects.requireNonNull(merchantCode, "merchantCode"); Objects.requireNonNull(readerId, "readerId"); String path = "/v0.1/merchants/{merchant_code}/readers/{reader_id}"; @@ -290,8 +286,8 @@ public CompletableFuture delete( * @return CompletableFuture resolved with com.sumup.sdk.models.Reader parsed response. * @throws ApiException if the SumUp API returns an error. */ - public CompletableFuture get( - String merchantCode, com.sumup.sdk.models.ReaderId readerId) throws ApiException { + public CompletableFuture get(String merchantCode, String readerId) + throws ApiException { return get(merchantCode, readerId, null); } @@ -311,8 +307,7 @@ public CompletableFuture get( * @throws ApiException if the SumUp API returns an error. */ public CompletableFuture get( - String merchantCode, com.sumup.sdk.models.ReaderId readerId, GetReaderHeaders getReader) - throws ApiException { + String merchantCode, String readerId, GetReaderHeaders getReader) throws ApiException { return get(merchantCode, readerId, getReader, null); } @@ -333,7 +328,7 @@ public CompletableFuture get( */ public CompletableFuture get( String merchantCode, - com.sumup.sdk.models.ReaderId readerId, + String readerId, GetReaderHeaders getReader, RequestOptions requestOptions) throws ApiException { @@ -623,9 +618,7 @@ public CompletableFuture terminateCheckout( * @throws ApiException if the SumUp API returns an error. */ public CompletableFuture update( - String merchantCode, - com.sumup.sdk.models.ReaderId readerId, - com.sumup.sdk.models.UpdateReaderRequest request) + String merchantCode, String readerId, com.sumup.sdk.models.UpdateReaderRequest request) throws ApiException { return update(merchantCode, readerId, request, null); } @@ -647,7 +640,7 @@ public CompletableFuture update( */ public CompletableFuture update( String merchantCode, - com.sumup.sdk.models.ReaderId readerId, + String readerId, com.sumup.sdk.models.UpdateReaderRequest request, RequestOptions requestOptions) throws ApiException { diff --git a/src/main/java/com/sumup/sdk/clients/ReadersClient.java b/src/main/java/com/sumup/sdk/clients/ReadersClient.java index 956505c..d3af542 100644 --- a/src/main/java/com/sumup/sdk/clients/ReadersClient.java +++ b/src/main/java/com/sumup/sdk/clients/ReadersClient.java @@ -174,9 +174,7 @@ public com.sumup.sdk.models.CreateReaderCheckoutResponse createCheckout( * @throws ApiException if the SumUp API returns an error. */ public com.sumup.sdk.models.ReaderPaymentResponse createGoCheckout( - String merchantCode, - com.sumup.sdk.models.ReaderId readerId, - com.sumup.sdk.models.ReaderPaymentRequestParams request) + String merchantCode, String readerId, com.sumup.sdk.models.ReaderPaymentRequestParams request) throws ApiException { return createGoCheckout(merchantCode, readerId, request, null); } @@ -200,7 +198,7 @@ public com.sumup.sdk.models.ReaderPaymentResponse createGoCheckout( */ public com.sumup.sdk.models.ReaderPaymentResponse createGoCheckout( String merchantCode, - com.sumup.sdk.models.ReaderId readerId, + String readerId, com.sumup.sdk.models.ReaderPaymentRequestParams request, RequestOptions requestOptions) throws ApiException { @@ -236,8 +234,7 @@ public com.sumup.sdk.models.ReaderPaymentResponse createGoCheckout( * request timeout. * @throws ApiException if the SumUp API returns an error. */ - public void delete(String merchantCode, com.sumup.sdk.models.ReaderId readerId) - throws ApiException { + public void delete(String merchantCode, String readerId) throws ApiException { delete(merchantCode, readerId, null); } @@ -254,8 +251,7 @@ public void delete(String merchantCode, com.sumup.sdk.models.ReaderId readerId) * {@code null} to use client defaults. * @throws ApiException if the SumUp API returns an error. */ - public void delete( - String merchantCode, com.sumup.sdk.models.ReaderId readerId, RequestOptions requestOptions) + public void delete(String merchantCode, String readerId, RequestOptions requestOptions) throws ApiException { Objects.requireNonNull(merchantCode, "merchantCode"); Objects.requireNonNull(readerId, "readerId"); @@ -282,8 +278,7 @@ public void delete( * @return com.sumup.sdk.models.Reader parsed response. * @throws ApiException if the SumUp API returns an error. */ - public com.sumup.sdk.models.Reader get( - String merchantCode, com.sumup.sdk.models.ReaderId readerId) throws ApiException { + public com.sumup.sdk.models.Reader get(String merchantCode, String readerId) throws ApiException { return get(merchantCode, readerId, null); } @@ -303,8 +298,7 @@ public com.sumup.sdk.models.Reader get( * @throws ApiException if the SumUp API returns an error. */ public com.sumup.sdk.models.Reader get( - String merchantCode, com.sumup.sdk.models.ReaderId readerId, GetReaderHeaders getReader) - throws ApiException { + String merchantCode, String readerId, GetReaderHeaders getReader) throws ApiException { return get(merchantCode, readerId, getReader, null); } @@ -325,7 +319,7 @@ public com.sumup.sdk.models.Reader get( */ public com.sumup.sdk.models.Reader get( String merchantCode, - com.sumup.sdk.models.ReaderId readerId, + String readerId, GetReaderHeaders getReader, RequestOptions requestOptions) throws ApiException { @@ -607,9 +601,7 @@ public void terminateCheckout( * @throws ApiException if the SumUp API returns an error. */ public com.sumup.sdk.models.Reader update( - String merchantCode, - com.sumup.sdk.models.ReaderId readerId, - com.sumup.sdk.models.UpdateReaderRequest request) + String merchantCode, String readerId, com.sumup.sdk.models.UpdateReaderRequest request) throws ApiException { return update(merchantCode, readerId, request, null); } @@ -631,7 +623,7 @@ public com.sumup.sdk.models.Reader update( */ public com.sumup.sdk.models.Reader update( String merchantCode, - com.sumup.sdk.models.ReaderId readerId, + String readerId, com.sumup.sdk.models.UpdateReaderRequest request, RequestOptions requestOptions) throws ApiException { diff --git a/src/main/java/com/sumup/sdk/models/Address.java b/src/main/java/com/sumup/sdk/models/Address.java index 8df35ed..c054f4c 100644 --- a/src/main/java/com/sumup/sdk/models/Address.java +++ b/src/main/java/com/sumup/sdk/models/Address.java @@ -31,7 +31,7 @@ public record Address( * 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, + String country, /** * A county is a geographic region of a country used for administrative or other purposes in @@ -103,7 +103,7 @@ public static final class Builder { private String autonomousCommunity; private String city; private String commune; - private com.sumup.sdk.models.CountryCode country; + private String country; private String county; private String department; private String district; @@ -163,7 +163,7 @@ public Builder commune(String commune) { * support of future countries in client code. * @return This builder instance. */ - public Builder country(com.sumup.sdk.models.CountryCode country) { + public Builder country(String country) { this.country = country; return this; } diff --git a/src/main/java/com/sumup/sdk/models/BasePerson.java b/src/main/java/com/sumup/sdk/models/BasePerson.java index de877f9..9f5c317 100644 --- a/src/main/java/com/sumup/sdk/models/BasePerson.java +++ b/src/main/java/com/sumup/sdk/models/BasePerson.java @@ -28,14 +28,14 @@ public record BasePerson( * 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, + String 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, + String citizenship, /** * An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code @@ -73,7 +73,7 @@ public record BasePerson( 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, + String phoneNumber, /** * A list of roles the Person has in the Merchant or towards SumUp. A Merchant must have at @@ -88,7 +88,7 @@ public record BasePerson( * 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) { + String version) { /** * Creates a builder for BasePerson. * @@ -102,7 +102,7 @@ public static Builder builder() { 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 citizenship; private String countryOfResidence; private String familyName; private String givenName; @@ -110,10 +110,10 @@ public static final class Builder { private String middleName; private String nationality; private com.sumup.sdk.models.Ownership ownership; - private com.sumup.sdk.models.PhoneNumber phoneNumber; + private String phoneNumber; private java.util.List relationships; private String userId; - private com.sumup.sdk.models.Version version; + private String version; private Builder() {} @@ -152,7 +152,7 @@ public Builder birthdate(java.time.LocalDate birthdate) { * support of future countries in client code. * @return This builder instance. */ - public Builder citizenship(com.sumup.sdk.models.CountryCode citizenship) { + public Builder citizenship(String citizenship) { this.citizenship = citizenship; return this; } @@ -247,7 +247,7 @@ public Builder ownership(com.sumup.sdk.models.Ownership ownership) { * [E.164](https://en.wikipedia.org/wiki/E.164) format. * @return This builder instance. */ - public Builder phoneNumber(com.sumup.sdk.models.PhoneNumber phoneNumber) { + public Builder phoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; return this; } @@ -282,7 +282,7 @@ public Builder userId(String userId) { * to the API via one of the `PATCH` endpoints. * @return This builder instance. */ - public Builder version(com.sumup.sdk.models.Version version) { + public Builder version(String version) { this.version = version; return this; } diff --git a/src/main/java/com/sumup/sdk/models/BusinessProfile.java b/src/main/java/com/sumup/sdk/models/BusinessProfile.java index f9968f3..8f1d0d3 100644 --- a/src/main/java/com/sumup/sdk/models/BusinessProfile.java +++ b/src/main/java/com/sumup/sdk/models/BusinessProfile.java @@ -35,7 +35,7 @@ public record BusinessProfile( String name, /** A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format. */ - com.sumup.sdk.models.PhoneNumber phoneNumber, + String phoneNumber, /** The business's publicly available website. */ String website) { @@ -55,7 +55,7 @@ public static final class Builder { private String dynamicDescriptor; private String email; private String name; - private com.sumup.sdk.models.PhoneNumber phoneNumber; + private String phoneNumber; private String website; private Builder() {} @@ -129,7 +129,7 @@ public Builder name(String name) { * [E.164](https://en.wikipedia.org/wiki/E.164) format. * @return This builder instance. */ - public Builder phoneNumber(com.sumup.sdk.models.PhoneNumber phoneNumber) { + public Builder phoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; return this; } diff --git a/src/main/java/com/sumup/sdk/models/ChangeStatus.java b/src/main/java/com/sumup/sdk/models/ChangeStatus.java deleted file mode 100644 index 4d5d39a..0000000 --- a/src/main/java/com/sumup/sdk/models/ChangeStatus.java +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** - * 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. - */ -public record ChangeStatus(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/Company.java b/src/main/java/com/sumup/sdk/models/Company.java index 4d00e16..4e1443b 100644 --- a/src/main/java/com/sumup/sdk/models/Company.java +++ b/src/main/java/com/sumup/sdk/models/Company.java @@ -26,7 +26,7 @@ public record Company( * by other services. Consumers of this API are expected to use the country SDK to map to any * other IDs, translation keys, or descriptions. */ - com.sumup.sdk.models.LegalType legalType, + String legalType, /** * The merchant category code for the account as specified by @@ -39,7 +39,7 @@ public record Company( String name, /** A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format. */ - com.sumup.sdk.models.PhoneNumber phoneNumber, + String phoneNumber, /** * An address somewhere in the world. The address fields used depend on the country conventions. @@ -66,10 +66,10 @@ public static final class Builder { private com.sumup.sdk.models.Address address; private com.sumup.sdk.models.Attributes attributes; private com.sumup.sdk.models.CompanyIdentifiers identifiers; - private com.sumup.sdk.models.LegalType legalType; + private String legalType; private String merchantCategoryCode; private String name; - private com.sumup.sdk.models.PhoneNumber phoneNumber; + private String phoneNumber; private com.sumup.sdk.models.Address tradingAddress; private String website; @@ -120,7 +120,7 @@ public Builder identifiers(com.sumup.sdk.models.CompanyIdentifiers identifiers) * country SDK to map to any other IDs, translation keys, or descriptions. * @return This builder instance. */ - public Builder legalType(com.sumup.sdk.models.LegalType legalType) { + public Builder legalType(String legalType) { this.legalType = legalType; return this; } @@ -156,7 +156,7 @@ public Builder name(String name) { * [E.164](https://en.wikipedia.org/wiki/E.164) format. * @return This builder instance. */ - public Builder phoneNumber(com.sumup.sdk.models.PhoneNumber phoneNumber) { + public Builder phoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; return this; } diff --git a/src/main/java/com/sumup/sdk/models/CountryCode.java b/src/main/java/com/sumup/sdk/models/CountryCode.java deleted file mode 100644 index df3c0a5..0000000 --- a/src/main/java/com/sumup/sdk/models/CountryCode.java +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** - * 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. - */ -public record CountryCode(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/CreateReaderRequest.java b/src/main/java/com/sumup/sdk/models/CreateReaderRequest.java index 7b1a5e2..29c9f87 100644 --- a/src/main/java/com/sumup/sdk/models/CreateReaderRequest.java +++ b/src/main/java/com/sumup/sdk/models/CreateReaderRequest.java @@ -12,14 +12,14 @@ public record CreateReaderRequest( com.sumup.sdk.models.Metadata metadata, /** Custom human-readable, user-defined name for easier identification of the reader. */ - com.sumup.sdk.models.ReaderName name, + String name, /** * The pairing code is a 8 or 9 character alphanumeric string that is displayed on a SumUp * Device after initiating the pairing. It is used to link the physical device to the created * pairing. */ - com.sumup.sdk.models.ReaderPairingCode pairingCode) { + String pairingCode) { /** * Creates a builder for CreateReaderRequest. * @@ -32,8 +32,8 @@ public static Builder builder() { /** Builder for CreateReaderRequest instances. */ public static final class Builder { private com.sumup.sdk.models.Metadata metadata; - private com.sumup.sdk.models.ReaderName name; - private com.sumup.sdk.models.ReaderPairingCode pairingCode; + private String name; + private String pairingCode; private Builder() {} @@ -56,7 +56,7 @@ public Builder metadata(com.sumup.sdk.models.Metadata metadata) { * @param name Custom human-readable, user-defined name for easier identification of the reader. * @return This builder instance. */ - public Builder name(com.sumup.sdk.models.ReaderName name) { + public Builder name(String name) { this.name = name; return this; } @@ -69,7 +69,7 @@ public Builder name(com.sumup.sdk.models.ReaderName name) { * device to the created pairing. * @return This builder instance. */ - public Builder pairingCode(com.sumup.sdk.models.ReaderPairingCode pairingCode) { + public Builder pairingCode(String pairingCode) { this.pairingCode = pairingCode; return this; } diff --git a/src/main/java/com/sumup/sdk/models/Event.java b/src/main/java/com/sumup/sdk/models/Event.java index 82595c5..7cc6794 100644 --- a/src/main/java/com/sumup/sdk/models/Event.java +++ b/src/main/java/com/sumup/sdk/models/Event.java @@ -16,7 +16,7 @@ public record Event( Float feeAmount, /** Unique identifier of the transaction event. */ - com.sumup.sdk.models.TransactionEventId id, + Long id, /** Consecutive number of the installment associated with the event. */ Long installmentNumber, @@ -43,7 +43,7 @@ public record Event( java.time.OffsetDateTime timestamp, /** Unique identifier of the transaction. */ - com.sumup.sdk.models.TransactionId transactionId, + String transactionId, /** Type of the transaction event. */ com.sumup.sdk.models.TransactionEventType type) { @@ -62,11 +62,11 @@ public static final class Builder { private Float deductedAmount; private Float deductedFeeAmount; private Float feeAmount; - private com.sumup.sdk.models.TransactionEventId id; + private Long id; private Long installmentNumber; private com.sumup.sdk.models.TransactionEventStatus status; private java.time.OffsetDateTime timestamp; - private com.sumup.sdk.models.TransactionId transactionId; + private String transactionId; private com.sumup.sdk.models.TransactionEventType type; private Builder() {} @@ -121,7 +121,7 @@ public Builder feeAmount(Float feeAmount) { * @param id Unique identifier of the transaction event. * @return This builder instance. */ - public Builder id(com.sumup.sdk.models.TransactionEventId id) { + public Builder id(Long id) { this.id = id; return this; } @@ -179,7 +179,7 @@ public Builder timestamp(java.time.OffsetDateTime timestamp) { * @param transactionId Unique identifier of the transaction. * @return This builder instance. */ - public Builder transactionId(com.sumup.sdk.models.TransactionId transactionId) { + public Builder transactionId(String transactionId) { this.transactionId = transactionId; return this; } diff --git a/src/main/java/com/sumup/sdk/models/HorizontalAccuracy.java b/src/main/java/com/sumup/sdk/models/HorizontalAccuracy.java deleted file mode 100644 index 62c4b4e..0000000 --- a/src/main/java/com/sumup/sdk/models/HorizontalAccuracy.java +++ /dev/null @@ -1,5 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** Indication of the precision of the geographical position received from the payment terminal. */ -public record HorizontalAccuracy(Float value) {} diff --git a/src/main/java/com/sumup/sdk/models/Lat.java b/src/main/java/com/sumup/sdk/models/Lat.java deleted file mode 100644 index df7a02d..0000000 --- a/src/main/java/com/sumup/sdk/models/Lat.java +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** - * Latitude value from the coordinates of the payment location (as received from the payment - * terminal reader). - */ -public record Lat(Float value) {} diff --git a/src/main/java/com/sumup/sdk/models/LegalType.java b/src/main/java/com/sumup/sdk/models/LegalType.java deleted file mode 100644 index ce6fcd8..0000000 --- a/src/main/java/com/sumup/sdk/models/LegalType.java +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** - * The unique legal type reference as defined in the country SDK. We do not rely on IDs as used by - * other services. Consumers of this API are expected to use the country SDK to map to any other - * IDs, translation keys, or descriptions. - */ -public record LegalType(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/Lon.java b/src/main/java/com/sumup/sdk/models/Lon.java deleted file mode 100644 index 62242b9..0000000 --- a/src/main/java/com/sumup/sdk/models/Lon.java +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** - * Longitude value from the coordinates of the payment location (as received from the payment - * terminal reader). - */ -public record Lon(Float value) {} diff --git a/src/main/java/com/sumup/sdk/models/Membership.java b/src/main/java/com/sumup/sdk/models/Membership.java index 7001e78..c9b8c3e 100644 --- a/src/main/java/com/sumup/sdk/models/Membership.java +++ b/src/main/java/com/sumup/sdk/models/Membership.java @@ -46,7 +46,7 @@ public record Membership( * The type of the membership resource. Possible values are: * `merchant` - merchant account(s) * * `organization` - organization(s) */ - com.sumup.sdk.models.ResourceType type, + String type, /** The timestamp of when the membership was last updated. */ java.time.OffsetDateTime updatedAt) { @@ -71,7 +71,7 @@ public static final class Builder { private String resourceId; private java.util.List roles; private com.sumup.sdk.models.MembershipStatus status; - private com.sumup.sdk.models.ResourceType type; + private String type; private java.time.OffsetDateTime updatedAt; private Builder() {} @@ -195,7 +195,7 @@ public Builder status(com.sumup.sdk.models.MembershipStatus status) { * account(s) * `organization` - organization(s) * @return This builder instance. */ - public Builder type(com.sumup.sdk.models.ResourceType type) { + public Builder type(String type) { this.type = type; return this; } diff --git a/src/main/java/com/sumup/sdk/models/MembershipResource.java b/src/main/java/com/sumup/sdk/models/MembershipResource.java index 6fba58b..af4ef9e 100644 --- a/src/main/java/com/sumup/sdk/models/MembershipResource.java +++ b/src/main/java/com/sumup/sdk/models/MembershipResource.java @@ -24,7 +24,7 @@ public record MembershipResource( * The type of the membership resource. Possible values are: * `merchant` - merchant account(s) * * `organization` - organization(s) */ - com.sumup.sdk.models.ResourceType type, + String type, /** The timestamp of when the membership resource was last updated. */ java.time.OffsetDateTime updatedAt) { @@ -44,7 +44,7 @@ public static final class Builder { private String id; private String logo; private String name; - private com.sumup.sdk.models.ResourceType type; + private String type; private java.time.OffsetDateTime updatedAt; private Builder() {} @@ -111,7 +111,7 @@ public Builder name(String name) { * account(s) * `organization` - organization(s) * @return This builder instance. */ - public Builder type(com.sumup.sdk.models.ResourceType type) { + public Builder type(String type) { this.type = type; return this; } diff --git a/src/main/java/com/sumup/sdk/models/Merchant.java b/src/main/java/com/sumup/sdk/models/Merchant.java index bd65da7..ba6a14f 100644 --- a/src/main/java/com/sumup/sdk/models/Merchant.java +++ b/src/main/java/com/sumup/sdk/models/Merchant.java @@ -37,7 +37,7 @@ public record Merchant( * 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, + String changeStatus, com.sumup.sdk.models.ClassicMerchantIdentifiers classic, /** @@ -51,7 +51,7 @@ public record Merchant( * 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, + String country, /** * The date and time when the resource was created. This is a string as defined in [RFC 3339, @@ -103,7 +103,7 @@ public record Merchant( * 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) { + String version) { /** * Creates a builder for Merchant. * @@ -121,12 +121,12 @@ public static final class Builder { 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 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 String version; private Builder() {} @@ -214,7 +214,7 @@ public Builder company(com.sumup.sdk.models.Company company) { * support of future countries in client code. * @return This builder instance. */ - public Builder country(com.sumup.sdk.models.CountryCode country) { + public Builder country(String country) { this.country = country; return this; } @@ -280,7 +280,7 @@ public Builder sandbox(Boolean sandbox) { * to the API via one of the `PATCH` endpoints. * @return This builder instance. */ - public Builder version(com.sumup.sdk.models.Version version) { + public Builder version(String version) { this.version = version; return this; } diff --git a/src/main/java/com/sumup/sdk/models/Person.java b/src/main/java/com/sumup/sdk/models/Person.java index 1232068..dee505a 100644 --- a/src/main/java/com/sumup/sdk/models/Person.java +++ b/src/main/java/com/sumup/sdk/models/Person.java @@ -23,14 +23,14 @@ public record Person( * 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, + String 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, + String citizenship, /** * An [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code @@ -68,7 +68,7 @@ public record Person( 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, + String phoneNumber, /** * A list of roles the Person has in the Merchant or towards SumUp. A Merchant must have at @@ -83,7 +83,7 @@ public record Person( * 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) { + String version) { /** * Creates a builder for Person. * @@ -97,7 +97,7 @@ public static Builder builder() { 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 citizenship; private String countryOfResidence; private String familyName; private String givenName; @@ -105,10 +105,10 @@ public static final class Builder { private String middleName; private String nationality; private com.sumup.sdk.models.Ownership ownership; - private com.sumup.sdk.models.PhoneNumber phoneNumber; + private String phoneNumber; private java.util.List relationships; private String userId; - private com.sumup.sdk.models.Version version; + private String version; private Builder() {} @@ -147,7 +147,7 @@ public Builder birthdate(java.time.LocalDate birthdate) { * support of future countries in client code. * @return This builder instance. */ - public Builder citizenship(com.sumup.sdk.models.CountryCode citizenship) { + public Builder citizenship(String citizenship) { this.citizenship = citizenship; return this; } @@ -242,7 +242,7 @@ public Builder ownership(com.sumup.sdk.models.Ownership ownership) { * [E.164](https://en.wikipedia.org/wiki/E.164) format. * @return This builder instance. */ - public Builder phoneNumber(com.sumup.sdk.models.PhoneNumber phoneNumber) { + public Builder phoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; return this; } @@ -277,7 +277,7 @@ public Builder userId(String userId) { * to the API via one of the `PATCH` endpoints. * @return This builder instance. */ - public Builder version(com.sumup.sdk.models.Version version) { + public Builder version(String version) { this.version = version; return this; } diff --git a/src/main/java/com/sumup/sdk/models/PhoneNumber.java b/src/main/java/com/sumup/sdk/models/PhoneNumber.java deleted file mode 100644 index 821d4f6..0000000 --- a/src/main/java/com/sumup/sdk/models/PhoneNumber.java +++ /dev/null @@ -1,5 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** A publicly available phone number in [E.164](https://en.wikipedia.org/wiki/E.164) format. */ -public record PhoneNumber(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/Reader.java b/src/main/java/com/sumup/sdk/models/Reader.java index aa4b17d..dffcf79 100644 --- a/src/main/java/com/sumup/sdk/models/Reader.java +++ b/src/main/java/com/sumup/sdk/models/Reader.java @@ -12,7 +12,7 @@ public record Reader( com.sumup.sdk.models.ReaderDevice device, /** Unique identifier of the reader that the payment is initiated on. */ - com.sumup.sdk.models.ReaderId id, + String id, /** * Set of user-defined key-value pairs attached to the object. Partial updates are not @@ -22,7 +22,7 @@ public record Reader( com.sumup.sdk.models.Metadata metadata, /** Custom human-readable, user-defined name for easier identification of the reader. */ - com.sumup.sdk.models.ReaderName name, + String name, /** * Identifier of the system-managed service account associated with this reader. Present only @@ -54,9 +54,9 @@ public static Builder builder() { public static final class Builder { private java.time.OffsetDateTime createdAt; private com.sumup.sdk.models.ReaderDevice device; - private com.sumup.sdk.models.ReaderId id; + private String id; private com.sumup.sdk.models.Metadata metadata; - private com.sumup.sdk.models.ReaderName name; + private String name; private java.util.UUID serviceAccountId; private com.sumup.sdk.models.ReaderStatus status; private java.time.OffsetDateTime updatedAt; @@ -91,7 +91,7 @@ public Builder device(com.sumup.sdk.models.ReaderDevice device) { * @param id Unique identifier of the reader that the payment is initiated on. * @return This builder instance. */ - public Builder id(com.sumup.sdk.models.ReaderId id) { + public Builder id(String id) { this.id = id; return this; } @@ -115,7 +115,7 @@ public Builder metadata(com.sumup.sdk.models.Metadata metadata) { * @param name Custom human-readable, user-defined name for easier identification of the reader. * @return This builder instance. */ - public Builder name(com.sumup.sdk.models.ReaderName name) { + public Builder name(String name) { this.name = name; return this; } diff --git a/src/main/java/com/sumup/sdk/models/ReaderId.java b/src/main/java/com/sumup/sdk/models/ReaderId.java deleted file mode 100644 index 6c65be8..0000000 --- a/src/main/java/com/sumup/sdk/models/ReaderId.java +++ /dev/null @@ -1,5 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** Unique identifier of the reader that the payment is initiated on. */ -public record ReaderId(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/ReaderName.java b/src/main/java/com/sumup/sdk/models/ReaderName.java deleted file mode 100644 index aa85cdc..0000000 --- a/src/main/java/com/sumup/sdk/models/ReaderName.java +++ /dev/null @@ -1,5 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** Custom human-readable, user-defined name for easier identification of the reader. */ -public record ReaderName(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/ReaderPairingCode.java b/src/main/java/com/sumup/sdk/models/ReaderPairingCode.java deleted file mode 100644 index 6c9c18c..0000000 --- a/src/main/java/com/sumup/sdk/models/ReaderPairingCode.java +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** - * The pairing code is a 8 or 9 character alphanumeric string that is displayed on a SumUp Device - * after initiating the pairing. It is used to link the physical device to the created pairing. - */ -public record ReaderPairingCode(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/ReceiptEvent.java b/src/main/java/com/sumup/sdk/models/ReceiptEvent.java index 20bae0f..ac69c42 100644 --- a/src/main/java/com/sumup/sdk/models/ReceiptEvent.java +++ b/src/main/java/com/sumup/sdk/models/ReceiptEvent.java @@ -7,7 +7,7 @@ public record ReceiptEvent( String amount, /** Unique identifier of the transaction event. */ - com.sumup.sdk.models.TransactionEventId id, + Long id, /** Receipt number associated with the event. */ String receiptNo, @@ -34,7 +34,7 @@ public record ReceiptEvent( java.time.OffsetDateTime timestamp, /** Unique identifier of the transaction. */ - com.sumup.sdk.models.TransactionId transactionId, + String transactionId, /** Type of the transaction event. */ com.sumup.sdk.models.TransactionEventType type) { @@ -50,11 +50,11 @@ public static Builder builder() { /** Builder for ReceiptEvent instances. */ public static final class Builder { private String amount; - private com.sumup.sdk.models.TransactionEventId id; + private Long id; private String receiptNo; private com.sumup.sdk.models.TransactionEventStatus status; private java.time.OffsetDateTime timestamp; - private com.sumup.sdk.models.TransactionId transactionId; + private String transactionId; private com.sumup.sdk.models.TransactionEventType type; private Builder() {} @@ -76,7 +76,7 @@ public Builder amount(String amount) { * @param id Unique identifier of the transaction event. * @return This builder instance. */ - public Builder id(com.sumup.sdk.models.TransactionEventId id) { + public Builder id(Long id) { this.id = id; return this; } @@ -134,7 +134,7 @@ public Builder timestamp(java.time.OffsetDateTime timestamp) { * @param transactionId Unique identifier of the transaction. * @return This builder instance. */ - public Builder transactionId(com.sumup.sdk.models.TransactionId transactionId) { + public Builder transactionId(String transactionId) { this.transactionId = transactionId; return this; } diff --git a/src/main/java/com/sumup/sdk/models/ReceiptTransaction.java b/src/main/java/com/sumup/sdk/models/ReceiptTransaction.java index 1e23185..391f595 100644 --- a/src/main/java/com/sumup/sdk/models/ReceiptTransaction.java +++ b/src/main/java/com/sumup/sdk/models/ReceiptTransaction.java @@ -52,7 +52,7 @@ public record ReceiptTransaction( String transactionCode, /** Unique identifier of the transaction. */ - com.sumup.sdk.models.TransactionId transactionId, + String transactionId, /** VAT included in the transaction amount, in major units. */ String vatAmount, @@ -89,7 +89,7 @@ public static final class Builder { private java.time.OffsetDateTime timestamp; private String tipAmount; private String transactionCode; - private com.sumup.sdk.models.TransactionId transactionId; + private String transactionId; private String vatAmount; private java.util.List vatRates; private String verificationMethod; @@ -279,7 +279,7 @@ public Builder transactionCode(String transactionCode) { * @param transactionId Unique identifier of the transaction. * @return This builder instance. */ - public Builder transactionId(com.sumup.sdk.models.TransactionId transactionId) { + public Builder transactionId(String transactionId) { this.transactionId = transactionId; return this; } diff --git a/src/main/java/com/sumup/sdk/models/ResourceType.java b/src/main/java/com/sumup/sdk/models/ResourceType.java deleted file mode 100644 index 8c89b91..0000000 --- a/src/main/java/com/sumup/sdk/models/ResourceType.java +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** - * The type of the membership resource. Possible values are: * `merchant` - merchant account(s) * - * `organization` - organization(s) - */ -public record ResourceType(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/TransactionEvent.java b/src/main/java/com/sumup/sdk/models/TransactionEvent.java index 6807dd7..52a0283 100644 --- a/src/main/java/com/sumup/sdk/models/TransactionEvent.java +++ b/src/main/java/com/sumup/sdk/models/TransactionEvent.java @@ -16,7 +16,7 @@ public record TransactionEvent( com.sumup.sdk.models.TransactionEventType eventType, /** Unique identifier of the transaction event. */ - com.sumup.sdk.models.TransactionEventId id, + Long id, /** * Consecutive number of the installment that is paid. Applicable only payout events, i.e. @@ -59,7 +59,7 @@ public static final class Builder { private java.time.LocalDate date; private java.time.LocalDate dueDate; private com.sumup.sdk.models.TransactionEventType eventType; - private com.sumup.sdk.models.TransactionEventId id; + private Long id; private Long installmentNumber; private com.sumup.sdk.models.TransactionEventStatus status; private java.time.OffsetDateTime timestamp; @@ -116,7 +116,7 @@ public Builder eventType(com.sumup.sdk.models.TransactionEventType eventType) { * @param id Unique identifier of the transaction event. * @return This builder instance. */ - public Builder id(com.sumup.sdk.models.TransactionEventId id) { + public Builder id(Long id) { this.id = id; return this; } diff --git a/src/main/java/com/sumup/sdk/models/TransactionEventId.java b/src/main/java/com/sumup/sdk/models/TransactionEventId.java deleted file mode 100644 index c77c296..0000000 --- a/src/main/java/com/sumup/sdk/models/TransactionEventId.java +++ /dev/null @@ -1,5 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** Unique identifier of the transaction event. */ -public record TransactionEventId(Long value) {} diff --git a/src/main/java/com/sumup/sdk/models/TransactionFull.java b/src/main/java/com/sumup/sdk/models/TransactionFull.java index 1460cd0..61b5294 100644 --- a/src/main/java/com/sumup/sdk/models/TransactionFull.java +++ b/src/main/java/com/sumup/sdk/models/TransactionFull.java @@ -44,7 +44,7 @@ public record TransactionFull( /** * Indication of the precision of the geographical position received from the payment terminal. */ - com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy, + Float horizontalAccuracy, /** Unique identifier of the transaction. */ String id, @@ -56,7 +56,7 @@ public record TransactionFull( * Latitude value from the coordinates of the payment location (as received from the payment * terminal reader). */ - com.sumup.sdk.models.Lat lat, + Float lat, /** List of hyperlinks for accessing related resources. */ java.util.List links, @@ -71,7 +71,7 @@ public record TransactionFull( * Longitude value from the coordinates of the payment location (as received from the payment * terminal reader). */ - com.sumup.sdk.models.Lon lon, + Float lon, /** Unique code of the registered merchant to whom the payment is made. */ String merchantCode, @@ -188,14 +188,14 @@ public static final class Builder { private java.util.List events; private Double feeAmount; private String foreignTransactionId; - private com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy; + private Float horizontalAccuracy; private String id; private Long installmentsCount; - private com.sumup.sdk.models.Lat lat; + private Float 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 Float lon; private String merchantCode; private Long merchantId; private com.sumup.sdk.models.PaymentType paymentType; @@ -352,7 +352,7 @@ public Builder foreignTransactionId(String foreignTransactionId) { * from the payment terminal. * @return This builder instance. */ - public Builder horizontalAccuracy(com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy) { + public Builder horizontalAccuracy(Float horizontalAccuracy) { this.horizontalAccuracy = horizontalAccuracy; return this; } @@ -386,7 +386,7 @@ public Builder installmentsCount(Long installmentsCount) { * payment terminal reader). * @return This builder instance. */ - public Builder lat(com.sumup.sdk.models.Lat lat) { + public Builder lat(Float lat) { this.lat = lat; return this; } @@ -431,7 +431,7 @@ public Builder location(com.sumup.sdk.models.TransactionFullLocation location) { * payment terminal reader). * @return This builder instance. */ - public Builder lon(com.sumup.sdk.models.Lon lon) { + public Builder lon(Float lon) { this.lon = lon; return this; } diff --git a/src/main/java/com/sumup/sdk/models/TransactionFullLocation.java b/src/main/java/com/sumup/sdk/models/TransactionFullLocation.java index a344a21..2c7213b 100644 --- a/src/main/java/com/sumup/sdk/models/TransactionFullLocation.java +++ b/src/main/java/com/sumup/sdk/models/TransactionFullLocation.java @@ -6,19 +6,19 @@ public record TransactionFullLocation( /** * Indication of the precision of the geographical position received from the payment terminal. */ - com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy, + Float horizontalAccuracy, /** * Latitude value from the coordinates of the payment location (as received from the payment * terminal reader). */ - com.sumup.sdk.models.Lat lat, + Float lat, /** * Longitude value from the coordinates of the payment location (as received from the payment * terminal reader). */ - com.sumup.sdk.models.Lon lon) { + Float lon) { /** * Creates a builder for TransactionFullLocation. * @@ -30,9 +30,9 @@ public static Builder 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 Float horizontalAccuracy; + private Float lat; + private Float lon; private Builder() {} @@ -43,7 +43,7 @@ private Builder() {} * from the payment terminal. * @return This builder instance. */ - public Builder horizontalAccuracy(com.sumup.sdk.models.HorizontalAccuracy horizontalAccuracy) { + public Builder horizontalAccuracy(Float horizontalAccuracy) { this.horizontalAccuracy = horizontalAccuracy; return this; } @@ -55,7 +55,7 @@ public Builder horizontalAccuracy(com.sumup.sdk.models.HorizontalAccuracy horizo * payment terminal reader). * @return This builder instance. */ - public Builder lat(com.sumup.sdk.models.Lat lat) { + public Builder lat(Float lat) { this.lat = lat; return this; } @@ -67,7 +67,7 @@ public Builder lat(com.sumup.sdk.models.Lat lat) { * payment terminal reader). * @return This builder instance. */ - public Builder lon(com.sumup.sdk.models.Lon lon) { + public Builder lon(Float lon) { this.lon = lon; return this; } diff --git a/src/main/java/com/sumup/sdk/models/TransactionHistory.java b/src/main/java/com/sumup/sdk/models/TransactionHistory.java index 2e7abf9..bea9280 100644 --- a/src/main/java/com/sumup/sdk/models/TransactionHistory.java +++ b/src/main/java/com/sumup/sdk/models/TransactionHistory.java @@ -68,7 +68,7 @@ public record TransactionHistory( String transactionCode, /** Unique identifier of the transaction. */ - com.sumup.sdk.models.TransactionId transactionId, + String transactionId, /** Type of the transaction for the registered user specified in the `user` property. */ com.sumup.sdk.models.TransactionHistoryType type, @@ -103,7 +103,7 @@ public static final class Builder { private com.sumup.sdk.models.TransactionStatus status; private java.time.OffsetDateTime timestamp; private String transactionCode; - private com.sumup.sdk.models.TransactionId transactionId; + private String transactionId; private com.sumup.sdk.models.TransactionHistoryType type; private String user; @@ -312,7 +312,7 @@ public Builder transactionCode(String transactionCode) { * @param transactionId Unique identifier of the transaction. * @return This builder instance. */ - public Builder transactionId(com.sumup.sdk.models.TransactionId transactionId) { + public Builder transactionId(String transactionId) { this.transactionId = transactionId; return this; } diff --git a/src/main/java/com/sumup/sdk/models/TransactionId.java b/src/main/java/com/sumup/sdk/models/TransactionId.java deleted file mode 100644 index 46d5ffa..0000000 --- a/src/main/java/com/sumup/sdk/models/TransactionId.java +++ /dev/null @@ -1,5 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** Unique identifier of the transaction. */ -public record TransactionId(String value) {} diff --git a/src/main/java/com/sumup/sdk/models/UpdateReaderRequest.java b/src/main/java/com/sumup/sdk/models/UpdateReaderRequest.java index 5c40e4c..83b1d18 100644 --- a/src/main/java/com/sumup/sdk/models/UpdateReaderRequest.java +++ b/src/main/java/com/sumup/sdk/models/UpdateReaderRequest.java @@ -10,7 +10,7 @@ public record UpdateReaderRequest( com.sumup.sdk.models.Metadata metadata, /** Custom human-readable, user-defined name for easier identification of the reader. */ - com.sumup.sdk.models.ReaderName name) { + String name) { /** * Creates a builder for UpdateReaderRequest. * @@ -23,7 +23,7 @@ public static Builder builder() { /** Builder for UpdateReaderRequest instances. */ public static final class Builder { private com.sumup.sdk.models.Metadata metadata; - private com.sumup.sdk.models.ReaderName name; + private String name; private Builder() {} @@ -46,7 +46,7 @@ public Builder metadata(com.sumup.sdk.models.Metadata metadata) { * @param name Custom human-readable, user-defined name for easier identification of the reader. * @return This builder instance. */ - public Builder name(com.sumup.sdk.models.ReaderName name) { + public Builder name(String name) { this.name = name; return this; } diff --git a/src/main/java/com/sumup/sdk/models/Version.java b/src/main/java/com/sumup/sdk/models/Version.java deleted file mode 100644 index b271038..0000000 --- a/src/main/java/com/sumup/sdk/models/Version.java +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by sumup-java/codegen. DO NOT EDIT. -package com.sumup.sdk.models; - -/** - * The version of the resource. The version reflects a specific change submitted to the API via one - * of the `PATCH` endpoints. - */ -public record Version(String value) {} diff --git a/src/test/java/com/sumup/sdk/core/ApiClientTest.java b/src/test/java/com/sumup/sdk/core/ApiClientTest.java index 0bb5a8d..3d04a0e 100644 --- a/src/test/java/com/sumup/sdk/core/ApiClientTest.java +++ b/src/test/java/com/sumup/sdk/core/ApiClientTest.java @@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import com.sumup.sdk.clients.ReadersClient; -import com.sumup.sdk.models.ReaderId; import java.net.Authenticator; import java.net.CookieHandler; import java.net.ProxySelector; @@ -113,12 +112,12 @@ void requestOptionsCanOverrideTimeout() { } @Test - void pathParamsUnwrapSingleValueRecords() { + void readerPathParamsEncodeStrings() { CapturingHttpClient httpClient = new CapturingHttpClient(); ApiClient apiClient = ApiClient.builder().httpClient(httpClient).build(); ReadersClient readersClient = new ReadersClient(apiClient); - readersClient.delete("merchant-code", new ReaderId("reader 123")); + readersClient.delete("merchant-code", "reader 123"); assertEquals( URI.create("https://api.sumup.com/v0.1/merchants/merchant-code/readers/reader+123"), diff --git a/src/test/java/com/sumup/sdk/models/ScalarModelsTest.java b/src/test/java/com/sumup/sdk/models/ScalarModelsTest.java new file mode 100644 index 0000000..6401e7c --- /dev/null +++ b/src/test/java/com/sumup/sdk/models/ScalarModelsTest.java @@ -0,0 +1,27 @@ +package com.sumup.sdk.models; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +final class ScalarModelsTest { + @Test + void readerScalarsUseJsonStrings() throws Exception { + var mapper = new ObjectMapper(); + var request = CreateReaderRequest.builder().name("Counter 1").pairingCode("ABC123XYZ").build(); + var json = mapper.readTree(mapper.writeValueAsString(request)); + assertEquals("Counter 1", json.get("name").textValue()); + assertEquals("ABC123XYZ", json.get("pairingCode").textValue()); + + var reader = + mapper.readValue( + """ + {"id":"reader-123","name":"Counter 1","status":"paired"} + """, + Reader.class); + assertEquals("reader-123", reader.id()); + assertEquals("Counter 1", reader.name()); + assertEquals(ReaderStatus.PAIRED, reader.status()); + } +}