diff --git a/.spec-sha256 b/.spec-sha256 index c86c3d8..903fef4 100644 --- a/.spec-sha256 +++ b/.spec-sha256 @@ -1 +1 @@ -1c648bd5dd3dab534723d1cb26e19fdbfcc7359cd8a33a1f8d99e5688e4ba54f +8c6a3b8bfecad67daa21d1361057c24f2e063b17c13afdcc93e7f71806011003 diff --git a/src/main/java/com/controlresell/sdk/ControlResell.java b/src/main/java/com/controlresell/sdk/ControlResell.java index 3de5129..901b5fb 100644 --- a/src/main/java/com/controlresell/sdk/ControlResell.java +++ b/src/main/java/com/controlresell/sdk/ControlResell.java @@ -4,6 +4,7 @@ import com.controlresell.sdk.generated.ApiException; import com.controlresell.sdk.generated.api.AccountsApi; import com.controlresell.sdk.generated.api.ConversationsApi; +import com.controlresell.sdk.generated.api.CustomersApi; import com.controlresell.sdk.generated.api.ItemsApi; import com.controlresell.sdk.generated.api.MeApi; import com.controlresell.sdk.generated.api.OrdersApi; @@ -11,6 +12,8 @@ import com.controlresell.sdk.generated.model.AccountPage; import com.controlresell.sdk.generated.model.Conversation; import com.controlresell.sdk.generated.model.ConversationPage; +import com.controlresell.sdk.generated.model.Customer; +import com.controlresell.sdk.generated.model.CustomerPage; import com.controlresell.sdk.generated.model.Item; import com.controlresell.sdk.generated.model.ItemCreateRequest; import com.controlresell.sdk.generated.model.ItemPage; @@ -143,6 +146,9 @@ public T call(boolean write, HttpCall call) { /** The seller's sales and purchases. */ public Orders orders() { return new Orders(); } + /** The other parties of the seller's sales and purchases (needs the {@code customers:read} scope). */ + public Customers customers() { return new Customers(); } + /** The seller the API key acts for. */ public final class MeResource { private final MeApi api = new MeApi(apiClient); @@ -336,6 +342,29 @@ public Iterable listAll(Integer limit, String bucket, String platform, UU } } + /** The other parties of the seller's sales and purchases. */ + public final class Customers { + private final CustomersApi api = new CustomersApi(apiClient); + + private Customers() {} + + /** + * One page of customers, the most recently created first; every argument may be {@code null}. {@code from} is + * inclusive and {@code to} exclusive, on the creation date. + */ + public CustomerPage list(Integer limit, String cursor, UUID accountId, OffsetDateTime from, OffsetDateTime to) { + return call(false, h -> api.listCustomers(limit, cursor, from, to, accountId, h)); + } + + public Customer get(UUID id) { return call(false, h -> api.getCustomer(id, h)); } + + /** Every customer, page after page, with the same filters. */ + public Iterable listAll(Integer limit, UUID accountId, OffsetDateTime from, OffsetDateTime to) { + return new Paginator<>(cursor -> list(limit, cursor, accountId, from, to), + p -> page(p.getData(), p.getNextCursor())); + } + } + /** * The {@code Idempotency-Key} of a write: the caller's, else a random one. It is chosen once, outside the retries, so * every attempt of the call sends the same key (the typed methods take the key as an argument, not through the retrier). diff --git a/src/main/java/com/controlresell/sdk/generated/api/CustomersApi.java b/src/main/java/com/controlresell/sdk/generated/api/CustomersApi.java new file mode 100644 index 0000000..193858b --- /dev/null +++ b/src/main/java/com/controlresell/sdk/generated/api/CustomersApi.java @@ -0,0 +1,439 @@ +/* + * ControlResell public API + * The public API of ControlResell. Every error answers `{\"error\": {\"code\", \"message\", \"params\", \"requestId\"}}`; a `POST` takes an `Idempotency-Key` header. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.controlresell.sdk.generated.api; + +import com.controlresell.sdk.generated.ApiClient; +import com.controlresell.sdk.generated.ApiException; +import com.controlresell.sdk.generated.ApiResponse; +import com.controlresell.sdk.generated.Configuration; +import com.controlresell.sdk.generated.Pair; + +import com.controlresell.sdk.generated.model.Customer; +import com.controlresell.sdk.generated.model.CustomerPage; +import com.controlresell.sdk.generated.model.ErrorResponse; +import java.time.OffsetDateTime; +import java.util.UUID; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0") +public class CustomersApi { + /** + * Utility class for extending HttpRequest.Builder functionality. + */ + private static class HttpRequestBuilderExtensions { + /** + * Adds additional headers to the provided HttpRequest.Builder. Useful for adding method/endpoint specific headers. + * + * @param builder the HttpRequest.Builder to which headers will be added + * @param headers a map of header names and values to add; may be null + * @return the same HttpRequest.Builder instance with the additional headers set + */ + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public CustomersApi() { + this(Configuration.getDefaultApiClient()); + } + + public CustomersApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + InputStream responseBody = ApiClient.getResponseBody(response); + String body = null; + try { + body = responseBody == null ? null : new String(responseBody.readAllBytes()); + } finally { + if (responseBody != null) { + responseBody.close(); + } + } + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Download file from the given response. + * + * @param response Response + * @return File + * @throws ApiException If fail to read file content from response and write to disk + */ + public File downloadFileFromResponse(HttpResponse response, InputStream responseBody) throws ApiException { + if (responseBody == null) { + throw new ApiException(new IOException("Response body is empty")); + } + try { + File file = prepareDownloadFile(response); + java.nio.file.Files.copy(responseBody, file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + *

Prepare the file for download from the response.

+ * + * @param response a {@link java.net.http.HttpResponse} object. + * @return a {@link java.io.File} object. + * @throws java.io.IOException if any. + */ + private File prepareDownloadFile(HttpResponse response) throws IOException { + String filename = null; + java.util.Optional contentDisposition = response.headers().firstValue("Content-Disposition"); + if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) { + // Get filename from the Content-Disposition header. + java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get()); + if (matcher.find()) + filename = matcher.group(1); + } + File file = null; + if (filename != null) { + java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native"); + java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename)); + file = filePath.toFile(); + tempDir.toFile().deleteOnExit(); // best effort cleanup + file.deleteOnExit(); // best effort cleanup + } else { + file = java.nio.file.Files.createTempFile("download-", "").toFile(); + file.deleteOnExit(); // best effort cleanup + } + return file; + } + + /** + * Read one customer + * One customer of the seller, by its identifier (`GET /customers` lists them). Requires `customers:read`. + * @param id The customer's identifier, a UUID. (required) + * @return Customer + * @throws ApiException if fails to make API call + */ + public Customer getCustomer(@jakarta.annotation.Nonnull UUID id) throws ApiException { + return getCustomer(id, null); + } + + /** + * Read one customer + * One customer of the seller, by its identifier (`GET /customers` lists them). Requires `customers:read`. + * @param id The customer's identifier, a UUID. (required) + * @param headers Optional headers to include in the request + * @return Customer + * @throws ApiException if fails to make API call + */ + public Customer getCustomer(@jakarta.annotation.Nonnull UUID id, Map headers) throws ApiException { + ApiResponse localVarResponse = getCustomerWithHttpInfo(id, headers); + return localVarResponse.getData(); + } + + /** + * Read one customer + * One customer of the seller, by its identifier (`GET /customers` lists them). Requires `customers:read`. + * @param id The customer's identifier, a UUID. (required) + * @return ApiResponse<Customer> + * @throws ApiException if fails to make API call + */ + public ApiResponse getCustomerWithHttpInfo(@jakarta.annotation.Nonnull UUID id) throws ApiException { + return getCustomerWithHttpInfo(id, null); + } + + /** + * Read one customer + * One customer of the seller, by its identifier (`GET /customers` lists them). Requires `customers:read`. + * @param id The customer's identifier, a UUID. (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<Customer> + * @throws ApiException if fails to make API call + */ + public ApiResponse getCustomerWithHttpInfo(@jakarta.annotation.Nonnull UUID id, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getCustomerRequestBuilder(id, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + InputStream localVarResponseBody = null; + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getCustomer", localVarResponse); + } + localVarResponseBody = ApiClient.getResponseBody(localVarResponse); + if (localVarResponseBody == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + + + String responseBody = new String(localVarResponseBody.readAllBytes()); + Customer responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}); + + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseValue + ); + } finally { + if (localVarResponseBody != null) { + localVarResponseBody.close(); + } + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getCustomerRequestBuilder(@jakarta.annotation.Nonnull UUID id, Map headers) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException(400, "Missing the required parameter 'id' when calling getCustomer"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/api/public/v1/customers/{id}" + .replace("{id}", ApiClient.urlEncode(id.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * List the seller's customers + * The other parties of the seller's sales and purchases, as written on their invoices: a customer is created with the invoice of its first order. The most recently created first (by `createdAt`, then `id`), one page at a time: pass the `nextCursor` of a page as `cursor` to read the next one, with the same filters (a cursor reused with other filters is an `invalid_cursor`). `from` and `to` go straight to a period of creation: `from` is inclusive, `to` exclusive. Requires `customers:read`. + * @param limit Page size, 1 to 100 (50 by default). (optional, default to 50) + * @param cursor The `nextCursor` of the previous page. (optional) + * @param from Only the customers created at or after this instant (inclusive), ISO-8601 with its offset, such as `2026-10-01T00:00:00Z`. (optional) + * @param to Only the customers created before this instant (exclusive), ISO-8601 with its offset; after `from`. (optional) + * @param accountId Only the customers of an order on this marketplace account (`GET /accounts`). (optional) + * @return CustomerPage + * @throws ApiException if fails to make API call + */ + public CustomerPage listCustomers(@jakarta.annotation.Nullable Integer limit, @jakarta.annotation.Nullable String cursor, @jakarta.annotation.Nullable OffsetDateTime from, @jakarta.annotation.Nullable OffsetDateTime to, @jakarta.annotation.Nullable UUID accountId) throws ApiException { + return listCustomers(limit, cursor, from, to, accountId, null); + } + + /** + * List the seller's customers + * The other parties of the seller's sales and purchases, as written on their invoices: a customer is created with the invoice of its first order. The most recently created first (by `createdAt`, then `id`), one page at a time: pass the `nextCursor` of a page as `cursor` to read the next one, with the same filters (a cursor reused with other filters is an `invalid_cursor`). `from` and `to` go straight to a period of creation: `from` is inclusive, `to` exclusive. Requires `customers:read`. + * @param limit Page size, 1 to 100 (50 by default). (optional, default to 50) + * @param cursor The `nextCursor` of the previous page. (optional) + * @param from Only the customers created at or after this instant (inclusive), ISO-8601 with its offset, such as `2026-10-01T00:00:00Z`. (optional) + * @param to Only the customers created before this instant (exclusive), ISO-8601 with its offset; after `from`. (optional) + * @param accountId Only the customers of an order on this marketplace account (`GET /accounts`). (optional) + * @param headers Optional headers to include in the request + * @return CustomerPage + * @throws ApiException if fails to make API call + */ + public CustomerPage listCustomers(@jakarta.annotation.Nullable Integer limit, @jakarta.annotation.Nullable String cursor, @jakarta.annotation.Nullable OffsetDateTime from, @jakarta.annotation.Nullable OffsetDateTime to, @jakarta.annotation.Nullable UUID accountId, Map headers) throws ApiException { + ApiResponse localVarResponse = listCustomersWithHttpInfo(limit, cursor, from, to, accountId, headers); + return localVarResponse.getData(); + } + + /** + * List the seller's customers + * The other parties of the seller's sales and purchases, as written on their invoices: a customer is created with the invoice of its first order. The most recently created first (by `createdAt`, then `id`), one page at a time: pass the `nextCursor` of a page as `cursor` to read the next one, with the same filters (a cursor reused with other filters is an `invalid_cursor`). `from` and `to` go straight to a period of creation: `from` is inclusive, `to` exclusive. Requires `customers:read`. + * @param limit Page size, 1 to 100 (50 by default). (optional, default to 50) + * @param cursor The `nextCursor` of the previous page. (optional) + * @param from Only the customers created at or after this instant (inclusive), ISO-8601 with its offset, such as `2026-10-01T00:00:00Z`. (optional) + * @param to Only the customers created before this instant (exclusive), ISO-8601 with its offset; after `from`. (optional) + * @param accountId Only the customers of an order on this marketplace account (`GET /accounts`). (optional) + * @return ApiResponse<CustomerPage> + * @throws ApiException if fails to make API call + */ + public ApiResponse listCustomersWithHttpInfo(@jakarta.annotation.Nullable Integer limit, @jakarta.annotation.Nullable String cursor, @jakarta.annotation.Nullable OffsetDateTime from, @jakarta.annotation.Nullable OffsetDateTime to, @jakarta.annotation.Nullable UUID accountId) throws ApiException { + return listCustomersWithHttpInfo(limit, cursor, from, to, accountId, null); + } + + /** + * List the seller's customers + * The other parties of the seller's sales and purchases, as written on their invoices: a customer is created with the invoice of its first order. The most recently created first (by `createdAt`, then `id`), one page at a time: pass the `nextCursor` of a page as `cursor` to read the next one, with the same filters (a cursor reused with other filters is an `invalid_cursor`). `from` and `to` go straight to a period of creation: `from` is inclusive, `to` exclusive. Requires `customers:read`. + * @param limit Page size, 1 to 100 (50 by default). (optional, default to 50) + * @param cursor The `nextCursor` of the previous page. (optional) + * @param from Only the customers created at or after this instant (inclusive), ISO-8601 with its offset, such as `2026-10-01T00:00:00Z`. (optional) + * @param to Only the customers created before this instant (exclusive), ISO-8601 with its offset; after `from`. (optional) + * @param accountId Only the customers of an order on this marketplace account (`GET /accounts`). (optional) + * @param headers Optional headers to include in the request + * @return ApiResponse<CustomerPage> + * @throws ApiException if fails to make API call + */ + public ApiResponse listCustomersWithHttpInfo(@jakarta.annotation.Nullable Integer limit, @jakarta.annotation.Nullable String cursor, @jakarta.annotation.Nullable OffsetDateTime from, @jakarta.annotation.Nullable OffsetDateTime to, @jakarta.annotation.Nullable UUID accountId, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = listCustomersRequestBuilder(limit, cursor, from, to, accountId, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + InputStream localVarResponseBody = null; + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("listCustomers", localVarResponse); + } + localVarResponseBody = ApiClient.getResponseBody(localVarResponse); + if (localVarResponseBody == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + + + String responseBody = new String(localVarResponseBody.readAllBytes()); + CustomerPage responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}); + + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseValue + ); + } finally { + if (localVarResponseBody != null) { + localVarResponseBody.close(); + } + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder listCustomersRequestBuilder(@jakarta.annotation.Nullable Integer limit, @jakarta.annotation.Nullable String cursor, @jakarta.annotation.Nullable OffsetDateTime from, @jakarta.annotation.Nullable OffsetDateTime to, @jakarta.annotation.Nullable UUID accountId, Map headers) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/api/public/v1/customers"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "limit"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("limit", limit)); + localVarQueryParameterBaseName = "cursor"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("cursor", cursor)); + localVarQueryParameterBaseName = "from"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("from", from)); + localVarQueryParameterBaseName = "to"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("to", to)); + localVarQueryParameterBaseName = "accountId"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("accountId", accountId)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/src/main/java/com/controlresell/sdk/generated/model/Customer.java b/src/main/java/com/controlresell/sdk/generated/model/Customer.java new file mode 100644 index 0000000..6af2a06 --- /dev/null +++ b/src/main/java/com/controlresell/sdk/generated/model/Customer.java @@ -0,0 +1,331 @@ +/* + * ControlResell public API + * The public API of ControlResell. Every error answers `{\"error\": {\"code\", \"message\", \"params\", \"requestId\"}}`; a `POST` takes an `Idempotency-Key` header. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.controlresell.sdk.generated.model; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.controlresell.sdk.generated.model.CustomerAddress; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import com.controlresell.sdk.generated.ApiClient; +/** + * Customer + */ +@JsonPropertyOrder({ + Customer.JSON_PROPERTY_ID, + Customer.JSON_PROPERTY_FIRST_NAME, + Customer.JSON_PROPERTY_LAST_NAME, + Customer.JSON_PROPERTY_EMAIL, + Customer.JSON_PROPERTY_ADDRESS, + Customer.JSON_PROPERTY_CREATED_AT +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0") +public class Customer { + public static final String JSON_PROPERTY_ID = "id"; + @jakarta.annotation.Nonnull + private UUID id; + + public static final String JSON_PROPERTY_FIRST_NAME = "firstName"; + @jakarta.annotation.Nonnull + private String firstName; + + public static final String JSON_PROPERTY_LAST_NAME = "lastName"; + @jakarta.annotation.Nonnull + private String lastName; + + public static final String JSON_PROPERTY_EMAIL = "email"; + @jakarta.annotation.Nullable + private String email; + + public static final String JSON_PROPERTY_ADDRESS = "address"; + @jakarta.annotation.Nonnull + private CustomerAddress address; + + public static final String JSON_PROPERTY_CREATED_AT = "createdAt"; + @jakarta.annotation.Nonnull + private OffsetDateTime createdAt; + + public Customer() { + } + + public Customer id(@jakarta.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(value = JSON_PROPERTY_ID, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UUID getId() { + return id; + } + + + @JsonProperty(value = JSON_PROPERTY_ID, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(@jakarta.annotation.Nonnull UUID id) { + this.id = id; + } + + + public Customer firstName(@jakarta.annotation.Nonnull String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + */ + @jakarta.annotation.Nonnull + @JsonProperty(value = JSON_PROPERTY_FIRST_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getFirstName() { + return firstName; + } + + + @JsonProperty(value = JSON_PROPERTY_FIRST_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFirstName(@jakarta.annotation.Nonnull String firstName) { + this.firstName = firstName; + } + + + public Customer lastName(@jakarta.annotation.Nonnull String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + */ + @jakarta.annotation.Nonnull + @JsonProperty(value = JSON_PROPERTY_LAST_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getLastName() { + return lastName; + } + + + @JsonProperty(value = JSON_PROPERTY_LAST_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setLastName(@jakarta.annotation.Nonnull String lastName) { + this.lastName = lastName; + } + + + public Customer email(@jakarta.annotation.Nullable String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + */ + @jakarta.annotation.Nullable + @JsonProperty(value = JSON_PROPERTY_EMAIL, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEmail() { + return email; + } + + + @JsonProperty(value = JSON_PROPERTY_EMAIL, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEmail(@jakarta.annotation.Nullable String email) { + this.email = email; + } + + + public Customer address(@jakarta.annotation.Nonnull CustomerAddress address) { + this.address = address; + return this; + } + + /** + * Get address + * @return address + */ + @jakarta.annotation.Nonnull + @JsonProperty(value = JSON_PROPERTY_ADDRESS, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public CustomerAddress getAddress() { + return address; + } + + + @JsonProperty(value = JSON_PROPERTY_ADDRESS, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setAddress(@jakarta.annotation.Nonnull CustomerAddress address) { + this.address = address; + } + + + public Customer createdAt(@jakarta.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * @return createdAt + */ + @jakarta.annotation.Nonnull + @JsonProperty(value = JSON_PROPERTY_CREATED_AT, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + @JsonProperty(value = JSON_PROPERTY_CREATED_AT, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setCreatedAt(@jakarta.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + /** + * Return true if this Customer object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Customer customer = (Customer) o; + return Objects.equals(this.id, customer.id) && + Objects.equals(this.firstName, customer.firstName) && + Objects.equals(this.lastName, customer.lastName) && + Objects.equals(this.email, customer.email) && + Objects.equals(this.address, customer.address) && + Objects.equals(this.createdAt, customer.createdAt); + } + + @Override + public int hashCode() { + return Objects.hash(id, firstName, lastName, email, address, createdAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Customer {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%sid%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getId())))); + } + + // add `firstName` to the URL query string + if (getFirstName() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%sfirstName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getFirstName())))); + } + + // add `lastName` to the URL query string + if (getLastName() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%slastName%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getLastName())))); + } + + // add `email` to the URL query string + if (getEmail() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%semail%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getEmail())))); + } + + // add `address` to the URL query string + if (getAddress() != null) { + joiner.add(getAddress().toUrlQueryString(prefix + "address" + suffix)); + } + + // add `createdAt` to the URL query string + if (getCreatedAt() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%screatedAt%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getCreatedAt())))); + } + + return joiner.toString(); + } +} + diff --git a/src/main/java/com/controlresell/sdk/generated/model/CustomerAddress.java b/src/main/java/com/controlresell/sdk/generated/model/CustomerAddress.java new file mode 100644 index 0000000..7853a75 --- /dev/null +++ b/src/main/java/com/controlresell/sdk/generated/model/CustomerAddress.java @@ -0,0 +1,292 @@ +/* + * ControlResell public API + * The public API of ControlResell. Every error answers `{\"error\": {\"code\", \"message\", \"params\", \"requestId\"}}`; a `POST` takes an `Idempotency-Key` header. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.controlresell.sdk.generated.model; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import com.controlresell.sdk.generated.ApiClient; +/** + * CustomerAddress + */ +@JsonPropertyOrder({ + CustomerAddress.JSON_PROPERTY_LINE1, + CustomerAddress.JSON_PROPERTY_LINE2, + CustomerAddress.JSON_PROPERTY_CITY, + CustomerAddress.JSON_PROPERTY_POSTAL_CODE, + CustomerAddress.JSON_PROPERTY_COUNTRY +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0") +public class CustomerAddress { + public static final String JSON_PROPERTY_LINE1 = "line1"; + @jakarta.annotation.Nullable + private String line1; + + public static final String JSON_PROPERTY_LINE2 = "line2"; + @jakarta.annotation.Nullable + private String line2; + + public static final String JSON_PROPERTY_CITY = "city"; + @jakarta.annotation.Nullable + private String city; + + public static final String JSON_PROPERTY_POSTAL_CODE = "postalCode"; + @jakarta.annotation.Nullable + private String postalCode; + + public static final String JSON_PROPERTY_COUNTRY = "country"; + @jakarta.annotation.Nullable + private String country; + + public CustomerAddress() { + } + + public CustomerAddress line1(@jakarta.annotation.Nullable String line1) { + this.line1 = line1; + return this; + } + + /** + * Get line1 + * @return line1 + */ + @jakarta.annotation.Nullable + @JsonProperty(value = JSON_PROPERTY_LINE1, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLine1() { + return line1; + } + + + @JsonProperty(value = JSON_PROPERTY_LINE1, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLine1(@jakarta.annotation.Nullable String line1) { + this.line1 = line1; + } + + + public CustomerAddress line2(@jakarta.annotation.Nullable String line2) { + this.line2 = line2; + return this; + } + + /** + * Get line2 + * @return line2 + */ + @jakarta.annotation.Nullable + @JsonProperty(value = JSON_PROPERTY_LINE2, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLine2() { + return line2; + } + + + @JsonProperty(value = JSON_PROPERTY_LINE2, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLine2(@jakarta.annotation.Nullable String line2) { + this.line2 = line2; + } + + + public CustomerAddress city(@jakarta.annotation.Nullable String city) { + this.city = city; + return this; + } + + /** + * Get city + * @return city + */ + @jakarta.annotation.Nullable + @JsonProperty(value = JSON_PROPERTY_CITY, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCity() { + return city; + } + + + @JsonProperty(value = JSON_PROPERTY_CITY, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCity(@jakarta.annotation.Nullable String city) { + this.city = city; + } + + + public CustomerAddress postalCode(@jakarta.annotation.Nullable String postalCode) { + this.postalCode = postalCode; + return this; + } + + /** + * Get postalCode + * @return postalCode + */ + @jakarta.annotation.Nullable + @JsonProperty(value = JSON_PROPERTY_POSTAL_CODE, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPostalCode() { + return postalCode; + } + + + @JsonProperty(value = JSON_PROPERTY_POSTAL_CODE, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPostalCode(@jakarta.annotation.Nullable String postalCode) { + this.postalCode = postalCode; + } + + + public CustomerAddress country(@jakarta.annotation.Nullable String country) { + this.country = country; + return this; + } + + /** + * Get country + * @return country + */ + @jakarta.annotation.Nullable + @JsonProperty(value = JSON_PROPERTY_COUNTRY, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCountry() { + return country; + } + + + @JsonProperty(value = JSON_PROPERTY_COUNTRY, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCountry(@jakarta.annotation.Nullable String country) { + this.country = country; + } + + + /** + * Return true if this CustomerAddress object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomerAddress customerAddress = (CustomerAddress) o; + return Objects.equals(this.line1, customerAddress.line1) && + Objects.equals(this.line2, customerAddress.line2) && + Objects.equals(this.city, customerAddress.city) && + Objects.equals(this.postalCode, customerAddress.postalCode) && + Objects.equals(this.country, customerAddress.country); + } + + @Override + public int hashCode() { + return Objects.hash(line1, line2, city, postalCode, country); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CustomerAddress {\n"); + sb.append(" line1: ").append(toIndentedString(line1)).append("\n"); + sb.append(" line2: ").append(toIndentedString(line2)).append("\n"); + sb.append(" city: ").append(toIndentedString(city)).append("\n"); + sb.append(" postalCode: ").append(toIndentedString(postalCode)).append("\n"); + sb.append(" country: ").append(toIndentedString(country)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `line1` to the URL query string + if (getLine1() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%sline1%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getLine1())))); + } + + // add `line2` to the URL query string + if (getLine2() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%sline2%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getLine2())))); + } + + // add `city` to the URL query string + if (getCity() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%scity%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getCity())))); + } + + // add `postalCode` to the URL query string + if (getPostalCode() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%spostalCode%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getPostalCode())))); + } + + // add `country` to the URL query string + if (getCountry() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%scountry%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getCountry())))); + } + + return joiner.toString(); + } +} + diff --git a/src/main/java/com/controlresell/sdk/generated/model/CustomerPage.java b/src/main/java/com/controlresell/sdk/generated/model/CustomerPage.java new file mode 100644 index 0000000..54c65c8 --- /dev/null +++ b/src/main/java/com/controlresell/sdk/generated/model/CustomerPage.java @@ -0,0 +1,200 @@ +/* + * ControlResell public API + * The public API of ControlResell. Every error answers `{\"error\": {\"code\", \"message\", \"params\", \"requestId\"}}`; a `POST` takes an `Idempotency-Key` header. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.controlresell.sdk.generated.model; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.controlresell.sdk.generated.model.Customer; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import com.controlresell.sdk.generated.ApiClient; +/** + * CustomerPage + */ +@JsonPropertyOrder({ + CustomerPage.JSON_PROPERTY_DATA, + CustomerPage.JSON_PROPERTY_NEXT_CURSOR +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0") +public class CustomerPage { + public static final String JSON_PROPERTY_DATA = "data"; + @jakarta.annotation.Nonnull + private List data = new ArrayList<>(); + + public static final String JSON_PROPERTY_NEXT_CURSOR = "nextCursor"; + @jakarta.annotation.Nullable + private String nextCursor; + + public CustomerPage() { + } + + public CustomerPage data(@jakarta.annotation.Nonnull List data) { + this.data = data; + return this; + } + + public CustomerPage addDataItem(Customer dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + */ + @jakarta.annotation.Nonnull + @JsonProperty(value = JSON_PROPERTY_DATA, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + + @JsonProperty(value = JSON_PROPERTY_DATA, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setData(@jakarta.annotation.Nonnull List data) { + this.data = data; + } + + + public CustomerPage nextCursor(@jakarta.annotation.Nullable String nextCursor) { + this.nextCursor = nextCursor; + return this; + } + + /** + * Get nextCursor + * @return nextCursor + */ + @jakarta.annotation.Nullable + @JsonProperty(value = JSON_PROPERTY_NEXT_CURSOR, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getNextCursor() { + return nextCursor; + } + + + @JsonProperty(value = JSON_PROPERTY_NEXT_CURSOR, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNextCursor(@jakarta.annotation.Nullable String nextCursor) { + this.nextCursor = nextCursor; + } + + + /** + * Return true if this CustomerPage object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomerPage customerPage = (CustomerPage) o; + return Objects.equals(this.data, customerPage.data) && + Objects.equals(this.nextCursor, customerPage.nextCursor); + } + + @Override + public int hashCode() { + return Objects.hash(data, nextCursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CustomerPage {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" nextCursor: ").append(toIndentedString(nextCursor)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `data` to the URL query string + if (getData() != null) { + for (int i = 0; i < getData().size(); i++) { + if (getData().get(i) != null) { + joiner.add(getData().get(i).toUrlQueryString(String.format(java.util.Locale.ROOT, "%sdata%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format(java.util.Locale.ROOT, "%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `nextCursor` to the URL query string + if (getNextCursor() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%snextCursor%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getNextCursor())))); + } + + return joiner.toString(); + } +} + diff --git a/src/test/java/com/controlresell/sdk/ControlResellTest.java b/src/test/java/com/controlresell/sdk/ControlResellTest.java index 9dc0fec..7f9091b 100644 --- a/src/test/java/com/controlresell/sdk/ControlResellTest.java +++ b/src/test/java/com/controlresell/sdk/ControlResellTest.java @@ -319,4 +319,30 @@ void conversationMessagesSendTheFromAndToWindow() throws Exception { java.time.OffsetDateTime.parse("2026-10-02T00:00:00Z")); assertTrue(queries.get(0).contains("from=2026-10-01") && queries.get(0).contains("to=2026-10-02"), queries.toString()); } + + private static String customer(String firstName) { + return "{\"id\":\"" + ACCOUNT + "\",\"firstName\":\"" + firstName + "\",\"lastName\":\"Doe\",\"email\":null," + + "\"address\":{\"country\":\"FR\"},\"createdAt\":\"2026-10-21T10:00:00Z\"}"; + } + + @Test + void customersListAllFollowsTheCursorWithTheSameFilters() throws Exception { + ControlResell sdk = client(n -> n == 1 + ? new Reply(200, "{\"data\":[" + customer("Ann") + "],\"nextCursor\":\"c2\"}") + : new Reply(200, "{\"data\":[" + customer("Bob") + "],\"nextCursor\":null}")); + List names = new ArrayList<>(); + var from = java.time.OffsetDateTime.parse("2026-10-01T00:00:00Z"); + for (var c : sdk.customers().listAll(1, java.util.UUID.fromString(ACCOUNT), from, null)) names.add(c.getFirstName()); + assertEquals(List.of("Ann", "Bob"), names); + assertEquals("/api/public/v1/customers", exchanges.get(0).getRequestURI().getPath()); + for (String q : queries) assertTrue(q.contains("accountId=" + ACCOUNT) && q.contains("from=2026-10-01"), q); + assertTrue(!queries.get(0).contains("cursor") && queries.get(1).contains("cursor=c2"), queries.toString()); + } + + @Test + void customersGetReadsOneCustomer() throws Exception { + ControlResell sdk = client(n -> new Reply(200, customer("Ann"))); + assertEquals("Ann", sdk.customers().get(java.util.UUID.fromString(ACCOUNT)).getFirstName()); + assertEquals("/api/public/v1/customers/" + ACCOUNT, exchanges.get(0).getRequestURI().getPath()); + } }