diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d870fc4..2cba5f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Java id: setup-jre @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Java id: setup-jre @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Java id: setup-jre diff --git a/build.gradle b/build.gradle index 32c0e35..b3cd566 100644 --- a/build.gradle +++ b/build.gradle @@ -18,10 +18,12 @@ dependencies { api 'com.fasterxml.jackson.core:jackson-databind:2.17.2' api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2' api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2' - testImplementation 'org.mockito:mockito-core:5.3.1' - testImplementation 'org.mockito:mockito-junit-jupiter:5.3.1' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2' + testImplementation 'org.mockito:mockito-core:5.3.1' + testImplementation 'org.mockito:mockito-junit-jupiter:5.3.1' + testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0' } @@ -48,7 +50,7 @@ java { group = 'com.schematichq' -version = '1.1.3' +version = '3.10.2' jar { dependsOn(":generatePomFileForMavenPublication") @@ -79,7 +81,7 @@ publishing { maven(MavenPublication) { groupId = 'com.schematichq' artifactId = 'schematic-java' - version = '1.1.3' + version = '3.10.2' from components.java pom { name = 'schematic' @@ -123,9 +125,10 @@ sonatypeCentralUpload { } signing { - def signingKeyId = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" + def signingKeyId = "$System.env.MAVEN_SIGNATURE_KID" + def signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" def signingPassword = "$System.env.MAVEN_SIGNATURE_PASSWORD" - useInMemoryPgpKeys(signingKeyId, signingPassword) + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) sign publishing.publications.maven } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a4b76b9..1b33c55 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e18bc25..d4081da 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f3b75f3..23d15a9 100755 --- a/gradlew +++ b/gradlew @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -205,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. @@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9b42019..5eed7ee 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..2c875fc --- /dev/null +++ b/reference.md @@ -0,0 +1,14429 @@ +# Reference +
client.putPlanAudiencesPlanAudienceId(planAudienceId) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.putPlanAudiencesPlanAudienceId("plan_audience_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planAudienceId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.deletePlanAudiencesPlanAudienceId(planAudienceId) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.deletePlanAudiencesPlanAudienceId("plan_audience_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planAudienceId:** `String` + +
+
+
+
+ + +
+
+
+ +## accounts +
client.accounts.listApiKeys() -> ListApiKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().listApiKeys( + ListApiKeysRequest + .builder() + .requireEnvironment(true) + .environmentId("environment_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentId:** `Optional` + +
+
+ +
+
+ +**requireEnvironment:** `Boolean` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.accounts.createApiKey(request) -> CreateApiKeyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().createApiKey( + CreateApiKeyRequestBody + .builder() + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**description:** `Optional` + +
+
+ +
+
+ +**environmentId:** `Optional` + +
+
+ +
+
+ +**name:** `String` + +
+
+
+
+ + +
+
+
+ +
client.accounts.getApiKey(apiKeyId) -> GetApiKeyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().getApiKey("api_key_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**apiKeyId:** `String` — api_key_id + +
+
+
+
+ + +
+
+
+ +
client.accounts.updateApiKey(apiKeyId, request) -> UpdateApiKeyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().updateApiKey( + "api_key_id", + UpdateApiKeyRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**apiKeyId:** `String` — api_key_id + +
+
+ +
+
+ +**description:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.accounts.deleteApiKey(apiKeyId) -> DeleteApiKeyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().deleteApiKey("api_key_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**apiKeyId:** `String` — api_key_id + +
+
+
+
+ + +
+
+
+ +
client.accounts.countApiKeys() -> CountApiKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().countApiKeys( + CountApiKeysRequest + .builder() + .requireEnvironment(true) + .environmentId("environment_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentId:** `Optional` + +
+
+ +
+
+ +**requireEnvironment:** `Boolean` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.accounts.listApiRequests() -> ListApiRequestsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().listApiRequests( + ListApiRequestsRequest + .builder() + .q("q") + .requestType("request_type") + .environmentId("environment_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**requestType:** `Optional` + +
+
+ +
+
+ +**environmentId:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.accounts.getApiRequest(apiRequestId) -> GetApiRequestResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().getApiRequest("api_request_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**apiRequestId:** `String` — api_request_id + +
+
+
+
+ + +
+
+
+ +
client.accounts.countApiRequests() -> CountApiRequestsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().countApiRequests( + CountApiRequestsRequest + .builder() + .q("q") + .requestType("request_type") + .environmentId("environment_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**requestType:** `Optional` + +
+
+ +
+
+ +**environmentId:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.accounts.listEnvironments() -> ListEnvironmentsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().listEnvironments( + ListEnvironmentsRequest + .builder() + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.accounts.createEnvironment(request) -> CreateEnvironmentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().createEnvironment( + CreateEnvironmentRequestBody + .builder() + .environmentType(CreateEnvironmentRequestBodyEnvironmentType.DEVELOPMENT) + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentType:** `CreateEnvironmentRequestBodyEnvironmentType` + +
+
+ +
+
+ +**name:** `String` + +
+
+
+
+ + +
+
+
+ +
client.accounts.getEnvironment(environmentId) -> GetEnvironmentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().getEnvironment("environment_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentId:** `String` — environment_id + +
+
+
+
+ + +
+
+
+ +
client.accounts.updateEnvironment(environmentId, request) -> UpdateEnvironmentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().updateEnvironment( + "environment_id", + UpdateEnvironmentRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentId:** `String` — environment_id + +
+
+ +
+
+ +**environmentType:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.accounts.deleteEnvironment(environmentId) -> DeleteEnvironmentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().deleteEnvironment("environment_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentId:** `String` — environment_id + +
+
+
+
+ + +
+
+
+ +
client.accounts.quickstart() -> QuickstartResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accounts().quickstart(); +``` +
+
+
+
+ + +
+
+
+ +## billing +
client.billing.listCoupons() -> ListCouponsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().listCoupons( + ListCouponsRequest + .builder() + .isActive(true) + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**isActive:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.upsertBillingCoupon(request) -> UpsertBillingCouponResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().upsertBillingCoupon( + CreateCouponRequestBody + .builder() + .amountOff(1) + .duration("duration") + .durationInMonths(1) + .externalId("external_id") + .maxRedemptions(1) + .name("name") + .percentOff(1.1) + .timesRedeemed(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**amountOff:** `Integer` + +
+
+ +
+
+ +**currency:** `Optional` + +
+
+ +
+
+ +**duration:** `String` + +
+
+ +
+
+ +**durationInMonths:** `Integer` + +
+
+ +
+
+ +**externalId:** `String` + +
+
+ +
+
+ +**maxRedemptions:** `Integer` + +
+
+ +
+
+ +**name:** `String` + +
+
+ +
+
+ +**percentOff:** `Double` + +
+
+ +
+
+ +**timesRedeemed:** `Integer` + +
+
+
+
+ + +
+
+
+ +
client.billing.upsertBillingCustomer(request) -> UpsertBillingCustomerResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().upsertBillingCustomer( + CreateBillingCustomerRequestBody + .builder() + .email("email") + .externalId("external_id") + .failedToImport(true) + .meta( + new HashMap() {{ + put("key", "value"); + }} + ) + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**defaultPaymentMethodId:** `Optional` + +
+
+ +
+
+ +**email:** `String` + +
+
+ +
+
+ +**externalId:** `String` + +
+
+ +
+
+ +**failedToImport:** `Boolean` + +
+
+ +
+
+ +**meta:** `Map` + +
+
+ +
+
+ +**name:** `String` + +
+
+
+
+ + +
+
+
+ +
client.billing.listCustomersWithSubscriptions() -> ListCustomersWithSubscriptionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest + .builder() + .name("name") + .failedToImport(true) + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyIds:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**failedToImport:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.countCustomers() -> CountCustomersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().countCustomers( + CountCustomersRequest + .builder() + .name("name") + .failedToImport(true) + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyIds:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**failedToImport:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.listInvoices() -> ListInvoicesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().listInvoices( + ListInvoicesRequest + .builder() + .customerExternalId("customer_external_id") + .subscriptionExternalId("subscription_external_id") + .companyId("company_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**customerExternalId:** `String` + +
+
+ +
+
+ +**subscriptionExternalId:** `String` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.upsertInvoice(request) -> UpsertInvoiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().upsertInvoice( + CreateInvoiceRequestBody + .builder() + .amountDue(1) + .amountPaid(1) + .amountRemaining(1) + .collectionMethod("collection_method") + .currency("currency") + .customerExternalId("customer_external_id") + .subtotal(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**amountDue:** `Integer` + +
+
+ +
+
+ +**amountPaid:** `Integer` + +
+
+ +
+
+ +**amountRemaining:** `Integer` + +
+
+ +
+
+ +**collectionMethod:** `String` + +
+
+ +
+
+ +**currency:** `String` + +
+
+ +
+
+ +**customerExternalId:** `String` + +
+
+ +
+
+ +**dueDate:** `Optional` + +
+
+ +
+
+ +**externalId:** `Optional` + +
+
+ +
+
+ +**paymentMethodExternalId:** `Optional` + +
+
+ +
+
+ +**subscriptionExternalId:** `Optional` + +
+
+ +
+
+ +**subtotal:** `Integer` + +
+
+ +
+
+ +**url:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.billing.listMeters() -> ListMetersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().listMeters( + ListMetersRequest + .builder() + .displayName("display_name") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**displayName:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.upsertBillingMeter(request) -> UpsertBillingMeterResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().upsertBillingMeter( + CreateMeterRequestBody + .builder() + .displayName("display_name") + .eventName("event_name") + .eventPayloadKey("event_payload_key") + .externalId("external_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**displayName:** `String` + +
+
+ +
+
+ +**eventName:** `String` + +
+
+ +
+
+ +**eventPayloadKey:** `String` + +
+
+ +
+
+ +**externalId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.billing.listPaymentMethods() -> ListPaymentMethodsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().listPaymentMethods( + ListPaymentMethodsRequest + .builder() + .customerExternalId("customer_external_id") + .companyId("company_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**customerExternalId:** `String` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.upsertPaymentMethod(request) -> UpsertPaymentMethodResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().upsertPaymentMethod( + CreatePaymentMethodRequestBody + .builder() + .customerExternalId("customer_external_id") + .externalId("external_id") + .paymentMethodType("payment_method_type") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**accountLast4:** `Optional` + +
+
+ +
+
+ +**accountName:** `Optional` + +
+
+ +
+
+ +**bankName:** `Optional` + +
+
+ +
+
+ +**billingEmail:** `Optional` + +
+
+ +
+
+ +**billingName:** `Optional` + +
+
+ +
+
+ +**cardBrand:** `Optional` + +
+
+ +
+
+ +**cardExpMonth:** `Optional` + +
+
+ +
+
+ +**cardExpYear:** `Optional` + +
+
+ +
+
+ +**cardLast4:** `Optional` + +
+
+ +
+
+ +**customerExternalId:** `String` + +
+
+ +
+
+ +**externalId:** `String` + +
+
+ +
+
+ +**paymentMethodType:** `String` + +
+
+
+
+ + +
+
+
+ +
client.billing.searchBillingPrices() -> SearchBillingPricesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().searchBillingPrices( + SearchBillingPricesRequest + .builder() + .forInitialPlan(true) + .forTrialExpiryPlan(true) + .productId("product_id") + .interval("interval") + .price(1) + .q("q") + .requiresPaymentMethod(true) + .tiersMode(SearchBillingPricesRequestTiersMode.VOLUME) + .usageType(SearchBillingPricesRequestUsageType.LICENSED) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**forInitialPlan:** `Optional` — Filter for prices valid for initial plans (free prices only) + +
+
+ +
+
+ +**forTrialExpiryPlan:** `Optional` — Filter for prices valid for trial expiry plans (free prices only) + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**productId:** `Optional` + +
+
+ +
+
+ +**interval:** `Optional` + +
+
+ +
+
+ +**price:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**requiresPaymentMethod:** `Optional` — Filter for prices that require a payment method (inverse of ForInitialPlan) + +
+
+ +
+
+ +**tiersMode:** `Optional` + +
+
+ +
+
+ +**usageType:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.upsertBillingPrice(request) -> UpsertBillingPriceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().upsertBillingPrice( + CreateBillingPriceRequestBody + .builder() + .billingScheme(CreateBillingPriceRequestBodyBillingScheme.PER_UNIT) + .currency("currency") + .externalAccountId("external_account_id") + .interval("interval") + .isActive(true) + .price(1) + .priceExternalId("price_external_id") + .priceTiers( + Arrays.asList( + CreateBillingPriceTierRequestBody + .builder() + .priceExternalId("price_external_id") + .build() + ) + ) + .productExternalId("product_external_id") + .usageType(CreateBillingPriceRequestBodyUsageType.LICENSED) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingScheme:** `CreateBillingPriceRequestBodyBillingScheme` + +
+
+ +
+
+ +**currency:** `String` + +
+
+ +
+
+ +**externalAccountId:** `String` + +
+
+ +
+
+ +**interval:** `String` + +
+
+ +
+
+ +**isActive:** `Boolean` + +
+
+ +
+
+ +**meterId:** `Optional` + +
+
+ +
+
+ +**packageSize:** `Optional` + +
+
+ +
+
+ +**price:** `Integer` + +
+
+ +
+
+ +**priceDecimal:** `Optional` + +
+
+ +
+
+ +**priceExternalId:** `String` + +
+
+ +
+
+ +**priceTiers:** `List` + +
+
+ +
+
+ +**productExternalId:** `String` + +
+
+ +
+
+ +**tiersMode:** `Optional` + +
+
+ +
+
+ +**usageType:** `CreateBillingPriceRequestBodyUsageType` + +
+
+
+
+ + +
+
+
+ +
client.billing.deleteBillingProduct(billingId) -> DeleteBillingProductResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().deleteBillingProduct("billing_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingId:** `String` — billing_id + +
+
+
+
+ + +
+
+
+ +
client.billing.listProductPrices() -> ListProductPricesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().listProductPrices( + ListProductPricesRequest + .builder() + .name("name") + .q("q") + .priceUsageType(ListProductPricesRequestPriceUsageType.LICENSED) + .withoutLinkedToPlan(true) + .withOneTimeCharges(true) + .withZeroPrice(true) + .withPricesOnly(true) + .isActive(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**priceUsageType:** `Optional` + +
+
+ +
+
+ +**withoutLinkedToPlan:** `Optional` — Filter products that are not linked to any plan + +
+
+ +
+
+ +**withOneTimeCharges:** `Optional` — Filter products that are one time charges + +
+
+ +
+
+ +**withZeroPrice:** `Optional` — Filter products that have zero price for free subscription type + +
+
+ +
+
+ +**withPricesOnly:** `Optional` — Filter products that have prices + +
+
+ +
+
+ +**isActive:** `Optional` — Filter products that are active + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.deleteProductPrice(billingId) -> DeleteProductPriceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().deleteProductPrice("billing_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingId:** `String` — billing_id + +
+
+
+
+ + +
+
+
+ +
client.billing.upsertBillingProduct(request) -> UpsertBillingProductResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().upsertBillingProduct( + CreateBillingProductRequestBody + .builder() + .externalId("external_id") + .name("name") + .price(1.1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**externalId:** `String` + +
+
+ +
+
+ +**isActive:** `Optional` + +
+
+ +
+
+ +**name:** `String` + +
+
+ +
+
+ +**price:** `Double` + +
+
+
+
+ + +
+
+
+ +
client.billing.listBillingProducts() -> ListBillingProductsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().listBillingProducts( + ListBillingProductsRequest + .builder() + .name("name") + .q("q") + .priceUsageType(ListBillingProductsRequestPriceUsageType.LICENSED) + .withoutLinkedToPlan(true) + .withOneTimeCharges(true) + .withZeroPrice(true) + .withPricesOnly(true) + .isActive(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**priceUsageType:** `Optional` + +
+
+ +
+
+ +**withoutLinkedToPlan:** `Optional` — Filter products that are not linked to any plan + +
+
+ +
+
+ +**withOneTimeCharges:** `Optional` — Filter products that are one time charges + +
+
+ +
+
+ +**withZeroPrice:** `Optional` — Filter products that have zero price for free subscription type + +
+
+ +
+
+ +**withPricesOnly:** `Optional` — Filter products that have prices + +
+
+ +
+
+ +**isActive:** `Optional` — Filter products that are active + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.countBillingProducts() -> CountBillingProductsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().countBillingProducts( + CountBillingProductsRequest + .builder() + .name("name") + .q("q") + .priceUsageType(CountBillingProductsRequestPriceUsageType.LICENSED) + .withoutLinkedToPlan(true) + .withOneTimeCharges(true) + .withZeroPrice(true) + .withPricesOnly(true) + .isActive(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**priceUsageType:** `Optional` + +
+
+ +
+
+ +**withoutLinkedToPlan:** `Optional` — Filter products that are not linked to any plan + +
+
+ +
+
+ +**withOneTimeCharges:** `Optional` — Filter products that are one time charges + +
+
+ +
+
+ +**withZeroPrice:** `Optional` — Filter products that have zero price for free subscription type + +
+
+ +
+
+ +**withPricesOnly:** `Optional` — Filter products that have prices + +
+
+ +
+
+ +**isActive:** `Optional` — Filter products that are active + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.billing.upsertBillingSubscription(request) -> UpsertBillingSubscriptionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.billing().upsertBillingSubscription( + CreateBillingSubscriptionRequestBody + .builder() + .cancelAtPeriodEnd(true) + .currency("currency") + .customerExternalId("customer_external_id") + .discounts( + Arrays.asList( + BillingSubscriptionDiscount + .builder() + .couponExternalId("coupon_external_id") + .externalId("external_id") + .isActive(true) + .startedAt(OffsetDateTime.parse("2024-01-15T09:30:00Z")) + .build() + ) + ) + .expiredAt(OffsetDateTime.parse("2024-01-15T09:30:00Z")) + .productExternalIds( + Arrays.asList( + BillingProductPricing + .builder() + .currency("currency") + .interval("interval") + .price(1) + .priceExternalId("price_external_id") + .productExternalId("product_external_id") + .quantity(1) + .usageType(BillingProductPricingUsageType.LICENSED) + .build() + ) + ) + .subscriptionExternalId("subscription_external_id") + .totalPrice(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**cancelAt:** `Optional` + +
+
+ +
+
+ +**cancelAtPeriodEnd:** `Boolean` + +
+
+ +
+
+ +**currency:** `String` + +
+
+ +
+
+ +**customerExternalId:** `String` + +
+
+ +
+
+ +**defaultPaymentMethodExternalId:** `Optional` + +
+
+ +
+
+ +**defaultPaymentMethodId:** `Optional` + +
+
+ +
+
+ +**discounts:** `List` + +
+
+ +
+
+ +**expiredAt:** `OffsetDateTime` + +
+
+ +
+
+ +**interval:** `Optional` + +
+
+ +
+
+ +**metadata:** `Optional>` + +
+
+ +
+
+ +**periodEnd:** `Optional` + +
+
+ +
+
+ +**periodStart:** `Optional` + +
+
+ +
+
+ +**productExternalIds:** `List` + +
+
+ +
+
+ +**status:** `Optional` + +
+
+ +
+
+ +**subscriptionExternalId:** `String` + +
+
+ +
+
+ +**totalPrice:** `Integer` + +
+
+ +
+
+ +**trialEnd:** `Optional` + +
+
+ +
+
+ +**trialEndSetting:** `Optional` + +
+
+
+
+ + +
+
+
+ +## credits +
client.credits.listBillingCredits() -> ListBillingCreditsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().listBillingCredits( + ListBillingCreditsRequest + .builder() + .name("name") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.createBillingCredit(request) -> CreateBillingCreditResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().createBillingCredit( + CreateBillingCreditRequestBody + .builder() + .currency("currency") + .description("description") + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**burnStrategy:** `Optional` + +
+
+ +
+
+ +**currency:** `String` + +
+
+ +
+
+ +**defaultExpiryUnit:** `Optional` + +
+
+ +
+
+ +**defaultExpiryUnitCount:** `Optional` + +
+
+ +
+
+ +**defaultRolloverPolicy:** `Optional` + +
+
+ +
+
+ +**description:** `String` + +
+
+ +
+
+ +**icon:** `Optional` + +
+
+ +
+
+ +**name:** `String` + +
+
+ +
+
+ +**perUnitPrice:** `Optional` + +
+
+ +
+
+ +**perUnitPriceDecimal:** `Optional` + +
+
+ +
+
+ +**pluralName:** `Optional` + +
+
+ +
+
+ +**singularName:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.credits.getSingleBillingCredit(creditId) -> GetSingleBillingCreditResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().getSingleBillingCredit("credit_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditId:** `String` — credit_id + +
+
+
+
+ + +
+
+
+ +
client.credits.updateBillingCredit(creditId, request) -> UpdateBillingCreditResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().updateBillingCredit( + "credit_id", + UpdateBillingCreditRequestBody + .builder() + .description("description") + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditId:** `String` — credit_id + +
+
+ +
+
+ +**burnStrategy:** `Optional` + +
+
+ +
+
+ +**defaultExpiryUnit:** `Optional` + +
+
+ +
+
+ +**defaultExpiryUnitCount:** `Optional` + +
+
+ +
+
+ +**defaultRolloverPolicy:** `Optional` + +
+
+ +
+
+ +**description:** `String` + +
+
+ +
+
+ +**icon:** `Optional` + +
+
+ +
+
+ +**name:** `String` + +
+
+ +
+
+ +**perUnitPrice:** `Optional` + +
+
+ +
+
+ +**perUnitPriceDecimal:** `Optional` + +
+
+ +
+
+ +**pluralName:** `Optional` + +
+
+ +
+
+ +**singularName:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.credits.softDeleteBillingCredit(creditId) -> SoftDeleteBillingCreditResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().softDeleteBillingCredit("credit_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditId:** `String` — credit_id + +
+
+
+
+ + +
+
+
+ +
client.credits.listCreditBundles() -> ListCreditBundlesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().listCreditBundles( + ListCreditBundlesRequest + .builder() + .creditId("credit_id") + .status(ListCreditBundlesRequestStatus.ACTIVE) + .bundleType("fixed") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**creditId:** `Optional` + +
+
+ +
+
+ +**status:** `Optional` + +
+
+ +
+
+ +**bundleType:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.createCreditBundle(request) -> CreateCreditBundleResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().createCreditBundle( + CreateCreditBundleRequestBody + .builder() + .bundleName("bundle_name") + .creditId("credit_id") + .currency("currency") + .pricePerUnit(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bundleName:** `String` + +
+
+ +
+
+ +**bundleType:** `Optional` + +
+
+ +
+
+ +**creditId:** `String` + +
+
+ +
+
+ +**currency:** `String` + +
+
+ +
+
+ +**expiryType:** `Optional` + +
+
+ +
+
+ +**expiryUnit:** `Optional` + +
+
+ +
+
+ +**expiryUnitCount:** `Optional` + +
+
+ +
+
+ +**pricePerUnit:** `Integer` + +
+
+ +
+
+ +**pricePerUnitDecimal:** `Optional` + +
+
+ +
+
+ +**quantity:** `Optional` + +
+
+ +
+
+ +**status:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.credits.getCreditBundle(bundleId) -> GetCreditBundleResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().getCreditBundle("bundle_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bundleId:** `String` — bundle_id + +
+
+
+
+ + +
+
+
+ +
client.credits.updateCreditBundleDetails(bundleId, request) -> UpdateCreditBundleDetailsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().updateCreditBundleDetails( + "bundle_id", + UpdateCreditBundleDetailsRequestBody + .builder() + .bundleName("bundle_name") + .pricePerUnit(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bundleId:** `String` — bundle_id + +
+
+ +
+
+ +**bundleName:** `String` + +
+
+ +
+
+ +**expiryType:** `Optional` + +
+
+ +
+
+ +**expiryUnit:** `Optional` + +
+
+ +
+
+ +**expiryUnitCount:** `Optional` + +
+
+ +
+
+ +**pricePerUnit:** `Integer` + +
+
+ +
+
+ +**pricePerUnitDecimal:** `Optional` + +
+
+ +
+
+ +**quantity:** `Optional` + +
+
+ +
+
+ +**status:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.credits.deleteCreditBundle(bundleId) -> DeleteCreditBundleResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().deleteCreditBundle("bundle_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**bundleId:** `String` — bundle_id + +
+
+
+
+ + +
+
+
+ +
client.credits.countCreditBundles() -> CountCreditBundlesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().countCreditBundles( + CountCreditBundlesRequest + .builder() + .creditId("credit_id") + .status(CountCreditBundlesRequestStatus.ACTIVE) + .bundleType("fixed") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**creditId:** `Optional` + +
+
+ +
+
+ +**status:** `Optional` + +
+
+ +
+
+ +**bundleType:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.countBillingCredits() -> CountBillingCreditsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().countBillingCredits( + CountBillingCreditsRequest + .builder() + .name("name") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.zeroOutGrant(grantId, request) -> ZeroOutGrantResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().zeroOutGrant( + "grant_id", + ZeroOutGrantRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**grantId:** `String` — grant_id + +
+
+ +
+
+ +**reason:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.credits.grantBillingCreditsToCompany(request) -> GrantBillingCreditsToCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().grantBillingCreditsToCompany( + CreateCompanyCreditGrant + .builder() + .companyId("company_id") + .creditId("credit_id") + .quantity(1) + .reason("reason") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingPeriodsCount:** `Optional` + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**creditId:** `String` + +
+
+ +
+
+ +**expiresAt:** `Optional` + +
+
+ +
+
+ +**expiryType:** `Optional` + +
+
+ +
+
+ +**expiryUnit:** `Optional` + +
+
+ +
+
+ +**expiryUnitCount:** `Optional` + +
+
+ +
+
+ +**quantity:** `Integer` + +
+
+ +
+
+ +**reason:** `String` + +
+
+
+
+ + +
+
+
+ +
client.credits.listCompanyGrants() -> ListCompanyGrantsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().listCompanyGrants( + ListCompanyGrantsRequest + .builder() + .companyId("company_id") + .order(ListCompanyGrantsRequestOrder.CREATED_AT) + .dir(ListCompanyGrantsRequestDir.ASC) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**order:** `Optional` + +
+
+ +
+
+ +**dir:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.countBillingCreditsGrants() -> CountBillingCreditsGrantsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().countBillingCreditsGrants( + CountBillingCreditsGrantsRequest + .builder() + .creditId("credit_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditId:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.listGrantsForCredit() -> ListGrantsForCreditResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().listGrantsForCredit( + ListGrantsForCreditRequest + .builder() + .creditId("credit_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditId:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.getEnrichedCreditLedger() -> GetEnrichedCreditLedgerResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().getEnrichedCreditLedger( + GetEnrichedCreditLedgerRequest + .builder() + .companyId("company_id") + .period(GetEnrichedCreditLedgerRequestPeriod.DAILY) + .billingCreditId("billing_credit_id") + .featureId("feature_id") + .startTime("start_time") + .endTime("end_time") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**billingCreditId:** `Optional` + +
+
+ +
+
+ +**featureId:** `Optional` + +
+
+ +
+
+ +**period:** `GetEnrichedCreditLedgerRequestPeriod` + +
+
+ +
+
+ +**startTime:** `Optional` + +
+
+ +
+
+ +**endTime:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.countCreditLedger() -> CountCreditLedgerResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().countCreditLedger( + CountCreditLedgerRequest + .builder() + .companyId("company_id") + .period(CountCreditLedgerRequestPeriod.DAILY) + .billingCreditId("billing_credit_id") + .featureId("feature_id") + .startTime("start_time") + .endTime("end_time") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**billingCreditId:** `Optional` + +
+
+ +
+
+ +**featureId:** `Optional` + +
+
+ +
+
+ +**period:** `CountCreditLedgerRequestPeriod` + +
+
+ +
+
+ +**startTime:** `Optional` + +
+
+ +
+
+ +**endTime:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.listBillingPlanCreditGrants() -> ListBillingPlanCreditGrantsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().listBillingPlanCreditGrants( + ListBillingPlanCreditGrantsRequest + .builder() + .creditId("credit_id") + .planId("plan_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditId:** `Optional` + +
+
+ +
+
+ +**planId:** `Optional` + +
+
+ +
+
+ +**planIds:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.credits.createBillingPlanCreditGrant(request) -> CreateBillingPlanCreditGrantResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().createBillingPlanCreditGrant( + CreateBillingPlanCreditGrantRequestBody + .builder() + .creditAmount(1) + .creditId("credit_id") + .planId("plan_id") + .resetCadence(CreateBillingPlanCreditGrantRequestBodyResetCadence.MONTHLY) + .resetStart(CreateBillingPlanCreditGrantRequestBodyResetStart.BILLING_PERIOD) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditAmount:** `Integer` + +
+
+ +
+
+ +**creditId:** `String` + +
+
+ +
+
+ +**expiryType:** `Optional` + +
+
+ +
+
+ +**expiryUnit:** `Optional` + +
+
+ +
+
+ +**expiryUnitCount:** `Optional` + +
+
+ +
+
+ +**planId:** `String` + +
+
+ +
+
+ +**resetCadence:** `CreateBillingPlanCreditGrantRequestBodyResetCadence` + +
+
+ +
+
+ +**resetStart:** `CreateBillingPlanCreditGrantRequestBodyResetStart` + +
+
+ +
+
+ +**resetType:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.credits.deleteBillingPlanCreditGrant(planGrantId) -> DeleteBillingPlanCreditGrantResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().deleteBillingPlanCreditGrant("plan_grant_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planGrantId:** `String` — plan_grant_id + +
+
+
+
+ + +
+
+
+ +
client.credits.countBillingPlanCreditGrants() -> CountBillingPlanCreditGrantsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.credits().countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest + .builder() + .creditId("credit_id") + .planId("plan_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditId:** `Optional` + +
+
+ +
+
+ +**planId:** `Optional` + +
+
+ +
+
+ +**planIds:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +## checkout +
client.checkout.internal(request) -> CheckoutInternalResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.checkout().internal( + ChangeSubscriptionInternalRequestBody + .builder() + .addOnIds( + Arrays.asList( + UpdateAddOnRequestBody + .builder() + .addOnId("add_on_id") + .priceId("price_id") + .build() + ) + ) + .companyId("company_id") + .creditBundles( + Arrays.asList( + UpdateCreditBundleRequestBody + .builder() + .bundleId("bundle_id") + .quantity(1) + .build() + ) + ) + .newPlanId("new_plan_id") + .newPriceId("new_price_id") + .payInAdvance( + Arrays.asList( + UpdatePayInAdvanceRequestBody + .builder() + .priceId("price_id") + .quantity(1) + .build() + ) + ) + .skipTrial(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ChangeSubscriptionInternalRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.checkout.getCheckoutData(request) -> GetCheckoutDataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.checkout().getCheckoutData( + CheckoutDataRequestBody + .builder() + .companyId("company_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**selectedPlanId:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.checkout.previewCheckoutInternal(request) -> PreviewCheckoutInternalResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.checkout().previewCheckoutInternal( + ChangeSubscriptionInternalRequestBody + .builder() + .addOnIds( + Arrays.asList( + UpdateAddOnRequestBody + .builder() + .addOnId("add_on_id") + .priceId("price_id") + .build() + ) + ) + .companyId("company_id") + .creditBundles( + Arrays.asList( + UpdateCreditBundleRequestBody + .builder() + .bundleId("bundle_id") + .quantity(1) + .build() + ) + ) + .newPlanId("new_plan_id") + .newPriceId("new_price_id") + .payInAdvance( + Arrays.asList( + UpdatePayInAdvanceRequestBody + .builder() + .priceId("price_id") + .quantity(1) + .build() + ) + ) + .skipTrial(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ChangeSubscriptionInternalRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.checkout.managePlan(request) -> ManagePlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.checkout().managePlan( + ManagePlanRequest + .builder() + .addOnSelections( + Arrays.asList( + PlanSelection + .builder() + .planId("plan_id") + .build() + ) + ) + .companyId("company_id") + .creditBundles( + Arrays.asList( + UpdateCreditBundleRequestBody + .builder() + .bundleId("bundle_id") + .quantity(1) + .build() + ) + ) + .payInAdvanceEntitlements( + Arrays.asList( + UpdatePayInAdvanceRequestBody + .builder() + .priceId("price_id") + .quantity(1) + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ManagePlanRequest` + +
+
+
+
+ + +
+
+
+ +
client.checkout.previewManagePlan(request) -> PreviewManagePlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.checkout().previewManagePlan( + ManagePlanRequest + .builder() + .addOnSelections( + Arrays.asList( + PlanSelection + .builder() + .planId("plan_id") + .build() + ) + ) + .companyId("company_id") + .creditBundles( + Arrays.asList( + UpdateCreditBundleRequestBody + .builder() + .bundleId("bundle_id") + .quantity(1) + .build() + ) + ) + .payInAdvanceEntitlements( + Arrays.asList( + UpdatePayInAdvanceRequestBody + .builder() + .priceId("price_id") + .quantity(1) + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ManagePlanRequest` + +
+
+
+
+ + +
+
+
+ +
client.checkout.updateCustomerSubscriptionTrialEnd(subscriptionId, request) -> UpdateCustomerSubscriptionTrialEndResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.checkout().updateCustomerSubscriptionTrialEnd( + "subscription_id", + UpdateTrialEndRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**subscriptionId:** `String` — subscription_id + +
+
+ +
+
+ +**trialEnd:** `Optional` + +
+
+
+
+ + +
+
+
+ +## companies +
client.companies.listCompanies() -> ListCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listCompanies( + ListCompaniesRequest + .builder() + .planId("plan_id") + .q("q") + .withoutFeatureOverrideFor("without_feature_override_for") + .withoutPlan(true) + .withSubscription(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` — Filter companies by multiple company IDs (starts with comp_) + +
+
+ +
+
+ +**planId:** `Optional` — Filter companies by plan ID (starts with plan_) + +
+
+ +
+
+ +**q:** `Optional` — Search for companies by name, keys or string traits + +
+
+ +
+
+ +**withoutFeatureOverrideFor:** `Optional` — Filter out companies that already have a company override for the specified feature ID + +
+
+ +
+
+ +**withoutPlan:** `Optional` — Filter out companies that have a plan + +
+
+ +
+
+ +**withSubscription:** `Optional` — Filter companies that have a subscription + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.upsertCompany(request) -> UpsertCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().upsertCompany( + UpsertCompanyRequestBody + .builder() + .keys( + new HashMap() {{ + put("key", "value"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertCompanyRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.companies.getCompany(companyId) -> GetCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getCompany("company_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` — company_id + +
+
+
+
+ + +
+
+
+ +
client.companies.deleteCompany(companyId) -> DeleteCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().deleteCompany("company_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` — company_id + +
+
+
+
+ + +
+
+
+ +
client.companies.countCompanies() -> CountCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().countCompanies( + CountCompaniesRequest + .builder() + .planId("plan_id") + .q("q") + .withoutFeatureOverrideFor("without_feature_override_for") + .withoutPlan(true) + .withSubscription(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` — Filter companies by multiple company IDs (starts with comp_) + +
+
+ +
+
+ +**planId:** `Optional` — Filter companies by plan ID (starts with plan_) + +
+
+ +
+
+ +**q:** `Optional` — Search for companies by name, keys or string traits + +
+
+ +
+
+ +**withoutFeatureOverrideFor:** `Optional` — Filter out companies that already have a company override for the specified feature ID + +
+
+ +
+
+ +**withoutPlan:** `Optional` — Filter out companies that have a plan + +
+
+ +
+
+ +**withSubscription:** `Optional` — Filter companies that have a subscription + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.countCompaniesForAdvancedFilter() -> CountCompaniesForAdvancedFilterResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().countCompaniesForAdvancedFilter( + CountCompaniesForAdvancedFilterRequest + .builder() + .monetizedSubscriptions(true) + .q("q") + .withoutPlan(true) + .withoutSubscription(true) + .sortOrderColumn("sort_order_column") + .sortOrderDirection(CountCompaniesForAdvancedFilterRequestSortOrderDirection.ASC) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` — Filter companies by multiple company IDs (starts with comp_) + +
+
+ +
+
+ +**planIds:** `Optional` — Filter companies by one or more plan IDs (each ID starts with plan_) + +
+
+ +
+
+ +**featureIds:** `Optional` — Filter companies by one or more feature IDs (each ID starts with feat_) + +
+
+ +
+
+ +**creditTypeIds:** `Optional` — Filter companies by one or more credit type IDs (each ID starts with bcrd_) + +
+
+ +
+
+ +**subscriptionStatuses:** `Optional` — Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid) + +
+
+ +
+
+ +**subscriptionTypes:** `Optional` — Filter companies by one or more subscription types (paid, free, trial) + +
+
+ +
+
+ +**monetizedSubscriptions:** `Optional` — Filter companies that have monetized subscriptions + +
+
+ +
+
+ +**q:** `Optional` — Search for companies by name, keys or string traits + +
+
+ +
+
+ +**withoutPlan:** `Optional` — Filter out companies that have a plan + +
+
+ +
+
+ +**withoutSubscription:** `Optional` — Filter out companies that have a subscription + +
+
+ +
+
+ +**sortOrderColumn:** `Optional` — Column to sort by (e.g. name, created_at, last_seen_at) + +
+
+ +
+
+ +**sortOrderDirection:** `Optional` — Direction to sort by (asc or desc) + +
+
+ +
+
+ +**displayProperties:** `Optional` — Select the display columns to return (e.g. plan, subscription, users, last_seen_at) + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.createCompany(request) -> CreateCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().createCompany( + UpsertCompanyRequestBody + .builder() + .keys( + new HashMap() {{ + put("key", "value"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertCompanyRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.companies.deleteCompanyByKeys(request) -> DeleteCompanyByKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().deleteCompanyByKeys( + KeysRequestBody + .builder() + .keys( + new HashMap() {{ + put("key", "value"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `KeysRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.companies.listCompaniesForAdvancedFilter() -> ListCompaniesForAdvancedFilterResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listCompaniesForAdvancedFilter( + ListCompaniesForAdvancedFilterRequest + .builder() + .monetizedSubscriptions(true) + .q("q") + .withoutPlan(true) + .withoutSubscription(true) + .sortOrderColumn("sort_order_column") + .sortOrderDirection(ListCompaniesForAdvancedFilterRequestSortOrderDirection.ASC) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` — Filter companies by multiple company IDs (starts with comp_) + +
+
+ +
+
+ +**planIds:** `Optional` — Filter companies by one or more plan IDs (each ID starts with plan_) + +
+
+ +
+
+ +**featureIds:** `Optional` — Filter companies by one or more feature IDs (each ID starts with feat_) + +
+
+ +
+
+ +**creditTypeIds:** `Optional` — Filter companies by one or more credit type IDs (each ID starts with bcrd_) + +
+
+ +
+
+ +**subscriptionStatuses:** `Optional` — Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid) + +
+
+ +
+
+ +**subscriptionTypes:** `Optional` — Filter companies by one or more subscription types (paid, free, trial) + +
+
+ +
+
+ +**monetizedSubscriptions:** `Optional` — Filter companies that have monetized subscriptions + +
+
+ +
+
+ +**q:** `Optional` — Search for companies by name, keys or string traits + +
+
+ +
+
+ +**withoutPlan:** `Optional` — Filter out companies that have a plan + +
+
+ +
+
+ +**withoutSubscription:** `Optional` — Filter out companies that have a subscription + +
+
+ +
+
+ +**sortOrderColumn:** `Optional` — Column to sort by (e.g. name, created_at, last_seen_at) + +
+
+ +
+
+ +**sortOrderDirection:** `Optional` — Direction to sort by (asc or desc) + +
+
+ +
+
+ +**displayProperties:** `Optional` — Select the display columns to return (e.g. plan, subscription, users, last_seen_at) + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.lookupCompany() -> LookupCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().lookupCompany( + LookupCompanyRequest + .builder() + .keys( + new HashMap() {{ + put("keys", "keys"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `Map` — Key/value pairs + +
+
+
+
+ + +
+
+
+ +
client.companies.getActiveDeals() -> GetActiveDealsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getActiveDeals( + GetActiveDealsRequest + .builder() + .companyId("company_id") + .dealStage("deal_stage") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**dealStage:** `String` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.listCompanyMemberships() -> ListCompanyMembershipsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listCompanyMemberships( + ListCompanyMembershipsRequest + .builder() + .companyId("company_id") + .userId("user_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**userId:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.getOrCreateCompanyMembership(request) -> GetOrCreateCompanyMembershipResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getOrCreateCompanyMembership( + GetOrCreateCompanyMembershipRequestBody + .builder() + .companyId("company_id") + .userId("user_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**userId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.companies.deleteCompanyMembership(companyMembershipId) -> DeleteCompanyMembershipResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().deleteCompanyMembership("company_membership_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyMembershipId:** `String` — company_membership_id + +
+
+
+
+ + +
+
+
+ +
client.companies.getActiveCompanySubscription() -> GetActiveCompanySubscriptionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getActiveCompanySubscription( + GetActiveCompanySubscriptionRequest + .builder() + .companyId("company_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**companyIds:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.upsertCompanyTrait(request) -> UpsertCompanyTraitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().upsertCompanyTrait( + UpsertTraitRequestBody + .builder() + .keys( + new HashMap() {{ + put("key", "value"); + }} + ) + .trait("trait") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertTraitRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.companies.listEntityKeyDefinitions() -> ListEntityKeyDefinitionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest + .builder() + .entityType(ListEntityKeyDefinitionsRequestEntityType.COMPANY) + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityType:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.countEntityKeyDefinitions() -> CountEntityKeyDefinitionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest + .builder() + .entityType(CountEntityKeyDefinitionsRequestEntityType.COMPANY) + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityType:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.listEntityTraitDefinitions() -> ListEntityTraitDefinitionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest + .builder() + .entityType(ListEntityTraitDefinitionsRequestEntityType.COMPANY) + .q("q") + .traitType(ListEntityTraitDefinitionsRequestTraitType.BOOLEAN) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityType:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**traitType:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.getOrCreateEntityTraitDefinition(request) -> GetOrCreateEntityTraitDefinitionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getOrCreateEntityTraitDefinition( + CreateEntityTraitDefinitionRequestBody + .builder() + .entityType(CreateEntityTraitDefinitionRequestBodyEntityType.COMPANY) + .hierarchy( + Arrays.asList("hierarchy") + ) + .traitType(CreateEntityTraitDefinitionRequestBodyTraitType.BOOLEAN) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**displayName:** `Optional` + +
+
+ +
+
+ +**entityType:** `CreateEntityTraitDefinitionRequestBodyEntityType` + +
+
+ +
+
+ +**hierarchy:** `List` + +
+
+ +
+
+ +**traitType:** `CreateEntityTraitDefinitionRequestBodyTraitType` + +
+
+
+
+ + +
+
+
+ +
client.companies.getEntityTraitDefinition(entityTraitDefinitionId) -> GetEntityTraitDefinitionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getEntityTraitDefinition("entity_trait_definition_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityTraitDefinitionId:** `String` — entity_trait_definition_id + +
+
+
+
+ + +
+
+
+ +
client.companies.updateEntityTraitDefinition(entityTraitDefinitionId, request) -> UpdateEntityTraitDefinitionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().updateEntityTraitDefinition( + "entity_trait_definition_id", + UpdateEntityTraitDefinitionRequestBody + .builder() + .traitType(UpdateEntityTraitDefinitionRequestBodyTraitType.BOOLEAN) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityTraitDefinitionId:** `String` — entity_trait_definition_id + +
+
+ +
+
+ +**displayName:** `Optional` + +
+
+ +
+
+ +**traitType:** `UpdateEntityTraitDefinitionRequestBodyTraitType` + +
+
+
+
+ + +
+
+
+ +
client.companies.countEntityTraitDefinitions() -> CountEntityTraitDefinitionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().countEntityTraitDefinitions( + CountEntityTraitDefinitionsRequest + .builder() + .entityType(CountEntityTraitDefinitionsRequestEntityType.COMPANY) + .q("q") + .traitType(CountEntityTraitDefinitionsRequestTraitType.BOOLEAN) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityType:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**traitType:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.getEntityTraitValues() -> GetEntityTraitValuesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getEntityTraitValues( + GetEntityTraitValuesRequest + .builder() + .definitionId("definition_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**definitionId:** `String` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.listPlanChanges() -> ListPlanChangesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listPlanChanges( + ListPlanChangesRequest + .builder() + .action("action") + .basePlanAction("base_plan_action") + .companyId("company_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**action:** `Optional` + +
+
+ +
+
+ +**basePlanAction:** `Optional` + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**companyIds:** `Optional` + +
+
+ +
+
+ +**planIds:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.getPlanChange(planChangeId) -> GetPlanChangeResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getPlanChange("plan_change_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planChangeId:** `String` — plan_change_id + +
+
+
+
+ + +
+
+
+ +
client.companies.listPlanTraits() -> ListPlanTraitsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listPlanTraits( + ListPlanTraitsRequest + .builder() + .planId("plan_id") + .traitId("trait_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**planId:** `Optional` + +
+
+ +
+
+ +**traitId:** `Optional` + +
+
+ +
+
+ +**traitIds:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.createPlanTrait(request) -> CreatePlanTraitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().createPlanTrait( + CreatePlanTraitRequestBody + .builder() + .planId("plan_id") + .traitId("trait_id") + .traitValue("trait_value") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `String` + +
+
+ +
+
+ +**traitId:** `String` + +
+
+ +
+
+ +**traitValue:** `String` + +
+
+
+
+ + +
+
+
+ +
client.companies.getPlanTrait(planTraitId) -> GetPlanTraitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getPlanTrait("plan_trait_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planTraitId:** `String` — plan_trait_id + +
+
+
+
+ + +
+
+
+ +
client.companies.updatePlanTrait(planTraitId, request) -> UpdatePlanTraitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().updatePlanTrait( + "plan_trait_id", + UpdatePlanTraitRequestBody + .builder() + .planId("plan_id") + .traitValue("trait_value") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planTraitId:** `String` — plan_trait_id + +
+
+ +
+
+ +**planId:** `String` + +
+
+ +
+
+ +**traitValue:** `String` + +
+
+
+
+ + +
+
+
+ +
client.companies.deletePlanTrait(planTraitId) -> DeletePlanTraitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().deletePlanTrait("plan_trait_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planTraitId:** `String` — plan_trait_id + +
+
+
+
+ + +
+
+
+ +
client.companies.updatePlanTraitsBulk(request) -> UpdatePlanTraitsBulkResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().updatePlanTraitsBulk( + UpdatePlanTraitBulkRequestBody + .builder() + .planId("plan_id") + .traits( + Arrays.asList( + UpdatePlanTraitTraitRequestBody + .builder() + .traitId("trait_id") + .traitValue("trait_value") + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `String` + +
+
+ +
+
+ +**traits:** `List` + +
+
+
+
+ + +
+
+
+ +
client.companies.countPlanTraits() -> CountPlanTraitsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().countPlanTraits( + CountPlanTraitsRequest + .builder() + .planId("plan_id") + .traitId("trait_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**planId:** `Optional` + +
+
+ +
+
+ +**traitId:** `Optional` + +
+
+ +
+
+ +**traitIds:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.upsertUserTrait(request) -> UpsertUserTraitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().upsertUserTrait( + UpsertTraitRequestBody + .builder() + .keys( + new HashMap() {{ + put("key", "value"); + }} + ) + .trait("trait") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertTraitRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.companies.listUsers() -> ListUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listUsers( + ListUsersRequest + .builder() + .companyId("company_id") + .planId("plan_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` — Filter users by company ID (starts with comp_) + +
+
+ +
+
+ +**ids:** `Optional` — Filter users by multiple user IDs (starts with user_) + +
+
+ +
+
+ +**planId:** `Optional` — Filter users by plan ID (starts with plan_) + +
+
+ +
+
+ +**q:** `Optional` — Search for users by name, keys or string traits + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.upsertUser(request) -> UpsertUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().upsertUser( + UpsertUserRequestBody + .builder() + .keys( + new HashMap() {{ + put("key", "value"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertUserRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.companies.getUser(userId) -> GetUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().getUser("user_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `String` — user_id + +
+
+
+
+ + +
+
+
+ +
client.companies.deleteUser(userId) -> DeleteUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().deleteUser("user_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `String` — user_id + +
+
+
+
+ + +
+
+
+ +
client.companies.countUsers() -> CountUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().countUsers( + CountUsersRequest + .builder() + .companyId("company_id") + .planId("plan_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` — Filter users by company ID (starts with comp_) + +
+
+ +
+
+ +**ids:** `Optional` — Filter users by multiple user IDs (starts with user_) + +
+
+ +
+
+ +**planId:** `Optional` — Filter users by plan ID (starts with plan_) + +
+
+ +
+
+ +**q:** `Optional` — Search for users by name, keys or string traits + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.companies.createUser(request) -> CreateUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().createUser( + UpsertUserRequestBody + .builder() + .keys( + new HashMap() {{ + put("key", "value"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertUserRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.companies.deleteUserByKeys(request) -> DeleteUserByKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().deleteUserByKeys( + KeysRequestBody + .builder() + .keys( + new HashMap() {{ + put("key", "value"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `KeysRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.companies.lookupUser() -> LookupUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().lookupUser( + LookupUserRequest + .builder() + .keys( + new HashMap() {{ + put("keys", "keys"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `Map` — Key/value pairs + +
+
+
+
+ + +
+
+
+ +## entitlements +
client.entitlements.listCompanyOverrides() -> ListCompanyOverridesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().listCompanyOverrides( + ListCompanyOverridesRequest + .builder() + .companyId("company_id") + .featureId("feature_id") + .withoutExpired(true) + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` — Filter company overrides by a single company ID (starting with comp_) + +
+
+ +
+
+ +**companyIds:** `Optional` — Filter company overrides by multiple company IDs (starting with comp_) + +
+
+ +
+
+ +**featureId:** `Optional` — Filter company overrides by a single feature ID (starting with feat_) + +
+
+ +
+
+ +**featureIds:** `Optional` — Filter company overrides by multiple feature IDs (starting with feat_) + +
+
+ +
+
+ +**ids:** `Optional` — Filter company overrides by multiple company override IDs (starting with cmov_) + +
+
+ +
+
+ +**withoutExpired:** `Optional` — Filter company overrides by whether they have not expired + +
+
+ +
+
+ +**q:** `Optional` — Search for company overrides by feature or company name + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.createCompanyOverride(request) -> CreateCompanyOverrideResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().createCompanyOverride( + CreateCompanyOverrideRequestBody + .builder() + .companyId("company_id") + .featureId("feature_id") + .valueType(CreateCompanyOverrideRequestBodyValueType.BOOLEAN) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` + +
+
+ +
+
+ +**creditConsumptionRate:** `Optional` + +
+
+ +
+
+ +**expirationDate:** `Optional` + +
+
+ +
+
+ +**featureId:** `String` + +
+
+ +
+
+ +**metricPeriod:** `Optional` + +
+
+ +
+
+ +**metricPeriodMonthReset:** `Optional` + +
+
+ +
+
+ +**note:** `Optional` + +
+
+ +
+
+ +**valueBool:** `Optional` + +
+
+ +
+
+ +**valueCreditId:** `Optional` + +
+
+ +
+
+ +**valueNumeric:** `Optional` + +
+
+ +
+
+ +**valueTraitId:** `Optional` + +
+
+ +
+
+ +**valueType:** `CreateCompanyOverrideRequestBodyValueType` + +
+
+
+
+ + +
+
+
+ +
client.entitlements.getCompanyOverride(companyOverrideId) -> GetCompanyOverrideResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().getCompanyOverride("company_override_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyOverrideId:** `String` — company_override_id + +
+
+
+
+ + +
+
+
+ +
client.entitlements.updateCompanyOverride(companyOverrideId, request) -> UpdateCompanyOverrideResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().updateCompanyOverride( + "company_override_id", + UpdateCompanyOverrideRequestBody + .builder() + .valueType(UpdateCompanyOverrideRequestBodyValueType.BOOLEAN) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyOverrideId:** `String` — company_override_id + +
+
+ +
+
+ +**creditConsumptionRate:** `Optional` + +
+
+ +
+
+ +**expirationDate:** `Optional` + +
+
+ +
+
+ +**metricPeriod:** `Optional` + +
+
+ +
+
+ +**metricPeriodMonthReset:** `Optional` + +
+
+ +
+
+ +**note:** `Optional` + +
+
+ +
+
+ +**valueBool:** `Optional` + +
+
+ +
+
+ +**valueCreditId:** `Optional` + +
+
+ +
+
+ +**valueNumeric:** `Optional` + +
+
+ +
+
+ +**valueTraitId:** `Optional` + +
+
+ +
+
+ +**valueType:** `UpdateCompanyOverrideRequestBodyValueType` + +
+
+
+
+ + +
+
+
+ +
client.entitlements.deleteCompanyOverride(companyOverrideId) -> DeleteCompanyOverrideResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().deleteCompanyOverride("company_override_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyOverrideId:** `String` — company_override_id + +
+
+
+
+ + +
+
+
+ +
client.entitlements.countCompanyOverrides() -> CountCompanyOverridesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().countCompanyOverrides( + CountCompanyOverridesRequest + .builder() + .companyId("company_id") + .featureId("feature_id") + .withoutExpired(true) + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` — Filter company overrides by a single company ID (starting with comp_) + +
+
+ +
+
+ +**companyIds:** `Optional` — Filter company overrides by multiple company IDs (starting with comp_) + +
+
+ +
+
+ +**featureId:** `Optional` — Filter company overrides by a single feature ID (starting with feat_) + +
+
+ +
+
+ +**featureIds:** `Optional` — Filter company overrides by multiple feature IDs (starting with feat_) + +
+
+ +
+
+ +**ids:** `Optional` — Filter company overrides by multiple company override IDs (starting with cmov_) + +
+
+ +
+
+ +**withoutExpired:** `Optional` — Filter company overrides by whether they have not expired + +
+
+ +
+
+ +**q:** `Optional` — Search for company overrides by feature or company name + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.listFeatureCompanies() -> ListFeatureCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().listFeatureCompanies( + ListFeatureCompaniesRequest + .builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `String` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.countFeatureCompanies() -> CountFeatureCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().countFeatureCompanies( + CountFeatureCompaniesRequest + .builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `String` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.listFeatureUsage() -> ListFeatureUsageResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().listFeatureUsage( + ListFeatureUsageRequest + .builder() + .companyId("company_id") + .q("q") + .withoutNegativeEntitlements(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**companyKeys:** `Optional>` + +
+
+ +
+
+ +**featureIds:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**withoutNegativeEntitlements:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.countFeatureUsage() -> CountFeatureUsageResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().countFeatureUsage( + CountFeatureUsageRequest + .builder() + .companyId("company_id") + .q("q") + .withoutNegativeEntitlements(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**companyKeys:** `Optional>` + +
+
+ +
+
+ +**featureIds:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**withoutNegativeEntitlements:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.listFeatureUsers() -> ListFeatureUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().listFeatureUsers( + ListFeatureUsersRequest + .builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `String` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.countFeatureUsers() -> CountFeatureUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().countFeatureUsers( + CountFeatureUsersRequest + .builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `String` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.listPlanEntitlements() -> ListPlanEntitlementsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().listPlanEntitlements( + ListPlanEntitlementsRequest + .builder() + .featureId("feature_id") + .planId("plan_id") + .q("q") + .withMeteredProducts(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `Optional` — Filter plan entitlements by a single feature ID (starting with feat_) + +
+
+ +
+
+ +**featureIds:** `Optional` — Filter plan entitlements by multiple feature IDs (starting with feat_) + +
+
+ +
+
+ +**ids:** `Optional` — Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) + +
+
+ +
+
+ +**planId:** `Optional` — Filter plan entitlements by a single plan ID (starting with plan_) + +
+
+ +
+
+ +**planIds:** `Optional` — Filter plan entitlements by multiple plan IDs (starting with plan_) + +
+
+ +
+
+ +**q:** `Optional` — Search for plan entitlements by feature or company name + +
+
+ +
+
+ +**withMeteredProducts:** `Optional` — Filter plan entitlements only with metered products + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.createPlanEntitlement(request) -> CreatePlanEntitlementResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().createPlanEntitlement( + CreatePlanEntitlementRequestBody + .builder() + .featureId("feature_id") + .planId("plan_id") + .valueType(CreatePlanEntitlementRequestBodyValueType.BOOLEAN) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingProductId:** `Optional` + +
+
+ +
+
+ +**billingThreshold:** `Optional` + +
+
+ +
+
+ +**creditConsumptionRate:** `Optional` + +
+
+ +
+
+ +**currency:** `Optional` + +
+
+ +
+
+ +**featureId:** `String` + +
+
+ +
+
+ +**metricPeriod:** `Optional` + +
+
+ +
+
+ +**metricPeriodMonthReset:** `Optional` + +
+
+ +
+
+ +**monthlyMeteredPriceId:** `Optional` + +
+
+ +
+
+ +**monthlyPriceTiers:** `Optional>` + +
+
+ +
+
+ +**monthlyUnitPrice:** `Optional` + +
+
+ +
+
+ +**monthlyUnitPriceDecimal:** `Optional` + +
+
+ +
+
+ +**overageBillingProductId:** `Optional` + +
+
+ +
+
+ +**planId:** `String` + +
+
+ +
+
+ +**priceBehavior:** `Optional` + +
+
+ +
+
+ +**priceTiers:** `Optional>` — Use MonthlyPriceTiers or YearlyPriceTiers instead + +
+
+ +
+
+ +**softLimit:** `Optional` + +
+
+ +
+
+ +**tierMode:** `Optional` + +
+
+ +
+
+ +**valueBool:** `Optional` + +
+
+ +
+
+ +**valueCreditId:** `Optional` + +
+
+ +
+
+ +**valueNumeric:** `Optional` + +
+
+ +
+
+ +**valueTraitId:** `Optional` + +
+
+ +
+
+ +**valueType:** `CreatePlanEntitlementRequestBodyValueType` + +
+
+ +
+
+ +**yearlyMeteredPriceId:** `Optional` + +
+
+ +
+
+ +**yearlyPriceTiers:** `Optional>` + +
+
+ +
+
+ +**yearlyUnitPrice:** `Optional` + +
+
+ +
+
+ +**yearlyUnitPriceDecimal:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.entitlements.getPlanEntitlement(planEntitlementId) -> GetPlanEntitlementResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().getPlanEntitlement("plan_entitlement_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planEntitlementId:** `String` — plan_entitlement_id + +
+
+
+
+ + +
+
+
+ +
client.entitlements.updatePlanEntitlement(planEntitlementId, request) -> UpdatePlanEntitlementResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().updatePlanEntitlement( + "plan_entitlement_id", + UpdatePlanEntitlementRequestBody + .builder() + .valueType(UpdatePlanEntitlementRequestBodyValueType.BOOLEAN) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planEntitlementId:** `String` — plan_entitlement_id + +
+
+ +
+
+ +**billingProductId:** `Optional` + +
+
+ +
+
+ +**billingThreshold:** `Optional` + +
+
+ +
+
+ +**creditConsumptionRate:** `Optional` + +
+
+ +
+
+ +**currency:** `Optional` + +
+
+ +
+
+ +**metricPeriod:** `Optional` + +
+
+ +
+
+ +**metricPeriodMonthReset:** `Optional` + +
+
+ +
+
+ +**monthlyMeteredPriceId:** `Optional` + +
+
+ +
+
+ +**monthlyPriceTiers:** `Optional>` + +
+
+ +
+
+ +**monthlyUnitPrice:** `Optional` + +
+
+ +
+
+ +**monthlyUnitPriceDecimal:** `Optional` + +
+
+ +
+
+ +**overageBillingProductId:** `Optional` + +
+
+ +
+
+ +**priceBehavior:** `Optional` + +
+
+ +
+
+ +**priceTiers:** `Optional>` — Use MonthlyPriceTiers or YearlyPriceTiers instead + +
+
+ +
+
+ +**softLimit:** `Optional` + +
+
+ +
+
+ +**tierMode:** `Optional` + +
+
+ +
+
+ +**valueBool:** `Optional` + +
+
+ +
+
+ +**valueCreditId:** `Optional` + +
+
+ +
+
+ +**valueNumeric:** `Optional` + +
+
+ +
+
+ +**valueTraitId:** `Optional` + +
+
+ +
+
+ +**valueType:** `UpdatePlanEntitlementRequestBodyValueType` + +
+
+ +
+
+ +**yearlyMeteredPriceId:** `Optional` + +
+
+ +
+
+ +**yearlyPriceTiers:** `Optional>` + +
+
+ +
+
+ +**yearlyUnitPrice:** `Optional` + +
+
+ +
+
+ +**yearlyUnitPriceDecimal:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.entitlements.deletePlanEntitlement(planEntitlementId) -> DeletePlanEntitlementResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().deletePlanEntitlement("plan_entitlement_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planEntitlementId:** `String` — plan_entitlement_id + +
+
+
+
+ + +
+
+
+ +
client.entitlements.countPlanEntitlements() -> CountPlanEntitlementsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().countPlanEntitlements( + CountPlanEntitlementsRequest + .builder() + .featureId("feature_id") + .planId("plan_id") + .q("q") + .withMeteredProducts(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `Optional` — Filter plan entitlements by a single feature ID (starting with feat_) + +
+
+ +
+
+ +**featureIds:** `Optional` — Filter plan entitlements by multiple feature IDs (starting with feat_) + +
+
+ +
+
+ +**ids:** `Optional` — Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) + +
+
+ +
+
+ +**planId:** `Optional` — Filter plan entitlements by a single plan ID (starting with plan_) + +
+
+ +
+
+ +**planIds:** `Optional` — Filter plan entitlements by multiple plan IDs (starting with plan_) + +
+
+ +
+
+ +**q:** `Optional` — Search for plan entitlements by feature or company name + +
+
+ +
+
+ +**withMeteredProducts:** `Optional` — Filter plan entitlements only with metered products + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.entitlements.getFeatureUsageByCompany() -> GetFeatureUsageByCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entitlements().getFeatureUsageByCompany( + GetFeatureUsageByCompanyRequest + .builder() + .keys( + new HashMap() {{ + put("keys", "keys"); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `Map` — Key/value pairs + +
+
+
+
+ + +
+
+
+ +## plans +
client.plans.updateCompanyPlans(companyPlanId, request) -> UpdateCompanyPlansResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().updateCompanyPlans( + "company_plan_id", + UpdateCompanyPlansRequestBody + .builder() + .addOnIds( + Arrays.asList("add_on_ids") + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyPlanId:** `String` — company_plan_id + +
+
+ +
+
+ +**addOnIds:** `List` + +
+
+ +
+
+ +**basePlanId:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.plans.listPlans() -> ListPlansResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().listPlans( + ListPlansRequest + .builder() + .companyId("company_id") + .forFallbackPlan(true) + .forInitialPlan(true) + .forTrialExpiryPlan(true) + .hasProductId(true) + .planType(ListPlansRequestPlanType.PLAN) + .q("q") + .requiresPaymentMethod(true) + .withoutEntitlementFor("without_entitlement_for") + .withoutProductId(true) + .withoutPaidProductId(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**forFallbackPlan:** `Optional` — Filter for plans valid as fallback plans (not linked to billing) + +
+
+ +
+
+ +**forInitialPlan:** `Optional` — Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial) + +
+
+ +
+
+ +**forTrialExpiryPlan:** `Optional` — Filter for plans valid as trial expiry plans (not linked to billing or free) + +
+
+ +
+
+ +**hasProductId:** `Optional` — Filter out plans that do not have a billing product ID + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**planType:** `Optional` — Filter by plan type + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**requiresPaymentMethod:** `Optional` — Filter for plans that require a payment method (inverse of ForInitialPlan) + +
+
+ +
+
+ +**withoutEntitlementFor:** `Optional` — Filter out plans that already have a plan entitlement for the specified feature ID + +
+
+ +
+
+ +**withoutProductId:** `Optional` — Filter out plans that have a billing product ID + +
+
+ +
+
+ +**withoutPaidProductId:** `Optional` — Filter out plans that have a paid billing product ID + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.plans.createPlan(request) -> CreatePlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().createPlan( + CreatePlanRequestBody + .builder() + .description("description") + .name("name") + .planType(CreatePlanRequestBodyPlanType.PLAN) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**description:** `String` + +
+
+ +
+
+ +**icon:** `Optional` + +
+
+ +
+
+ +**name:** `String` + +
+
+ +
+
+ +**planType:** `CreatePlanRequestBodyPlanType` + +
+
+
+
+ + +
+
+
+ +
client.plans.getPlan(planId) -> GetPlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().getPlan("plan_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `String` — plan_id + +
+
+
+
+ + +
+
+
+ +
client.plans.updatePlan(planId, request) -> UpdatePlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().updatePlan( + "plan_id", + UpdatePlanRequestBody + .builder() + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `String` — plan_id + +
+
+ +
+
+ +**description:** `Optional` + +
+
+ +
+
+ +**icon:** `Optional` + +
+
+ +
+
+ +**name:** `String` + +
+
+
+
+ + +
+
+
+ +
client.plans.deletePlan(planId) -> DeletePlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().deletePlan("plan_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `String` — plan_id + +
+
+
+
+ + +
+
+
+ +
client.plans.upsertBillingProductPlan(planId, request) -> UpsertBillingProductPlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().upsertBillingProductPlan( + "plan_id", + UpsertBillingProductRequestBody + .builder() + .chargeType(UpsertBillingProductRequestBodyChargeType.ONE_TIME) + .isTrialable(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `String` — plan_id + +
+
+ +
+
+ +**billingProductId:** `Optional` + +
+
+ +
+
+ +**chargeType:** `UpsertBillingProductRequestBodyChargeType` + +
+
+ +
+
+ +**currency:** `Optional` + +
+
+ +
+
+ +**isTrialable:** `Boolean` + +
+
+ +
+
+ +**monthlyPrice:** `Optional` + +
+
+ +
+
+ +**monthlyPriceId:** `Optional` + +
+
+ +
+
+ +**oneTimePrice:** `Optional` + +
+
+ +
+
+ +**oneTimePriceId:** `Optional` + +
+
+ +
+
+ +**trialDays:** `Optional` + +
+
+ +
+
+ +**yearlyPrice:** `Optional` + +
+
+ +
+
+ +**yearlyPriceId:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.plans.countPlans() -> CountPlansResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().countPlans( + CountPlansRequest + .builder() + .companyId("company_id") + .forFallbackPlan(true) + .forInitialPlan(true) + .forTrialExpiryPlan(true) + .hasProductId(true) + .planType(CountPlansRequestPlanType.PLAN) + .q("q") + .requiresPaymentMethod(true) + .withoutEntitlementFor("without_entitlement_for") + .withoutProductId(true) + .withoutPaidProductId(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**forFallbackPlan:** `Optional` — Filter for plans valid as fallback plans (not linked to billing) + +
+
+ +
+
+ +**forInitialPlan:** `Optional` — Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial) + +
+
+ +
+
+ +**forTrialExpiryPlan:** `Optional` — Filter for plans valid as trial expiry plans (not linked to billing or free) + +
+
+ +
+
+ +**hasProductId:** `Optional` — Filter out plans that do not have a billing product ID + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**planType:** `Optional` — Filter by plan type + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**requiresPaymentMethod:** `Optional` — Filter for plans that require a payment method (inverse of ForInitialPlan) + +
+
+ +
+
+ +**withoutEntitlementFor:** `Optional` — Filter out plans that already have a plan entitlement for the specified feature ID + +
+
+ +
+
+ +**withoutProductId:** `Optional` — Filter out plans that have a billing product ID + +
+
+ +
+
+ +**withoutPaidProductId:** `Optional` — Filter out plans that have a paid billing product ID + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.plans.listPlanIssues() -> ListPlanIssuesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plans().listPlanIssues( + ListPlanIssuesRequest + .builder() + .planId("plan_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `String` + +
+
+
+
+ + +
+
+
+ +## components +
client.components.listComponents() -> ListComponentsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.components().listComponents( + ListComponentsRequest + .builder() + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.components.createComponent(request) -> CreateComponentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.components().createComponent( + CreateComponentRequestBody + .builder() + .entityType(CreateComponentRequestBodyEntityType.ENTITLEMENT) + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ast:** `Optional>` + +
+
+ +
+
+ +**entityType:** `CreateComponentRequestBodyEntityType` + +
+
+ +
+
+ +**name:** `String` + +
+
+
+
+ + +
+
+
+ +
client.components.getComponent(componentId) -> GetComponentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.components().getComponent("component_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**componentId:** `String` — component_id + +
+
+
+
+ + +
+
+
+ +
client.components.updateComponent(componentId, request) -> UpdateComponentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.components().updateComponent( + "component_id", + UpdateComponentRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**componentId:** `String` — component_id + +
+
+ +
+
+ +**ast:** `Optional>` + +
+
+ +
+
+ +**entityType:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**state:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.components.deleteComponent(componentId) -> DeleteComponentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.components().deleteComponent("component_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**componentId:** `String` — component_id + +
+
+
+
+ + +
+
+
+ +
client.components.countComponents() -> CountComponentsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.components().countComponents( + CountComponentsRequest + .builder() + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.components.previewComponentData() -> PreviewComponentDataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.components().previewComponentData( + PreviewComponentDataRequest + .builder() + .companyId("company_id") + .componentId("component_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**componentId:** `Optional` + +
+
+
+
+ + +
+
+
+ +## crm +
client.crm.upsertDealLineItemAssociation(request) -> UpsertDealLineItemAssociationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.crm().upsertDealLineItemAssociation( + CreateCrmDealLineItemAssociationRequestBody + .builder() + .dealExternalId("deal_external_id") + .lineItemExternalId("line_item_external_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dealExternalId:** `String` + +
+
+ +
+
+ +**lineItemExternalId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.crm.upsertLineItem(request) -> UpsertLineItemResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.crm().upsertLineItem( + CreateCrmLineItemRequestBody + .builder() + .amount("amount") + .interval("interval") + .lineItemExternalId("line_item_external_id") + .productExternalId("product_external_id") + .quantity(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**amount:** `String` + +
+
+ +
+
+ +**discountPercentage:** `Optional` + +
+
+ +
+
+ +**interval:** `String` + +
+
+ +
+
+ +**lineItemExternalId:** `String` + +
+
+ +
+
+ +**productExternalId:** `String` + +
+
+ +
+
+ +**quantity:** `Integer` + +
+
+ +
+
+ +**termMonth:** `Optional` + +
+
+ +
+
+ +**totalDiscount:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.crm.upsertCrmDeal(request) -> UpsertCrmDealResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.crm().upsertCrmDeal( + CreateCrmDealRequestBody + .builder() + .crmCompanyKey("crm_company_key") + .crmType("crm_type") + .dealExternalId("deal_external_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**arr:** `Optional` + +
+
+ +
+
+ +**crmCompanyId:** `Optional` + +
+
+ +
+
+ +**crmCompanyKey:** `String` + +
+
+ +
+
+ +**crmProductId:** `Optional` + +
+
+ +
+
+ +**crmType:** `String` + +
+
+ +
+
+ +**dealExternalId:** `String` + +
+
+ +
+
+ +**dealName:** `Optional` + +
+
+ +
+
+ +**dealStage:** `Optional` + +
+
+ +
+
+ +**mrr:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.crm.listCrmProducts() -> ListCrmProductsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.crm().listCrmProducts( + ListCrmProductsRequest + .builder() + .name("name") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.crm.upsertCrmProduct(request) -> UpsertCrmProductResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.crm().upsertCrmProduct( + CreateCrmProductRequestBody + .builder() + .currency("currency") + .description("description") + .externalId("external_id") + .interval("interval") + .name("name") + .price("price") + .quantity(1) + .sku("sku") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**currency:** `String` + +
+
+ +
+
+ +**description:** `String` + +
+
+ +
+
+ +**externalId:** `String` + +
+
+ +
+
+ +**interval:** `String` + +
+
+ +
+
+ +**name:** `String` + +
+
+ +
+
+ +**price:** `String` + +
+
+ +
+
+ +**quantity:** `Integer` + +
+
+ +
+
+ +**sku:** `String` + +
+
+
+
+ + +
+
+
+ +## dataexports +
client.dataexports.createDataExport(request) -> CreateDataExportResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataexports().createDataExport( + CreateDataExportRequestBody + .builder() + .exportType("company-feature-usage") + .metadata("metadata") + .outputFileType("csv") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**exportType:** `String` + +
+
+ +
+
+ +**metadata:** `String` + +
+
+ +
+
+ +**outputFileType:** `String` + +
+
+
+
+ + +
+
+
+ +
client.dataexports.getDataExportArtifact(dataExportId) -> InputStream +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataexports().getDataExportArtifact("data_export_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataExportId:** `String` — data_export_id + +
+
+
+
+ + +
+
+
+ +## events +
client.events.createEventBatch(request) -> CreateEventBatchResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().createEventBatch( + CreateEventBatchRequestBody + .builder() + .events( + Arrays.asList( + CreateEventRequestBody + .builder() + .eventType(CreateEventRequestBodyEventType.IDENTIFY) + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**events:** `List` + +
+
+
+
+ + +
+
+
+ +
client.events.getEventSummaries() -> GetEventSummariesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().getEventSummaries( + GetEventSummariesRequest + .builder() + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**eventSubtypes:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.events.listEvents() -> ListEventsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().listEvents( + ListEventsRequest + .builder() + .companyId("company_id") + .eventSubtype("event_subtype") + .flagId("flag_id") + .userId("user_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `Optional` + +
+
+ +
+
+ +**eventSubtype:** `Optional` + +
+
+ +
+
+ +**eventTypes:** `Optional` + +
+
+ +
+
+ +**flagId:** `Optional` + +
+
+ +
+
+ +**userId:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.events.createEvent(request) -> CreateEventResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().createEvent( + CreateEventRequestBody + .builder() + .eventType(CreateEventRequestBodyEventType.IDENTIFY) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateEventRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.events.getEvent(eventId) -> GetEventResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().getEvent("event_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**eventId:** `String` — event_id + +
+
+
+
+ + +
+
+
+ +
client.events.getSegmentIntegrationStatus() -> GetSegmentIntegrationStatusResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().getSegmentIntegrationStatus(); +``` +
+
+
+
+ + +
+
+
+ +## features +
client.features.listFeatures() -> ListFeaturesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().listFeatures( + ListFeaturesRequest + .builder() + .q("q") + .withoutCompanyOverrideFor("without_company_override_for") + .withoutPlanEntitlementFor("without_plan_entitlement_for") + .booleanRequireEvent(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` — Search by feature name or ID + +
+
+ +
+
+ +**withoutCompanyOverrideFor:** `Optional` — Filter out features that already have a company override for the specified company ID + +
+
+ +
+
+ +**withoutPlanEntitlementFor:** `Optional` — Filter out features that already have a plan entitlement for the specified plan ID + +
+
+ +
+
+ +**featureType:** `Optional` — Filter by one or more feature types (boolean, event, trait) + +
+
+ +
+
+ +**booleanRequireEvent:** `Optional` — Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter. + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.features.createFeature(request) -> CreateFeatureResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().createFeature( + CreateFeatureRequestBody + .builder() + .description("description") + .featureType(CreateFeatureRequestBodyFeatureType.BOOLEAN) + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**description:** `String` + +
+
+ +
+
+ +**eventSubtype:** `Optional` + +
+
+ +
+
+ +**featureType:** `CreateFeatureRequestBodyFeatureType` + +
+
+ +
+
+ +**flag:** `Optional` + +
+
+ +
+
+ +**icon:** `Optional` + +
+
+ +
+
+ +**lifecyclePhase:** `Optional` + +
+
+ +
+
+ +**maintainerId:** `Optional` + +
+
+ +
+
+ +**name:** `String` + +
+
+ +
+
+ +**pluralName:** `Optional` + +
+
+ +
+
+ +**singularName:** `Optional` + +
+
+ +
+
+ +**traitId:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.features.getFeature(featureId) -> GetFeatureResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().getFeature("feature_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `String` — feature_id + +
+
+
+
+ + +
+
+
+ +
client.features.updateFeature(featureId, request) -> UpdateFeatureResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().updateFeature( + "feature_id", + UpdateFeatureRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `String` — feature_id + +
+
+ +
+
+ +**description:** `Optional` + +
+
+ +
+
+ +**eventSubtype:** `Optional` + +
+
+ +
+
+ +**featureType:** `Optional` + +
+
+ +
+
+ +**flag:** `Optional` + +
+
+ +
+
+ +**icon:** `Optional` + +
+
+ +
+
+ +**lifecyclePhase:** `Optional` + +
+
+ +
+
+ +**maintainerId:** `Optional` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**pluralName:** `Optional` + +
+
+ +
+
+ +**singularName:** `Optional` + +
+
+ +
+
+ +**traitId:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.features.deleteFeature(featureId) -> DeleteFeatureResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().deleteFeature("feature_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `String` — feature_id + +
+
+
+
+ + +
+
+
+ +
client.features.countFeatures() -> CountFeaturesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().countFeatures( + CountFeaturesRequest + .builder() + .q("q") + .withoutCompanyOverrideFor("without_company_override_for") + .withoutPlanEntitlementFor("without_plan_entitlement_for") + .booleanRequireEvent(true) + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` — Search by feature name or ID + +
+
+ +
+
+ +**withoutCompanyOverrideFor:** `Optional` — Filter out features that already have a company override for the specified company ID + +
+
+ +
+
+ +**withoutPlanEntitlementFor:** `Optional` — Filter out features that already have a plan entitlement for the specified plan ID + +
+
+ +
+
+ +**featureType:** `Optional` — Filter by one or more feature types (boolean, event, trait) + +
+
+ +
+
+ +**booleanRequireEvent:** `Optional` — Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter. + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.features.listFlags() -> ListFlagsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().listFlags( + ListFlagsRequest + .builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` — Search by flag name, key, or ID + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.features.createFlag(request) -> CreateFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().createFlag( + CreateFlagRequestBody + .builder() + .defaultValue(true) + .description("description") + .flagType("boolean") + .key("key") + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateFlagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.features.getFlag(flagId) -> GetFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().getFlag("flag_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flagId:** `String` — flag_id + +
+
+
+
+ + +
+
+
+ +
client.features.updateFlag(flagId, request) -> UpdateFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().updateFlag( + "flag_id", + CreateFlagRequestBody + .builder() + .defaultValue(true) + .description("description") + .flagType("boolean") + .key("key") + .name("name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flagId:** `String` — flag_id + +
+
+ +
+
+ +**request:** `CreateFlagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.features.deleteFlag(flagId) -> DeleteFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().deleteFlag("flag_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flagId:** `String` — flag_id + +
+
+
+
+ + +
+
+
+ +
client.features.updateFlagRules(flagId, request) -> UpdateFlagRulesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().updateFlagRules( + "flag_id", + UpdateFlagRulesRequestBody + .builder() + .rules( + Arrays.asList( + CreateOrUpdateRuleRequestBody + .builder() + .conditionGroups( + Arrays.asList( + CreateOrUpdateConditionGroupRequestBody + .builder() + .conditions( + Arrays.asList( + CreateOrUpdateConditionRequestBody + .builder() + .conditionType(CreateOrUpdateConditionRequestBodyConditionType.COMPANY) + .operator(CreateOrUpdateConditionRequestBodyOperator.EQ) + .resourceIds( + Arrays.asList("resource_ids") + ) + .build() + ) + ) + .build() + ) + ) + .conditions( + Arrays.asList( + CreateOrUpdateConditionRequestBody + .builder() + .conditionType(CreateOrUpdateConditionRequestBodyConditionType.COMPANY) + .operator(CreateOrUpdateConditionRequestBodyOperator.EQ) + .resourceIds( + Arrays.asList("resource_ids") + ) + .build() + ) + ) + .name("name") + .priority(1) + .value(true) + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flagId:** `String` — flag_id + +
+
+ +
+
+ +**rules:** `List` + +
+
+
+
+ + +
+
+
+ +
client.features.checkFlag(key, request) -> CheckFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().checkFlag( + "key", + CheckFlagRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**key:** `String` — key + +
+
+ +
+
+ +**request:** `CheckFlagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.features.checkFlags(request) -> CheckFlagsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().checkFlags( + CheckFlagRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CheckFlagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.features.countFlags() -> CountFlagsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.features().countFlags( + CountFlagsRequest + .builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `Optional` + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` — Search by flag name, key, or ID + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +## plangroups +
client.plangroups.getPlanGroup() -> GetPlanGroupResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plangroups().getPlanGroup(); +``` +
+
+
+
+ + +
+
+
+ +
client.plangroups.createPlanGroup(request) -> CreatePlanGroupResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plangroups().createPlanGroup( + CreatePlanGroupRequestBody + .builder() + .addOnIds( + Arrays.asList("add_on_ids") + ) + .checkoutCollectAddress(true) + .checkoutCollectEmail(true) + .checkoutCollectPhone(true) + .enableTaxCollection(true) + .orderedAddOns( + Arrays.asList( + OrderedPlansInGroup + .builder() + .planId("plan_id") + .build() + ) + ) + .orderedBundleList( + Arrays.asList( + PlanGroupBundleOrder + .builder() + .bundleId("bundleId") + .build() + ) + ) + .orderedPlans( + Arrays.asList( + OrderedPlansInGroup + .builder() + .planId("plan_id") + .build() + ) + ) + .preventDowngradesWhenOverLimit(true) + .showCredits(true) + .showPeriodToggle(true) + .showZeroPriceAsFree(true) + .syncCustomerBillingDetailsForTax(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**addOnCompatibilities:** `Optional>` + +
+
+ +
+
+ +**addOnIds:** `List` — Use OrderedAddOns instead + +
+
+ +
+
+ +**checkoutCollectAddress:** `Boolean` + +
+
+ +
+
+ +**checkoutCollectEmail:** `Boolean` + +
+
+ +
+
+ +**checkoutCollectPhone:** `Boolean` + +
+
+ +
+
+ +**customPlanConfig:** `Optional` + +
+
+ +
+
+ +**customPlanId:** `Optional` + +
+
+ +
+
+ +**enableTaxCollection:** `Boolean` + +
+
+ +
+
+ +**fallbackPlanId:** `Optional` + +
+
+ +
+
+ +**initialPlanId:** `Optional` + +
+
+ +
+
+ +**initialPlanPriceId:** `Optional` + +
+
+ +
+
+ +**orderedAddOns:** `List` + +
+
+ +
+
+ +**orderedBundleList:** `List` + +
+
+ +
+
+ +**orderedPlans:** `List` + +
+
+ +
+
+ +**preventDowngradesWhenOverLimit:** `Boolean` + +
+
+ +
+
+ +**showCredits:** `Boolean` + +
+
+ +
+
+ +**showPeriodToggle:** `Boolean` + +
+
+ +
+
+ +**showZeroPriceAsFree:** `Boolean` + +
+
+ +
+
+ +**syncCustomerBillingDetailsForTax:** `Boolean` + +
+
+ +
+
+ +**trialDays:** `Optional` + +
+
+ +
+
+ +**trialExpiryPlanId:** `Optional` + +
+
+ +
+
+ +**trialExpiryPlanPriceId:** `Optional` + +
+
+ +
+
+ +**trialPaymentMethodRequired:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.plangroups.updatePlanGroup(planGroupId, request) -> UpdatePlanGroupResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.plangroups().updatePlanGroup( + "plan_group_id", + UpdatePlanGroupRequestBody + .builder() + .addOnIds( + Arrays.asList("add_on_ids") + ) + .checkoutCollectAddress(true) + .checkoutCollectEmail(true) + .checkoutCollectPhone(true) + .enableTaxCollection(true) + .orderedAddOns( + Arrays.asList( + OrderedPlansInGroup + .builder() + .planId("plan_id") + .build() + ) + ) + .orderedBundleList( + Arrays.asList( + PlanGroupBundleOrder + .builder() + .bundleId("bundleId") + .build() + ) + ) + .orderedPlans( + Arrays.asList( + OrderedPlansInGroup + .builder() + .planId("plan_id") + .build() + ) + ) + .preventDowngradesWhenOverLimit(true) + .showCredits(true) + .showPeriodToggle(true) + .showZeroPriceAsFree(true) + .syncCustomerBillingDetailsForTax(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planGroupId:** `String` — plan_group_id + +
+
+ +
+
+ +**addOnCompatibilities:** `Optional>` + +
+
+ +
+
+ +**addOnIds:** `List` — Use OrderedAddOns instead + +
+
+ +
+
+ +**checkoutCollectAddress:** `Boolean` + +
+
+ +
+
+ +**checkoutCollectEmail:** `Boolean` + +
+
+ +
+
+ +**checkoutCollectPhone:** `Boolean` + +
+
+ +
+
+ +**customPlanConfig:** `Optional` + +
+
+ +
+
+ +**customPlanId:** `Optional` + +
+
+ +
+
+ +**enableTaxCollection:** `Boolean` + +
+
+ +
+
+ +**fallbackPlanId:** `Optional` + +
+
+ +
+
+ +**initialPlanId:** `Optional` + +
+
+ +
+
+ +**initialPlanPriceId:** `Optional` + +
+
+ +
+
+ +**orderedAddOns:** `List` + +
+
+ +
+
+ +**orderedBundleList:** `List` + +
+
+ +
+
+ +**orderedPlans:** `List` + +
+
+ +
+
+ +**preventDowngradesWhenOverLimit:** `Boolean` + +
+
+ +
+
+ +**showCredits:** `Boolean` + +
+
+ +
+
+ +**showPeriodToggle:** `Boolean` + +
+
+ +
+
+ +**showZeroPriceAsFree:** `Boolean` + +
+
+ +
+
+ +**syncCustomerBillingDetailsForTax:** `Boolean` + +
+
+ +
+
+ +**trialDays:** `Optional` + +
+
+ +
+
+ +**trialExpiryPlanId:** `Optional` + +
+
+ +
+
+ +**trialExpiryPlanPriceId:** `Optional` + +
+
+ +
+
+ +**trialPaymentMethodRequired:** `Optional` + +
+
+
+
+ + +
+
+
+ +## accesstokens +
client.accesstokens.issueTemporaryAccessToken(request) -> IssueTemporaryAccessTokenResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.accesstokens().issueTemporaryAccessToken( + IssueTemporaryAccessTokenRequestBody + .builder() + .lookup( + new HashMap() {{ + put("key", "value"); + }} + ) + .resourceType("company") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**lookup:** `Map` + +
+
+ +
+
+ +**resourceType:** `String` + +
+
+
+
+ + +
+
+
+ +## webhooks +
client.webhooks.listWebhookEvents() -> ListWebhookEventsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().listWebhookEvents( + ListWebhookEventsRequest + .builder() + .q("q") + .webhookId("webhook_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**webhookId:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.webhooks.getWebhookEvent(webhookEventId) -> GetWebhookEventResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().getWebhookEvent("webhook_event_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookEventId:** `String` — webhook_event_id + +
+
+
+
+ + +
+
+
+ +
client.webhooks.countWebhookEvents() -> CountWebhookEventsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().countWebhookEvents( + CountWebhookEventsRequest + .builder() + .q("q") + .webhookId("webhook_id") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `Optional` + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**webhookId:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.webhooks.listWebhooks() -> ListWebhooksResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().listWebhooks( + ListWebhooksRequest + .builder() + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
+ +
client.webhooks.createWebhook(request) -> CreateWebhookResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().createWebhook( + CreateWebhookRequestBody + .builder() + .name("name") + .requestTypes( + Arrays.asList(CreateWebhookRequestBodyRequestTypesItem.COMPANY_UPDATED) + ) + .url("url") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**creditTriggerConfigs:** `Optional>` + +
+
+ +
+
+ +**entitlementTriggerConfigs:** `Optional>` + +
+
+ +
+
+ +**name:** `String` + +
+
+ +
+
+ +**requestTypes:** `List` + +
+
+ +
+
+ +**url:** `String` + +
+
+
+
+ + +
+
+
+ +
client.webhooks.getWebhook(webhookId) -> GetWebhookResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().getWebhook("webhook_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookId:** `String` — webhook_id + +
+
+
+
+ + +
+
+
+ +
client.webhooks.updateWebhook(webhookId, request) -> UpdateWebhookResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().updateWebhook( + "webhook_id", + UpdateWebhookRequestBody + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookId:** `String` — webhook_id + +
+
+ +
+
+ +**creditTriggerConfigs:** `Optional>` + +
+
+ +
+
+ +**entitlementTriggerConfigs:** `Optional>` + +
+
+ +
+
+ +**name:** `Optional` + +
+
+ +
+
+ +**requestTypes:** `Optional>` + +
+
+ +
+
+ +**status:** `Optional` + +
+
+ +
+
+ +**url:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.webhooks.deleteWebhook(webhookId) -> DeleteWebhookResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().deleteWebhook("webhook_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookId:** `String` — webhook_id + +
+
+
+
+ + +
+
+
+ +
client.webhooks.countWebhooks() -> CountWebhooksResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().countWebhooks( + CountWebhooksRequest + .builder() + .q("q") + .limit(1) + .offset(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `Optional` + +
+
+ +
+
+ +**limit:** `Optional` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Optional` — Page offset (default 0) + +
+
+
+
+ + +
+
+
diff --git a/sample-app/src/main/java/sample/App.java b/sample-app/src/main/java/sample/App.java index 52f020c..1330241 100644 --- a/sample-app/src/main/java/sample/App.java +++ b/sample-app/src/main/java/sample/App.java @@ -8,6 +8,6 @@ public final class App { public static void main(String[] args) { - // import com.schematic.api.BaseSchematic + // import com.schematic.api.AsyncBaseSchematic } } diff --git a/src/main/java/com/schematic/api/AsyncBaseSchematic.java b/src/main/java/com/schematic/api/AsyncBaseSchematic.java new file mode 100644 index 0000000..ee22084 --- /dev/null +++ b/src/main/java/com/schematic/api/AsyncBaseSchematic.java @@ -0,0 +1,174 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.Suppliers; +import com.schematic.api.resources.accesstokens.AsyncAccesstokensClient; +import com.schematic.api.resources.accounts.AsyncAccountsClient; +import com.schematic.api.resources.billing.AsyncBillingClient; +import com.schematic.api.resources.checkout.AsyncCheckoutClient; +import com.schematic.api.resources.companies.AsyncCompaniesClient; +import com.schematic.api.resources.components.AsyncComponentsClient; +import com.schematic.api.resources.credits.AsyncCreditsClient; +import com.schematic.api.resources.crm.AsyncCrmClient; +import com.schematic.api.resources.dataexports.AsyncDataexportsClient; +import com.schematic.api.resources.entitlements.AsyncEntitlementsClient; +import com.schematic.api.resources.events.AsyncEventsClient; +import com.schematic.api.resources.features.AsyncFeaturesClient; +import com.schematic.api.resources.plangroups.AsyncPlangroupsClient; +import com.schematic.api.resources.plans.AsyncPlansClient; +import com.schematic.api.resources.webhooks.AsyncWebhooksClient; +import java.util.concurrent.CompletableFuture; +import java.util.function.Supplier; + +public class AsyncBaseSchematic { + protected final ClientOptions clientOptions; + + private final AsyncRawBaseSchematic rawClient; + + protected final Supplier accountsClient; + + protected final Supplier billingClient; + + protected final Supplier creditsClient; + + protected final Supplier checkoutClient; + + protected final Supplier companiesClient; + + protected final Supplier entitlementsClient; + + protected final Supplier plansClient; + + protected final Supplier componentsClient; + + protected final Supplier crmClient; + + protected final Supplier dataexportsClient; + + protected final Supplier eventsClient; + + protected final Supplier featuresClient; + + protected final Supplier plangroupsClient; + + protected final Supplier accesstokensClient; + + protected final Supplier webhooksClient; + + public AsyncBaseSchematic(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawBaseSchematic(clientOptions); + this.accountsClient = Suppliers.memoize(() -> new AsyncAccountsClient(clientOptions)); + this.billingClient = Suppliers.memoize(() -> new AsyncBillingClient(clientOptions)); + this.creditsClient = Suppliers.memoize(() -> new AsyncCreditsClient(clientOptions)); + this.checkoutClient = Suppliers.memoize(() -> new AsyncCheckoutClient(clientOptions)); + this.companiesClient = Suppliers.memoize(() -> new AsyncCompaniesClient(clientOptions)); + this.entitlementsClient = Suppliers.memoize(() -> new AsyncEntitlementsClient(clientOptions)); + this.plansClient = Suppliers.memoize(() -> new AsyncPlansClient(clientOptions)); + this.componentsClient = Suppliers.memoize(() -> new AsyncComponentsClient(clientOptions)); + this.crmClient = Suppliers.memoize(() -> new AsyncCrmClient(clientOptions)); + this.dataexportsClient = Suppliers.memoize(() -> new AsyncDataexportsClient(clientOptions)); + this.eventsClient = Suppliers.memoize(() -> new AsyncEventsClient(clientOptions)); + this.featuresClient = Suppliers.memoize(() -> new AsyncFeaturesClient(clientOptions)); + this.plangroupsClient = Suppliers.memoize(() -> new AsyncPlangroupsClient(clientOptions)); + this.accesstokensClient = Suppliers.memoize(() -> new AsyncAccesstokensClient(clientOptions)); + this.webhooksClient = Suppliers.memoize(() -> new AsyncWebhooksClient(clientOptions)); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawBaseSchematic withRawResponse() { + return this.rawClient; + } + + public CompletableFuture putPlanAudiencesPlanAudienceId(String planAudienceId) { + return this.rawClient.putPlanAudiencesPlanAudienceId(planAudienceId).thenApply(response -> response.body()); + } + + public CompletableFuture putPlanAudiencesPlanAudienceId( + String planAudienceId, RequestOptions requestOptions) { + return this.rawClient + .putPlanAudiencesPlanAudienceId(planAudienceId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deletePlanAudiencesPlanAudienceId(String planAudienceId) { + return this.rawClient.deletePlanAudiencesPlanAudienceId(planAudienceId).thenApply(response -> response.body()); + } + + public CompletableFuture deletePlanAudiencesPlanAudienceId( + String planAudienceId, RequestOptions requestOptions) { + return this.rawClient + .deletePlanAudiencesPlanAudienceId(planAudienceId, requestOptions) + .thenApply(response -> response.body()); + } + + public AsyncAccountsClient accounts() { + return this.accountsClient.get(); + } + + public AsyncBillingClient billing() { + return this.billingClient.get(); + } + + public AsyncCreditsClient credits() { + return this.creditsClient.get(); + } + + public AsyncCheckoutClient checkout() { + return this.checkoutClient.get(); + } + + public AsyncCompaniesClient companies() { + return this.companiesClient.get(); + } + + public AsyncEntitlementsClient entitlements() { + return this.entitlementsClient.get(); + } + + public AsyncPlansClient plans() { + return this.plansClient.get(); + } + + public AsyncComponentsClient components() { + return this.componentsClient.get(); + } + + public AsyncCrmClient crm() { + return this.crmClient.get(); + } + + public AsyncDataexportsClient dataexports() { + return this.dataexportsClient.get(); + } + + public AsyncEventsClient events() { + return this.eventsClient.get(); + } + + public AsyncFeaturesClient features() { + return this.featuresClient.get(); + } + + public AsyncPlangroupsClient plangroups() { + return this.plangroupsClient.get(); + } + + public AsyncAccesstokensClient accesstokens() { + return this.accesstokensClient.get(); + } + + public AsyncWebhooksClient webhooks() { + return this.webhooksClient.get(); + } + + public static AsyncBaseSchematicBuilder builder() { + return new AsyncBaseSchematicBuilder(); + } +} diff --git a/src/main/java/com/schematic/api/AsyncBaseSchematicBuilder.java b/src/main/java/com/schematic/api/AsyncBaseSchematicBuilder.java new file mode 100644 index 0000000..7b81183 --- /dev/null +++ b/src/main/java/com/schematic/api/AsyncBaseSchematicBuilder.java @@ -0,0 +1,203 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.Environment; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import okhttp3.OkHttpClient; + +public class AsyncBaseSchematicBuilder { + private Optional timeout = Optional.empty(); + + private Optional maxRetries = Optional.empty(); + + private final Map customHeaders = new HashMap<>(); + + private String apiKey = null; + + private Environment environment = Environment.DEFAULT; + + private OkHttpClient httpClient; + + /** + * Sets apiKey + */ + public AsyncBaseSchematicBuilder apiKey(String apiKey) { + this.apiKey = apiKey; + return this; + } + + public AsyncBaseSchematicBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + public AsyncBaseSchematicBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + /** + * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. + */ + public AsyncBaseSchematicBuilder timeout(int timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public AsyncBaseSchematicBuilder maxRetries(int maxRetries) { + this.maxRetries = Optional.of(maxRetries); + return this; + } + + /** + * Sets the underlying OkHttp client + */ + public AsyncBaseSchematicBuilder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /** + * Add a custom header to be sent with all requests. + * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. + * + * @param name The header name + * @param value The header value + * @return This builder for method chaining + */ + public AsyncBaseSchematicBuilder addHeader(String name, String value) { + this.customHeaders.put(name, value); + return this; + } + + protected ClientOptions buildClientOptions() { + ClientOptions.Builder builder = ClientOptions.builder(); + setEnvironment(builder); + setAuthentication(builder); + setHttpClient(builder); + setTimeouts(builder); + setRetries(builder); + for (Map.Entry header : this.customHeaders.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + setAdditional(builder); + return builder.build(); + } + + /** + * Sets the environment configuration for the client. + * Override this method to modify URLs or add environment-specific logic. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setEnvironment(ClientOptions.Builder builder) { + builder.environment(this.environment); + } + + /** + * Override this method to customize authentication. + * This method is called during client options construction to set up authentication headers. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAuthentication(ClientOptions.Builder builder) {
+     *     super.setAuthentication(builder); // Keep existing auth
+     *     builder.addHeader("X-API-Key", this.apiKey);
+     * }
+     * }
+ */ + protected void setAuthentication(ClientOptions.Builder builder) { + builder.addHeader("X-Schematic-Api-Key", this.apiKey); + } + + /** + * Sets the request timeout configuration. + * Override this method to customize timeout behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setTimeouts(ClientOptions.Builder builder) { + if (this.timeout.isPresent()) { + builder.timeout(this.timeout.get()); + } + } + + /** + * Sets the retry configuration for failed requests. + * Override this method to implement custom retry strategies. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setRetries(ClientOptions.Builder builder) { + if (this.maxRetries.isPresent()) { + builder.maxRetries(this.maxRetries.get()); + } + } + + /** + * Sets the OkHttp client configuration. + * Override this method to customize HTTP client behavior (interceptors, connection pools, etc). + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setHttpClient(ClientOptions.Builder builder) { + if (this.httpClient != null) { + builder.httpClient(this.httpClient); + } + } + + /** + * Override this method to add any additional configuration to the client. + * This method is called at the end of the configuration chain, allowing you to add + * custom headers, modify settings, or perform any other client customization. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAdditional(ClientOptions.Builder builder) {
+     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
+     *     builder.addHeader("X-Client-Version", "1.0.0");
+     * }
+     * }
+ */ + protected void setAdditional(ClientOptions.Builder builder) {} + + /** + * Override this method to add custom validation logic before the client is built. + * This method is called at the beginning of the build() method to ensure the configuration is valid. + * Throw an exception to prevent client creation if validation fails. + * + * Example: + *
{@code
+     * @Override
+     * protected void validateConfiguration() {
+     *     super.validateConfiguration(); // Run parent validations
+     *     if (tenantId == null || tenantId.isEmpty()) {
+     *         throw new IllegalStateException("tenantId is required");
+     *     }
+     * }
+     * }
+ */ + protected void validateConfiguration() {} + + public AsyncBaseSchematic build() { + if (apiKey == null) { + throw new RuntimeException("Please provide apiKey"); + } + validateConfiguration(); + return new AsyncBaseSchematic(buildClientOptions()); + } +} diff --git a/src/main/java/com/schematic/api/AsyncRawBaseSchematic.java b/src/main/java/com/schematic/api/AsyncRawBaseSchematic.java new file mode 100644 index 0000000..1fb115f --- /dev/null +++ b/src/main/java/com/schematic/api/AsyncRawBaseSchematic.java @@ -0,0 +1,129 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api; + +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawBaseSchematic { + protected final ClientOptions clientOptions; + + public AsyncRawBaseSchematic(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> putPlanAudiencesPlanAudienceId(String planAudienceId) { + return putPlanAudiencesPlanAudienceId(planAudienceId, null); + } + + public CompletableFuture> putPlanAudiencesPlanAudienceId( + String planAudienceId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-audiences") + .addPathSegment(planAudienceId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deletePlanAudiencesPlanAudienceId(String planAudienceId) { + return deletePlanAudiencesPlanAudienceId(planAudienceId, null); + } + + public CompletableFuture> deletePlanAudiencesPlanAudienceId( + String planAudienceId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-audiences") + .addPathSegment(planAudienceId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/BaseSchematicBuilder.java b/src/main/java/com/schematic/api/BaseSchematicBuilder.java index f86e4c6..9410ba7 100644 --- a/src/main/java/com/schematic/api/BaseSchematicBuilder.java +++ b/src/main/java/com/schematic/api/BaseSchematicBuilder.java @@ -5,15 +5,24 @@ import com.schematic.api.core.ClientOptions; import com.schematic.api.core.Environment; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; import okhttp3.OkHttpClient; -public final class BaseSchematicBuilder { - private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); +public class BaseSchematicBuilder { + private Optional timeout = Optional.empty(); + + private Optional maxRetries = Optional.empty(); + + private final Map customHeaders = new HashMap<>(); private String apiKey = null; private Environment environment = Environment.DEFAULT; + private OkHttpClient httpClient; + /** * Sets apiKey */ @@ -33,10 +42,18 @@ public BaseSchematicBuilder url(String url) { } /** - * Sets the timeout (in seconds) for the client + * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. */ public BaseSchematicBuilder timeout(int timeout) { - this.clientOptionsBuilder.timeout(timeout); + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Sets the maximum number of retries for the client. Defaults to 2 retries. + */ + public BaseSchematicBuilder maxRetries(int maxRetries) { + this.maxRetries = Optional.of(maxRetries); return this; } @@ -44,16 +61,143 @@ public BaseSchematicBuilder timeout(int timeout) { * Sets the underlying OkHttp client */ public BaseSchematicBuilder httpClient(OkHttpClient httpClient) { - this.clientOptionsBuilder.httpClient(httpClient); + this.httpClient = httpClient; return this; } + /** + * Add a custom header to be sent with all requests. + * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. + * + * @param name The header name + * @param value The header value + * @return This builder for method chaining + */ + public BaseSchematicBuilder addHeader(String name, String value) { + this.customHeaders.put(name, value); + return this; + } + + protected ClientOptions buildClientOptions() { + ClientOptions.Builder builder = ClientOptions.builder(); + setEnvironment(builder); + setAuthentication(builder); + setHttpClient(builder); + setTimeouts(builder); + setRetries(builder); + for (Map.Entry header : this.customHeaders.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + setAdditional(builder); + return builder.build(); + } + + /** + * Sets the environment configuration for the client. + * Override this method to modify URLs or add environment-specific logic. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setEnvironment(ClientOptions.Builder builder) { + builder.environment(this.environment); + } + + /** + * Override this method to customize authentication. + * This method is called during client options construction to set up authentication headers. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAuthentication(ClientOptions.Builder builder) {
+     *     super.setAuthentication(builder); // Keep existing auth
+     *     builder.addHeader("X-API-Key", this.apiKey);
+     * }
+     * }
+ */ + protected void setAuthentication(ClientOptions.Builder builder) { + builder.addHeader("X-Schematic-Api-Key", this.apiKey); + } + + /** + * Sets the request timeout configuration. + * Override this method to customize timeout behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setTimeouts(ClientOptions.Builder builder) { + if (this.timeout.isPresent()) { + builder.timeout(this.timeout.get()); + } + } + + /** + * Sets the retry configuration for failed requests. + * Override this method to implement custom retry strategies. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setRetries(ClientOptions.Builder builder) { + if (this.maxRetries.isPresent()) { + builder.maxRetries(this.maxRetries.get()); + } + } + + /** + * Sets the OkHttp client configuration. + * Override this method to customize HTTP client behavior (interceptors, connection pools, etc). + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setHttpClient(ClientOptions.Builder builder) { + if (this.httpClient != null) { + builder.httpClient(this.httpClient); + } + } + + /** + * Override this method to add any additional configuration to the client. + * This method is called at the end of the configuration chain, allowing you to add + * custom headers, modify settings, or perform any other client customization. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAdditional(ClientOptions.Builder builder) {
+     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
+     *     builder.addHeader("X-Client-Version", "1.0.0");
+     * }
+     * }
+ */ + protected void setAdditional(ClientOptions.Builder builder) {} + + /** + * Override this method to add custom validation logic before the client is built. + * This method is called at the beginning of the build() method to ensure the configuration is valid. + * Throw an exception to prevent client creation if validation fails. + * + * Example: + *
{@code
+     * @Override
+     * protected void validateConfiguration() {
+     *     super.validateConfiguration(); // Run parent validations
+     *     if (tenantId == null || tenantId.isEmpty()) {
+     *         throw new IllegalStateException("tenantId is required");
+     *     }
+     * }
+     * }
+ */ + protected void validateConfiguration() {} + public BaseSchematic build() { if (apiKey == null) { throw new RuntimeException("Please provide apiKey"); } - this.clientOptionsBuilder.addHeader("X-Schematic-Api-Key", this.apiKey); - clientOptionsBuilder.environment(this.environment); - return new BaseSchematic(clientOptionsBuilder.build()); + validateConfiguration(); + return new BaseSchematic(buildClientOptions()); } } diff --git a/src/main/java/com/schematic/api/RawBaseSchematic.java b/src/main/java/com/schematic/api/RawBaseSchematic.java new file mode 100644 index 0000000..803f99e --- /dev/null +++ b/src/main/java/com/schematic/api/RawBaseSchematic.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api; + +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawBaseSchematic { + protected final ClientOptions clientOptions; + + public RawBaseSchematic(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse putPlanAudiencesPlanAudienceId(String planAudienceId) { + return putPlanAudiencesPlanAudienceId(planAudienceId, null); + } + + public BaseSchematicHttpResponse putPlanAudiencesPlanAudienceId( + String planAudienceId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-audiences") + .addPathSegment(planAudienceId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deletePlanAudiencesPlanAudienceId(String planAudienceId) { + return deletePlanAudiencesPlanAudienceId(planAudienceId, null); + } + + public BaseSchematicHttpResponse deletePlanAudiencesPlanAudienceId( + String planAudienceId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-audiences") + .addPathSegment(planAudienceId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/core/BaseSchematicApiException.java b/src/main/java/com/schematic/api/core/BaseSchematicApiException.java index cd48ad0..067cd1f 100644 --- a/src/main/java/com/schematic/api/core/BaseSchematicApiException.java +++ b/src/main/java/com/schematic/api/core/BaseSchematicApiException.java @@ -3,6 +3,12 @@ */ package com.schematic.api.core; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Response; + /** * This exception type will be thrown for any non-2XX API responses. */ @@ -17,10 +23,25 @@ public class BaseSchematicApiException extends BaseSchematicException { */ private final Object body; + private final Map> headers; + public BaseSchematicApiException(String message, int statusCode, Object body) { super(message); this.statusCode = statusCode; this.body = body; + this.headers = new HashMap<>(); + } + + public BaseSchematicApiException(String message, int statusCode, Object body, Response rawResponse) { + super(message); + this.statusCode = statusCode; + this.body = body; + this.headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + this.headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); } /** @@ -37,6 +58,13 @@ public Object body() { return this.body; } + /** + * @return the headers + */ + public Map> headers() { + return this.headers; + } + @java.lang.Override public String toString() { return "BaseSchematicApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " diff --git a/src/main/java/com/schematic/api/core/BaseSchematicHttpResponse.java b/src/main/java/com/schematic/api/core/BaseSchematicHttpResponse.java new file mode 100644 index 0000000..4a8cec1 --- /dev/null +++ b/src/main/java/com/schematic/api/core/BaseSchematicHttpResponse.java @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Response; + +public final class BaseSchematicHttpResponse { + + private final T body; + + private final Map> headers; + + public BaseSchematicHttpResponse(T body, Response rawResponse) { + this.body = body; + + Map> headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); + this.headers = headers; + } + + public T body() { + return this.body; + } + + public Map> headers() { + return headers; + } +} diff --git a/src/main/java/com/schematic/api/core/ClientOptions.java b/src/main/java/com/schematic/api/core/ClientOptions.java index 41df9ca..220517d 100644 --- a/src/main/java/com/schematic/api/core/ClientOptions.java +++ b/src/main/java/com/schematic/api/core/ClientOptions.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import okhttp3.OkHttpClient; @@ -31,10 +32,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.schematichq:schematic-java/1.1.3"); + put("User-Agent", "com.schematichq:schematic-java/3.10.2"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.schematic.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.1.3"); + put("X-Fern-SDK-Version", "3.10.2"); } }); this.headerSuppliers = headerSuppliers; @@ -57,6 +58,13 @@ public Map headers(RequestOptions requestOptions) { return values; } + public int timeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.timeout; + } + return requestOptions.getTimeout().orElse(this.timeout); + } + public OkHttpClient httpClient() { return this.httpClient; } @@ -78,19 +86,18 @@ public static Builder builder() { return new Builder(); } - public static final class Builder { + public static class Builder { private Environment environment; private final Map headers = new HashMap<>(); private final Map> headerSuppliers = new HashMap<>(); - private int timeout = 60; + private int maxRetries = 2; - private OkHttpClient httpClient = new OkHttpClient.Builder() - .addInterceptor(new RetryInterceptor(3)) - .callTimeout(this.timeout, TimeUnit.SECONDS) - .build(); + private Optional timeout = Optional.empty(); + + private OkHttpClient httpClient = null; public Builder environment(Environment environment) { this.environment = environment; @@ -111,17 +118,65 @@ public Builder addHeader(String key, Supplier value) { * Override the timeout in seconds. Defaults to 60 seconds. */ public Builder timeout(int timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(Optional timeout) { this.timeout = timeout; return this; } + /** + * Override the maximum number of retries. Defaults to 2 retries. + */ + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + public Builder httpClient(OkHttpClient httpClient) { this.httpClient = httpClient; return this; } public ClientOptions build() { - return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout); + OkHttpClient.Builder httpClientBuilder = + this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); + + if (this.httpClient != null) { + timeout.ifPresent(timeout -> httpClientBuilder + .callTimeout(timeout, TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS)); + } else { + httpClientBuilder + .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .addInterceptor(new RetryInterceptor(this.maxRetries)); + } + + this.httpClient = httpClientBuilder.build(); + this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); + + return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get()); + } + + /** + * Create a new Builder initialized with values from an existing ClientOptions + */ + public static Builder from(ClientOptions clientOptions) { + Builder builder = new Builder(); + builder.environment = clientOptions.environment(); + builder.timeout = Optional.of(clientOptions.timeout(null)); + builder.httpClient = clientOptions.httpClient(); + return builder; } } } diff --git a/src/main/java/com/schematic/api/core/InputStreamRequestBody.java b/src/main/java/com/schematic/api/core/InputStreamRequestBody.java index eb4c5b8..f879d50 100644 --- a/src/main/java/com/schematic/api/core/InputStreamRequestBody.java +++ b/src/main/java/com/schematic/api/core/InputStreamRequestBody.java @@ -8,7 +8,6 @@ import java.util.Objects; import okhttp3.MediaType; import okhttp3.RequestBody; -import okhttp3.internal.Util; import okio.BufferedSink; import okio.Okio; import okio.Source; @@ -68,12 +67,8 @@ public long contentLength() throws IOException { */ @Override public void writeTo(BufferedSink sink) throws IOException { - Source source = null; - try { - source = Okio.source(inputStream); + try (Source source = Okio.source(inputStream)) { sink.writeAll(source); - } finally { - Util.closeQuietly(Objects.requireNonNull(source)); } } } diff --git a/src/main/java/com/schematic/api/core/Nullable.java b/src/main/java/com/schematic/api/core/Nullable.java new file mode 100644 index 0000000..d9161d1 --- /dev/null +++ b/src/main/java/com/schematic/api/core/Nullable.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.core; + +import java.util.Optional; +import java.util.function.Function; + +public final class Nullable { + + private final Either, Null> value; + + private Nullable() { + this.value = Either.left(Optional.empty()); + } + + private Nullable(T value) { + if (value == null) { + this.value = Either.right(Null.INSTANCE); + } else { + this.value = Either.left(Optional.of(value)); + } + } + + public static Nullable ofNull() { + return new Nullable<>(null); + } + + public static Nullable of(T value) { + return new Nullable<>(value); + } + + public static Nullable empty() { + return new Nullable<>(); + } + + public static Nullable ofOptional(Optional value) { + if (value.isPresent()) { + return of(value.get()); + } else { + return empty(); + } + } + + public boolean isNull() { + return this.value.isRight(); + } + + public boolean isEmpty() { + return this.value.isLeft() && !this.value.getLeft().isPresent(); + } + + public T get() { + if (this.isNull()) { + return null; + } + + return this.value.getLeft().get(); + } + + public Nullable map(Function mapper) { + if (this.isNull()) { + return Nullable.ofNull(); + } + + return Nullable.ofOptional(this.value.getLeft().map(mapper)); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Nullable)) { + return false; + } + + if (((Nullable) other).isNull() && this.isNull()) { + return true; + } + + return this.value.getLeft().equals(((Nullable) other).value.getLeft()); + } + + private static final class Either { + private L left = null; + private R right = null; + + private Either(L left, R right) { + if (left != null && right != null) { + throw new IllegalArgumentException("Left and right argument cannot both be non-null."); + } + + if (left == null && right == null) { + throw new IllegalArgumentException("Left and right argument cannot both be null."); + } + + if (left != null) { + this.left = left; + } + + if (right != null) { + this.right = right; + } + } + + public static Either left(L left) { + return new Either<>(left, null); + } + + public static Either right(R right) { + return new Either<>(null, right); + } + + public boolean isLeft() { + return this.left != null; + } + + public boolean isRight() { + return this.right != null; + } + + public L getLeft() { + if (!this.isLeft()) { + throw new IllegalArgumentException("Cannot get left from right Either."); + } + return this.left; + } + + public R getRight() { + if (!this.isRight()) { + throw new IllegalArgumentException("Cannot get right from left Either."); + } + return this.right; + } + } + + private static final class Null { + private static final Null INSTANCE = new Null(); + + private Null() {} + } +} diff --git a/src/main/java/com/schematic/api/core/NullableNonemptyFilter.java b/src/main/java/com/schematic/api/core/NullableNonemptyFilter.java new file mode 100644 index 0000000..f230447 --- /dev/null +++ b/src/main/java/com/schematic/api/core/NullableNonemptyFilter.java @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.core; + +import java.util.Optional; + +public final class NullableNonemptyFilter { + @Override + public boolean equals(Object o) { + boolean isOptionalEmpty = isOptionalEmpty(o); + + return isOptionalEmpty; + } + + private boolean isOptionalEmpty(Object o) { + return o instanceof Optional && !((Optional) o).isPresent(); + } +} diff --git a/src/main/java/com/schematic/api/core/QueryStringMapper.java b/src/main/java/com/schematic/api/core/QueryStringMapper.java new file mode 100644 index 0000000..035dfb2 --- /dev/null +++ b/src/main/java/com/schematic/api/core/QueryStringMapper.java @@ -0,0 +1,142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.core; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import okhttp3.HttpUrl; +import okhttp3.MultipartBody; + +public class QueryStringMapper { + + private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER; + + public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + httpUrl.addQueryParameter(key, valueNode.textValue()); + } else { + httpUrl.addQueryParameter(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue()); + } else { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().toString()); + } + } + } + + public static void addFormDataPart( + MultipartBody.Builder multipartBody, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + multipartBody.addFormDataPart(key, valueNode.textValue()); + } else { + multipartBody.addFormDataPart(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().textValue()); + } else { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().toString()); + } + } + } + + public static List> flattenObject(ObjectNode object, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator> fields = object.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + + String key = "[" + field.getKey() + "]"; + + if (field.getValue().isObject()) { + List> flatField = + flattenObject((ObjectNode) field.getValue(), arraysAsRepeats); + addAll(flat, flatField, key); + } else if (field.getValue().isArray()) { + List> flatField = + flattenArray((ArrayNode) field.getValue(), key, arraysAsRepeats); + addAll(flat, flatField, ""); + } else { + flat.add(new AbstractMap.SimpleEntry<>(key, field.getValue())); + } + } + + return flat; + } + + private static List> flattenArray( + ArrayNode array, String key, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator elements = array.elements(); + + int index = 0; + while (elements.hasNext()) { + JsonNode element = elements.next(); + + String indexKey = key + "[" + index + "]"; + + if (arraysAsRepeats) { + indexKey = key; + } + + if (element.isObject()) { + List> flatField = flattenObject((ObjectNode) element, arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else if (element.isArray()) { + List> flatField = flattenArray((ArrayNode) element, "", arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else { + flat.add(new AbstractMap.SimpleEntry<>(indexKey, element)); + } + + index++; + } + + return flat; + } + + private static void addAll( + List> target, List> source, String prefix) { + for (Map.Entry entry : source) { + Map.Entry entryToAdd = + new AbstractMap.SimpleEntry<>(prefix + entry.getKey(), entry.getValue()); + target.add(entryToAdd); + } + } +} diff --git a/src/main/java/com/schematic/api/core/RequestOptions.java b/src/main/java/com/schematic/api/core/RequestOptions.java index 2b4fb2e..4618051 100644 --- a/src/main/java/com/schematic/api/core/RequestOptions.java +++ b/src/main/java/com/schematic/api/core/RequestOptions.java @@ -57,7 +57,7 @@ public static Builder builder() { return new Builder(); } - public static final class Builder { + public static class Builder { private String apiKey = null; private Optional timeout = Optional.empty(); diff --git a/src/main/java/com/schematic/api/core/RetryInterceptor.java b/src/main/java/com/schematic/api/core/RetryInterceptor.java index f91a46b..9579be6 100644 --- a/src/main/java/com/schematic/api/core/RetryInterceptor.java +++ b/src/main/java/com/schematic/api/core/RetryInterceptor.java @@ -5,6 +5,9 @@ import java.io.IOException; import java.time.Duration; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Optional; import java.util.Random; import okhttp3.Interceptor; @@ -12,7 +15,10 @@ public class RetryInterceptor implements Interceptor { - private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private static final Duration INITIAL_RETRY_DELAY = Duration.ofMillis(1000); + private static final Duration MAX_RETRY_DELAY = Duration.ofMillis(60000); + private static final double JITTER_FACTOR = 0.2; + private final ExponentialBackoff backoff; private final Random random = new Random(); @@ -32,7 +38,7 @@ public Response intercept(Chain chain) throws IOException { } private Response retryChain(Response response, Chain chain) throws IOException { - Optional nextBackoff = this.backoff.nextBackoff(); + Optional nextBackoff = this.backoff.nextBackoff(response); while (nextBackoff.isPresent()) { try { Thread.sleep(nextBackoff.get().toMillis()); @@ -42,7 +48,7 @@ private Response retryChain(Response response, Chain chain) throws IOException { response.close(); response = chain.proceed(chain.request()); if (shouldRetry(response.code())) { - nextBackoff = this.backoff.nextBackoff(); + nextBackoff = this.backoff.nextBackoff(response); } else { return response; } @@ -51,8 +57,104 @@ private Response retryChain(Response response, Chain chain) throws IOException { return response; } + /** + * Calculates the retry delay from response headers, with fallback to exponential backoff. + * Priority: Retry-After > X-RateLimit-Reset > Exponential Backoff + */ + private Duration getRetryDelayFromHeaders(Response response, int retryAttempt) { + // Check for Retry-After header first (RFC 7231), with no jitter + String retryAfter = response.header("Retry-After"); + if (retryAfter != null) { + // Parse as number of seconds... + Optional secondsDelay = tryParseLong(retryAfter) + .map(seconds -> seconds * 1000) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(Duration::ofMillis); + if (secondsDelay.isPresent()) { + return secondsDelay.get(); + } + + // ...or as an HTTP date; both are valid + Optional dateDelay = tryParseHttpDate(retryAfter) + .map(resetTime -> resetTime.toInstant().toEpochMilli() - System.currentTimeMillis()) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(Duration::ofMillis); + if (dateDelay.isPresent()) { + return dateDelay.get(); + } + } + + // Then check for industry-standard X-RateLimit-Reset header, with positive jitter + String rateLimitReset = response.header("X-RateLimit-Reset"); + if (rateLimitReset != null) { + // Assume Unix timestamp in epoch seconds + Optional rateLimitDelay = tryParseLong(rateLimitReset) + .map(resetTimeSeconds -> (resetTimeSeconds * 1000) - System.currentTimeMillis()) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(this::addPositiveJitter) + .map(Duration::ofMillis); + if (rateLimitDelay.isPresent()) { + return rateLimitDelay.get(); + } + } + + // Fall back to exponential backoff, with symmetric jitter + long baseDelay = INITIAL_RETRY_DELAY.toMillis() * (1L << retryAttempt); // 2^retryAttempt + long cappedDelay = Math.min(baseDelay, MAX_RETRY_DELAY.toMillis()); + return Duration.ofMillis(addSymmetricJitter(cappedDelay)); + } + + /** + * Attempts to parse a string as a long, returning empty Optional on failure. + */ + private Optional tryParseLong(String value) { + if (value == null) { + return Optional.empty(); + } + try { + return Optional.of(Long.parseLong(value)); + } catch (NumberFormatException e) { + return Optional.empty(); + } + } + + /** + * Attempts to parse a string as an HTTP date (RFC 1123), returning empty Optional on failure. + */ + private Optional tryParseHttpDate(String value) { + if (value == null) { + return Optional.empty(); + } + try { + return Optional.of(ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME)); + } catch (DateTimeParseException e) { + return Optional.empty(); + } + } + + /** + * Adds positive jitter (100-120% of original value) to prevent thundering herd. + * Used for X-RateLimit-Reset header delays. + */ + private long addPositiveJitter(long delayMs) { + double jitterMultiplier = 1.0 + (random.nextDouble() * JITTER_FACTOR); + return (long) (delayMs * jitterMultiplier); + } + + /** + * Adds symmetric jitter (90-110% of original value) to prevent thundering herd. + * Used for exponential backoff delays. + */ + private long addSymmetricJitter(long delayMs) { + double jitterMultiplier = 1.0 + ((random.nextDouble() - 0.5) * JITTER_FACTOR); + return (long) (delayMs * jitterMultiplier); + } + private static boolean shouldRetry(int statusCode) { - return statusCode == 408 || statusCode == 409 || statusCode == 429 || statusCode >= 500; + return statusCode == 408 || statusCode == 429 || statusCode >= 500; } private final class ExponentialBackoff { @@ -65,14 +167,14 @@ private final class ExponentialBackoff { this.maxNumRetries = maxNumRetries; } - public Optional nextBackoff() { - retryNumber += 1; - if (retryNumber > maxNumRetries) { + public Optional nextBackoff(Response response) { + if (retryNumber >= maxNumRetries) { return Optional.empty(); } - int upperBound = (int) Math.pow(2, retryNumber); - return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + Duration delay = getRetryDelayFromHeaders(response, retryNumber); + retryNumber += 1; + return Optional.of(delay); } } } diff --git a/src/main/java/com/schematic/api/core/Stream.java b/src/main/java/com/schematic/api/core/Stream.java index 89ae9c7..b4e9ab3 100644 --- a/src/main/java/com/schematic/api/core/Stream.java +++ b/src/main/java/com/schematic/api/core/Stream.java @@ -3,6 +3,8 @@ */ package com.schematic.api.core; +import java.io.Closeable; +import java.io.IOException; import java.io.Reader; import java.util.Iterator; import java.util.NoSuchElementException; @@ -14,18 +16,28 @@ *

* {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a * {@code Scanner} to block during iteration if the next object is not available. + * Iterable stream for parsing JSON and Server-Sent Events (SSE) data. + * Supports both newline-delimited JSON and SSE with optional stream termination. * * @param The type of objects in the stream. */ -public final class Stream implements Iterable { - /** - * The {@link Class} of the objects in the stream. - */ +public final class Stream implements Iterable, Closeable { + + private static final String NEWLINE = "\n"; + private static final String DATA_PREFIX = "data:"; + + public enum StreamType { + JSON, + SSE + } + private final Class valueType; - /** - * The {@link Scanner} used for reading from the input stream and blocking when needed during iteration. - */ private final Scanner scanner; + private final StreamType streamType; + private final String messageTerminator; + private final String streamTerminator; + private final Reader sseReader; + private boolean isClosed = false; /** * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. @@ -35,8 +47,61 @@ public final class Stream implements Iterable { * @param delimiter The delimiter used to separate elements in the stream. */ public Stream(Class valueType, Reader reader, String delimiter) { + this.valueType = valueType; this.scanner = new Scanner(reader).useDelimiter(delimiter); + this.streamType = StreamType.JSON; + this.messageTerminator = delimiter; + this.streamTerminator = null; + this.sseReader = null; + } + + private Stream(Class valueType, StreamType type, Reader reader, String terminator) { this.valueType = valueType; + this.streamType = type; + if (type == StreamType.JSON) { + this.scanner = new Scanner(reader).useDelimiter(terminator); + this.messageTerminator = terminator; + this.streamTerminator = null; + this.sseReader = null; + } else { + this.scanner = null; + this.messageTerminator = NEWLINE; + this.streamTerminator = terminator; + this.sseReader = reader; + } + } + + public static Stream fromJson(Class valueType, Reader reader, String delimiter) { + return new Stream<>(valueType, reader, delimiter); + } + + public static Stream fromJson(Class valueType, Reader reader) { + return new Stream<>(valueType, reader, NEWLINE); + } + + public static Stream fromSse(Class valueType, Reader sseReader) { + return new Stream<>(valueType, StreamType.SSE, sseReader, null); + } + + public static Stream fromSse(Class valueType, Reader sseReader, String streamTerminator) { + return new Stream<>(valueType, StreamType.SSE, sseReader, streamTerminator); + } + + @Override + public void close() throws IOException { + if (!isClosed) { + isClosed = true; + if (scanner != null) { + scanner.close(); + } + if (sseReader != null) { + sseReader.close(); + } + } + } + + private boolean isStreamClosed() { + return isClosed; } /** @@ -47,51 +112,191 @@ public Stream(Class valueType, Reader reader, String delimiter) { */ @Override public Iterator iterator() { - return new Iterator() { - /** - * Returns {@code true} if there are more elements in the stream. - *

- * Will block and wait for input if the stream has not ended and the next object is not yet available. - * - * @return {@code true} if there are more elements, {@code false} otherwise. - */ - @Override - public boolean hasNext() { - return scanner.hasNext(); + if (streamType == StreamType.SSE) { + return new SSEIterator(); + } else { + return new JsonIterator(); + } + } + + private final class JsonIterator implements Iterator { + + /** + * Returns {@code true} if there are more elements in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return {@code true} if there are more elements, {@code false} otherwise. + */ + @Override + public boolean hasNext() { + if (isStreamClosed()) { + return false; + } + return scanner.hasNext(); + } + + /** + * Returns the next element in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return The next element in the stream. + * @throws NoSuchElementException If there are no more elements in the stream. + */ + @Override + public T next() { + if (isStreamClosed()) { + throw new NoSuchElementException("Stream is closed"); + } + + if (!scanner.hasNext()) { + throw new NoSuchElementException(); + } else { + try { + T parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(scanner.next().trim(), valueType); + return parsedResponse; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + } + + private final class SSEIterator implements Iterator { + private Scanner sseScanner; + private T nextItem; + private boolean hasNextItem = false; + private boolean endOfStream = false; + private StringBuilder eventDataBuffer = new StringBuilder(); + private String currentEventType = null; + + private SSEIterator() { + if (sseReader != null && !isStreamClosed()) { + this.sseScanner = new Scanner(sseReader); + } else { + this.endOfStream = true; + } + } + + @Override + public boolean hasNext() { + if (isStreamClosed() || endOfStream) { + return false; + } + + if (hasNextItem) { + return true; + } + + return readNextMessage(); + } + + @Override + public T next() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements in stream"); + } + + T result = nextItem; + nextItem = null; + hasNextItem = false; + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + private boolean readNextMessage() { + if (sseScanner == null || isStreamClosed()) { + endOfStream = true; + return false; } - /** - * Returns the next element in the stream. - *

- * Will block and wait for input if the stream has not ended and the next object is not yet available. - * - * @return The next element in the stream. - * @throws NoSuchElementException If there are no more elements in the stream. - */ - @Override - public T next() { - if (!scanner.hasNext()) { - throw new NoSuchElementException(); - } else { + try { + while (sseScanner.hasNextLine()) { + String line = sseScanner.nextLine(); + + if (line.trim().isEmpty()) { + if (eventDataBuffer.length() > 0) { + try { + nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType); + hasNextItem = true; + eventDataBuffer.setLength(0); + currentEventType = null; + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse SSE event: " + parseEx.getMessage()); + eventDataBuffer.setLength(0); + currentEventType = null; + continue; + } + } + continue; + } + + if (line.startsWith(DATA_PREFIX)) { + String dataContent = line.substring(DATA_PREFIX.length()); + if (dataContent.startsWith(" ")) { + dataContent = dataContent.substring(1); + } + + if (eventDataBuffer.length() == 0 + && streamTerminator != null + && dataContent.trim().equals(streamTerminator)) { + endOfStream = true; + return false; + } + + if (eventDataBuffer.length() > 0) { + eventDataBuffer.append('\n'); + } + eventDataBuffer.append(dataContent); + } else if (line.startsWith("event:")) { + String eventValue = line.length() > 6 ? line.substring(6) : ""; + if (eventValue.startsWith(" ")) { + eventValue = eventValue.substring(1); + } + currentEventType = eventValue; + } else if (line.startsWith("id:")) { + // Event ID field (ignored) + } else if (line.startsWith("retry:")) { + // Retry field (ignored) + } else if (line.startsWith(":")) { + // Comment line (ignored) + } + } + + if (eventDataBuffer.length() > 0) { try { - T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - scanner.next().trim(), valueType); - return parsedResponse; - } catch (Exception e) { - throw new RuntimeException(e); + nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType); + hasNextItem = true; + eventDataBuffer.setLength(0); + currentEventType = null; + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse final SSE event: " + parseEx.getMessage()); + eventDataBuffer.setLength(0); + currentEventType = null; } } - } - /** - * Removing elements from {@code Stream} is not supported. - * - * @throws UnsupportedOperationException Always, as removal is not supported. - */ - @Override - public void remove() { - throw new UnsupportedOperationException(); + endOfStream = true; + return false; + + } catch (Exception e) { + System.err.println("Failed to parse SSE stream: " + e.getMessage()); + endOfStream = true; + return false; } - }; + } } } diff --git a/src/main/java/com/schematic/api/errors/BadRequestError.java b/src/main/java/com/schematic/api/errors/BadRequestError.java index f51e164..40a637d 100644 --- a/src/main/java/com/schematic/api/errors/BadRequestError.java +++ b/src/main/java/com/schematic/api/errors/BadRequestError.java @@ -5,6 +5,7 @@ import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.types.ApiError; +import okhttp3.Response; public final class BadRequestError extends BaseSchematicApiException { /** @@ -17,6 +18,11 @@ public BadRequestError(ApiError body) { this.body = body; } + public BadRequestError(ApiError body, Response rawResponse) { + super("BadRequestError", 400, body, rawResponse); + this.body = body; + } + /** * @return the body */ diff --git a/src/main/java/com/schematic/api/errors/ForbiddenError.java b/src/main/java/com/schematic/api/errors/ForbiddenError.java index 0294ce2..eb08c0f 100644 --- a/src/main/java/com/schematic/api/errors/ForbiddenError.java +++ b/src/main/java/com/schematic/api/errors/ForbiddenError.java @@ -5,6 +5,7 @@ import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.types.ApiError; +import okhttp3.Response; public final class ForbiddenError extends BaseSchematicApiException { /** @@ -17,6 +18,11 @@ public ForbiddenError(ApiError body) { this.body = body; } + public ForbiddenError(ApiError body, Response rawResponse) { + super("ForbiddenError", 403, body, rawResponse); + this.body = body; + } + /** * @return the body */ diff --git a/src/main/java/com/schematic/api/errors/InternalServerError.java b/src/main/java/com/schematic/api/errors/InternalServerError.java index f39e7dd..eceb750 100644 --- a/src/main/java/com/schematic/api/errors/InternalServerError.java +++ b/src/main/java/com/schematic/api/errors/InternalServerError.java @@ -5,6 +5,7 @@ import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.types.ApiError; +import okhttp3.Response; public final class InternalServerError extends BaseSchematicApiException { /** @@ -17,6 +18,11 @@ public InternalServerError(ApiError body) { this.body = body; } + public InternalServerError(ApiError body, Response rawResponse) { + super("InternalServerError", 500, body, rawResponse); + this.body = body; + } + /** * @return the body */ diff --git a/src/main/java/com/schematic/api/errors/NotFoundError.java b/src/main/java/com/schematic/api/errors/NotFoundError.java index e3a83dc..203741d 100644 --- a/src/main/java/com/schematic/api/errors/NotFoundError.java +++ b/src/main/java/com/schematic/api/errors/NotFoundError.java @@ -5,6 +5,7 @@ import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.types.ApiError; +import okhttp3.Response; public final class NotFoundError extends BaseSchematicApiException { /** @@ -17,6 +18,11 @@ public NotFoundError(ApiError body) { this.body = body; } + public NotFoundError(ApiError body, Response rawResponse) { + super("NotFoundError", 404, body, rawResponse); + this.body = body; + } + /** * @return the body */ diff --git a/src/main/java/com/schematic/api/errors/UnauthorizedError.java b/src/main/java/com/schematic/api/errors/UnauthorizedError.java index d25c733..18fad20 100644 --- a/src/main/java/com/schematic/api/errors/UnauthorizedError.java +++ b/src/main/java/com/schematic/api/errors/UnauthorizedError.java @@ -5,6 +5,7 @@ import com.schematic.api.core.BaseSchematicApiException; import com.schematic.api.types.ApiError; +import okhttp3.Response; public final class UnauthorizedError extends BaseSchematicApiException { /** @@ -17,6 +18,11 @@ public UnauthorizedError(ApiError body) { this.body = body; } + public UnauthorizedError(ApiError body, Response rawResponse) { + super("UnauthorizedError", 401, body, rawResponse); + this.body = body; + } + /** * @return the body */ diff --git a/src/main/java/com/schematic/api/resources/accesstokens/AccesstokensClient.java b/src/main/java/com/schematic/api/resources/accesstokens/AccesstokensClient.java index 6f6bd7a..2f3d47f 100644 --- a/src/main/java/com/schematic/api/resources/accesstokens/AccesstokensClient.java +++ b/src/main/java/com/schematic/api/resources/accesstokens/AccesstokensClient.java @@ -3,95 +3,34 @@ */ package com.schematic.api.resources.accesstokens; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.accesstokens.requests.IssueTemporaryAccessTokenRequestBody; import com.schematic.api.resources.accesstokens.types.IssueTemporaryAccessTokenResponse; -import com.schematic.api.types.ApiError; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccesstokensClient { protected final ClientOptions clientOptions; + private final RawAccesstokensClient rawClient; + public AccesstokensClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccesstokensClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccesstokensClient withRawResponse() { + return this.rawClient; } public IssueTemporaryAccessTokenResponse issueTemporaryAccessToken(IssueTemporaryAccessTokenRequestBody request) { - return issueTemporaryAccessToken(request, null); + return this.rawClient.issueTemporaryAccessToken(request).body(); } public IssueTemporaryAccessTokenResponse issueTemporaryAccessToken( IssueTemporaryAccessTokenRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("temporary-access-tokens") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), IssueTemporaryAccessTokenResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.issueTemporaryAccessToken(request, requestOptions).body(); } } diff --git a/src/main/java/com/schematic/api/resources/accesstokens/AsyncAccesstokensClient.java b/src/main/java/com/schematic/api/resources/accesstokens/AsyncAccesstokensClient.java new file mode 100644 index 0000000..4b5174d --- /dev/null +++ b/src/main/java/com/schematic/api/resources/accesstokens/AsyncAccesstokensClient.java @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.accesstokens; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.accesstokens.requests.IssueTemporaryAccessTokenRequestBody; +import com.schematic.api.resources.accesstokens.types.IssueTemporaryAccessTokenResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccesstokensClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccesstokensClient rawClient; + + public AsyncAccesstokensClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccesstokensClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccesstokensClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture issueTemporaryAccessToken( + IssueTemporaryAccessTokenRequestBody request) { + return this.rawClient.issueTemporaryAccessToken(request).thenApply(response -> response.body()); + } + + public CompletableFuture issueTemporaryAccessToken( + IssueTemporaryAccessTokenRequestBody request, RequestOptions requestOptions) { + return this.rawClient.issueTemporaryAccessToken(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/accesstokens/AsyncRawAccesstokensClient.java b/src/main/java/com/schematic/api/resources/accesstokens/AsyncRawAccesstokensClient.java new file mode 100644 index 0000000..95f064e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/accesstokens/AsyncRawAccesstokensClient.java @@ -0,0 +1,134 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.accesstokens; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.accesstokens.requests.IssueTemporaryAccessTokenRequestBody; +import com.schematic.api.resources.accesstokens.types.IssueTemporaryAccessTokenResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccesstokensClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccesstokensClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> issueTemporaryAccessToken( + IssueTemporaryAccessTokenRequestBody request) { + return issueTemporaryAccessToken(request, null); + } + + public CompletableFuture> issueTemporaryAccessToken( + IssueTemporaryAccessTokenRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("temporary-access-tokens") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), IssueTemporaryAccessTokenResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/accesstokens/RawAccesstokensClient.java b/src/main/java/com/schematic/api/resources/accesstokens/RawAccesstokensClient.java new file mode 100644 index 0000000..d9553c9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/accesstokens/RawAccesstokensClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.accesstokens; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.accesstokens.requests.IssueTemporaryAccessTokenRequestBody; +import com.schematic.api.resources.accesstokens.types.IssueTemporaryAccessTokenResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccesstokensClient { + protected final ClientOptions clientOptions; + + public RawAccesstokensClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse issueTemporaryAccessToken( + IssueTemporaryAccessTokenRequestBody request) { + return issueTemporaryAccessToken(request, null); + } + + public BaseSchematicHttpResponse issueTemporaryAccessToken( + IssueTemporaryAccessTokenRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("temporary-access-tokens") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), IssueTemporaryAccessTokenResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/accesstokens/requests/IssueTemporaryAccessTokenRequestBody.java b/src/main/java/com/schematic/api/resources/accesstokens/requests/IssueTemporaryAccessTokenRequestBody.java index 8ff89c2..0aa459d 100644 --- a/src/main/java/com/schematic/api/resources/accesstokens/requests/IssueTemporaryAccessTokenRequestBody.java +++ b/src/main/java/com/schematic/api/resources/accesstokens/requests/IssueTemporaryAccessTokenRequestBody.java @@ -16,21 +16,16 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = IssueTemporaryAccessTokenRequestBody.Builder.class) public final class IssueTemporaryAccessTokenRequestBody { private final Map lookup; - private final String resourceType; - private final Map additionalProperties; - private IssueTemporaryAccessTokenRequestBody( - Map lookup, String resourceType, Map additionalProperties) { + private IssueTemporaryAccessTokenRequestBody(Map lookup, Map additionalProperties) { this.lookup = lookup; - this.resourceType = resourceType; this.additionalProperties = additionalProperties; } @@ -41,7 +36,7 @@ public Map getLookup() { @JsonProperty("resource_type") public String getResourceType() { - return resourceType; + return "company"; } @java.lang.Override @@ -57,12 +52,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(IssueTemporaryAccessTokenRequestBody other) { - return lookup.equals(other.lookup) && resourceType.equals(other.resourceType); + return lookup.equals(other.lookup); } @java.lang.Override public int hashCode() { - return Objects.hash(this.lookup, this.resourceType); + return Objects.hash(this.lookup); } @java.lang.Override @@ -70,30 +65,12 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ResourceTypeStage builder() { + public static Builder builder() { return new Builder(); } - public interface ResourceTypeStage { - _FinalStage resourceType(@NotNull String resourceType); - - Builder from(IssueTemporaryAccessTokenRequestBody other); - } - - public interface _FinalStage { - IssueTemporaryAccessTokenRequestBody build(); - - _FinalStage lookup(Map lookup); - - _FinalStage putAllLookup(Map lookup); - - _FinalStage lookup(String key, String value); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ResourceTypeStage, _FinalStage { - private String resourceType; - + public static final class Builder { private Map lookup = new LinkedHashMap<>(); @JsonAnySetter @@ -101,43 +78,34 @@ public static final class Builder implements ResourceTypeStage, _FinalStage { private Builder() {} - @java.lang.Override public Builder from(IssueTemporaryAccessTokenRequestBody other) { lookup(other.getLookup()); - resourceType(other.getResourceType()); return this; } - @java.lang.Override - @JsonSetter("resource_type") - public _FinalStage resourceType(@NotNull String resourceType) { - this.resourceType = Objects.requireNonNull(resourceType, "resourceType must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage lookup(String key, String value) { - this.lookup.put(key, value); + @JsonSetter(value = "lookup", nulls = Nulls.SKIP) + public Builder lookup(Map lookup) { + this.lookup.clear(); + if (lookup != null) { + this.lookup.putAll(lookup); + } return this; } - @java.lang.Override - public _FinalStage putAllLookup(Map lookup) { - this.lookup.putAll(lookup); + public Builder putAllLookup(Map lookup) { + if (lookup != null) { + this.lookup.putAll(lookup); + } return this; } - @java.lang.Override - @JsonSetter(value = "lookup", nulls = Nulls.SKIP) - public _FinalStage lookup(Map lookup) { - this.lookup.clear(); - this.lookup.putAll(lookup); + public Builder lookup(String key, String value) { + this.lookup.put(key, value); return this; } - @java.lang.Override public IssueTemporaryAccessTokenRequestBody build() { - return new IssueTemporaryAccessTokenRequestBody(lookup, resourceType, additionalProperties); + return new IssueTemporaryAccessTokenRequestBody(lookup, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/accesstokens/types/IssueTemporaryAccessTokenResponse.java b/src/main/java/com/schematic/api/resources/accesstokens/types/IssueTemporaryAccessTokenResponse.java index 863fbf0..a2583ef 100644 --- a/src/main/java/com/schematic/api/resources/accesstokens/types/IssueTemporaryAccessTokenResponse.java +++ b/src/main/java/com/schematic/api/resources/accesstokens/types/IssueTemporaryAccessTokenResponse.java @@ -89,6 +89,9 @@ public interface DataStage { public interface _FinalStage { IssueTemporaryAccessTokenResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -137,15 +140,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/AsyncAccountsClient.java b/src/main/java/com/schematic/api/resources/accounts/AsyncAccountsClient.java new file mode 100644 index 0000000..a7b11ac --- /dev/null +++ b/src/main/java/com/schematic/api/resources/accounts/AsyncAccountsClient.java @@ -0,0 +1,204 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.accounts; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.accounts.requests.CountApiKeysRequest; +import com.schematic.api.resources.accounts.requests.CountApiRequestsRequest; +import com.schematic.api.resources.accounts.requests.CreateApiKeyRequestBody; +import com.schematic.api.resources.accounts.requests.CreateEnvironmentRequestBody; +import com.schematic.api.resources.accounts.requests.ListApiKeysRequest; +import com.schematic.api.resources.accounts.requests.ListApiRequestsRequest; +import com.schematic.api.resources.accounts.requests.ListEnvironmentsRequest; +import com.schematic.api.resources.accounts.requests.UpdateApiKeyRequestBody; +import com.schematic.api.resources.accounts.requests.UpdateEnvironmentRequestBody; +import com.schematic.api.resources.accounts.types.CountApiKeysResponse; +import com.schematic.api.resources.accounts.types.CountApiRequestsResponse; +import com.schematic.api.resources.accounts.types.CreateApiKeyResponse; +import com.schematic.api.resources.accounts.types.CreateEnvironmentResponse; +import com.schematic.api.resources.accounts.types.DeleteApiKeyResponse; +import com.schematic.api.resources.accounts.types.DeleteEnvironmentResponse; +import com.schematic.api.resources.accounts.types.GetApiKeyResponse; +import com.schematic.api.resources.accounts.types.GetApiRequestResponse; +import com.schematic.api.resources.accounts.types.GetEnvironmentResponse; +import com.schematic.api.resources.accounts.types.ListApiKeysResponse; +import com.schematic.api.resources.accounts.types.ListApiRequestsResponse; +import com.schematic.api.resources.accounts.types.ListEnvironmentsResponse; +import com.schematic.api.resources.accounts.types.QuickstartResponse; +import com.schematic.api.resources.accounts.types.UpdateApiKeyResponse; +import com.schematic.api.resources.accounts.types.UpdateEnvironmentResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountsClient rawClient; + + public AsyncAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountsClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture listApiKeys(ListApiKeysRequest request) { + return this.rawClient.listApiKeys(request).thenApply(response -> response.body()); + } + + public CompletableFuture listApiKeys( + ListApiKeysRequest request, RequestOptions requestOptions) { + return this.rawClient.listApiKeys(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createApiKey(CreateApiKeyRequestBody request) { + return this.rawClient.createApiKey(request).thenApply(response -> response.body()); + } + + public CompletableFuture createApiKey( + CreateApiKeyRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createApiKey(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getApiKey(String apiKeyId) { + return this.rawClient.getApiKey(apiKeyId).thenApply(response -> response.body()); + } + + public CompletableFuture getApiKey(String apiKeyId, RequestOptions requestOptions) { + return this.rawClient.getApiKey(apiKeyId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateApiKey(String apiKeyId) { + return this.rawClient.updateApiKey(apiKeyId).thenApply(response -> response.body()); + } + + public CompletableFuture updateApiKey(String apiKeyId, UpdateApiKeyRequestBody request) { + return this.rawClient.updateApiKey(apiKeyId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateApiKey( + String apiKeyId, UpdateApiKeyRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateApiKey(apiKeyId, request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteApiKey(String apiKeyId) { + return this.rawClient.deleteApiKey(apiKeyId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteApiKey(String apiKeyId, RequestOptions requestOptions) { + return this.rawClient.deleteApiKey(apiKeyId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countApiKeys(CountApiKeysRequest request) { + return this.rawClient.countApiKeys(request).thenApply(response -> response.body()); + } + + public CompletableFuture countApiKeys( + CountApiKeysRequest request, RequestOptions requestOptions) { + return this.rawClient.countApiKeys(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listApiRequests() { + return this.rawClient.listApiRequests().thenApply(response -> response.body()); + } + + public CompletableFuture listApiRequests(ListApiRequestsRequest request) { + return this.rawClient.listApiRequests(request).thenApply(response -> response.body()); + } + + public CompletableFuture listApiRequests( + ListApiRequestsRequest request, RequestOptions requestOptions) { + return this.rawClient.listApiRequests(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getApiRequest(String apiRequestId) { + return this.rawClient.getApiRequest(apiRequestId).thenApply(response -> response.body()); + } + + public CompletableFuture getApiRequest(String apiRequestId, RequestOptions requestOptions) { + return this.rawClient.getApiRequest(apiRequestId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countApiRequests() { + return this.rawClient.countApiRequests().thenApply(response -> response.body()); + } + + public CompletableFuture countApiRequests(CountApiRequestsRequest request) { + return this.rawClient.countApiRequests(request).thenApply(response -> response.body()); + } + + public CompletableFuture countApiRequests( + CountApiRequestsRequest request, RequestOptions requestOptions) { + return this.rawClient.countApiRequests(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listEnvironments() { + return this.rawClient.listEnvironments().thenApply(response -> response.body()); + } + + public CompletableFuture listEnvironments(ListEnvironmentsRequest request) { + return this.rawClient.listEnvironments(request).thenApply(response -> response.body()); + } + + public CompletableFuture listEnvironments( + ListEnvironmentsRequest request, RequestOptions requestOptions) { + return this.rawClient.listEnvironments(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createEnvironment(CreateEnvironmentRequestBody request) { + return this.rawClient.createEnvironment(request).thenApply(response -> response.body()); + } + + public CompletableFuture createEnvironment( + CreateEnvironmentRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createEnvironment(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getEnvironment(String environmentId) { + return this.rawClient.getEnvironment(environmentId).thenApply(response -> response.body()); + } + + public CompletableFuture getEnvironment( + String environmentId, RequestOptions requestOptions) { + return this.rawClient.getEnvironment(environmentId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateEnvironment(String environmentId) { + return this.rawClient.updateEnvironment(environmentId).thenApply(response -> response.body()); + } + + public CompletableFuture updateEnvironment( + String environmentId, UpdateEnvironmentRequestBody request) { + return this.rawClient.updateEnvironment(environmentId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateEnvironment( + String environmentId, UpdateEnvironmentRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateEnvironment(environmentId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deleteEnvironment(String environmentId) { + return this.rawClient.deleteEnvironment(environmentId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteEnvironment( + String environmentId, RequestOptions requestOptions) { + return this.rawClient.deleteEnvironment(environmentId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture quickstart() { + return this.rawClient.quickstart().thenApply(response -> response.body()); + } + + public CompletableFuture quickstart(RequestOptions requestOptions) { + return this.rawClient.quickstart(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java b/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java new file mode 100644 index 0000000..caf2ae4 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/accounts/AsyncRawAccountsClient.java @@ -0,0 +1,1425 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.accounts; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.accounts.requests.CountApiKeysRequest; +import com.schematic.api.resources.accounts.requests.CountApiRequestsRequest; +import com.schematic.api.resources.accounts.requests.CreateApiKeyRequestBody; +import com.schematic.api.resources.accounts.requests.CreateEnvironmentRequestBody; +import com.schematic.api.resources.accounts.requests.ListApiKeysRequest; +import com.schematic.api.resources.accounts.requests.ListApiRequestsRequest; +import com.schematic.api.resources.accounts.requests.ListEnvironmentsRequest; +import com.schematic.api.resources.accounts.requests.UpdateApiKeyRequestBody; +import com.schematic.api.resources.accounts.requests.UpdateEnvironmentRequestBody; +import com.schematic.api.resources.accounts.types.CountApiKeysResponse; +import com.schematic.api.resources.accounts.types.CountApiRequestsResponse; +import com.schematic.api.resources.accounts.types.CreateApiKeyResponse; +import com.schematic.api.resources.accounts.types.CreateEnvironmentResponse; +import com.schematic.api.resources.accounts.types.DeleteApiKeyResponse; +import com.schematic.api.resources.accounts.types.DeleteEnvironmentResponse; +import com.schematic.api.resources.accounts.types.GetApiKeyResponse; +import com.schematic.api.resources.accounts.types.GetApiRequestResponse; +import com.schematic.api.resources.accounts.types.GetEnvironmentResponse; +import com.schematic.api.resources.accounts.types.ListApiKeysResponse; +import com.schematic.api.resources.accounts.types.ListApiRequestsResponse; +import com.schematic.api.resources.accounts.types.ListEnvironmentsResponse; +import com.schematic.api.resources.accounts.types.QuickstartResponse; +import com.schematic.api.resources.accounts.types.UpdateApiKeyResponse; +import com.schematic.api.resources.accounts.types.UpdateEnvironmentResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> listApiKeys(ListApiKeysRequest request) { + return listApiKeys(request, null); + } + + public CompletableFuture> listApiKeys( + ListApiKeysRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys"); + if (request.getEnvironmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "environment_id", request.getEnvironmentId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "require_environment", request.getRequireEnvironment(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListApiKeysResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createApiKey( + CreateApiKeyRequestBody request) { + return createApiKey(request, null); + } + + public CompletableFuture> createApiKey( + CreateApiKeyRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateApiKeyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getApiKey(String apiKeyId) { + return getApiKey(apiKeyId, null); + } + + public CompletableFuture> getApiKey( + String apiKeyId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys") + .addPathSegment(apiKeyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetApiKeyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateApiKey(String apiKeyId) { + return updateApiKey(apiKeyId, UpdateApiKeyRequestBody.builder().build()); + } + + public CompletableFuture> updateApiKey( + String apiKeyId, UpdateApiKeyRequestBody request) { + return updateApiKey(apiKeyId, request, null); + } + + public CompletableFuture> updateApiKey( + String apiKeyId, UpdateApiKeyRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys") + .addPathSegment(apiKeyId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateApiKeyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteApiKey(String apiKeyId) { + return deleteApiKey(apiKeyId, null); + } + + public CompletableFuture> deleteApiKey( + String apiKeyId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys") + .addPathSegment(apiKeyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteApiKeyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countApiKeys( + CountApiKeysRequest request) { + return countApiKeys(request, null); + } + + public CompletableFuture> countApiKeys( + CountApiKeysRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys/count"); + if (request.getEnvironmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "environment_id", request.getEnvironmentId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "require_environment", request.getRequireEnvironment(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountApiKeysResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listApiRequests() { + return listApiRequests(ListApiRequestsRequest.builder().build()); + } + + public CompletableFuture> listApiRequests( + ListApiRequestsRequest request) { + return listApiRequests(request, null); + } + + public CompletableFuture> listApiRequests( + ListApiRequestsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-requests"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequestType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "request_type", request.getRequestType().get(), false); + } + if (request.getEnvironmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "environment_id", request.getEnvironmentId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListApiRequestsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getApiRequest(String apiRequestId) { + return getApiRequest(apiRequestId, null); + } + + public CompletableFuture> getApiRequest( + String apiRequestId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-requests") + .addPathSegment(apiRequestId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetApiRequestResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countApiRequests() { + return countApiRequests(CountApiRequestsRequest.builder().build()); + } + + public CompletableFuture> countApiRequests( + CountApiRequestsRequest request) { + return countApiRequests(request, null); + } + + public CompletableFuture> countApiRequests( + CountApiRequestsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-requests/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequestType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "request_type", request.getRequestType().get(), false); + } + if (request.getEnvironmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "environment_id", request.getEnvironmentId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountApiRequestsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listEnvironments() { + return listEnvironments(ListEnvironmentsRequest.builder().build()); + } + + public CompletableFuture> listEnvironments( + ListEnvironmentsRequest request) { + return listEnvironments(request, null); + } + + public CompletableFuture> listEnvironments( + ListEnvironmentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments"); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListEnvironmentsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createEnvironment( + CreateEnvironmentRequestBody request) { + return createEnvironment(request, null); + } + + public CompletableFuture> createEnvironment( + CreateEnvironmentRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateEnvironmentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getEnvironment(String environmentId) { + return getEnvironment(environmentId, null); + } + + public CompletableFuture> getEnvironment( + String environmentId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments") + .addPathSegment(environmentId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetEnvironmentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateEnvironment( + String environmentId) { + return updateEnvironment( + environmentId, UpdateEnvironmentRequestBody.builder().build()); + } + + public CompletableFuture> updateEnvironment( + String environmentId, UpdateEnvironmentRequestBody request) { + return updateEnvironment(environmentId, request, null); + } + + public CompletableFuture> updateEnvironment( + String environmentId, UpdateEnvironmentRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments") + .addPathSegment(environmentId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateEnvironmentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteEnvironment( + String environmentId) { + return deleteEnvironment(environmentId, null); + } + + public CompletableFuture> deleteEnvironment( + String environmentId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments") + .addPathSegment(environmentId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteEnvironmentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> quickstart() { + return quickstart(null); + } + + public CompletableFuture> quickstart(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("quickstart") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), QuickstartResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java b/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java new file mode 100644 index 0000000..808a848 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/accounts/RawAccountsClient.java @@ -0,0 +1,1065 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.accounts; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.accounts.requests.CountApiKeysRequest; +import com.schematic.api.resources.accounts.requests.CountApiRequestsRequest; +import com.schematic.api.resources.accounts.requests.CreateApiKeyRequestBody; +import com.schematic.api.resources.accounts.requests.CreateEnvironmentRequestBody; +import com.schematic.api.resources.accounts.requests.ListApiKeysRequest; +import com.schematic.api.resources.accounts.requests.ListApiRequestsRequest; +import com.schematic.api.resources.accounts.requests.ListEnvironmentsRequest; +import com.schematic.api.resources.accounts.requests.UpdateApiKeyRequestBody; +import com.schematic.api.resources.accounts.requests.UpdateEnvironmentRequestBody; +import com.schematic.api.resources.accounts.types.CountApiKeysResponse; +import com.schematic.api.resources.accounts.types.CountApiRequestsResponse; +import com.schematic.api.resources.accounts.types.CreateApiKeyResponse; +import com.schematic.api.resources.accounts.types.CreateEnvironmentResponse; +import com.schematic.api.resources.accounts.types.DeleteApiKeyResponse; +import com.schematic.api.resources.accounts.types.DeleteEnvironmentResponse; +import com.schematic.api.resources.accounts.types.GetApiKeyResponse; +import com.schematic.api.resources.accounts.types.GetApiRequestResponse; +import com.schematic.api.resources.accounts.types.GetEnvironmentResponse; +import com.schematic.api.resources.accounts.types.ListApiKeysResponse; +import com.schematic.api.resources.accounts.types.ListApiRequestsResponse; +import com.schematic.api.resources.accounts.types.ListEnvironmentsResponse; +import com.schematic.api.resources.accounts.types.QuickstartResponse; +import com.schematic.api.resources.accounts.types.UpdateApiKeyResponse; +import com.schematic.api.resources.accounts.types.UpdateEnvironmentResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountsClient { + protected final ClientOptions clientOptions; + + public RawAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse listApiKeys(ListApiKeysRequest request) { + return listApiKeys(request, null); + } + + public BaseSchematicHttpResponse listApiKeys( + ListApiKeysRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys"); + if (request.getEnvironmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "environment_id", request.getEnvironmentId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "require_environment", request.getRequireEnvironment(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListApiKeysResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createApiKey(CreateApiKeyRequestBody request) { + return createApiKey(request, null); + } + + public BaseSchematicHttpResponse createApiKey( + CreateApiKeyRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateApiKeyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getApiKey(String apiKeyId) { + return getApiKey(apiKeyId, null); + } + + public BaseSchematicHttpResponse getApiKey(String apiKeyId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys") + .addPathSegment(apiKeyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetApiKeyResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateApiKey(String apiKeyId) { + return updateApiKey(apiKeyId, UpdateApiKeyRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse updateApiKey( + String apiKeyId, UpdateApiKeyRequestBody request) { + return updateApiKey(apiKeyId, request, null); + } + + public BaseSchematicHttpResponse updateApiKey( + String apiKeyId, UpdateApiKeyRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys") + .addPathSegment(apiKeyId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateApiKeyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteApiKey(String apiKeyId) { + return deleteApiKey(apiKeyId, null); + } + + public BaseSchematicHttpResponse deleteApiKey( + String apiKeyId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys") + .addPathSegment(apiKeyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteApiKeyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countApiKeys(CountApiKeysRequest request) { + return countApiKeys(request, null); + } + + public BaseSchematicHttpResponse countApiKeys( + CountApiKeysRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-keys/count"); + if (request.getEnvironmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "environment_id", request.getEnvironmentId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "require_environment", request.getRequireEnvironment(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountApiKeysResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listApiRequests() { + return listApiRequests(ListApiRequestsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listApiRequests(ListApiRequestsRequest request) { + return listApiRequests(request, null); + } + + public BaseSchematicHttpResponse listApiRequests( + ListApiRequestsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-requests"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequestType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "request_type", request.getRequestType().get(), false); + } + if (request.getEnvironmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "environment_id", request.getEnvironmentId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListApiRequestsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getApiRequest(String apiRequestId) { + return getApiRequest(apiRequestId, null); + } + + public BaseSchematicHttpResponse getApiRequest( + String apiRequestId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-requests") + .addPathSegment(apiRequestId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetApiRequestResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countApiRequests() { + return countApiRequests(CountApiRequestsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countApiRequests(CountApiRequestsRequest request) { + return countApiRequests(request, null); + } + + public BaseSchematicHttpResponse countApiRequests( + CountApiRequestsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("api-requests/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequestType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "request_type", request.getRequestType().get(), false); + } + if (request.getEnvironmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "environment_id", request.getEnvironmentId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountApiRequestsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listEnvironments() { + return listEnvironments(ListEnvironmentsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listEnvironments(ListEnvironmentsRequest request) { + return listEnvironments(request, null); + } + + public BaseSchematicHttpResponse listEnvironments( + ListEnvironmentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments"); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListEnvironmentsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createEnvironment( + CreateEnvironmentRequestBody request) { + return createEnvironment(request, null); + } + + public BaseSchematicHttpResponse createEnvironment( + CreateEnvironmentRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateEnvironmentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getEnvironment(String environmentId) { + return getEnvironment(environmentId, null); + } + + public BaseSchematicHttpResponse getEnvironment( + String environmentId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments") + .addPathSegment(environmentId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetEnvironmentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateEnvironment(String environmentId) { + return updateEnvironment( + environmentId, UpdateEnvironmentRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse updateEnvironment( + String environmentId, UpdateEnvironmentRequestBody request) { + return updateEnvironment(environmentId, request, null); + } + + public BaseSchematicHttpResponse updateEnvironment( + String environmentId, UpdateEnvironmentRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments") + .addPathSegment(environmentId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateEnvironmentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteEnvironment(String environmentId) { + return deleteEnvironment(environmentId, null); + } + + public BaseSchematicHttpResponse deleteEnvironment( + String environmentId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("environments") + .addPathSegment(environmentId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteEnvironmentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse quickstart() { + return quickstart(null); + } + + public BaseSchematicHttpResponse quickstart(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("quickstart") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), QuickstartResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/accounts/requests/CountApiKeysRequest.java b/src/main/java/com/schematic/api/resources/accounts/requests/CountApiKeysRequest.java index c305dcc..332acff 100644 --- a/src/main/java/com/schematic/api/resources/accounts/requests/CountApiKeysRequest.java +++ b/src/main/java/com/schematic/api/resources/accounts/requests/CountApiKeysRequest.java @@ -114,10 +114,16 @@ public interface _FinalStage { _FinalStage environmentId(String environmentId); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -164,6 +170,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -181,6 +190,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/accounts/requests/CountApiRequestsRequest.java b/src/main/java/com/schematic/api/resources/accounts/requests/CountApiRequestsRequest.java index 0af3b86..b6e8e81 100644 --- a/src/main/java/com/schematic/api/resources/accounts/requests/CountApiRequestsRequest.java +++ b/src/main/java/com/schematic/api/resources/accounts/requests/CountApiRequestsRequest.java @@ -170,6 +170,9 @@ public Builder environmentId(String environmentId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -181,6 +184,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/accounts/requests/ListApiKeysRequest.java b/src/main/java/com/schematic/api/resources/accounts/requests/ListApiKeysRequest.java index 12d61bb..53be023 100644 --- a/src/main/java/com/schematic/api/resources/accounts/requests/ListApiKeysRequest.java +++ b/src/main/java/com/schematic/api/resources/accounts/requests/ListApiKeysRequest.java @@ -114,10 +114,16 @@ public interface _FinalStage { _FinalStage environmentId(String environmentId); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -164,6 +170,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -181,6 +190,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/accounts/requests/ListApiRequestsRequest.java b/src/main/java/com/schematic/api/resources/accounts/requests/ListApiRequestsRequest.java index 86e442a..dcb8d71 100644 --- a/src/main/java/com/schematic/api/resources/accounts/requests/ListApiRequestsRequest.java +++ b/src/main/java/com/schematic/api/resources/accounts/requests/ListApiRequestsRequest.java @@ -170,6 +170,9 @@ public Builder environmentId(String environmentId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -181,6 +184,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/accounts/requests/ListEnvironmentsRequest.java b/src/main/java/com/schematic/api/resources/accounts/requests/ListEnvironmentsRequest.java index 2aa573c..7546910 100644 --- a/src/main/java/com/schematic/api/resources/accounts/requests/ListEnvironmentsRequest.java +++ b/src/main/java/com/schematic/api/resources/accounts/requests/ListEnvironmentsRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,7 +22,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListEnvironmentsRequest.Builder.class) public final class ListEnvironmentsRequest { - private final Optional ids; + private final Optional> ids; private final Optional limit; @@ -29,7 +31,7 @@ public final class ListEnvironmentsRequest { private final Map additionalProperties; private ListEnvironmentsRequest( - Optional ids, + Optional> ids, Optional limit, Optional offset, Map additionalProperties) { @@ -40,7 +42,7 @@ private ListEnvironmentsRequest( } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -91,7 +93,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional limit = Optional.empty(); @@ -110,16 +112,24 @@ public Builder from(ListEnvironmentsRequest other) { } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -131,6 +141,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysParams.java b/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysParams.java index 8c9a83c..6774dba 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysParams.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysParams.java @@ -135,6 +135,9 @@ public Builder environmentId(String environmentId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysResponse.java index a2b2226..c608cbd 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CountApiKeysResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountApiKeysParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CountApiRequestsParams.java b/src/main/java/com/schematic/api/resources/accounts/types/CountApiRequestsParams.java index 7a2888d..de2cc99 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CountApiRequestsParams.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CountApiRequestsParams.java @@ -148,6 +148,9 @@ public Builder environmentId(String environmentId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -159,6 +162,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CountApiRequestsResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/CountApiRequestsResponse.java index 98402fd..a1f1795 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CountApiRequestsResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CountApiRequestsResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountApiRequestsParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CreateApiKeyResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/CreateApiKeyResponse.java index 9d2e4fe..2ea77c1 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CreateApiKeyResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CreateApiKeyResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateApiKeyResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CreateEnvironmentRequestBodyEnvironmentType.java b/src/main/java/com/schematic/api/resources/accounts/types/CreateEnvironmentRequestBodyEnvironmentType.java index 664ac01..54b7ffe 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CreateEnvironmentRequestBodyEnvironmentType.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CreateEnvironmentRequestBodyEnvironmentType.java @@ -3,24 +3,95 @@ */ package com.schematic.api.resources.accounts.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateEnvironmentRequestBodyEnvironmentType { - DEVELOPMENT("development"), +public final class CreateEnvironmentRequestBodyEnvironmentType { + public static final CreateEnvironmentRequestBodyEnvironmentType DEVELOPMENT = + new CreateEnvironmentRequestBodyEnvironmentType(Value.DEVELOPMENT, "development"); - STAGING("staging"), + public static final CreateEnvironmentRequestBodyEnvironmentType STAGING = + new CreateEnvironmentRequestBodyEnvironmentType(Value.STAGING, "staging"); - PRODUCTION("production"); + public static final CreateEnvironmentRequestBodyEnvironmentType PRODUCTION = + new CreateEnvironmentRequestBodyEnvironmentType(Value.PRODUCTION, "production"); - private final String value; + private final Value value; - CreateEnvironmentRequestBodyEnvironmentType(String value) { + private final String string; + + CreateEnvironmentRequestBodyEnvironmentType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateEnvironmentRequestBodyEnvironmentType + && this.string.equals(((CreateEnvironmentRequestBodyEnvironmentType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEVELOPMENT: + return visitor.visitDevelopment(); + case STAGING: + return visitor.visitStaging(); + case PRODUCTION: + return visitor.visitProduction(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateEnvironmentRequestBodyEnvironmentType valueOf(String value) { + switch (value) { + case "development": + return DEVELOPMENT; + case "staging": + return STAGING; + case "production": + return PRODUCTION; + default: + return new CreateEnvironmentRequestBodyEnvironmentType(Value.UNKNOWN, value); + } + } + + public enum Value { + DEVELOPMENT, + + STAGING, + + PRODUCTION, + + UNKNOWN + } + + public interface Visitor { + T visitDevelopment(); + + T visitStaging(); + + T visitProduction(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/CreateEnvironmentResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/CreateEnvironmentResponse.java index 3b23821..3a2fb8b 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/CreateEnvironmentResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/CreateEnvironmentResponse.java @@ -89,6 +89,9 @@ public interface DataStage { public interface _FinalStage { CreateEnvironmentResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -137,15 +140,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/DeleteApiKeyResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/DeleteApiKeyResponse.java index a8fdb02..fcf304d 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/DeleteApiKeyResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/DeleteApiKeyResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteApiKeyResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/DeleteEnvironmentResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/DeleteEnvironmentResponse.java index 1fca182..d6605c2 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/DeleteEnvironmentResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/DeleteEnvironmentResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteEnvironmentResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/GetApiKeyResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/GetApiKeyResponse.java index a976064..931d51d 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/GetApiKeyResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/GetApiKeyResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetApiKeyResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/GetApiRequestResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/GetApiRequestResponse.java index bbdb235..64ae918 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/GetApiRequestResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/GetApiRequestResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetApiRequestResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/GetEnvironmentResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/GetEnvironmentResponse.java index 5054c17..eac3b9f 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/GetEnvironmentResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/GetEnvironmentResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetEnvironmentResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysParams.java b/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysParams.java index bbe3972..9a6ee79 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysParams.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysParams.java @@ -135,6 +135,9 @@ public Builder environmentId(String environmentId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysResponse.java index cd3f647..2cc3051 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListApiKeysResponse.java @@ -36,9 +36,6 @@ private ListApiKeysResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListApiKeysParams params); Builder from(ListApiKeysResponse other); @@ -116,6 +116,7 @@ public Builder from(ListApiKeysResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListApiKeysParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(ApiKeyResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(ApiKeyResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListApiRequestsParams.java b/src/main/java/com/schematic/api/resources/accounts/types/ListApiRequestsParams.java index f38ec52..c39baef 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListApiRequestsParams.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListApiRequestsParams.java @@ -148,6 +148,9 @@ public Builder environmentId(String environmentId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -159,6 +162,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListApiRequestsResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/ListApiRequestsResponse.java index 1df7fed..33c4c17 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListApiRequestsResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListApiRequestsResponse.java @@ -38,9 +38,6 @@ private ListApiRequestsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListApiRequestsParams params); Builder from(ListApiRequestsResponse other); @@ -118,6 +118,7 @@ public Builder from(ListApiRequestsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListApiRequestsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(ApiKeyRequestListResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(ApiKeyRequestListResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsParams.java b/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsParams.java index b0a5528..12cf49c 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsParams.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsParams.java @@ -121,6 +121,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -132,6 +135,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsResponse.java index 8777c6e..c016816 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/ListEnvironmentsResponse.java @@ -38,9 +38,6 @@ private ListEnvironmentsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListEnvironmentsParams params); Builder from(ListEnvironmentsResponse other); @@ -118,6 +118,7 @@ public Builder from(ListEnvironmentsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListEnvironmentsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(EnvironmentResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(EnvironmentResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/CountAudienceUsersResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/QuickstartResponse.java similarity index 73% rename from src/main/java/com/schematic/api/resources/features/types/CountAudienceUsersResponse.java rename to src/main/java/com/schematic/api/resources/accounts/types/QuickstartResponse.java index b0680fd..3faae64 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CountAudienceUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/QuickstartResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.schematic.api.resources.features.types; +package com.schematic.api.resources.accounts.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import com.schematic.api.types.CountResponse; +import com.schematic.api.types.QuickstartResp; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -21,23 +21,23 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = CountAudienceUsersResponse.Builder.class) -public final class CountAudienceUsersResponse { - private final CountResponse data; +@JsonDeserialize(builder = QuickstartResponse.Builder.class) +public final class QuickstartResponse { + private final QuickstartResp data; private final Map params; private final Map additionalProperties; - private CountAudienceUsersResponse( - CountResponse data, Map params, Map additionalProperties) { + private QuickstartResponse( + QuickstartResp data, Map params, Map additionalProperties) { this.data = data; this.params = params; this.additionalProperties = additionalProperties; } @JsonProperty("data") - public CountResponse getData() { + public QuickstartResp getData() { return data; } @@ -52,7 +52,7 @@ public Map getParams() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CountAudienceUsersResponse && equalTo((CountAudienceUsersResponse) other); + return other instanceof QuickstartResponse && equalTo((QuickstartResponse) other); } @JsonAnyGetter @@ -60,7 +60,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CountAudienceUsersResponse other) { + private boolean equalTo(QuickstartResponse other) { return data.equals(other.data) && params.equals(other.params); } @@ -79,14 +79,17 @@ public static DataStage builder() { } public interface DataStage { - _FinalStage data(@NotNull CountResponse data); + _FinalStage data(@NotNull QuickstartResp data); - Builder from(CountAudienceUsersResponse other); + Builder from(QuickstartResponse other); } public interface _FinalStage { - CountAudienceUsersResponse build(); + QuickstartResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -96,7 +99,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements DataStage, _FinalStage { - private CountResponse data; + private QuickstartResp data; private Map params = new LinkedHashMap<>(); @@ -106,7 +109,7 @@ public static final class Builder implements DataStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(CountAudienceUsersResponse other) { + public Builder from(QuickstartResponse other) { data(other.getData()); params(other.getParams()); return this; @@ -114,7 +117,7 @@ public Builder from(CountAudienceUsersResponse other) { @java.lang.Override @JsonSetter("data") - public _FinalStage data(@NotNull CountResponse data) { + public _FinalStage data(@NotNull QuickstartResp data) { this.data = Objects.requireNonNull(data, "data must not be null"); return this; } @@ -135,21 +138,28 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } @java.lang.Override - public CountAudienceUsersResponse build() { - return new CountAudienceUsersResponse(data, params, additionalProperties); + public QuickstartResponse build() { + return new QuickstartResponse(data, params, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/UpdateApiKeyResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/UpdateApiKeyResponse.java index 96ba9a7..cb6e1fa 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/UpdateApiKeyResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/UpdateApiKeyResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateApiKeyResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/UpdateEnvironmentRequestBodyEnvironmentType.java b/src/main/java/com/schematic/api/resources/accounts/types/UpdateEnvironmentRequestBodyEnvironmentType.java index bf4015f..39d9ea7 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/UpdateEnvironmentRequestBodyEnvironmentType.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/UpdateEnvironmentRequestBodyEnvironmentType.java @@ -3,24 +3,95 @@ */ package com.schematic.api.resources.accounts.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateEnvironmentRequestBodyEnvironmentType { - DEVELOPMENT("development"), +public final class UpdateEnvironmentRequestBodyEnvironmentType { + public static final UpdateEnvironmentRequestBodyEnvironmentType DEVELOPMENT = + new UpdateEnvironmentRequestBodyEnvironmentType(Value.DEVELOPMENT, "development"); - STAGING("staging"), + public static final UpdateEnvironmentRequestBodyEnvironmentType STAGING = + new UpdateEnvironmentRequestBodyEnvironmentType(Value.STAGING, "staging"); - PRODUCTION("production"); + public static final UpdateEnvironmentRequestBodyEnvironmentType PRODUCTION = + new UpdateEnvironmentRequestBodyEnvironmentType(Value.PRODUCTION, "production"); - private final String value; + private final Value value; - UpdateEnvironmentRequestBodyEnvironmentType(String value) { + private final String string; + + UpdateEnvironmentRequestBodyEnvironmentType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateEnvironmentRequestBodyEnvironmentType + && this.string.equals(((UpdateEnvironmentRequestBodyEnvironmentType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEVELOPMENT: + return visitor.visitDevelopment(); + case STAGING: + return visitor.visitStaging(); + case PRODUCTION: + return visitor.visitProduction(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateEnvironmentRequestBodyEnvironmentType valueOf(String value) { + switch (value) { + case "development": + return DEVELOPMENT; + case "staging": + return STAGING; + case "production": + return PRODUCTION; + default: + return new UpdateEnvironmentRequestBodyEnvironmentType(Value.UNKNOWN, value); + } + } + + public enum Value { + DEVELOPMENT, + + STAGING, + + PRODUCTION, + + UNKNOWN + } + + public interface Visitor { + T visitDevelopment(); + + T visitStaging(); + + T visitProduction(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/accounts/types/UpdateEnvironmentResponse.java b/src/main/java/com/schematic/api/resources/accounts/types/UpdateEnvironmentResponse.java index acf27a4..52444d0 100644 --- a/src/main/java/com/schematic/api/resources/accounts/types/UpdateEnvironmentResponse.java +++ b/src/main/java/com/schematic/api/resources/accounts/types/UpdateEnvironmentResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateEnvironmentResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java b/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java new file mode 100644 index 0000000..da31034 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/AsyncBillingClient.java @@ -0,0 +1,281 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.billing.requests.CountBillingProductsRequest; +import com.schematic.api.resources.billing.requests.CountCustomersRequest; +import com.schematic.api.resources.billing.requests.CreateBillingCustomerRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingPriceRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingProductRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingSubscriptionRequestBody; +import com.schematic.api.resources.billing.requests.CreateCouponRequestBody; +import com.schematic.api.resources.billing.requests.CreateInvoiceRequestBody; +import com.schematic.api.resources.billing.requests.CreateMeterRequestBody; +import com.schematic.api.resources.billing.requests.CreatePaymentMethodRequestBody; +import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCouponsRequest; +import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; +import com.schematic.api.resources.billing.requests.ListInvoicesRequest; +import com.schematic.api.resources.billing.requests.ListMetersRequest; +import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; +import com.schematic.api.resources.billing.requests.ListProductPricesRequest; +import com.schematic.api.resources.billing.requests.SearchBillingPricesRequest; +import com.schematic.api.resources.billing.types.CountBillingProductsResponse; +import com.schematic.api.resources.billing.types.CountCustomersResponse; +import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; +import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; +import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCouponsResponse; +import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; +import com.schematic.api.resources.billing.types.ListInvoicesResponse; +import com.schematic.api.resources.billing.types.ListMetersResponse; +import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; +import com.schematic.api.resources.billing.types.ListProductPricesResponse; +import com.schematic.api.resources.billing.types.SearchBillingPricesResponse; +import com.schematic.api.resources.billing.types.UpsertBillingCouponResponse; +import com.schematic.api.resources.billing.types.UpsertBillingCustomerResponse; +import com.schematic.api.resources.billing.types.UpsertBillingMeterResponse; +import com.schematic.api.resources.billing.types.UpsertBillingPriceResponse; +import com.schematic.api.resources.billing.types.UpsertBillingProductResponse; +import com.schematic.api.resources.billing.types.UpsertBillingSubscriptionResponse; +import com.schematic.api.resources.billing.types.UpsertInvoiceResponse; +import com.schematic.api.resources.billing.types.UpsertPaymentMethodResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncBillingClient { + protected final ClientOptions clientOptions; + + private final AsyncRawBillingClient rawClient; + + public AsyncBillingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawBillingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawBillingClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture listCoupons() { + return this.rawClient.listCoupons().thenApply(response -> response.body()); + } + + public CompletableFuture listCoupons(ListCouponsRequest request) { + return this.rawClient.listCoupons(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCoupons( + ListCouponsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCoupons(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingCoupon(CreateCouponRequestBody request) { + return this.rawClient.upsertBillingCoupon(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingCoupon( + CreateCouponRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertBillingCoupon(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingCustomer( + CreateBillingCustomerRequestBody request) { + return this.rawClient.upsertBillingCustomer(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingCustomer( + CreateBillingCustomerRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertBillingCustomer(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listCustomersWithSubscriptions() { + return this.rawClient.listCustomersWithSubscriptions().thenApply(response -> response.body()); + } + + public CompletableFuture listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest request) { + return this.rawClient.listCustomersWithSubscriptions(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest request, RequestOptions requestOptions) { + return this.rawClient + .listCustomersWithSubscriptions(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture countCustomers() { + return this.rawClient.countCustomers().thenApply(response -> response.body()); + } + + public CompletableFuture countCustomers(CountCustomersRequest request) { + return this.rawClient.countCustomers(request).thenApply(response -> response.body()); + } + + public CompletableFuture countCustomers( + CountCustomersRequest request, RequestOptions requestOptions) { + return this.rawClient.countCustomers(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listInvoices(ListInvoicesRequest request) { + return this.rawClient.listInvoices(request).thenApply(response -> response.body()); + } + + public CompletableFuture listInvoices( + ListInvoicesRequest request, RequestOptions requestOptions) { + return this.rawClient.listInvoices(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertInvoice(CreateInvoiceRequestBody request) { + return this.rawClient.upsertInvoice(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertInvoice( + CreateInvoiceRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertInvoice(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listMeters() { + return this.rawClient.listMeters().thenApply(response -> response.body()); + } + + public CompletableFuture listMeters(ListMetersRequest request) { + return this.rawClient.listMeters(request).thenApply(response -> response.body()); + } + + public CompletableFuture listMeters(ListMetersRequest request, RequestOptions requestOptions) { + return this.rawClient.listMeters(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingMeter(CreateMeterRequestBody request) { + return this.rawClient.upsertBillingMeter(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingMeter( + CreateMeterRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertBillingMeter(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listPaymentMethods(ListPaymentMethodsRequest request) { + return this.rawClient.listPaymentMethods(request).thenApply(response -> response.body()); + } + + public CompletableFuture listPaymentMethods( + ListPaymentMethodsRequest request, RequestOptions requestOptions) { + return this.rawClient.listPaymentMethods(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertPaymentMethod(CreatePaymentMethodRequestBody request) { + return this.rawClient.upsertPaymentMethod(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertPaymentMethod( + CreatePaymentMethodRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertPaymentMethod(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture searchBillingPrices() { + return this.rawClient.searchBillingPrices().thenApply(response -> response.body()); + } + + public CompletableFuture searchBillingPrices(SearchBillingPricesRequest request) { + return this.rawClient.searchBillingPrices(request).thenApply(response -> response.body()); + } + + public CompletableFuture searchBillingPrices( + SearchBillingPricesRequest request, RequestOptions requestOptions) { + return this.rawClient.searchBillingPrices(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingPrice(CreateBillingPriceRequestBody request) { + return this.rawClient.upsertBillingPrice(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingPrice( + CreateBillingPriceRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertBillingPrice(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteBillingProduct(String billingId) { + return this.rawClient.deleteBillingProduct(billingId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteBillingProduct( + String billingId, RequestOptions requestOptions) { + return this.rawClient.deleteBillingProduct(billingId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listProductPrices() { + return this.rawClient.listProductPrices().thenApply(response -> response.body()); + } + + public CompletableFuture listProductPrices(ListProductPricesRequest request) { + return this.rawClient.listProductPrices(request).thenApply(response -> response.body()); + } + + public CompletableFuture listProductPrices( + ListProductPricesRequest request, RequestOptions requestOptions) { + return this.rawClient.listProductPrices(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteProductPrice(String billingId) { + return this.rawClient.deleteProductPrice(billingId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteProductPrice( + String billingId, RequestOptions requestOptions) { + return this.rawClient.deleteProductPrice(billingId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingProduct( + CreateBillingProductRequestBody request) { + return this.rawClient.upsertBillingProduct(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingProduct( + CreateBillingProductRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertBillingProduct(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listBillingProducts() { + return this.rawClient.listBillingProducts().thenApply(response -> response.body()); + } + + public CompletableFuture listBillingProducts(ListBillingProductsRequest request) { + return this.rawClient.listBillingProducts(request).thenApply(response -> response.body()); + } + + public CompletableFuture listBillingProducts( + ListBillingProductsRequest request, RequestOptions requestOptions) { + return this.rawClient.listBillingProducts(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countBillingProducts() { + return this.rawClient.countBillingProducts().thenApply(response -> response.body()); + } + + public CompletableFuture countBillingProducts(CountBillingProductsRequest request) { + return this.rawClient.countBillingProducts(request).thenApply(response -> response.body()); + } + + public CompletableFuture countBillingProducts( + CountBillingProductsRequest request, RequestOptions requestOptions) { + return this.rawClient.countBillingProducts(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingSubscription( + CreateBillingSubscriptionRequestBody request) { + return this.rawClient.upsertBillingSubscription(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingSubscription( + CreateBillingSubscriptionRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertBillingSubscription(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java b/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java new file mode 100644 index 0000000..975d9b0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/AsyncRawBillingClient.java @@ -0,0 +1,2142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.billing.requests.CountBillingProductsRequest; +import com.schematic.api.resources.billing.requests.CountCustomersRequest; +import com.schematic.api.resources.billing.requests.CreateBillingCustomerRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingPriceRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingProductRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingSubscriptionRequestBody; +import com.schematic.api.resources.billing.requests.CreateCouponRequestBody; +import com.schematic.api.resources.billing.requests.CreateInvoiceRequestBody; +import com.schematic.api.resources.billing.requests.CreateMeterRequestBody; +import com.schematic.api.resources.billing.requests.CreatePaymentMethodRequestBody; +import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCouponsRequest; +import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; +import com.schematic.api.resources.billing.requests.ListInvoicesRequest; +import com.schematic.api.resources.billing.requests.ListMetersRequest; +import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; +import com.schematic.api.resources.billing.requests.ListProductPricesRequest; +import com.schematic.api.resources.billing.requests.SearchBillingPricesRequest; +import com.schematic.api.resources.billing.types.CountBillingProductsResponse; +import com.schematic.api.resources.billing.types.CountCustomersResponse; +import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; +import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; +import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCouponsResponse; +import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; +import com.schematic.api.resources.billing.types.ListInvoicesResponse; +import com.schematic.api.resources.billing.types.ListMetersResponse; +import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; +import com.schematic.api.resources.billing.types.ListProductPricesResponse; +import com.schematic.api.resources.billing.types.SearchBillingPricesResponse; +import com.schematic.api.resources.billing.types.UpsertBillingCouponResponse; +import com.schematic.api.resources.billing.types.UpsertBillingCustomerResponse; +import com.schematic.api.resources.billing.types.UpsertBillingMeterResponse; +import com.schematic.api.resources.billing.types.UpsertBillingPriceResponse; +import com.schematic.api.resources.billing.types.UpsertBillingProductResponse; +import com.schematic.api.resources.billing.types.UpsertBillingSubscriptionResponse; +import com.schematic.api.resources.billing.types.UpsertInvoiceResponse; +import com.schematic.api.resources.billing.types.UpsertPaymentMethodResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawBillingClient { + protected final ClientOptions clientOptions; + + public AsyncRawBillingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> listCoupons() { + return listCoupons(ListCouponsRequest.builder().build()); + } + + public CompletableFuture> listCoupons(ListCouponsRequest request) { + return listCoupons(request, null); + } + + public CompletableFuture> listCoupons( + ListCouponsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/coupons"); + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCouponsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertBillingCoupon( + CreateCouponRequestBody request) { + return upsertBillingCoupon(request, null); + } + + public CompletableFuture> upsertBillingCoupon( + CreateCouponRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/coupons") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingCouponResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertBillingCustomer( + CreateBillingCustomerRequestBody request) { + return upsertBillingCustomer(request, null); + } + + public CompletableFuture> upsertBillingCustomer( + CreateBillingCustomerRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/customer/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingCustomerResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + listCustomersWithSubscriptions() { + return listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest.builder().build()); + } + + public CompletableFuture> + listCustomersWithSubscriptions(ListCustomersWithSubscriptionsRequest request) { + return listCustomersWithSubscriptions(request, null); + } + + public CompletableFuture> + listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/customers"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getFailedToImport().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "failed_to_import", request.getFailedToImport().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCustomersWithSubscriptionsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countCustomers() { + return countCustomers(CountCustomersRequest.builder().build()); + } + + public CompletableFuture> countCustomers( + CountCustomersRequest request) { + return countCustomers(request, null); + } + + public CompletableFuture> countCustomers( + CountCustomersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/customers/count"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getFailedToImport().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "failed_to_import", request.getFailedToImport().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountCustomersResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listInvoices( + ListInvoicesRequest request) { + return listInvoices(request, null); + } + + public CompletableFuture> listInvoices( + ListInvoicesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/invoices"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "customer_external_id", request.getCustomerExternalId(), false); + QueryStringMapper.addQueryParameter( + httpUrl, "subscription_external_id", request.getSubscriptionExternalId(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListInvoicesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertInvoice( + CreateInvoiceRequestBody request) { + return upsertInvoice(request, null); + } + + public CompletableFuture> upsertInvoice( + CreateInvoiceRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/invoices") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertInvoiceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listMeters() { + return listMeters(ListMetersRequest.builder().build()); + } + + public CompletableFuture> listMeters(ListMetersRequest request) { + return listMeters(request, null); + } + + public CompletableFuture> listMeters( + ListMetersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/meter"); + if (request.getDisplayName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_name", request.getDisplayName().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListMetersResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertBillingMeter( + CreateMeterRequestBody request) { + return upsertBillingMeter(request, null); + } + + public CompletableFuture> upsertBillingMeter( + CreateMeterRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/meter/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingMeterResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listPaymentMethods( + ListPaymentMethodsRequest request) { + return listPaymentMethods(request, null); + } + + public CompletableFuture> listPaymentMethods( + ListPaymentMethodsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/payment-methods"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "customer_external_id", request.getCustomerExternalId(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListPaymentMethodsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertPaymentMethod( + CreatePaymentMethodRequestBody request) { + return upsertPaymentMethod(request, null); + } + + public CompletableFuture> upsertPaymentMethod( + CreatePaymentMethodRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/payment-methods") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertPaymentMethodResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> searchBillingPrices() { + return searchBillingPrices(SearchBillingPricesRequest.builder().build()); + } + + public CompletableFuture> searchBillingPrices( + SearchBillingPricesRequest request) { + return searchBillingPrices(request, null); + } + + public CompletableFuture> searchBillingPrices( + SearchBillingPricesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/price"); + if (request.getForInitialPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_initial_plan", request.getForInitialPlan().get(), false); + } + if (request.getForTrialExpiryPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "for_trial_expiry_plan", + request.getForTrialExpiryPlan().get(), + false); + } + if (request.getProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "product_id", request.getProductId().get(), false); + } + if (request.getInterval().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "interval", request.getInterval().get(), false); + } + if (request.getPrice().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "price", request.getPrice().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequiresPaymentMethod().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "requires_payment_method", + request.getRequiresPaymentMethod().get(), + false); + } + if (request.getTiersMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tiers_mode", request.getTiersMode().get(), false); + } + if (request.getUsageType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "usage_type", request.getUsageType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SearchBillingPricesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertBillingPrice( + CreateBillingPriceRequestBody request) { + return upsertBillingPrice(request, null); + } + + public CompletableFuture> upsertBillingPrice( + CreateBillingPriceRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/price/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingPriceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteBillingProduct( + String billingId) { + return deleteBillingProduct(billingId, null); + } + + public CompletableFuture> deleteBillingProduct( + String billingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/product") + .addPathSegment(billingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteBillingProductResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listProductPrices() { + return listProductPrices(ListProductPricesRequest.builder().build()); + } + + public CompletableFuture> listProductPrices( + ListProductPricesRequest request) { + return listProductPrices(request, null); + } + + public CompletableFuture> listProductPrices( + ListProductPricesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/product/prices"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getPriceUsageType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "price_usage_type", request.getPriceUsageType().get(), false); + } + if (request.getWithoutLinkedToPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_linked_to_plan", + request.getWithoutLinkedToPlan().get(), + false); + } + if (request.getWithOneTimeCharges().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_one_time_charges", + request.getWithOneTimeCharges().get(), + false); + } + if (request.getWithZeroPrice().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_zero_price", request.getWithZeroPrice().get(), false); + } + if (request.getWithPricesOnly().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_prices_only", request.getWithPricesOnly().get(), false); + } + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListProductPricesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteProductPrice( + String billingId) { + return deleteProductPrice(billingId, null); + } + + public CompletableFuture> deleteProductPrice( + String billingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/product/prices") + .addPathSegment(billingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteProductPriceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertBillingProduct( + CreateBillingProductRequestBody request) { + return upsertBillingProduct(request, null); + } + + public CompletableFuture> upsertBillingProduct( + CreateBillingProductRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/product/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingProductResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listBillingProducts() { + return listBillingProducts(ListBillingProductsRequest.builder().build()); + } + + public CompletableFuture> listBillingProducts( + ListBillingProductsRequest request) { + return listBillingProducts(request, null); + } + + public CompletableFuture> listBillingProducts( + ListBillingProductsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/products"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getPriceUsageType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "price_usage_type", request.getPriceUsageType().get(), false); + } + if (request.getWithoutLinkedToPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_linked_to_plan", + request.getWithoutLinkedToPlan().get(), + false); + } + if (request.getWithOneTimeCharges().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_one_time_charges", + request.getWithOneTimeCharges().get(), + false); + } + if (request.getWithZeroPrice().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_zero_price", request.getWithZeroPrice().get(), false); + } + if (request.getWithPricesOnly().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_prices_only", request.getWithPricesOnly().get(), false); + } + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListBillingProductsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countBillingProducts() { + return countBillingProducts(CountBillingProductsRequest.builder().build()); + } + + public CompletableFuture> countBillingProducts( + CountBillingProductsRequest request) { + return countBillingProducts(request, null); + } + + public CompletableFuture> countBillingProducts( + CountBillingProductsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/products/count"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getPriceUsageType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "price_usage_type", request.getPriceUsageType().get(), false); + } + if (request.getWithoutLinkedToPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_linked_to_plan", + request.getWithoutLinkedToPlan().get(), + false); + } + if (request.getWithOneTimeCharges().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_one_time_charges", + request.getWithOneTimeCharges().get(), + false); + } + if (request.getWithZeroPrice().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_zero_price", request.getWithZeroPrice().get(), false); + } + if (request.getWithPricesOnly().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_prices_only", request.getWithPricesOnly().get(), false); + } + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountBillingProductsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertBillingSubscription( + CreateBillingSubscriptionRequestBody request) { + return upsertBillingSubscription(request, null); + } + + public CompletableFuture> upsertBillingSubscription( + CreateBillingSubscriptionRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/subscription/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingSubscriptionResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/BillingClient.java b/src/main/java/com/schematic/api/resources/billing/BillingClient.java index 4f4292b..6fa2651 100644 --- a/src/main/java/com/schematic/api/resources/billing/BillingClient.java +++ b/src/main/java/com/schematic/api/resources/billing/BillingClient.java @@ -3,30 +3,21 @@ */ package com.schematic.api.resources.billing; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.billing.requests.CountBillingProductsRequest; import com.schematic.api.resources.billing.requests.CountCustomersRequest; import com.schematic.api.resources.billing.requests.CreateBillingCustomerRequestBody; import com.schematic.api.resources.billing.requests.CreateBillingPriceRequestBody; import com.schematic.api.resources.billing.requests.CreateBillingProductRequestBody; -import com.schematic.api.resources.billing.requests.CreateBillingSubscriptionsRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingSubscriptionRequestBody; import com.schematic.api.resources.billing.requests.CreateCouponRequestBody; import com.schematic.api.resources.billing.requests.CreateInvoiceRequestBody; import com.schematic.api.resources.billing.requests.CreateMeterRequestBody; import com.schematic.api.resources.billing.requests.CreatePaymentMethodRequestBody; import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; import com.schematic.api.resources.billing.requests.ListCouponsRequest; -import com.schematic.api.resources.billing.requests.ListCustomersRequest; +import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; import com.schematic.api.resources.billing.requests.ListInvoicesRequest; import com.schematic.api.resources.billing.requests.ListMetersRequest; import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; @@ -38,7 +29,7 @@ import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; import com.schematic.api.resources.billing.types.ListBillingProductsResponse; import com.schematic.api.resources.billing.types.ListCouponsResponse; -import com.schematic.api.resources.billing.types.ListCustomersResponse; +import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; import com.schematic.api.resources.billing.types.ListInvoicesResponse; import com.schematic.api.resources.billing.types.ListMetersResponse; import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; @@ -52,1368 +43,229 @@ import com.schematic.api.resources.billing.types.UpsertBillingSubscriptionResponse; import com.schematic.api.resources.billing.types.UpsertInvoiceResponse; import com.schematic.api.resources.billing.types.UpsertPaymentMethodResponse; -import com.schematic.api.types.ApiError; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class BillingClient { protected final ClientOptions clientOptions; + private final RawBillingClient rawClient; + public BillingClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawBillingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawBillingClient withRawResponse() { + return this.rawClient; } public ListCouponsResponse listCoupons() { - return listCoupons(ListCouponsRequest.builder().build()); + return this.rawClient.listCoupons().body(); } public ListCouponsResponse listCoupons(ListCouponsRequest request) { - return listCoupons(request, null); + return this.rawClient.listCoupons(request).body(); } public ListCouponsResponse listCoupons(ListCouponsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/coupons"); - if (request.getIsActive().isPresent()) { - httpUrl.addQueryParameter("is_active", request.getIsActive().get().toString()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCouponsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listCoupons(request, requestOptions).body(); } public UpsertBillingCouponResponse upsertBillingCoupon(CreateCouponRequestBody request) { - return upsertBillingCoupon(request, null); + return this.rawClient.upsertBillingCoupon(request).body(); } public UpsertBillingCouponResponse upsertBillingCoupon( CreateCouponRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/coupons") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingCouponResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertBillingCoupon(request, requestOptions).body(); } public UpsertBillingCustomerResponse upsertBillingCustomer(CreateBillingCustomerRequestBody request) { - return upsertBillingCustomer(request, null); + return this.rawClient.upsertBillingCustomer(request).body(); } public UpsertBillingCustomerResponse upsertBillingCustomer( CreateBillingCustomerRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/customer/upsert") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingCustomerResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertBillingCustomer(request, requestOptions).body(); } - public ListCustomersResponse listCustomers() { - return listCustomers(ListCustomersRequest.builder().build()); + public ListCustomersWithSubscriptionsResponse listCustomersWithSubscriptions() { + return this.rawClient.listCustomersWithSubscriptions().body(); } - public ListCustomersResponse listCustomers(ListCustomersRequest request) { - return listCustomers(request, null); + public ListCustomersWithSubscriptionsResponse listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest request) { + return this.rawClient.listCustomersWithSubscriptions(request).body(); } - public ListCustomersResponse listCustomers(ListCustomersRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/customers"); - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getFailedToImport().isPresent()) { - httpUrl.addQueryParameter( - "failed_to_import", request.getFailedToImport().get().toString()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCustomersResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + public ListCustomersWithSubscriptionsResponse listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest request, RequestOptions requestOptions) { + return this.rawClient + .listCustomersWithSubscriptions(request, requestOptions) + .body(); } public CountCustomersResponse countCustomers() { - return countCustomers(CountCustomersRequest.builder().build()); + return this.rawClient.countCustomers().body(); } public CountCustomersResponse countCustomers(CountCustomersRequest request) { - return countCustomers(request, null); + return this.rawClient.countCustomers(request).body(); } public CountCustomersResponse countCustomers(CountCustomersRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/customers/count"); - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getFailedToImport().isPresent()) { - httpUrl.addQueryParameter( - "failed_to_import", request.getFailedToImport().get().toString()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountCustomersResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.countCustomers(request, requestOptions).body(); } public ListInvoicesResponse listInvoices(ListInvoicesRequest request) { - return listInvoices(request, null); + return this.rawClient.listInvoices(request).body(); } public ListInvoicesResponse listInvoices(ListInvoicesRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/invoices"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - httpUrl.addQueryParameter("customer_external_id", request.getCustomerExternalId()); - if (request.getSubscriptionExternalId().isPresent()) { - httpUrl.addQueryParameter( - "subscription_external_id", - request.getSubscriptionExternalId().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListInvoicesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listInvoices(request, requestOptions).body(); } public UpsertInvoiceResponse upsertInvoice(CreateInvoiceRequestBody request) { - return upsertInvoice(request, null); + return this.rawClient.upsertInvoice(request).body(); } public UpsertInvoiceResponse upsertInvoice(CreateInvoiceRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/invoices") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertInvoiceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertInvoice(request, requestOptions).body(); } public ListMetersResponse listMeters() { - return listMeters(ListMetersRequest.builder().build()); + return this.rawClient.listMeters().body(); } public ListMetersResponse listMeters(ListMetersRequest request) { - return listMeters(request, null); + return this.rawClient.listMeters(request).body(); } public ListMetersResponse listMeters(ListMetersRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/meter"); - if (request.getDisplayName().isPresent()) { - httpUrl.addQueryParameter("display_name", request.getDisplayName().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListMetersResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listMeters(request, requestOptions).body(); } public UpsertBillingMeterResponse upsertBillingMeter(CreateMeterRequestBody request) { - return upsertBillingMeter(request, null); + return this.rawClient.upsertBillingMeter(request).body(); } public UpsertBillingMeterResponse upsertBillingMeter( CreateMeterRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/meter/upsert") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingMeterResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertBillingMeter(request, requestOptions).body(); } public ListPaymentMethodsResponse listPaymentMethods(ListPaymentMethodsRequest request) { - return listPaymentMethods(request, null); + return this.rawClient.listPaymentMethods(request).body(); } public ListPaymentMethodsResponse listPaymentMethods( ListPaymentMethodsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/payment-methods"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - httpUrl.addQueryParameter("customer_external_id", request.getCustomerExternalId()); - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPaymentMethodsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listPaymentMethods(request, requestOptions).body(); } public UpsertPaymentMethodResponse upsertPaymentMethod(CreatePaymentMethodRequestBody request) { - return upsertPaymentMethod(request, null); + return this.rawClient.upsertPaymentMethod(request).body(); } public UpsertPaymentMethodResponse upsertPaymentMethod( CreatePaymentMethodRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/payment-methods") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertPaymentMethodResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertPaymentMethod(request, requestOptions).body(); } public SearchBillingPricesResponse searchBillingPrices() { - return searchBillingPrices(SearchBillingPricesRequest.builder().build()); + return this.rawClient.searchBillingPrices().body(); } public SearchBillingPricesResponse searchBillingPrices(SearchBillingPricesRequest request) { - return searchBillingPrices(request, null); + return this.rawClient.searchBillingPrices(request).body(); } public SearchBillingPricesResponse searchBillingPrices( SearchBillingPricesRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/price"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getInterval().isPresent()) { - httpUrl.addQueryParameter("interval", request.getInterval().get()); - } - if (request.getUsageType().isPresent()) { - httpUrl.addQueryParameter("usage_type", request.getUsageType().get().toString()); - } - if (request.getPrice().isPresent()) { - httpUrl.addQueryParameter("price", request.getPrice().get().toString()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchBillingPricesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.searchBillingPrices(request, requestOptions).body(); } public UpsertBillingPriceResponse upsertBillingPrice(CreateBillingPriceRequestBody request) { - return upsertBillingPrice(request, null); + return this.rawClient.upsertBillingPrice(request).body(); } public UpsertBillingPriceResponse upsertBillingPrice( CreateBillingPriceRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/price/upsert") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingPriceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertBillingPrice(request, requestOptions).body(); } public DeleteBillingProductResponse deleteBillingProduct(String billingId) { - return deleteBillingProduct(billingId, null); + return this.rawClient.deleteBillingProduct(billingId).body(); } public DeleteBillingProductResponse deleteBillingProduct(String billingId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/product") - .addPathSegment(billingId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteBillingProductResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.deleteBillingProduct(billingId, requestOptions).body(); } public ListProductPricesResponse listProductPrices() { - return listProductPrices(ListProductPricesRequest.builder().build()); + return this.rawClient.listProductPrices().body(); } public ListProductPricesResponse listProductPrices(ListProductPricesRequest request) { - return listProductPrices(request, null); + return this.rawClient.listProductPrices(request).body(); } public ListProductPricesResponse listProductPrices( ListProductPricesRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/product/prices"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getPriceUsageType().isPresent()) { - httpUrl.addQueryParameter( - "price_usage_type", request.getPriceUsageType().get().toString()); - } - if (request.getWithoutLinkedToPlan().isPresent()) { - httpUrl.addQueryParameter( - "without_linked_to_plan", - request.getWithoutLinkedToPlan().get().toString()); - } - if (request.getWithZeroPrice().isPresent()) { - httpUrl.addQueryParameter( - "with_zero_price", request.getWithZeroPrice().get().toString()); - } - if (request.getWithPricesOnly().isPresent()) { - httpUrl.addQueryParameter( - "with_prices_only", request.getWithPricesOnly().get().toString()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListProductPricesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listProductPrices(request, requestOptions).body(); } public DeleteProductPriceResponse deleteProductPrice(String billingId) { - return deleteProductPrice(billingId, null); + return this.rawClient.deleteProductPrice(billingId).body(); } public DeleteProductPriceResponse deleteProductPrice(String billingId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/product/prices") - .addPathSegment(billingId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteProductPriceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.deleteProductPrice(billingId, requestOptions).body(); } public UpsertBillingProductResponse upsertBillingProduct(CreateBillingProductRequestBody request) { - return upsertBillingProduct(request, null); + return this.rawClient.upsertBillingProduct(request).body(); } public UpsertBillingProductResponse upsertBillingProduct( CreateBillingProductRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/product/upsert") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingProductResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertBillingProduct(request, requestOptions).body(); } public ListBillingProductsResponse listBillingProducts() { - return listBillingProducts(ListBillingProductsRequest.builder().build()); + return this.rawClient.listBillingProducts().body(); } public ListBillingProductsResponse listBillingProducts(ListBillingProductsRequest request) { - return listBillingProducts(request, null); + return this.rawClient.listBillingProducts(request).body(); } public ListBillingProductsResponse listBillingProducts( ListBillingProductsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/products"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getPriceUsageType().isPresent()) { - httpUrl.addQueryParameter( - "price_usage_type", request.getPriceUsageType().get().toString()); - } - if (request.getWithoutLinkedToPlan().isPresent()) { - httpUrl.addQueryParameter( - "without_linked_to_plan", - request.getWithoutLinkedToPlan().get().toString()); - } - if (request.getWithZeroPrice().isPresent()) { - httpUrl.addQueryParameter( - "with_zero_price", request.getWithZeroPrice().get().toString()); - } - if (request.getWithPricesOnly().isPresent()) { - httpUrl.addQueryParameter( - "with_prices_only", request.getWithPricesOnly().get().toString()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListBillingProductsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listBillingProducts(request, requestOptions).body(); } public CountBillingProductsResponse countBillingProducts() { - return countBillingProducts(CountBillingProductsRequest.builder().build()); + return this.rawClient.countBillingProducts().body(); } public CountBillingProductsResponse countBillingProducts(CountBillingProductsRequest request) { - return countBillingProducts(request, null); + return this.rawClient.countBillingProducts(request).body(); } public CountBillingProductsResponse countBillingProducts( CountBillingProductsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/products/count"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getPriceUsageType().isPresent()) { - httpUrl.addQueryParameter( - "price_usage_type", request.getPriceUsageType().get().toString()); - } - if (request.getWithoutLinkedToPlan().isPresent()) { - httpUrl.addQueryParameter( - "without_linked_to_plan", - request.getWithoutLinkedToPlan().get().toString()); - } - if (request.getWithZeroPrice().isPresent()) { - httpUrl.addQueryParameter( - "with_zero_price", request.getWithZeroPrice().get().toString()); - } - if (request.getWithPricesOnly().isPresent()) { - httpUrl.addQueryParameter( - "with_prices_only", request.getWithPricesOnly().get().toString()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountBillingProductsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.countBillingProducts(request, requestOptions).body(); } - public UpsertBillingSubscriptionResponse upsertBillingSubscription(CreateBillingSubscriptionsRequestBody request) { - return upsertBillingSubscription(request, null); + public UpsertBillingSubscriptionResponse upsertBillingSubscription(CreateBillingSubscriptionRequestBody request) { + return this.rawClient.upsertBillingSubscription(request).body(); } public UpsertBillingSubscriptionResponse upsertBillingSubscription( - CreateBillingSubscriptionsRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("billing/subscription/upsert") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), UpsertBillingSubscriptionResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + CreateBillingSubscriptionRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertBillingSubscription(request, requestOptions).body(); } } diff --git a/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java b/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java new file mode 100644 index 0000000..bc7a7f0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/RawBillingClient.java @@ -0,0 +1,1650 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.billing.requests.CountBillingProductsRequest; +import com.schematic.api.resources.billing.requests.CountCustomersRequest; +import com.schematic.api.resources.billing.requests.CreateBillingCustomerRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingPriceRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingProductRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingSubscriptionRequestBody; +import com.schematic.api.resources.billing.requests.CreateCouponRequestBody; +import com.schematic.api.resources.billing.requests.CreateInvoiceRequestBody; +import com.schematic.api.resources.billing.requests.CreateMeterRequestBody; +import com.schematic.api.resources.billing.requests.CreatePaymentMethodRequestBody; +import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCouponsRequest; +import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; +import com.schematic.api.resources.billing.requests.ListInvoicesRequest; +import com.schematic.api.resources.billing.requests.ListMetersRequest; +import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; +import com.schematic.api.resources.billing.requests.ListProductPricesRequest; +import com.schematic.api.resources.billing.requests.SearchBillingPricesRequest; +import com.schematic.api.resources.billing.types.CountBillingProductsResponse; +import com.schematic.api.resources.billing.types.CountCustomersResponse; +import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; +import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; +import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCouponsResponse; +import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; +import com.schematic.api.resources.billing.types.ListInvoicesResponse; +import com.schematic.api.resources.billing.types.ListMetersResponse; +import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; +import com.schematic.api.resources.billing.types.ListProductPricesResponse; +import com.schematic.api.resources.billing.types.SearchBillingPricesResponse; +import com.schematic.api.resources.billing.types.UpsertBillingCouponResponse; +import com.schematic.api.resources.billing.types.UpsertBillingCustomerResponse; +import com.schematic.api.resources.billing.types.UpsertBillingMeterResponse; +import com.schematic.api.resources.billing.types.UpsertBillingPriceResponse; +import com.schematic.api.resources.billing.types.UpsertBillingProductResponse; +import com.schematic.api.resources.billing.types.UpsertBillingSubscriptionResponse; +import com.schematic.api.resources.billing.types.UpsertInvoiceResponse; +import com.schematic.api.resources.billing.types.UpsertPaymentMethodResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawBillingClient { + protected final ClientOptions clientOptions; + + public RawBillingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse listCoupons() { + return listCoupons(ListCouponsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCoupons(ListCouponsRequest request) { + return listCoupons(request, null); + } + + public BaseSchematicHttpResponse listCoupons( + ListCouponsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/coupons"); + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCouponsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertBillingCoupon(CreateCouponRequestBody request) { + return upsertBillingCoupon(request, null); + } + + public BaseSchematicHttpResponse upsertBillingCoupon( + CreateCouponRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/coupons") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingCouponResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertBillingCustomer( + CreateBillingCustomerRequestBody request) { + return upsertBillingCustomer(request, null); + } + + public BaseSchematicHttpResponse upsertBillingCustomer( + CreateBillingCustomerRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/customer/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingCustomerResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listCustomersWithSubscriptions() { + return listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest request) { + return listCustomersWithSubscriptions(request, null); + } + + public BaseSchematicHttpResponse listCustomersWithSubscriptions( + ListCustomersWithSubscriptionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/customers"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getFailedToImport().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "failed_to_import", request.getFailedToImport().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCustomersWithSubscriptionsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countCustomers() { + return countCustomers(CountCustomersRequest.builder().build()); + } + + public BaseSchematicHttpResponse countCustomers(CountCustomersRequest request) { + return countCustomers(request, null); + } + + public BaseSchematicHttpResponse countCustomers( + CountCustomersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/customers/count"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getFailedToImport().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "failed_to_import", request.getFailedToImport().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountCustomersResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listInvoices(ListInvoicesRequest request) { + return listInvoices(request, null); + } + + public BaseSchematicHttpResponse listInvoices( + ListInvoicesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/invoices"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "customer_external_id", request.getCustomerExternalId(), false); + QueryStringMapper.addQueryParameter( + httpUrl, "subscription_external_id", request.getSubscriptionExternalId(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListInvoicesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertInvoice(CreateInvoiceRequestBody request) { + return upsertInvoice(request, null); + } + + public BaseSchematicHttpResponse upsertInvoice( + CreateInvoiceRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/invoices") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertInvoiceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listMeters() { + return listMeters(ListMetersRequest.builder().build()); + } + + public BaseSchematicHttpResponse listMeters(ListMetersRequest request) { + return listMeters(request, null); + } + + public BaseSchematicHttpResponse listMeters( + ListMetersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/meter"); + if (request.getDisplayName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_name", request.getDisplayName().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListMetersResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertBillingMeter(CreateMeterRequestBody request) { + return upsertBillingMeter(request, null); + } + + public BaseSchematicHttpResponse upsertBillingMeter( + CreateMeterRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/meter/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingMeterResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listPaymentMethods(ListPaymentMethodsRequest request) { + return listPaymentMethods(request, null); + } + + public BaseSchematicHttpResponse listPaymentMethods( + ListPaymentMethodsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/payment-methods"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "customer_external_id", request.getCustomerExternalId(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPaymentMethodsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertPaymentMethod( + CreatePaymentMethodRequestBody request) { + return upsertPaymentMethod(request, null); + } + + public BaseSchematicHttpResponse upsertPaymentMethod( + CreatePaymentMethodRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/payment-methods") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertPaymentMethodResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse searchBillingPrices() { + return searchBillingPrices(SearchBillingPricesRequest.builder().build()); + } + + public BaseSchematicHttpResponse searchBillingPrices( + SearchBillingPricesRequest request) { + return searchBillingPrices(request, null); + } + + public BaseSchematicHttpResponse searchBillingPrices( + SearchBillingPricesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/price"); + if (request.getForInitialPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_initial_plan", request.getForInitialPlan().get(), false); + } + if (request.getForTrialExpiryPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "for_trial_expiry_plan", + request.getForTrialExpiryPlan().get(), + false); + } + if (request.getProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "product_id", request.getProductId().get(), false); + } + if (request.getInterval().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "interval", request.getInterval().get(), false); + } + if (request.getPrice().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "price", request.getPrice().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequiresPaymentMethod().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "requires_payment_method", + request.getRequiresPaymentMethod().get(), + false); + } + if (request.getTiersMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tiers_mode", request.getTiersMode().get(), false); + } + if (request.getUsageType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "usage_type", request.getUsageType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchBillingPricesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertBillingPrice( + CreateBillingPriceRequestBody request) { + return upsertBillingPrice(request, null); + } + + public BaseSchematicHttpResponse upsertBillingPrice( + CreateBillingPriceRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/price/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingPriceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteBillingProduct(String billingId) { + return deleteBillingProduct(billingId, null); + } + + public BaseSchematicHttpResponse deleteBillingProduct( + String billingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/product") + .addPathSegment(billingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteBillingProductResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listProductPrices() { + return listProductPrices(ListProductPricesRequest.builder().build()); + } + + public BaseSchematicHttpResponse listProductPrices(ListProductPricesRequest request) { + return listProductPrices(request, null); + } + + public BaseSchematicHttpResponse listProductPrices( + ListProductPricesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/product/prices"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getPriceUsageType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "price_usage_type", request.getPriceUsageType().get(), false); + } + if (request.getWithoutLinkedToPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_linked_to_plan", + request.getWithoutLinkedToPlan().get(), + false); + } + if (request.getWithOneTimeCharges().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_one_time_charges", + request.getWithOneTimeCharges().get(), + false); + } + if (request.getWithZeroPrice().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_zero_price", request.getWithZeroPrice().get(), false); + } + if (request.getWithPricesOnly().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_prices_only", request.getWithPricesOnly().get(), false); + } + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListProductPricesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteProductPrice(String billingId) { + return deleteProductPrice(billingId, null); + } + + public BaseSchematicHttpResponse deleteProductPrice( + String billingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/product/prices") + .addPathSegment(billingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteProductPriceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertBillingProduct( + CreateBillingProductRequestBody request) { + return upsertBillingProduct(request, null); + } + + public BaseSchematicHttpResponse upsertBillingProduct( + CreateBillingProductRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/product/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertBillingProductResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listBillingProducts() { + return listBillingProducts(ListBillingProductsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listBillingProducts( + ListBillingProductsRequest request) { + return listBillingProducts(request, null); + } + + public BaseSchematicHttpResponse listBillingProducts( + ListBillingProductsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/products"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getPriceUsageType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "price_usage_type", request.getPriceUsageType().get(), false); + } + if (request.getWithoutLinkedToPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_linked_to_plan", + request.getWithoutLinkedToPlan().get(), + false); + } + if (request.getWithOneTimeCharges().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_one_time_charges", + request.getWithOneTimeCharges().get(), + false); + } + if (request.getWithZeroPrice().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_zero_price", request.getWithZeroPrice().get(), false); + } + if (request.getWithPricesOnly().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_prices_only", request.getWithPricesOnly().get(), false); + } + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListBillingProductsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countBillingProducts() { + return countBillingProducts(CountBillingProductsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countBillingProducts( + CountBillingProductsRequest request) { + return countBillingProducts(request, null); + } + + public BaseSchematicHttpResponse countBillingProducts( + CountBillingProductsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/products/count"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getPriceUsageType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "price_usage_type", request.getPriceUsageType().get(), false); + } + if (request.getWithoutLinkedToPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_linked_to_plan", + request.getWithoutLinkedToPlan().get(), + false); + } + if (request.getWithOneTimeCharges().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_one_time_charges", + request.getWithOneTimeCharges().get(), + false); + } + if (request.getWithZeroPrice().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_zero_price", request.getWithZeroPrice().get(), false); + } + if (request.getWithPricesOnly().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_prices_only", request.getWithPricesOnly().get(), false); + } + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountBillingProductsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertBillingSubscription( + CreateBillingSubscriptionRequestBody request) { + return upsertBillingSubscription(request, null); + } + + public BaseSchematicHttpResponse upsertBillingSubscription( + CreateBillingSubscriptionRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/subscription/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingSubscriptionResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/requests/CountBillingProductsRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/CountBillingProductsRequest.java index 978a21a..69ff4f0 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/CountBillingProductsRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/CountBillingProductsRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.billing.types.CountBillingProductsRequestPriceUsageType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,7 +23,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountBillingProductsRequest.Builder.class) public final class CountBillingProductsRequest { - private final Optional ids; + private final Optional> ids; private final Optional name; @@ -31,10 +33,14 @@ public final class CountBillingProductsRequest { private final Optional withoutLinkedToPlan; + private final Optional withOneTimeCharges; + private final Optional withZeroPrice; private final Optional withPricesOnly; + private final Optional isActive; + private final Optional limit; private final Optional offset; @@ -42,13 +48,15 @@ public final class CountBillingProductsRequest { private final Map additionalProperties; private CountBillingProductsRequest( - Optional ids, + Optional> ids, Optional name, Optional q, Optional priceUsageType, Optional withoutLinkedToPlan, + Optional withOneTimeCharges, Optional withZeroPrice, Optional withPricesOnly, + Optional isActive, Optional limit, Optional offset, Map additionalProperties) { @@ -57,15 +65,17 @@ private CountBillingProductsRequest( this.q = q; this.priceUsageType = priceUsageType; this.withoutLinkedToPlan = withoutLinkedToPlan; + this.withOneTimeCharges = withOneTimeCharges; this.withZeroPrice = withZeroPrice; this.withPricesOnly = withPricesOnly; + this.isActive = isActive; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -92,6 +102,14 @@ public Optional getWithoutLinkedToPlan() { return withoutLinkedToPlan; } + /** + * @return Filter products that are one time charges + */ + @JsonProperty("with_one_time_charges") + public Optional getWithOneTimeCharges() { + return withOneTimeCharges; + } + /** * @return Filter products that have zero price for free subscription type */ @@ -108,6 +126,14 @@ public Optional getWithPricesOnly() { return withPricesOnly; } + /** + * @return Filter products that are active + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + /** * @return Page limit (default 100) */ @@ -141,8 +167,10 @@ private boolean equalTo(CountBillingProductsRequest other) { && q.equals(other.q) && priceUsageType.equals(other.priceUsageType) && withoutLinkedToPlan.equals(other.withoutLinkedToPlan) + && withOneTimeCharges.equals(other.withOneTimeCharges) && withZeroPrice.equals(other.withZeroPrice) && withPricesOnly.equals(other.withPricesOnly) + && isActive.equals(other.isActive) && limit.equals(other.limit) && offset.equals(other.offset); } @@ -155,8 +183,10 @@ public int hashCode() { this.q, this.priceUsageType, this.withoutLinkedToPlan, + this.withOneTimeCharges, this.withZeroPrice, this.withPricesOnly, + this.isActive, this.limit, this.offset); } @@ -172,7 +202,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional name = Optional.empty(); @@ -182,10 +212,14 @@ public static final class Builder { private Optional withoutLinkedToPlan = Optional.empty(); + private Optional withOneTimeCharges = Optional.empty(); + private Optional withZeroPrice = Optional.empty(); private Optional withPricesOnly = Optional.empty(); + private Optional isActive = Optional.empty(); + private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); @@ -201,24 +235,31 @@ public Builder from(CountBillingProductsRequest other) { q(other.getQ()); priceUsageType(other.getPriceUsageType()); withoutLinkedToPlan(other.getWithoutLinkedToPlan()); + withOneTimeCharges(other.getWithOneTimeCharges()); withZeroPrice(other.getWithZeroPrice()); withPricesOnly(other.getWithPricesOnly()); + isActive(other.getIsActive()); limit(other.getLimit()); offset(other.getOffset()); return this; } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -252,6 +293,9 @@ public Builder priceUsageType(CountBillingProductsRequestPriceUsageType priceUsa return this; } + /** + *

Filter products that are not linked to any plan

+ */ @JsonSetter(value = "without_linked_to_plan", nulls = Nulls.SKIP) public Builder withoutLinkedToPlan(Optional withoutLinkedToPlan) { this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -263,6 +307,23 @@ public Builder withoutLinkedToPlan(Boolean withoutLinkedToPlan) { return this; } + /** + *

Filter products that are one time charges

+ */ + @JsonSetter(value = "with_one_time_charges", nulls = Nulls.SKIP) + public Builder withOneTimeCharges(Optional withOneTimeCharges) { + this.withOneTimeCharges = withOneTimeCharges; + return this; + } + + public Builder withOneTimeCharges(Boolean withOneTimeCharges) { + this.withOneTimeCharges = Optional.ofNullable(withOneTimeCharges); + return this; + } + + /** + *

Filter products that have zero price for free subscription type

+ */ @JsonSetter(value = "with_zero_price", nulls = Nulls.SKIP) public Builder withZeroPrice(Optional withZeroPrice) { this.withZeroPrice = withZeroPrice; @@ -274,6 +335,9 @@ public Builder withZeroPrice(Boolean withZeroPrice) { return this; } + /** + *

Filter products that have prices

+ */ @JsonSetter(value = "with_prices_only", nulls = Nulls.SKIP) public Builder withPricesOnly(Optional withPricesOnly) { this.withPricesOnly = withPricesOnly; @@ -285,6 +349,23 @@ public Builder withPricesOnly(Boolean withPricesOnly) { return this; } + /** + *

Filter products that are active

+ */ + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -296,6 +377,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -314,8 +398,10 @@ public CountBillingProductsRequest build() { q, priceUsageType, withoutLinkedToPlan, + withOneTimeCharges, withZeroPrice, withPricesOnly, + isActive, limit, offset, additionalProperties); diff --git a/src/main/java/com/schematic/api/resources/billing/requests/CountCustomersRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/CountCustomersRequest.java index 47f01dc..f786a79 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/CountCustomersRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/CountCustomersRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,6 +22,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountCustomersRequest.Builder.class) public final class CountCustomersRequest { + private final Optional> companyIds; + private final Optional name; private final Optional failedToImport; @@ -33,12 +37,14 @@ public final class CountCustomersRequest { private final Map additionalProperties; private CountCustomersRequest( + Optional> companyIds, Optional name, Optional failedToImport, Optional q, Optional limit, Optional offset, Map additionalProperties) { + this.companyIds = companyIds; this.name = name; this.failedToImport = failedToImport; this.q = q; @@ -47,6 +53,11 @@ private CountCustomersRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + @JsonProperty("name") public Optional getName() { return name; @@ -90,7 +101,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountCustomersRequest other) { - return name.equals(other.name) + return companyIds.equals(other.companyIds) + && name.equals(other.name) && failedToImport.equals(other.failedToImport) && q.equals(other.q) && limit.equals(other.limit) @@ -99,7 +111,7 @@ private boolean equalTo(CountCustomersRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.name, this.failedToImport, this.q, this.limit, this.offset); + return Objects.hash(this.companyIds, this.name, this.failedToImport, this.q, this.limit, this.offset); } @java.lang.Override @@ -113,6 +125,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> companyIds = Optional.empty(); + private Optional name = Optional.empty(); private Optional failedToImport = Optional.empty(); @@ -129,6 +143,7 @@ public static final class Builder { private Builder() {} public Builder from(CountCustomersRequest other) { + companyIds(other.getCompanyIds()); name(other.getName()); failedToImport(other.getFailedToImport()); q(other.getQ()); @@ -137,6 +152,22 @@ public Builder from(CountCustomersRequest other) { return this; } + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; + return this; + } + + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); + return this; + } + + public Builder companyIds(String companyIds) { + this.companyIds = Optional.of(Collections.singletonList(companyIds)); + return this; + } + @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -170,6 +201,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -181,6 +215,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -193,7 +230,7 @@ public Builder offset(Integer offset) { } public CountCustomersRequest build() { - return new CountCustomersRequest(name, failedToImport, q, limit, offset, additionalProperties); + return new CountCustomersRequest(companyIds, name, failedToImport, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingCustomerRequestBody.java b/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingCustomerRequestBody.java index 94a420f..8c34ad6 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingCustomerRequestBody.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingCustomerRequestBody.java @@ -240,7 +240,9 @@ public _FinalStage meta(String key, String value) { @java.lang.Override public _FinalStage putAllMeta(Map meta) { - this.meta.putAll(meta); + if (meta != null) { + this.meta.putAll(meta); + } return this; } @@ -248,7 +250,9 @@ public _FinalStage putAllMeta(Map meta) { @JsonSetter(value = "meta", nulls = Nulls.SKIP) public _FinalStage meta(Map meta) { this.meta.clear(); - this.meta.putAll(meta); + if (meta != null) { + this.meta.putAll(meta); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingPriceRequestBody.java b/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingPriceRequestBody.java index 5c59b94..a9212ba 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingPriceRequestBody.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingPriceRequestBody.java @@ -12,7 +12,8 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import com.schematic.api.resources.billing.types.CreateBillingPriceRequestBodyTierMode; +import com.schematic.api.resources.billing.types.CreateBillingPriceRequestBodyBillingScheme; +import com.schematic.api.resources.billing.types.CreateBillingPriceRequestBodyTiersMode; import com.schematic.api.resources.billing.types.CreateBillingPriceRequestBodyUsageType; import com.schematic.api.types.CreateBillingPriceTierRequestBody; import java.util.ArrayList; @@ -26,6 +27,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreateBillingPriceRequestBody.Builder.class) public final class CreateBillingPriceRequestBody { + private final CreateBillingPriceRequestBodyBillingScheme billingScheme; + private final String currency; private final String externalAccountId; @@ -36,47 +39,62 @@ public final class CreateBillingPriceRequestBody { private final Optional meterId; + private final Optional packageSize; + private final int price; + private final Optional priceDecimal; + private final String priceExternalId; private final List priceTiers; private final String productExternalId; - private final Optional tierMode; + private final Optional tiersMode; private final CreateBillingPriceRequestBodyUsageType usageType; private final Map additionalProperties; private CreateBillingPriceRequestBody( + CreateBillingPriceRequestBodyBillingScheme billingScheme, String currency, String externalAccountId, String interval, boolean isActive, Optional meterId, + Optional packageSize, int price, + Optional priceDecimal, String priceExternalId, List priceTiers, String productExternalId, - Optional tierMode, + Optional tiersMode, CreateBillingPriceRequestBodyUsageType usageType, Map additionalProperties) { + this.billingScheme = billingScheme; this.currency = currency; this.externalAccountId = externalAccountId; this.interval = interval; this.isActive = isActive; this.meterId = meterId; + this.packageSize = packageSize; this.price = price; + this.priceDecimal = priceDecimal; this.priceExternalId = priceExternalId; this.priceTiers = priceTiers; this.productExternalId = productExternalId; - this.tierMode = tierMode; + this.tiersMode = tiersMode; this.usageType = usageType; this.additionalProperties = additionalProperties; } + @JsonProperty("billing_scheme") + public CreateBillingPriceRequestBodyBillingScheme getBillingScheme() { + return billingScheme; + } + @JsonProperty("currency") public String getCurrency() { return currency; @@ -102,11 +120,21 @@ public Optional getMeterId() { return meterId; } + @JsonProperty("package_size") + public Optional getPackageSize() { + return packageSize; + } + @JsonProperty("price") public int getPrice() { return price; } + @JsonProperty("price_decimal") + public Optional getPriceDecimal() { + return priceDecimal; + } + @JsonProperty("price_external_id") public String getPriceExternalId() { return priceExternalId; @@ -122,9 +150,9 @@ public String getProductExternalId() { return productExternalId; } - @JsonProperty("tier_mode") - public Optional getTierMode() { - return tierMode; + @JsonProperty("tiers_mode") + public Optional getTiersMode() { + return tiersMode; } @JsonProperty("usage_type") @@ -144,32 +172,38 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateBillingPriceRequestBody other) { - return currency.equals(other.currency) + return billingScheme.equals(other.billingScheme) + && currency.equals(other.currency) && externalAccountId.equals(other.externalAccountId) && interval.equals(other.interval) && isActive == other.isActive && meterId.equals(other.meterId) + && packageSize.equals(other.packageSize) && price == other.price + && priceDecimal.equals(other.priceDecimal) && priceExternalId.equals(other.priceExternalId) && priceTiers.equals(other.priceTiers) && productExternalId.equals(other.productExternalId) - && tierMode.equals(other.tierMode) + && tiersMode.equals(other.tiersMode) && usageType.equals(other.usageType); } @java.lang.Override public int hashCode() { return Objects.hash( + this.billingScheme, this.currency, this.externalAccountId, this.interval, this.isActive, this.meterId, + this.packageSize, this.price, + this.priceDecimal, this.priceExternalId, this.priceTiers, this.productExternalId, - this.tierMode, + this.tiersMode, this.usageType); } @@ -178,16 +212,20 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CurrencyStage builder() { + public static BillingSchemeStage builder() { return new Builder(); } - public interface CurrencyStage { - ExternalAccountIdStage currency(@NotNull String currency); + public interface BillingSchemeStage { + CurrencyStage billingScheme(@NotNull CreateBillingPriceRequestBodyBillingScheme billingScheme); Builder from(CreateBillingPriceRequestBody other); } + public interface CurrencyStage { + ExternalAccountIdStage currency(@NotNull String currency); + } + public interface ExternalAccountIdStage { IntervalStage externalAccountId(@NotNull String externalAccountId); } @@ -223,20 +261,29 @@ public interface _FinalStage { _FinalStage meterId(String meterId); + _FinalStage packageSize(Optional packageSize); + + _FinalStage packageSize(Integer packageSize); + + _FinalStage priceDecimal(Optional priceDecimal); + + _FinalStage priceDecimal(String priceDecimal); + _FinalStage priceTiers(List priceTiers); _FinalStage addPriceTiers(CreateBillingPriceTierRequestBody priceTiers); _FinalStage addAllPriceTiers(List priceTiers); - _FinalStage tierMode(Optional tierMode); + _FinalStage tiersMode(Optional tiersMode); - _FinalStage tierMode(CreateBillingPriceRequestBodyTierMode tierMode); + _FinalStage tiersMode(CreateBillingPriceRequestBodyTiersMode tiersMode); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CurrencyStage, + implements BillingSchemeStage, + CurrencyStage, ExternalAccountIdStage, IntervalStage, IsActiveStage, @@ -245,6 +292,8 @@ public static final class Builder ProductExternalIdStage, UsageTypeStage, _FinalStage { + private CreateBillingPriceRequestBodyBillingScheme billingScheme; + private String currency; private String externalAccountId; @@ -261,10 +310,14 @@ public static final class Builder private CreateBillingPriceRequestBodyUsageType usageType; - private Optional tierMode = Optional.empty(); + private Optional tiersMode = Optional.empty(); private List priceTiers = new ArrayList<>(); + private Optional priceDecimal = Optional.empty(); + + private Optional packageSize = Optional.empty(); + private Optional meterId = Optional.empty(); @JsonAnySetter @@ -274,20 +327,30 @@ private Builder() {} @java.lang.Override public Builder from(CreateBillingPriceRequestBody other) { + billingScheme(other.getBillingScheme()); currency(other.getCurrency()); externalAccountId(other.getExternalAccountId()); interval(other.getInterval()); isActive(other.getIsActive()); meterId(other.getMeterId()); + packageSize(other.getPackageSize()); price(other.getPrice()); + priceDecimal(other.getPriceDecimal()); priceExternalId(other.getPriceExternalId()); priceTiers(other.getPriceTiers()); productExternalId(other.getProductExternalId()); - tierMode(other.getTierMode()); + tiersMode(other.getTiersMode()); usageType(other.getUsageType()); return this; } + @java.lang.Override + @JsonSetter("billing_scheme") + public CurrencyStage billingScheme(@NotNull CreateBillingPriceRequestBodyBillingScheme billingScheme) { + this.billingScheme = Objects.requireNonNull(billingScheme, "billingScheme must not be null"); + return this; + } + @java.lang.Override @JsonSetter("currency") public ExternalAccountIdStage currency(@NotNull String currency) { @@ -345,21 +408,23 @@ public _FinalStage usageType(@NotNull CreateBillingPriceRequestBodyUsageType usa } @java.lang.Override - public _FinalStage tierMode(CreateBillingPriceRequestBodyTierMode tierMode) { - this.tierMode = Optional.ofNullable(tierMode); + public _FinalStage tiersMode(CreateBillingPriceRequestBodyTiersMode tiersMode) { + this.tiersMode = Optional.ofNullable(tiersMode); return this; } @java.lang.Override - @JsonSetter(value = "tier_mode", nulls = Nulls.SKIP) - public _FinalStage tierMode(Optional tierMode) { - this.tierMode = tierMode; + @JsonSetter(value = "tiers_mode", nulls = Nulls.SKIP) + public _FinalStage tiersMode(Optional tiersMode) { + this.tiersMode = tiersMode; return this; } @java.lang.Override public _FinalStage addAllPriceTiers(List priceTiers) { - this.priceTiers.addAll(priceTiers); + if (priceTiers != null) { + this.priceTiers.addAll(priceTiers); + } return this; } @@ -373,7 +438,35 @@ public _FinalStage addPriceTiers(CreateBillingPriceTierRequestBody priceTiers) { @JsonSetter(value = "price_tiers", nulls = Nulls.SKIP) public _FinalStage priceTiers(List priceTiers) { this.priceTiers.clear(); - this.priceTiers.addAll(priceTiers); + if (priceTiers != null) { + this.priceTiers.addAll(priceTiers); + } + return this; + } + + @java.lang.Override + public _FinalStage priceDecimal(String priceDecimal) { + this.priceDecimal = Optional.ofNullable(priceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_decimal", nulls = Nulls.SKIP) + public _FinalStage priceDecimal(Optional priceDecimal) { + this.priceDecimal = priceDecimal; + return this; + } + + @java.lang.Override + public _FinalStage packageSize(Integer packageSize) { + this.packageSize = Optional.ofNullable(packageSize); + return this; + } + + @java.lang.Override + @JsonSetter(value = "package_size", nulls = Nulls.SKIP) + public _FinalStage packageSize(Optional packageSize) { + this.packageSize = packageSize; return this; } @@ -393,16 +486,19 @@ public _FinalStage meterId(Optional meterId) { @java.lang.Override public CreateBillingPriceRequestBody build() { return new CreateBillingPriceRequestBody( + billingScheme, currency, externalAccountId, interval, isActive, meterId, + packageSize, price, + priceDecimal, priceExternalId, priceTiers, productExternalId, - tierMode, + tiersMode, usageType, additionalProperties); } diff --git a/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingProductRequestBody.java b/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingProductRequestBody.java index 4dbf0f7..ea226ec 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingProductRequestBody.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingProductRequestBody.java @@ -9,62 +9,51 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreateBillingProductRequestBody.Builder.class) public final class CreateBillingProductRequestBody { - private final boolean active; - - private final String currency; - private final String externalId; + private final Optional isActive; + private final String name; private final double price; - private final int quantity; - private final Map additionalProperties; private CreateBillingProductRequestBody( - boolean active, - String currency, String externalId, + Optional isActive, String name, double price, - int quantity, Map additionalProperties) { - this.active = active; - this.currency = currency; this.externalId = externalId; + this.isActive = isActive; this.name = name; this.price = price; - this.quantity = quantity; this.additionalProperties = additionalProperties; } - @JsonProperty("active") - public boolean getActive() { - return active; - } - - @JsonProperty("currency") - public String getCurrency() { - return currency; - } - @JsonProperty("external_id") public String getExternalId() { return externalId; } + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + @JsonProperty("name") public String getName() { return name; @@ -75,11 +64,6 @@ public double getPrice() { return price; } - @JsonProperty("quantity") - public int getQuantity() { - return quantity; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -92,17 +76,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateBillingProductRequestBody other) { - return active == other.active - && currency.equals(other.currency) - && externalId.equals(other.externalId) + return externalId.equals(other.externalId) + && isActive.equals(other.isActive) && name.equals(other.name) - && price == other.price - && quantity == other.quantity; + && price == other.price; } @java.lang.Override public int hashCode() { - return Objects.hash(this.active, this.currency, this.externalId, this.name, this.price, this.quantity); + return Objects.hash(this.externalId, this.isActive, this.name, this.price); } @java.lang.Override @@ -110,22 +92,14 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ActiveStage builder() { + public static ExternalIdStage builder() { return new Builder(); } - public interface ActiveStage { - CurrencyStage active(boolean active); - - Builder from(CreateBillingProductRequestBody other); - } - - public interface CurrencyStage { - ExternalIdStage currency(@NotNull String currency); - } - public interface ExternalIdStage { NameStage externalId(@NotNull String externalId); + + Builder from(CreateBillingProductRequestBody other); } public interface NameStage { @@ -133,31 +107,26 @@ public interface NameStage { } public interface PriceStage { - QuantityStage price(double price); - } - - public interface QuantityStage { - _FinalStage quantity(int quantity); + _FinalStage price(double price); } public interface _FinalStage { CreateBillingProductRequestBody build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements ActiveStage, CurrencyStage, ExternalIdStage, NameStage, PriceStage, QuantityStage, _FinalStage { - private boolean active; + _FinalStage isActive(Optional isActive); - private String currency; + _FinalStage isActive(Boolean isActive); + } + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ExternalIdStage, NameStage, PriceStage, _FinalStage { private String externalId; private String name; private double price; - private int quantity; + private Optional isActive = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -166,26 +135,10 @@ private Builder() {} @java.lang.Override public Builder from(CreateBillingProductRequestBody other) { - active(other.getActive()); - currency(other.getCurrency()); externalId(other.getExternalId()); + isActive(other.getIsActive()); name(other.getName()); price(other.getPrice()); - quantity(other.getQuantity()); - return this; - } - - @java.lang.Override - @JsonSetter("active") - public CurrencyStage active(boolean active) { - this.active = active; - return this; - } - - @java.lang.Override - @JsonSetter("currency") - public ExternalIdStage currency(@NotNull String currency) { - this.currency = Objects.requireNonNull(currency, "currency must not be null"); return this; } @@ -205,22 +158,27 @@ public PriceStage name(@NotNull String name) { @java.lang.Override @JsonSetter("price") - public QuantityStage price(double price) { + public _FinalStage price(double price) { this.price = price; return this; } @java.lang.Override - @JsonSetter("quantity") - public _FinalStage quantity(int quantity) { - this.quantity = quantity; + public _FinalStage isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public _FinalStage isActive(Optional isActive) { + this.isActive = isActive; return this; } @java.lang.Override public CreateBillingProductRequestBody build() { - return new CreateBillingProductRequestBody( - active, currency, externalId, name, price, quantity, additionalProperties); + return new CreateBillingProductRequestBody(externalId, isActive, name, price, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingSubscriptionsRequestBody.java b/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingSubscriptionRequestBody.java similarity index 85% rename from src/main/java/com/schematic/api/resources/billing/requests/CreateBillingSubscriptionsRequestBody.java rename to src/main/java/com/schematic/api/resources/billing/requests/CreateBillingSubscriptionRequestBody.java index 3d2e850..d3f6b0f 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingSubscriptionsRequestBody.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/CreateBillingSubscriptionRequestBody.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import com.schematic.api.resources.billing.types.CreateBillingSubscriptionsRequestBodyTrialEndSetting; +import com.schematic.api.resources.billing.types.CreateBillingSubscriptionRequestBodyTrialEndSetting; import com.schematic.api.types.BillingProductPricing; import com.schematic.api.types.BillingSubscriptionDiscount; import java.time.OffsetDateTime; @@ -26,8 +26,8 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = CreateBillingSubscriptionsRequestBody.Builder.class) -public final class CreateBillingSubscriptionsRequestBody { +@JsonDeserialize(builder = CreateBillingSubscriptionRequestBody.Builder.class) +public final class CreateBillingSubscriptionRequestBody { private final Optional cancelAt; private final boolean cancelAtPeriodEnd; @@ -36,6 +36,8 @@ public final class CreateBillingSubscriptionsRequestBody { private final String customerExternalId; + private final Optional defaultPaymentMethodExternalId; + private final Optional defaultPaymentMethodId; private final List discounts; @@ -60,15 +62,16 @@ public final class CreateBillingSubscriptionsRequestBody { private final Optional trialEnd; - private final Optional trialEndSetting; + private final Optional trialEndSetting; private final Map additionalProperties; - private CreateBillingSubscriptionsRequestBody( + private CreateBillingSubscriptionRequestBody( Optional cancelAt, boolean cancelAtPeriodEnd, String currency, String customerExternalId, + Optional defaultPaymentMethodExternalId, Optional defaultPaymentMethodId, List discounts, OffsetDateTime expiredAt, @@ -81,12 +84,13 @@ private CreateBillingSubscriptionsRequestBody( String subscriptionExternalId, int totalPrice, Optional trialEnd, - Optional trialEndSetting, + Optional trialEndSetting, Map additionalProperties) { this.cancelAt = cancelAt; this.cancelAtPeriodEnd = cancelAtPeriodEnd; this.currency = currency; this.customerExternalId = customerExternalId; + this.defaultPaymentMethodExternalId = defaultPaymentMethodExternalId; this.defaultPaymentMethodId = defaultPaymentMethodId; this.discounts = discounts; this.expiredAt = expiredAt; @@ -123,6 +127,11 @@ public String getCustomerExternalId() { return customerExternalId; } + @JsonProperty("default_payment_method_external_id") + public Optional getDefaultPaymentMethodExternalId() { + return defaultPaymentMethodExternalId; + } + @JsonProperty("default_payment_method_id") public Optional getDefaultPaymentMethodId() { return defaultPaymentMethodId; @@ -184,15 +193,15 @@ public Optional getTrialEnd() { } @JsonProperty("trial_end_setting") - public Optional getTrialEndSetting() { + public Optional getTrialEndSetting() { return trialEndSetting; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CreateBillingSubscriptionsRequestBody - && equalTo((CreateBillingSubscriptionsRequestBody) other); + return other instanceof CreateBillingSubscriptionRequestBody + && equalTo((CreateBillingSubscriptionRequestBody) other); } @JsonAnyGetter @@ -200,11 +209,12 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CreateBillingSubscriptionsRequestBody other) { + private boolean equalTo(CreateBillingSubscriptionRequestBody other) { return cancelAt.equals(other.cancelAt) && cancelAtPeriodEnd == other.cancelAtPeriodEnd && currency.equals(other.currency) && customerExternalId.equals(other.customerExternalId) + && defaultPaymentMethodExternalId.equals(other.defaultPaymentMethodExternalId) && defaultPaymentMethodId.equals(other.defaultPaymentMethodId) && discounts.equals(other.discounts) && expiredAt.equals(other.expiredAt) @@ -227,6 +237,7 @@ public int hashCode() { this.cancelAtPeriodEnd, this.currency, this.customerExternalId, + this.defaultPaymentMethodExternalId, this.defaultPaymentMethodId, this.discounts, this.expiredAt, @@ -254,7 +265,7 @@ public static CancelAtPeriodEndStage builder() { public interface CancelAtPeriodEndStage { CurrencyStage cancelAtPeriodEnd(boolean cancelAtPeriodEnd); - Builder from(CreateBillingSubscriptionsRequestBody other); + Builder from(CreateBillingSubscriptionRequestBody other); } public interface CurrencyStage { @@ -278,12 +289,16 @@ public interface TotalPriceStage { } public interface _FinalStage { - CreateBillingSubscriptionsRequestBody build(); + CreateBillingSubscriptionRequestBody build(); _FinalStage cancelAt(Optional cancelAt); _FinalStage cancelAt(Integer cancelAt); + _FinalStage defaultPaymentMethodExternalId(Optional defaultPaymentMethodExternalId); + + _FinalStage defaultPaymentMethodExternalId(String defaultPaymentMethodExternalId); + _FinalStage defaultPaymentMethodId(Optional defaultPaymentMethodId); _FinalStage defaultPaymentMethodId(String defaultPaymentMethodId); @@ -324,9 +339,9 @@ public interface _FinalStage { _FinalStage trialEnd(Integer trialEnd); - _FinalStage trialEndSetting(Optional trialEndSetting); + _FinalStage trialEndSetting(Optional trialEndSetting); - _FinalStage trialEndSetting(CreateBillingSubscriptionsRequestBodyTrialEndSetting trialEndSetting); + _FinalStage trialEndSetting(CreateBillingSubscriptionRequestBodyTrialEndSetting trialEndSetting); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -350,7 +365,7 @@ public static final class Builder private int totalPrice; - private Optional trialEndSetting = Optional.empty(); + private Optional trialEndSetting = Optional.empty(); private Optional trialEnd = Optional.empty(); @@ -370,6 +385,8 @@ public static final class Builder private Optional defaultPaymentMethodId = Optional.empty(); + private Optional defaultPaymentMethodExternalId = Optional.empty(); + private Optional cancelAt = Optional.empty(); @JsonAnySetter @@ -378,11 +395,12 @@ public static final class Builder private Builder() {} @java.lang.Override - public Builder from(CreateBillingSubscriptionsRequestBody other) { + public Builder from(CreateBillingSubscriptionRequestBody other) { cancelAt(other.getCancelAt()); cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); currency(other.getCurrency()); customerExternalId(other.getCustomerExternalId()); + defaultPaymentMethodExternalId(other.getDefaultPaymentMethodExternalId()); defaultPaymentMethodId(other.getDefaultPaymentMethodId()); discounts(other.getDiscounts()); expiredAt(other.getExpiredAt()); @@ -443,7 +461,7 @@ public _FinalStage totalPrice(int totalPrice) { } @java.lang.Override - public _FinalStage trialEndSetting(CreateBillingSubscriptionsRequestBodyTrialEndSetting trialEndSetting) { + public _FinalStage trialEndSetting(CreateBillingSubscriptionRequestBodyTrialEndSetting trialEndSetting) { this.trialEndSetting = Optional.ofNullable(trialEndSetting); return this; } @@ -451,7 +469,7 @@ public _FinalStage trialEndSetting(CreateBillingSubscriptionsRequestBodyTrialEnd @java.lang.Override @JsonSetter(value = "trial_end_setting", nulls = Nulls.SKIP) public _FinalStage trialEndSetting( - Optional trialEndSetting) { + Optional trialEndSetting) { this.trialEndSetting = trialEndSetting; return this; } @@ -484,7 +502,9 @@ public _FinalStage status(Optional status) { @java.lang.Override public _FinalStage addAllProductExternalIds(List productExternalIds) { - this.productExternalIds.addAll(productExternalIds); + if (productExternalIds != null) { + this.productExternalIds.addAll(productExternalIds); + } return this; } @@ -498,7 +518,9 @@ public _FinalStage addProductExternalIds(BillingProductPricing productExternalId @JsonSetter(value = "product_external_ids", nulls = Nulls.SKIP) public _FinalStage productExternalIds(List productExternalIds) { this.productExternalIds.clear(); - this.productExternalIds.addAll(productExternalIds); + if (productExternalIds != null) { + this.productExternalIds.addAll(productExternalIds); + } return this; } @@ -556,7 +578,9 @@ public _FinalStage interval(Optional interval) { @java.lang.Override public _FinalStage addAllDiscounts(List discounts) { - this.discounts.addAll(discounts); + if (discounts != null) { + this.discounts.addAll(discounts); + } return this; } @@ -570,7 +594,9 @@ public _FinalStage addDiscounts(BillingSubscriptionDiscount discounts) { @JsonSetter(value = "discounts", nulls = Nulls.SKIP) public _FinalStage discounts(List discounts) { this.discounts.clear(); - this.discounts.addAll(discounts); + if (discounts != null) { + this.discounts.addAll(discounts); + } return this; } @@ -587,6 +613,19 @@ public _FinalStage defaultPaymentMethodId(Optional defaultPaymentMethodI return this; } + @java.lang.Override + public _FinalStage defaultPaymentMethodExternalId(String defaultPaymentMethodExternalId) { + this.defaultPaymentMethodExternalId = Optional.ofNullable(defaultPaymentMethodExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_payment_method_external_id", nulls = Nulls.SKIP) + public _FinalStage defaultPaymentMethodExternalId(Optional defaultPaymentMethodExternalId) { + this.defaultPaymentMethodExternalId = defaultPaymentMethodExternalId; + return this; + } + @java.lang.Override public _FinalStage cancelAt(Integer cancelAt) { this.cancelAt = Optional.ofNullable(cancelAt); @@ -601,12 +640,13 @@ public _FinalStage cancelAt(Optional cancelAt) { } @java.lang.Override - public CreateBillingSubscriptionsRequestBody build() { - return new CreateBillingSubscriptionsRequestBody( + public CreateBillingSubscriptionRequestBody build() { + return new CreateBillingSubscriptionRequestBody( cancelAt, cancelAtPeriodEnd, currency, customerExternalId, + defaultPaymentMethodExternalId, defaultPaymentMethodId, discounts, expiredAt, diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListBillingProductsRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListBillingProductsRequest.java index 50324cb..0f15fce 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/ListBillingProductsRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListBillingProductsRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.billing.types.ListBillingProductsRequestPriceUsageType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,7 +23,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListBillingProductsRequest.Builder.class) public final class ListBillingProductsRequest { - private final Optional ids; + private final Optional> ids; private final Optional name; @@ -31,10 +33,14 @@ public final class ListBillingProductsRequest { private final Optional withoutLinkedToPlan; + private final Optional withOneTimeCharges; + private final Optional withZeroPrice; private final Optional withPricesOnly; + private final Optional isActive; + private final Optional limit; private final Optional offset; @@ -42,13 +48,15 @@ public final class ListBillingProductsRequest { private final Map additionalProperties; private ListBillingProductsRequest( - Optional ids, + Optional> ids, Optional name, Optional q, Optional priceUsageType, Optional withoutLinkedToPlan, + Optional withOneTimeCharges, Optional withZeroPrice, Optional withPricesOnly, + Optional isActive, Optional limit, Optional offset, Map additionalProperties) { @@ -57,15 +65,17 @@ private ListBillingProductsRequest( this.q = q; this.priceUsageType = priceUsageType; this.withoutLinkedToPlan = withoutLinkedToPlan; + this.withOneTimeCharges = withOneTimeCharges; this.withZeroPrice = withZeroPrice; this.withPricesOnly = withPricesOnly; + this.isActive = isActive; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -92,6 +102,14 @@ public Optional getWithoutLinkedToPlan() { return withoutLinkedToPlan; } + /** + * @return Filter products that are one time charges + */ + @JsonProperty("with_one_time_charges") + public Optional getWithOneTimeCharges() { + return withOneTimeCharges; + } + /** * @return Filter products that have zero price for free subscription type */ @@ -108,6 +126,14 @@ public Optional getWithPricesOnly() { return withPricesOnly; } + /** + * @return Filter products that are active + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + /** * @return Page limit (default 100) */ @@ -141,8 +167,10 @@ private boolean equalTo(ListBillingProductsRequest other) { && q.equals(other.q) && priceUsageType.equals(other.priceUsageType) && withoutLinkedToPlan.equals(other.withoutLinkedToPlan) + && withOneTimeCharges.equals(other.withOneTimeCharges) && withZeroPrice.equals(other.withZeroPrice) && withPricesOnly.equals(other.withPricesOnly) + && isActive.equals(other.isActive) && limit.equals(other.limit) && offset.equals(other.offset); } @@ -155,8 +183,10 @@ public int hashCode() { this.q, this.priceUsageType, this.withoutLinkedToPlan, + this.withOneTimeCharges, this.withZeroPrice, this.withPricesOnly, + this.isActive, this.limit, this.offset); } @@ -172,7 +202,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional name = Optional.empty(); @@ -182,10 +212,14 @@ public static final class Builder { private Optional withoutLinkedToPlan = Optional.empty(); + private Optional withOneTimeCharges = Optional.empty(); + private Optional withZeroPrice = Optional.empty(); private Optional withPricesOnly = Optional.empty(); + private Optional isActive = Optional.empty(); + private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); @@ -201,24 +235,31 @@ public Builder from(ListBillingProductsRequest other) { q(other.getQ()); priceUsageType(other.getPriceUsageType()); withoutLinkedToPlan(other.getWithoutLinkedToPlan()); + withOneTimeCharges(other.getWithOneTimeCharges()); withZeroPrice(other.getWithZeroPrice()); withPricesOnly(other.getWithPricesOnly()); + isActive(other.getIsActive()); limit(other.getLimit()); offset(other.getOffset()); return this; } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -252,6 +293,9 @@ public Builder priceUsageType(ListBillingProductsRequestPriceUsageType priceUsag return this; } + /** + *

Filter products that are not linked to any plan

+ */ @JsonSetter(value = "without_linked_to_plan", nulls = Nulls.SKIP) public Builder withoutLinkedToPlan(Optional withoutLinkedToPlan) { this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -263,6 +307,23 @@ public Builder withoutLinkedToPlan(Boolean withoutLinkedToPlan) { return this; } + /** + *

Filter products that are one time charges

+ */ + @JsonSetter(value = "with_one_time_charges", nulls = Nulls.SKIP) + public Builder withOneTimeCharges(Optional withOneTimeCharges) { + this.withOneTimeCharges = withOneTimeCharges; + return this; + } + + public Builder withOneTimeCharges(Boolean withOneTimeCharges) { + this.withOneTimeCharges = Optional.ofNullable(withOneTimeCharges); + return this; + } + + /** + *

Filter products that have zero price for free subscription type

+ */ @JsonSetter(value = "with_zero_price", nulls = Nulls.SKIP) public Builder withZeroPrice(Optional withZeroPrice) { this.withZeroPrice = withZeroPrice; @@ -274,6 +335,9 @@ public Builder withZeroPrice(Boolean withZeroPrice) { return this; } + /** + *

Filter products that have prices

+ */ @JsonSetter(value = "with_prices_only", nulls = Nulls.SKIP) public Builder withPricesOnly(Optional withPricesOnly) { this.withPricesOnly = withPricesOnly; @@ -285,6 +349,23 @@ public Builder withPricesOnly(Boolean withPricesOnly) { return this; } + /** + *

Filter products that are active

+ */ + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -296,6 +377,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -314,8 +398,10 @@ public ListBillingProductsRequest build() { q, priceUsageType, withoutLinkedToPlan, + withOneTimeCharges, withZeroPrice, withPricesOnly, + isActive, limit, offset, additionalProperties); diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListCouponsRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListCouponsRequest.java index d5085f0..a66d099 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/ListCouponsRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListCouponsRequest.java @@ -146,6 +146,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -157,6 +160,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListCustomersRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListCustomersWithSubscriptionsRequest.java similarity index 72% rename from src/main/java/com/schematic/api/resources/billing/requests/ListCustomersRequest.java rename to src/main/java/com/schematic/api/resources/billing/requests/ListCustomersWithSubscriptionsRequest.java index c3fe55f..505457b 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/ListCustomersRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListCustomersWithSubscriptionsRequest.java @@ -12,14 +12,18 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListCustomersRequest.Builder.class) -public final class ListCustomersRequest { +@JsonDeserialize(builder = ListCustomersWithSubscriptionsRequest.Builder.class) +public final class ListCustomersWithSubscriptionsRequest { + private final Optional> companyIds; + private final Optional name; private final Optional failedToImport; @@ -32,13 +36,15 @@ public final class ListCustomersRequest { private final Map additionalProperties; - private ListCustomersRequest( + private ListCustomersWithSubscriptionsRequest( + Optional> companyIds, Optional name, Optional failedToImport, Optional q, Optional limit, Optional offset, Map additionalProperties) { + this.companyIds = companyIds; this.name = name; this.failedToImport = failedToImport; this.q = q; @@ -47,6 +53,11 @@ private ListCustomersRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + @JsonProperty("name") public Optional getName() { return name; @@ -81,7 +92,8 @@ public Optional getOffset() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ListCustomersRequest && equalTo((ListCustomersRequest) other); + return other instanceof ListCustomersWithSubscriptionsRequest + && equalTo((ListCustomersWithSubscriptionsRequest) other); } @JsonAnyGetter @@ -89,8 +101,9 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ListCustomersRequest other) { - return name.equals(other.name) + private boolean equalTo(ListCustomersWithSubscriptionsRequest other) { + return companyIds.equals(other.companyIds) + && name.equals(other.name) && failedToImport.equals(other.failedToImport) && q.equals(other.q) && limit.equals(other.limit) @@ -99,7 +112,7 @@ private boolean equalTo(ListCustomersRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.name, this.failedToImport, this.q, this.limit, this.offset); + return Objects.hash(this.companyIds, this.name, this.failedToImport, this.q, this.limit, this.offset); } @java.lang.Override @@ -113,6 +126,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> companyIds = Optional.empty(); + private Optional name = Optional.empty(); private Optional failedToImport = Optional.empty(); @@ -128,7 +143,8 @@ public static final class Builder { private Builder() {} - public Builder from(ListCustomersRequest other) { + public Builder from(ListCustomersWithSubscriptionsRequest other) { + companyIds(other.getCompanyIds()); name(other.getName()); failedToImport(other.getFailedToImport()); q(other.getQ()); @@ -137,6 +153,22 @@ public Builder from(ListCustomersRequest other) { return this; } + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; + return this; + } + + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); + return this; + } + + public Builder companyIds(String companyIds) { + this.companyIds = Optional.of(Collections.singletonList(companyIds)); + return this; + } + @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -170,6 +202,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -181,6 +216,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -192,8 +230,9 @@ public Builder offset(Integer offset) { return this; } - public ListCustomersRequest build() { - return new ListCustomersRequest(name, failedToImport, q, limit, offset, additionalProperties); + public ListCustomersWithSubscriptionsRequest build() { + return new ListCustomersWithSubscriptionsRequest( + companyIds, name, failedToImport, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListInvoicesRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListInvoicesRequest.java index 1f88f59..824455d 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/ListInvoicesRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListInvoicesRequest.java @@ -25,7 +25,7 @@ public final class ListInvoicesRequest { private final String customerExternalId; - private final Optional subscriptionExternalId; + private final String subscriptionExternalId; private final Optional limit; @@ -36,7 +36,7 @@ public final class ListInvoicesRequest { private ListInvoicesRequest( Optional companyId, String customerExternalId, - Optional subscriptionExternalId, + String subscriptionExternalId, Optional limit, Optional offset, Map additionalProperties) { @@ -59,7 +59,7 @@ public String getCustomerExternalId() { } @JsonProperty("subscription_external_id") - public Optional getSubscriptionExternalId() { + public String getSubscriptionExternalId() { return subscriptionExternalId; } @@ -114,11 +114,15 @@ public static CustomerExternalIdStage builder() { } public interface CustomerExternalIdStage { - _FinalStage customerExternalId(@NotNull String customerExternalId); + SubscriptionExternalIdStage customerExternalId(@NotNull String customerExternalId); Builder from(ListInvoicesRequest other); } + public interface SubscriptionExternalIdStage { + _FinalStage subscriptionExternalId(@NotNull String subscriptionExternalId); + } + public interface _FinalStage { ListInvoicesRequest build(); @@ -126,29 +130,31 @@ public interface _FinalStage { _FinalStage companyId(String companyId); - _FinalStage subscriptionExternalId(Optional subscriptionExternalId); - - _FinalStage subscriptionExternalId(String subscriptionExternalId); - + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements CustomerExternalIdStage, _FinalStage { + public static final class Builder implements CustomerExternalIdStage, SubscriptionExternalIdStage, _FinalStage { private String customerExternalId; + private String subscriptionExternalId; + private Optional offset = Optional.empty(); private Optional limit = Optional.empty(); - private Optional subscriptionExternalId = Optional.empty(); - private Optional companyId = Optional.empty(); @JsonAnySetter @@ -168,11 +174,19 @@ public Builder from(ListInvoicesRequest other) { @java.lang.Override @JsonSetter("customer_external_id") - public _FinalStage customerExternalId(@NotNull String customerExternalId) { + public SubscriptionExternalIdStage customerExternalId(@NotNull String customerExternalId) { this.customerExternalId = Objects.requireNonNull(customerExternalId, "customerExternalId must not be null"); return this; } + @java.lang.Override + @JsonSetter("subscription_external_id") + public _FinalStage subscriptionExternalId(@NotNull String subscriptionExternalId) { + this.subscriptionExternalId = + Objects.requireNonNull(subscriptionExternalId, "subscriptionExternalId must not be null"); + return this; + } + /** *

Page offset (default 0)

* @return Reference to {@code this} so that method calls can be chained together. @@ -183,6 +197,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -200,6 +217,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { @@ -207,19 +227,6 @@ public _FinalStage limit(Optional limit) { return this; } - @java.lang.Override - public _FinalStage subscriptionExternalId(String subscriptionExternalId) { - this.subscriptionExternalId = Optional.ofNullable(subscriptionExternalId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "subscription_external_id", nulls = Nulls.SKIP) - public _FinalStage subscriptionExternalId(Optional subscriptionExternalId) { - this.subscriptionExternalId = subscriptionExternalId; - return this; - } - @java.lang.Override public _FinalStage companyId(String companyId) { this.companyId = Optional.ofNullable(companyId); diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListMetersRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListMetersRequest.java index 0faa2fd..8ea5880 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/ListMetersRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListMetersRequest.java @@ -120,6 +120,9 @@ public Builder displayName(String displayName) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -131,6 +134,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListPaymentMethodsRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListPaymentMethodsRequest.java index 8bd9d92..e837895 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/ListPaymentMethodsRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListPaymentMethodsRequest.java @@ -115,10 +115,16 @@ public interface _FinalStage { _FinalStage companyId(String companyId); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -165,6 +171,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -182,6 +191,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/billing/requests/ListProductPricesRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/ListProductPricesRequest.java index 6440405..a6d6661 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/ListProductPricesRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/ListProductPricesRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.billing.types.ListProductPricesRequestPriceUsageType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,7 +23,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListProductPricesRequest.Builder.class) public final class ListProductPricesRequest { - private final Optional ids; + private final Optional> ids; private final Optional name; @@ -31,10 +33,14 @@ public final class ListProductPricesRequest { private final Optional withoutLinkedToPlan; + private final Optional withOneTimeCharges; + private final Optional withZeroPrice; private final Optional withPricesOnly; + private final Optional isActive; + private final Optional limit; private final Optional offset; @@ -42,13 +48,15 @@ public final class ListProductPricesRequest { private final Map additionalProperties; private ListProductPricesRequest( - Optional ids, + Optional> ids, Optional name, Optional q, Optional priceUsageType, Optional withoutLinkedToPlan, + Optional withOneTimeCharges, Optional withZeroPrice, Optional withPricesOnly, + Optional isActive, Optional limit, Optional offset, Map additionalProperties) { @@ -57,15 +65,17 @@ private ListProductPricesRequest( this.q = q; this.priceUsageType = priceUsageType; this.withoutLinkedToPlan = withoutLinkedToPlan; + this.withOneTimeCharges = withOneTimeCharges; this.withZeroPrice = withZeroPrice; this.withPricesOnly = withPricesOnly; + this.isActive = isActive; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -92,6 +102,14 @@ public Optional getWithoutLinkedToPlan() { return withoutLinkedToPlan; } + /** + * @return Filter products that are one time charges + */ + @JsonProperty("with_one_time_charges") + public Optional getWithOneTimeCharges() { + return withOneTimeCharges; + } + /** * @return Filter products that have zero price for free subscription type */ @@ -108,6 +126,14 @@ public Optional getWithPricesOnly() { return withPricesOnly; } + /** + * @return Filter products that are active + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + /** * @return Page limit (default 100) */ @@ -141,8 +167,10 @@ private boolean equalTo(ListProductPricesRequest other) { && q.equals(other.q) && priceUsageType.equals(other.priceUsageType) && withoutLinkedToPlan.equals(other.withoutLinkedToPlan) + && withOneTimeCharges.equals(other.withOneTimeCharges) && withZeroPrice.equals(other.withZeroPrice) && withPricesOnly.equals(other.withPricesOnly) + && isActive.equals(other.isActive) && limit.equals(other.limit) && offset.equals(other.offset); } @@ -155,8 +183,10 @@ public int hashCode() { this.q, this.priceUsageType, this.withoutLinkedToPlan, + this.withOneTimeCharges, this.withZeroPrice, this.withPricesOnly, + this.isActive, this.limit, this.offset); } @@ -172,7 +202,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional name = Optional.empty(); @@ -182,10 +212,14 @@ public static final class Builder { private Optional withoutLinkedToPlan = Optional.empty(); + private Optional withOneTimeCharges = Optional.empty(); + private Optional withZeroPrice = Optional.empty(); private Optional withPricesOnly = Optional.empty(); + private Optional isActive = Optional.empty(); + private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); @@ -201,24 +235,31 @@ public Builder from(ListProductPricesRequest other) { q(other.getQ()); priceUsageType(other.getPriceUsageType()); withoutLinkedToPlan(other.getWithoutLinkedToPlan()); + withOneTimeCharges(other.getWithOneTimeCharges()); withZeroPrice(other.getWithZeroPrice()); withPricesOnly(other.getWithPricesOnly()); + isActive(other.getIsActive()); limit(other.getLimit()); offset(other.getOffset()); return this; } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -252,6 +293,9 @@ public Builder priceUsageType(ListProductPricesRequestPriceUsageType priceUsageT return this; } + /** + *

Filter products that are not linked to any plan

+ */ @JsonSetter(value = "without_linked_to_plan", nulls = Nulls.SKIP) public Builder withoutLinkedToPlan(Optional withoutLinkedToPlan) { this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -263,6 +307,23 @@ public Builder withoutLinkedToPlan(Boolean withoutLinkedToPlan) { return this; } + /** + *

Filter products that are one time charges

+ */ + @JsonSetter(value = "with_one_time_charges", nulls = Nulls.SKIP) + public Builder withOneTimeCharges(Optional withOneTimeCharges) { + this.withOneTimeCharges = withOneTimeCharges; + return this; + } + + public Builder withOneTimeCharges(Boolean withOneTimeCharges) { + this.withOneTimeCharges = Optional.ofNullable(withOneTimeCharges); + return this; + } + + /** + *

Filter products that have zero price for free subscription type

+ */ @JsonSetter(value = "with_zero_price", nulls = Nulls.SKIP) public Builder withZeroPrice(Optional withZeroPrice) { this.withZeroPrice = withZeroPrice; @@ -274,6 +335,9 @@ public Builder withZeroPrice(Boolean withZeroPrice) { return this; } + /** + *

Filter products that have prices

+ */ @JsonSetter(value = "with_prices_only", nulls = Nulls.SKIP) public Builder withPricesOnly(Optional withPricesOnly) { this.withPricesOnly = withPricesOnly; @@ -285,6 +349,23 @@ public Builder withPricesOnly(Boolean withPricesOnly) { return this; } + /** + *

Filter products that are active

+ */ + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -296,6 +377,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -314,8 +398,10 @@ public ListProductPricesRequest build() { q, priceUsageType, withoutLinkedToPlan, + withOneTimeCharges, withZeroPrice, withPricesOnly, + isActive, limit, offset, additionalProperties); diff --git a/src/main/java/com/schematic/api/resources/billing/requests/SearchBillingPricesRequest.java b/src/main/java/com/schematic/api/resources/billing/requests/SearchBillingPricesRequest.java index 7eb5b84..91e7e7e 100644 --- a/src/main/java/com/schematic/api/resources/billing/requests/SearchBillingPricesRequest.java +++ b/src/main/java/com/schematic/api/resources/billing/requests/SearchBillingPricesRequest.java @@ -12,8 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.billing.types.SearchBillingPricesRequestTiersMode; import com.schematic.api.resources.billing.types.SearchBillingPricesRequestUsageType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,16 +24,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SearchBillingPricesRequest.Builder.class) public final class SearchBillingPricesRequest { - private final Optional ids; + private final Optional> ids; - private final Optional q; + private final Optional forInitialPlan; - private final Optional interval; + private final Optional forTrialExpiryPlan; - private final Optional usageType; + private final Optional productId; + + private final Optional interval; private final Optional price; + private final Optional q; + + private final Optional requiresPaymentMethod; + + private final Optional tiersMode; + + private final Optional usageType; + private final Optional limit; private final Optional offset; @@ -38,32 +51,58 @@ public final class SearchBillingPricesRequest { private final Map additionalProperties; private SearchBillingPricesRequest( - Optional ids, - Optional q, + Optional> ids, + Optional forInitialPlan, + Optional forTrialExpiryPlan, + Optional productId, Optional interval, - Optional usageType, Optional price, + Optional q, + Optional requiresPaymentMethod, + Optional tiersMode, + Optional usageType, Optional limit, Optional offset, Map additionalProperties) { this.ids = ids; - this.q = q; + this.forInitialPlan = forInitialPlan; + this.forTrialExpiryPlan = forTrialExpiryPlan; + this.productId = productId; this.interval = interval; - this.usageType = usageType; this.price = price; + this.q = q; + this.requiresPaymentMethod = requiresPaymentMethod; + this.tiersMode = tiersMode; + this.usageType = usageType; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } - @JsonProperty("q") - public Optional getQ() { - return q; + /** + * @return Filter for prices valid for initial plans (free prices only) + */ + @JsonProperty("for_initial_plan") + public Optional getForInitialPlan() { + return forInitialPlan; + } + + /** + * @return Filter for prices valid for trial expiry plans (free prices only) + */ + @JsonProperty("for_trial_expiry_plan") + public Optional getForTrialExpiryPlan() { + return forTrialExpiryPlan; + } + + @JsonProperty("product_id") + public Optional getProductId() { + return productId; } @JsonProperty("interval") @@ -71,16 +110,34 @@ public Optional getInterval() { return interval; } - @JsonProperty("usage_type") - public Optional getUsageType() { - return usageType; - } - @JsonProperty("price") public Optional getPrice() { return price; } + @JsonProperty("q") + public Optional getQ() { + return q; + } + + /** + * @return Filter for prices that require a payment method (inverse of ForInitialPlan) + */ + @JsonProperty("requires_payment_method") + public Optional getRequiresPaymentMethod() { + return requiresPaymentMethod; + } + + @JsonProperty("tiers_mode") + public Optional getTiersMode() { + return tiersMode; + } + + @JsonProperty("usage_type") + public Optional getUsageType() { + return usageType; + } + /** * @return Page limit (default 100) */ @@ -110,17 +167,34 @@ public Map getAdditionalProperties() { private boolean equalTo(SearchBillingPricesRequest other) { return ids.equals(other.ids) - && q.equals(other.q) + && forInitialPlan.equals(other.forInitialPlan) + && forTrialExpiryPlan.equals(other.forTrialExpiryPlan) + && productId.equals(other.productId) && interval.equals(other.interval) - && usageType.equals(other.usageType) && price.equals(other.price) + && q.equals(other.q) + && requiresPaymentMethod.equals(other.requiresPaymentMethod) + && tiersMode.equals(other.tiersMode) + && usageType.equals(other.usageType) && limit.equals(other.limit) && offset.equals(other.offset); } @java.lang.Override public int hashCode() { - return Objects.hash(this.ids, this.q, this.interval, this.usageType, this.price, this.limit, this.offset); + return Objects.hash( + this.ids, + this.forInitialPlan, + this.forTrialExpiryPlan, + this.productId, + this.interval, + this.price, + this.q, + this.requiresPaymentMethod, + this.tiersMode, + this.usageType, + this.limit, + this.offset); } @java.lang.Override @@ -134,16 +208,26 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional q = Optional.empty(); + private Optional forInitialPlan = Optional.empty(); - private Optional interval = Optional.empty(); + private Optional forTrialExpiryPlan = Optional.empty(); - private Optional usageType = Optional.empty(); + private Optional productId = Optional.empty(); + + private Optional interval = Optional.empty(); private Optional price = Optional.empty(); + private Optional q = Optional.empty(); + + private Optional requiresPaymentMethod = Optional.empty(); + + private Optional tiersMode = Optional.empty(); + + private Optional usageType = Optional.empty(); + private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); @@ -155,56 +239,83 @@ private Builder() {} public Builder from(SearchBillingPricesRequest other) { ids(other.getIds()); - q(other.getQ()); + forInitialPlan(other.getForInitialPlan()); + forTrialExpiryPlan(other.getForTrialExpiryPlan()); + productId(other.getProductId()); interval(other.getInterval()); - usageType(other.getUsageType()); price(other.getPrice()); + q(other.getQ()); + requiresPaymentMethod(other.getRequiresPaymentMethod()); + tiersMode(other.getTiersMode()); + usageType(other.getUsageType()); limit(other.getLimit()); offset(other.getOffset()); return this; } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "q", nulls = Nulls.SKIP) - public Builder q(Optional q) { - this.q = q; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder q(String q) { - this.q = Optional.ofNullable(q); + /** + *

Filter for prices valid for initial plans (free prices only)

+ */ + @JsonSetter(value = "for_initial_plan", nulls = Nulls.SKIP) + public Builder forInitialPlan(Optional forInitialPlan) { + this.forInitialPlan = forInitialPlan; return this; } - @JsonSetter(value = "interval", nulls = Nulls.SKIP) - public Builder interval(Optional interval) { - this.interval = interval; + public Builder forInitialPlan(Boolean forInitialPlan) { + this.forInitialPlan = Optional.ofNullable(forInitialPlan); return this; } - public Builder interval(String interval) { - this.interval = Optional.ofNullable(interval); + /** + *

Filter for prices valid for trial expiry plans (free prices only)

+ */ + @JsonSetter(value = "for_trial_expiry_plan", nulls = Nulls.SKIP) + public Builder forTrialExpiryPlan(Optional forTrialExpiryPlan) { + this.forTrialExpiryPlan = forTrialExpiryPlan; return this; } - @JsonSetter(value = "usage_type", nulls = Nulls.SKIP) - public Builder usageType(Optional usageType) { - this.usageType = usageType; + public Builder forTrialExpiryPlan(Boolean forTrialExpiryPlan) { + this.forTrialExpiryPlan = Optional.ofNullable(forTrialExpiryPlan); return this; } - public Builder usageType(SearchBillingPricesRequestUsageType usageType) { - this.usageType = Optional.ofNullable(usageType); + @JsonSetter(value = "product_id", nulls = Nulls.SKIP) + public Builder productId(Optional productId) { + this.productId = productId; + return this; + } + + public Builder productId(String productId) { + this.productId = Optional.ofNullable(productId); + return this; + } + + @JsonSetter(value = "interval", nulls = Nulls.SKIP) + public Builder interval(Optional interval) { + this.interval = interval; + return this; + } + + public Builder interval(String interval) { + this.interval = Optional.ofNullable(interval); return this; } @@ -219,6 +330,56 @@ public Builder price(Integer price) { return this; } + @JsonSetter(value = "q", nulls = Nulls.SKIP) + public Builder q(Optional q) { + this.q = q; + return this; + } + + public Builder q(String q) { + this.q = Optional.ofNullable(q); + return this; + } + + /** + *

Filter for prices that require a payment method (inverse of ForInitialPlan)

+ */ + @JsonSetter(value = "requires_payment_method", nulls = Nulls.SKIP) + public Builder requiresPaymentMethod(Optional requiresPaymentMethod) { + this.requiresPaymentMethod = requiresPaymentMethod; + return this; + } + + public Builder requiresPaymentMethod(Boolean requiresPaymentMethod) { + this.requiresPaymentMethod = Optional.ofNullable(requiresPaymentMethod); + return this; + } + + @JsonSetter(value = "tiers_mode", nulls = Nulls.SKIP) + public Builder tiersMode(Optional tiersMode) { + this.tiersMode = tiersMode; + return this; + } + + public Builder tiersMode(SearchBillingPricesRequestTiersMode tiersMode) { + this.tiersMode = Optional.ofNullable(tiersMode); + return this; + } + + @JsonSetter(value = "usage_type", nulls = Nulls.SKIP) + public Builder usageType(Optional usageType) { + this.usageType = usageType; + return this; + } + + public Builder usageType(SearchBillingPricesRequestUsageType usageType) { + this.usageType = Optional.ofNullable(usageType); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -230,6 +391,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -243,7 +407,19 @@ public Builder offset(Integer offset) { public SearchBillingPricesRequest build() { return new SearchBillingPricesRequest( - ids, q, interval, usageType, price, limit, offset, additionalProperties); + ids, + forInitialPlan, + forTrialExpiryPlan, + productId, + interval, + price, + q, + requiresPaymentMethod, + tiersMode, + usageType, + limit, + offset, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsParams.java b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsParams.java index 7918a47..3a0893a 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsParams.java @@ -23,6 +23,8 @@ public final class CountBillingProductsParams { private final Optional> ids; + private final Optional isActive; + private final Optional limit; private final Optional name; @@ -33,6 +35,8 @@ public final class CountBillingProductsParams { private final Optional q; + private final Optional withOneTimeCharges; + private final Optional withPricesOnly; private final Optional withZeroPrice; @@ -43,21 +47,25 @@ public final class CountBillingProductsParams { private CountBillingProductsParams( Optional> ids, + Optional isActive, Optional limit, Optional name, Optional offset, Optional priceUsageType, Optional q, + Optional withOneTimeCharges, Optional withPricesOnly, Optional withZeroPrice, Optional withoutLinkedToPlan, Map additionalProperties) { this.ids = ids; + this.isActive = isActive; this.limit = limit; this.name = name; this.offset = offset; this.priceUsageType = priceUsageType; this.q = q; + this.withOneTimeCharges = withOneTimeCharges; this.withPricesOnly = withPricesOnly; this.withZeroPrice = withZeroPrice; this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -69,6 +77,14 @@ public Optional> getIds() { return ids; } + /** + * @return Filter products that are active + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + /** * @return Page limit (default 100) */ @@ -100,6 +116,14 @@ public Optional getQ() { return q; } + /** + * @return Filter products that are one time charges + */ + @JsonProperty("with_one_time_charges") + public Optional getWithOneTimeCharges() { + return withOneTimeCharges; + } + /** * @return Filter products that have prices */ @@ -137,11 +161,13 @@ public Map getAdditionalProperties() { private boolean equalTo(CountBillingProductsParams other) { return ids.equals(other.ids) + && isActive.equals(other.isActive) && limit.equals(other.limit) && name.equals(other.name) && offset.equals(other.offset) && priceUsageType.equals(other.priceUsageType) && q.equals(other.q) + && withOneTimeCharges.equals(other.withOneTimeCharges) && withPricesOnly.equals(other.withPricesOnly) && withZeroPrice.equals(other.withZeroPrice) && withoutLinkedToPlan.equals(other.withoutLinkedToPlan); @@ -151,11 +177,13 @@ private boolean equalTo(CountBillingProductsParams other) { public int hashCode() { return Objects.hash( this.ids, + this.isActive, this.limit, this.name, this.offset, this.priceUsageType, this.q, + this.withOneTimeCharges, this.withPricesOnly, this.withZeroPrice, this.withoutLinkedToPlan); @@ -174,6 +202,8 @@ public static Builder builder() { public static final class Builder { private Optional> ids = Optional.empty(); + private Optional isActive = Optional.empty(); + private Optional limit = Optional.empty(); private Optional name = Optional.empty(); @@ -184,6 +214,8 @@ public static final class Builder { private Optional q = Optional.empty(); + private Optional withOneTimeCharges = Optional.empty(); + private Optional withPricesOnly = Optional.empty(); private Optional withZeroPrice = Optional.empty(); @@ -197,11 +229,13 @@ private Builder() {} public Builder from(CountBillingProductsParams other) { ids(other.getIds()); + isActive(other.getIsActive()); limit(other.getLimit()); name(other.getName()); offset(other.getOffset()); priceUsageType(other.getPriceUsageType()); q(other.getQ()); + withOneTimeCharges(other.getWithOneTimeCharges()); withPricesOnly(other.getWithPricesOnly()); withZeroPrice(other.getWithZeroPrice()); withoutLinkedToPlan(other.getWithoutLinkedToPlan()); @@ -219,6 +253,23 @@ public Builder ids(List ids) { return this; } + /** + *

Filter products that are active

+ */ + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -241,6 +292,9 @@ public Builder name(String name) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -274,6 +328,23 @@ public Builder q(String q) { return this; } + /** + *

Filter products that are one time charges

+ */ + @JsonSetter(value = "with_one_time_charges", nulls = Nulls.SKIP) + public Builder withOneTimeCharges(Optional withOneTimeCharges) { + this.withOneTimeCharges = withOneTimeCharges; + return this; + } + + public Builder withOneTimeCharges(Boolean withOneTimeCharges) { + this.withOneTimeCharges = Optional.ofNullable(withOneTimeCharges); + return this; + } + + /** + *

Filter products that have prices

+ */ @JsonSetter(value = "with_prices_only", nulls = Nulls.SKIP) public Builder withPricesOnly(Optional withPricesOnly) { this.withPricesOnly = withPricesOnly; @@ -285,6 +356,9 @@ public Builder withPricesOnly(Boolean withPricesOnly) { return this; } + /** + *

Filter products that have zero price for free subscription type

+ */ @JsonSetter(value = "with_zero_price", nulls = Nulls.SKIP) public Builder withZeroPrice(Optional withZeroPrice) { this.withZeroPrice = withZeroPrice; @@ -296,6 +370,9 @@ public Builder withZeroPrice(Boolean withZeroPrice) { return this; } + /** + *

Filter products that are not linked to any plan

+ */ @JsonSetter(value = "without_linked_to_plan", nulls = Nulls.SKIP) public Builder withoutLinkedToPlan(Optional withoutLinkedToPlan) { this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -310,11 +387,13 @@ public Builder withoutLinkedToPlan(Boolean withoutLinkedToPlan) { public CountBillingProductsParams build() { return new CountBillingProductsParams( ids, + isActive, limit, name, offset, priceUsageType, q, + withOneTimeCharges, withPricesOnly, withZeroPrice, withoutLinkedToPlan, diff --git a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsRequestPriceUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsRequestPriceUsageType.java index f52ba99..f769090 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsRequestPriceUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsRequestPriceUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountBillingProductsRequestPriceUsageType { - LICENSED("licensed"), +public final class CountBillingProductsRequestPriceUsageType { + public static final CountBillingProductsRequestPriceUsageType METERED = + new CountBillingProductsRequestPriceUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final CountBillingProductsRequestPriceUsageType LICENSED = + new CountBillingProductsRequestPriceUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - CountBillingProductsRequestPriceUsageType(String value) { + private final String string; + + CountBillingProductsRequestPriceUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountBillingProductsRequestPriceUsageType + && this.string.equals(((CountBillingProductsRequestPriceUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountBillingProductsRequestPriceUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new CountBillingProductsRequestPriceUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponse.java index 4b6ffd6..4670d23 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountBillingProductsParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponseParamsPriceUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponseParamsPriceUsageType.java index c0440ac..504b768 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponseParamsPriceUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CountBillingProductsResponseParamsPriceUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountBillingProductsResponseParamsPriceUsageType { - LICENSED("licensed"), +public final class CountBillingProductsResponseParamsPriceUsageType { + public static final CountBillingProductsResponseParamsPriceUsageType METERED = + new CountBillingProductsResponseParamsPriceUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final CountBillingProductsResponseParamsPriceUsageType LICENSED = + new CountBillingProductsResponseParamsPriceUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - CountBillingProductsResponseParamsPriceUsageType(String value) { + private final String string; + + CountBillingProductsResponseParamsPriceUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountBillingProductsResponseParamsPriceUsageType + && this.string.equals(((CountBillingProductsResponseParamsPriceUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountBillingProductsResponseParamsPriceUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new CountBillingProductsResponseParamsPriceUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/CountCustomersParams.java b/src/main/java/com/schematic/api/resources/billing/types/CountCustomersParams.java index 2d1263a..b768079 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CountCustomersParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CountCustomersParams.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,6 +21,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountCustomersParams.Builder.class) public final class CountCustomersParams { + private final Optional> companyIds; + private final Optional failedToImport; private final Optional limit; @@ -33,12 +36,14 @@ public final class CountCustomersParams { private final Map additionalProperties; private CountCustomersParams( + Optional> companyIds, Optional failedToImport, Optional limit, Optional name, Optional offset, Optional q, Map additionalProperties) { + this.companyIds = companyIds; this.failedToImport = failedToImport; this.limit = limit; this.name = name; @@ -47,6 +52,11 @@ private CountCustomersParams( this.additionalProperties = additionalProperties; } + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + @JsonProperty("failed_to_import") public Optional getFailedToImport() { return failedToImport; @@ -90,7 +100,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountCustomersParams other) { - return failedToImport.equals(other.failedToImport) + return companyIds.equals(other.companyIds) + && failedToImport.equals(other.failedToImport) && limit.equals(other.limit) && name.equals(other.name) && offset.equals(other.offset) @@ -99,7 +110,7 @@ private boolean equalTo(CountCustomersParams other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.failedToImport, this.limit, this.name, this.offset, this.q); + return Objects.hash(this.companyIds, this.failedToImport, this.limit, this.name, this.offset, this.q); } @java.lang.Override @@ -113,6 +124,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> companyIds = Optional.empty(); + private Optional failedToImport = Optional.empty(); private Optional limit = Optional.empty(); @@ -129,6 +142,7 @@ public static final class Builder { private Builder() {} public Builder from(CountCustomersParams other) { + companyIds(other.getCompanyIds()); failedToImport(other.getFailedToImport()); limit(other.getLimit()); name(other.getName()); @@ -137,6 +151,17 @@ public Builder from(CountCustomersParams other) { return this; } + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; + return this; + } + + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); + return this; + } + @JsonSetter(value = "failed_to_import", nulls = Nulls.SKIP) public Builder failedToImport(Optional failedToImport) { this.failedToImport = failedToImport; @@ -148,6 +173,9 @@ public Builder failedToImport(Boolean failedToImport) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -170,6 +198,9 @@ public Builder name(String name) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -193,7 +224,7 @@ public Builder q(String q) { } public CountCustomersParams build() { - return new CountCustomersParams(failedToImport, limit, name, offset, q, additionalProperties); + return new CountCustomersParams(companyIds, failedToImport, limit, name, offset, q, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/CountCustomersResponse.java b/src/main/java/com/schematic/api/resources/billing/types/CountCustomersResponse.java index af87fb0..080c19d 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CountCustomersResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CountCustomersResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountCustomersParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyBillingScheme.java b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyBillingScheme.java new file mode 100644 index 0000000..fb292ca --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyBillingScheme.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingPriceRequestBodyBillingScheme { + public static final CreateBillingPriceRequestBodyBillingScheme PER_UNIT = + new CreateBillingPriceRequestBodyBillingScheme(Value.PER_UNIT, "per_unit"); + + public static final CreateBillingPriceRequestBodyBillingScheme TIERED = + new CreateBillingPriceRequestBodyBillingScheme(Value.TIERED, "tiered"); + + private final Value value; + + private final String string; + + CreateBillingPriceRequestBodyBillingScheme(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingPriceRequestBodyBillingScheme + && this.string.equals(((CreateBillingPriceRequestBodyBillingScheme) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PER_UNIT: + return visitor.visitPerUnit(); + case TIERED: + return visitor.visitTiered(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingPriceRequestBodyBillingScheme valueOf(String value) { + switch (value) { + case "per_unit": + return PER_UNIT; + case "tiered": + return TIERED; + default: + return new CreateBillingPriceRequestBodyBillingScheme(Value.UNKNOWN, value); + } + } + + public enum Value { + PER_UNIT, + + TIERED, + + UNKNOWN + } + + public interface Visitor { + T visitPerUnit(); + + T visitTiered(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyTierMode.java b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyTierMode.java deleted file mode 100644 index 224e1e2..0000000 --- a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyTierMode.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.schematic.api.resources.billing.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CreateBillingPriceRequestBodyTierMode { - VOLUME("volume"), - - GRADUATED("graduated"); - - private final String value; - - CreateBillingPriceRequestBodyTierMode(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyTiersMode.java b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyTiersMode.java new file mode 100644 index 0000000..1dd8784 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyTiersMode.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingPriceRequestBodyTiersMode { + public static final CreateBillingPriceRequestBodyTiersMode GRADUATED = + new CreateBillingPriceRequestBodyTiersMode(Value.GRADUATED, "graduated"); + + public static final CreateBillingPriceRequestBodyTiersMode VOLUME = + new CreateBillingPriceRequestBodyTiersMode(Value.VOLUME, "volume"); + + private final Value value; + + private final String string; + + CreateBillingPriceRequestBodyTiersMode(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingPriceRequestBodyTiersMode + && this.string.equals(((CreateBillingPriceRequestBodyTiersMode) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case GRADUATED: + return visitor.visitGraduated(); + case VOLUME: + return visitor.visitVolume(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingPriceRequestBodyTiersMode valueOf(String value) { + switch (value) { + case "graduated": + return GRADUATED; + case "volume": + return VOLUME; + default: + return new CreateBillingPriceRequestBodyTiersMode(Value.UNKNOWN, value); + } + } + + public enum Value { + VOLUME, + + GRADUATED, + + UNKNOWN + } + + public interface Visitor { + T visitVolume(); + + T visitGraduated(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyUsageType.java index 69543bf..b5d5ac5 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingPriceRequestBodyUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateBillingPriceRequestBodyUsageType { - LICENSED("licensed"), +public final class CreateBillingPriceRequestBodyUsageType { + public static final CreateBillingPriceRequestBodyUsageType METERED = + new CreateBillingPriceRequestBodyUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final CreateBillingPriceRequestBodyUsageType LICENSED = + new CreateBillingPriceRequestBodyUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - CreateBillingPriceRequestBodyUsageType(String value) { + private final String string; + + CreateBillingPriceRequestBodyUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingPriceRequestBodyUsageType + && this.string.equals(((CreateBillingPriceRequestBodyUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingPriceRequestBodyUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new CreateBillingPriceRequestBodyUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingSubscriptionRequestBodyTrialEndSetting.java b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingSubscriptionRequestBodyTrialEndSetting.java new file mode 100644 index 0000000..0813a04 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingSubscriptionRequestBodyTrialEndSetting.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingSubscriptionRequestBodyTrialEndSetting { + public static final CreateBillingSubscriptionRequestBodyTrialEndSetting SUBSCRIBE = + new CreateBillingSubscriptionRequestBodyTrialEndSetting(Value.SUBSCRIBE, "subscribe"); + + public static final CreateBillingSubscriptionRequestBodyTrialEndSetting CANCEL = + new CreateBillingSubscriptionRequestBodyTrialEndSetting(Value.CANCEL, "cancel"); + + private final Value value; + + private final String string; + + CreateBillingSubscriptionRequestBodyTrialEndSetting(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingSubscriptionRequestBodyTrialEndSetting + && this.string.equals(((CreateBillingSubscriptionRequestBodyTrialEndSetting) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case SUBSCRIBE: + return visitor.visitSubscribe(); + case CANCEL: + return visitor.visitCancel(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingSubscriptionRequestBodyTrialEndSetting valueOf(String value) { + switch (value) { + case "subscribe": + return SUBSCRIBE; + case "cancel": + return CANCEL; + default: + return new CreateBillingSubscriptionRequestBodyTrialEndSetting(Value.UNKNOWN, value); + } + } + + public enum Value { + SUBSCRIBE, + + CANCEL, + + UNKNOWN + } + + public interface Visitor { + T visitSubscribe(); + + T visitCancel(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingSubscriptionsRequestBodyTrialEndSetting.java b/src/main/java/com/schematic/api/resources/billing/types/CreateBillingSubscriptionsRequestBodyTrialEndSetting.java deleted file mode 100644 index 636338a..0000000 --- a/src/main/java/com/schematic/api/resources/billing/types/CreateBillingSubscriptionsRequestBodyTrialEndSetting.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.schematic.api.resources.billing.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CreateBillingSubscriptionsRequestBodyTrialEndSetting { - SUBSCRIBE("subscribe"), - - CANCEL("cancel"); - - private final String value; - - CreateBillingSubscriptionsRequestBodyTrialEndSetting(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingProductResponse.java b/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingProductResponse.java index 32bc8e0..e9f3953 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingProductResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/DeleteBillingProductResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteBillingProductResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/DeleteProductPriceResponse.java b/src/main/java/com/schematic/api/resources/billing/types/DeleteProductPriceResponse.java index 565198d..f085f06 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/DeleteProductPriceResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/DeleteProductPriceResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteProductPriceResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsParams.java index 7235d48..b6d55b8 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsParams.java @@ -23,6 +23,8 @@ public final class ListBillingProductsParams { private final Optional> ids; + private final Optional isActive; + private final Optional limit; private final Optional name; @@ -33,6 +35,8 @@ public final class ListBillingProductsParams { private final Optional q; + private final Optional withOneTimeCharges; + private final Optional withPricesOnly; private final Optional withZeroPrice; @@ -43,21 +47,25 @@ public final class ListBillingProductsParams { private ListBillingProductsParams( Optional> ids, + Optional isActive, Optional limit, Optional name, Optional offset, Optional priceUsageType, Optional q, + Optional withOneTimeCharges, Optional withPricesOnly, Optional withZeroPrice, Optional withoutLinkedToPlan, Map additionalProperties) { this.ids = ids; + this.isActive = isActive; this.limit = limit; this.name = name; this.offset = offset; this.priceUsageType = priceUsageType; this.q = q; + this.withOneTimeCharges = withOneTimeCharges; this.withPricesOnly = withPricesOnly; this.withZeroPrice = withZeroPrice; this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -69,6 +77,14 @@ public Optional> getIds() { return ids; } + /** + * @return Filter products that are active + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + /** * @return Page limit (default 100) */ @@ -100,6 +116,14 @@ public Optional getQ() { return q; } + /** + * @return Filter products that are one time charges + */ + @JsonProperty("with_one_time_charges") + public Optional getWithOneTimeCharges() { + return withOneTimeCharges; + } + /** * @return Filter products that have prices */ @@ -137,11 +161,13 @@ public Map getAdditionalProperties() { private boolean equalTo(ListBillingProductsParams other) { return ids.equals(other.ids) + && isActive.equals(other.isActive) && limit.equals(other.limit) && name.equals(other.name) && offset.equals(other.offset) && priceUsageType.equals(other.priceUsageType) && q.equals(other.q) + && withOneTimeCharges.equals(other.withOneTimeCharges) && withPricesOnly.equals(other.withPricesOnly) && withZeroPrice.equals(other.withZeroPrice) && withoutLinkedToPlan.equals(other.withoutLinkedToPlan); @@ -151,11 +177,13 @@ private boolean equalTo(ListBillingProductsParams other) { public int hashCode() { return Objects.hash( this.ids, + this.isActive, this.limit, this.name, this.offset, this.priceUsageType, this.q, + this.withOneTimeCharges, this.withPricesOnly, this.withZeroPrice, this.withoutLinkedToPlan); @@ -174,6 +202,8 @@ public static Builder builder() { public static final class Builder { private Optional> ids = Optional.empty(); + private Optional isActive = Optional.empty(); + private Optional limit = Optional.empty(); private Optional name = Optional.empty(); @@ -184,6 +214,8 @@ public static final class Builder { private Optional q = Optional.empty(); + private Optional withOneTimeCharges = Optional.empty(); + private Optional withPricesOnly = Optional.empty(); private Optional withZeroPrice = Optional.empty(); @@ -197,11 +229,13 @@ private Builder() {} public Builder from(ListBillingProductsParams other) { ids(other.getIds()); + isActive(other.getIsActive()); limit(other.getLimit()); name(other.getName()); offset(other.getOffset()); priceUsageType(other.getPriceUsageType()); q(other.getQ()); + withOneTimeCharges(other.getWithOneTimeCharges()); withPricesOnly(other.getWithPricesOnly()); withZeroPrice(other.getWithZeroPrice()); withoutLinkedToPlan(other.getWithoutLinkedToPlan()); @@ -219,6 +253,23 @@ public Builder ids(List ids) { return this; } + /** + *

Filter products that are active

+ */ + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -241,6 +292,9 @@ public Builder name(String name) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -274,6 +328,23 @@ public Builder q(String q) { return this; } + /** + *

Filter products that are one time charges

+ */ + @JsonSetter(value = "with_one_time_charges", nulls = Nulls.SKIP) + public Builder withOneTimeCharges(Optional withOneTimeCharges) { + this.withOneTimeCharges = withOneTimeCharges; + return this; + } + + public Builder withOneTimeCharges(Boolean withOneTimeCharges) { + this.withOneTimeCharges = Optional.ofNullable(withOneTimeCharges); + return this; + } + + /** + *

Filter products that have prices

+ */ @JsonSetter(value = "with_prices_only", nulls = Nulls.SKIP) public Builder withPricesOnly(Optional withPricesOnly) { this.withPricesOnly = withPricesOnly; @@ -285,6 +356,9 @@ public Builder withPricesOnly(Boolean withPricesOnly) { return this; } + /** + *

Filter products that have zero price for free subscription type

+ */ @JsonSetter(value = "with_zero_price", nulls = Nulls.SKIP) public Builder withZeroPrice(Optional withZeroPrice) { this.withZeroPrice = withZeroPrice; @@ -296,6 +370,9 @@ public Builder withZeroPrice(Boolean withZeroPrice) { return this; } + /** + *

Filter products that are not linked to any plan

+ */ @JsonSetter(value = "without_linked_to_plan", nulls = Nulls.SKIP) public Builder withoutLinkedToPlan(Optional withoutLinkedToPlan) { this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -310,11 +387,13 @@ public Builder withoutLinkedToPlan(Boolean withoutLinkedToPlan) { public ListBillingProductsParams build() { return new ListBillingProductsParams( ids, + isActive, limit, name, offset, priceUsageType, q, + withOneTimeCharges, withPricesOnly, withZeroPrice, withoutLinkedToPlan, diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsRequestPriceUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsRequestPriceUsageType.java index c98f627..1e1d07f 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsRequestPriceUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsRequestPriceUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListBillingProductsRequestPriceUsageType { - LICENSED("licensed"), +public final class ListBillingProductsRequestPriceUsageType { + public static final ListBillingProductsRequestPriceUsageType METERED = + new ListBillingProductsRequestPriceUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final ListBillingProductsRequestPriceUsageType LICENSED = + new ListBillingProductsRequestPriceUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - ListBillingProductsRequestPriceUsageType(String value) { + private final String string; + + ListBillingProductsRequestPriceUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListBillingProductsRequestPriceUsageType + && this.string.equals(((ListBillingProductsRequestPriceUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListBillingProductsRequestPriceUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new ListBillingProductsRequestPriceUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponse.java index a966e4d..eddc6ec 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponse.java @@ -38,9 +38,6 @@ private ListBillingProductsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListBillingProductsParams params); Builder from(ListBillingProductsResponse other); @@ -118,6 +118,7 @@ public Builder from(ListBillingProductsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListBillingProductsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(BillingProductDetailResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(BillingProductDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponseParamsPriceUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponseParamsPriceUsageType.java index d556648..904f1d3 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponseParamsPriceUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListBillingProductsResponseParamsPriceUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListBillingProductsResponseParamsPriceUsageType { - LICENSED("licensed"), +public final class ListBillingProductsResponseParamsPriceUsageType { + public static final ListBillingProductsResponseParamsPriceUsageType METERED = + new ListBillingProductsResponseParamsPriceUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final ListBillingProductsResponseParamsPriceUsageType LICENSED = + new ListBillingProductsResponseParamsPriceUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - ListBillingProductsResponseParamsPriceUsageType(String value) { + private final String string; + + ListBillingProductsResponseParamsPriceUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListBillingProductsResponseParamsPriceUsageType + && this.string.equals(((ListBillingProductsResponseParamsPriceUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListBillingProductsResponseParamsPriceUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new ListBillingProductsResponseParamsPriceUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCouponsParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsParams.java index e46d9a2..4a2c6a6 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListCouponsParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsParams.java @@ -135,6 +135,9 @@ public Builder isActive(Boolean isActive) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java index 7a43098..dbf5b2a 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCouponsResponse.java @@ -36,9 +36,6 @@ private ListCouponsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListCouponsParams params); Builder from(ListCouponsResponse other); @@ -116,6 +116,7 @@ public Builder from(ListCouponsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListCouponsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(BillingCouponResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(BillingCouponResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCustomersParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsParams.java similarity index 73% rename from src/main/java/com/schematic/api/resources/billing/types/ListCustomersParams.java rename to src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsParams.java index b6d1432..e720a04 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListCustomersParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsParams.java @@ -13,13 +13,16 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListCustomersParams.Builder.class) -public final class ListCustomersParams { +@JsonDeserialize(builder = ListCustomersWithSubscriptionsParams.Builder.class) +public final class ListCustomersWithSubscriptionsParams { + private final Optional> companyIds; + private final Optional failedToImport; private final Optional limit; @@ -32,13 +35,15 @@ public final class ListCustomersParams { private final Map additionalProperties; - private ListCustomersParams( + private ListCustomersWithSubscriptionsParams( + Optional> companyIds, Optional failedToImport, Optional limit, Optional name, Optional offset, Optional q, Map additionalProperties) { + this.companyIds = companyIds; this.failedToImport = failedToImport; this.limit = limit; this.name = name; @@ -47,6 +52,11 @@ private ListCustomersParams( this.additionalProperties = additionalProperties; } + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + @JsonProperty("failed_to_import") public Optional getFailedToImport() { return failedToImport; @@ -81,7 +91,8 @@ public Optional getQ() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ListCustomersParams && equalTo((ListCustomersParams) other); + return other instanceof ListCustomersWithSubscriptionsParams + && equalTo((ListCustomersWithSubscriptionsParams) other); } @JsonAnyGetter @@ -89,8 +100,9 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ListCustomersParams other) { - return failedToImport.equals(other.failedToImport) + private boolean equalTo(ListCustomersWithSubscriptionsParams other) { + return companyIds.equals(other.companyIds) + && failedToImport.equals(other.failedToImport) && limit.equals(other.limit) && name.equals(other.name) && offset.equals(other.offset) @@ -99,7 +111,7 @@ private boolean equalTo(ListCustomersParams other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.failedToImport, this.limit, this.name, this.offset, this.q); + return Objects.hash(this.companyIds, this.failedToImport, this.limit, this.name, this.offset, this.q); } @java.lang.Override @@ -113,6 +125,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> companyIds = Optional.empty(); + private Optional failedToImport = Optional.empty(); private Optional limit = Optional.empty(); @@ -128,7 +142,8 @@ public static final class Builder { private Builder() {} - public Builder from(ListCustomersParams other) { + public Builder from(ListCustomersWithSubscriptionsParams other) { + companyIds(other.getCompanyIds()); failedToImport(other.getFailedToImport()); limit(other.getLimit()); name(other.getName()); @@ -137,6 +152,17 @@ public Builder from(ListCustomersParams other) { return this; } + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; + return this; + } + + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); + return this; + } + @JsonSetter(value = "failed_to_import", nulls = Nulls.SKIP) public Builder failedToImport(Optional failedToImport) { this.failedToImport = failedToImport; @@ -148,6 +174,9 @@ public Builder failedToImport(Boolean failedToImport) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -170,6 +199,9 @@ public Builder name(String name) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -192,8 +224,9 @@ public Builder q(String q) { return this; } - public ListCustomersParams build() { - return new ListCustomersParams(failedToImport, limit, name, offset, q, additionalProperties); + public ListCustomersWithSubscriptionsParams build() { + return new ListCustomersWithSubscriptionsParams( + companyIds, failedToImport, limit, name, offset, q, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListCustomersResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsResponse.java similarity index 73% rename from src/main/java/com/schematic/api/resources/billing/types/ListCustomersResponse.java rename to src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsResponse.java index 8b8441c..b6bcaa4 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListCustomersResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListCustomersWithSubscriptionsResponse.java @@ -21,26 +21,23 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListCustomersResponse.Builder.class) -public final class ListCustomersResponse { +@JsonDeserialize(builder = ListCustomersWithSubscriptionsResponse.Builder.class) +public final class ListCustomersWithSubscriptionsResponse { private final List data; - private final ListCustomersParams params; + private final ListCustomersWithSubscriptionsParams params; private final Map additionalProperties; - private ListCustomersResponse( + private ListCustomersWithSubscriptionsResponse( List data, - ListCustomersParams params, + ListCustomersWithSubscriptionsParams params, Map additionalProperties) { this.data = data; this.params = params; this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -50,14 +47,15 @@ public List getData() { * @return Input parameters */ @JsonProperty("params") - public ListCustomersParams getParams() { + public ListCustomersWithSubscriptionsParams getParams() { return params; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ListCustomersResponse && equalTo((ListCustomersResponse) other); + return other instanceof ListCustomersWithSubscriptionsResponse + && equalTo((ListCustomersWithSubscriptionsResponse) other); } @JsonAnyGetter @@ -65,7 +63,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ListCustomersResponse other) { + private boolean equalTo(ListCustomersWithSubscriptionsResponse other) { return data.equals(other.data) && params.equals(other.params); } @@ -84,13 +82,16 @@ public static ParamsStage builder() { } public interface ParamsStage { - _FinalStage params(@NotNull ListCustomersParams params); + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListCustomersWithSubscriptionsParams params); - Builder from(ListCustomersResponse other); + Builder from(ListCustomersWithSubscriptionsResponse other); } public interface _FinalStage { - ListCustomersResponse build(); + ListCustomersWithSubscriptionsResponse build(); _FinalStage data(List data); @@ -101,7 +102,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ParamsStage, _FinalStage { - private ListCustomersParams params; + private ListCustomersWithSubscriptionsParams params; private List data = new ArrayList<>(); @@ -111,37 +112,32 @@ public static final class Builder implements ParamsStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(ListCustomersResponse other) { + public Builder from(ListCustomersWithSubscriptionsResponse other) { data(other.getData()); params(other.getParams()); return this; } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @JsonSetter("params") - public _FinalStage params(@NotNull ListCustomersParams params) { + public _FinalStage params(@NotNull ListCustomersWithSubscriptionsParams params) { this.params = Objects.requireNonNull(params, "params must not be null"); return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(BillingCustomerWithSubscriptionsResponseData data) { this.data.add(data); @@ -152,13 +148,15 @@ public _FinalStage addData(BillingCustomerWithSubscriptionsResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } @java.lang.Override - public ListCustomersResponse build() { - return new ListCustomersResponse(data, params, additionalProperties); + public ListCustomersWithSubscriptionsResponse build() { + return new ListCustomersWithSubscriptionsResponse(data, params, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesParams.java index 8c6030d..4aba631 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesParams.java @@ -160,6 +160,9 @@ public Builder customerExternalId(String customerExternalId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -171,6 +174,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesResponse.java index 6a01d94..691efc2 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListInvoicesResponse.java @@ -36,9 +36,6 @@ private ListInvoicesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListInvoicesParams params); Builder from(ListInvoicesResponse other); @@ -116,6 +116,7 @@ public Builder from(ListInvoicesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListInvoicesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(InvoiceResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(InvoiceResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListMetersParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListMetersParams.java index 21b94c7..1aac646 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListMetersParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListMetersParams.java @@ -120,6 +120,9 @@ public Builder displayName(String displayName) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -131,6 +134,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListMetersResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListMetersResponse.java index db6f54e..d32f637 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListMetersResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListMetersResponse.java @@ -36,9 +36,6 @@ private ListMetersResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListMetersParams params); Builder from(ListMetersResponse other); @@ -116,6 +116,7 @@ public Builder from(ListMetersResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListMetersParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(BillingMeterResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(BillingMeterResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsParams.java index ecf2bbb..8d5b171 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsParams.java @@ -146,6 +146,9 @@ public Builder customerExternalId(String customerExternalId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -157,6 +160,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsResponse.java index 4212818..0ad01a7 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListPaymentMethodsResponse.java @@ -38,9 +38,6 @@ private ListPaymentMethodsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListPaymentMethodsParams params); Builder from(ListPaymentMethodsResponse other); @@ -118,6 +118,7 @@ public Builder from(ListPaymentMethodsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListPaymentMethodsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(PaymentMethodResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(PaymentMethodResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesParams.java b/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesParams.java index 46c81ba..88b6f52 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesParams.java @@ -23,6 +23,8 @@ public final class ListProductPricesParams { private final Optional> ids; + private final Optional isActive; + private final Optional limit; private final Optional name; @@ -33,6 +35,8 @@ public final class ListProductPricesParams { private final Optional q; + private final Optional withOneTimeCharges; + private final Optional withPricesOnly; private final Optional withZeroPrice; @@ -43,21 +47,25 @@ public final class ListProductPricesParams { private ListProductPricesParams( Optional> ids, + Optional isActive, Optional limit, Optional name, Optional offset, Optional priceUsageType, Optional q, + Optional withOneTimeCharges, Optional withPricesOnly, Optional withZeroPrice, Optional withoutLinkedToPlan, Map additionalProperties) { this.ids = ids; + this.isActive = isActive; this.limit = limit; this.name = name; this.offset = offset; this.priceUsageType = priceUsageType; this.q = q; + this.withOneTimeCharges = withOneTimeCharges; this.withPricesOnly = withPricesOnly; this.withZeroPrice = withZeroPrice; this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -69,6 +77,14 @@ public Optional> getIds() { return ids; } + /** + * @return Filter products that are active + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + /** * @return Page limit (default 100) */ @@ -100,6 +116,14 @@ public Optional getQ() { return q; } + /** + * @return Filter products that are one time charges + */ + @JsonProperty("with_one_time_charges") + public Optional getWithOneTimeCharges() { + return withOneTimeCharges; + } + /** * @return Filter products that have prices */ @@ -137,11 +161,13 @@ public Map getAdditionalProperties() { private boolean equalTo(ListProductPricesParams other) { return ids.equals(other.ids) + && isActive.equals(other.isActive) && limit.equals(other.limit) && name.equals(other.name) && offset.equals(other.offset) && priceUsageType.equals(other.priceUsageType) && q.equals(other.q) + && withOneTimeCharges.equals(other.withOneTimeCharges) && withPricesOnly.equals(other.withPricesOnly) && withZeroPrice.equals(other.withZeroPrice) && withoutLinkedToPlan.equals(other.withoutLinkedToPlan); @@ -151,11 +177,13 @@ private boolean equalTo(ListProductPricesParams other) { public int hashCode() { return Objects.hash( this.ids, + this.isActive, this.limit, this.name, this.offset, this.priceUsageType, this.q, + this.withOneTimeCharges, this.withPricesOnly, this.withZeroPrice, this.withoutLinkedToPlan); @@ -174,6 +202,8 @@ public static Builder builder() { public static final class Builder { private Optional> ids = Optional.empty(); + private Optional isActive = Optional.empty(); + private Optional limit = Optional.empty(); private Optional name = Optional.empty(); @@ -184,6 +214,8 @@ public static final class Builder { private Optional q = Optional.empty(); + private Optional withOneTimeCharges = Optional.empty(); + private Optional withPricesOnly = Optional.empty(); private Optional withZeroPrice = Optional.empty(); @@ -197,11 +229,13 @@ private Builder() {} public Builder from(ListProductPricesParams other) { ids(other.getIds()); + isActive(other.getIsActive()); limit(other.getLimit()); name(other.getName()); offset(other.getOffset()); priceUsageType(other.getPriceUsageType()); q(other.getQ()); + withOneTimeCharges(other.getWithOneTimeCharges()); withPricesOnly(other.getWithPricesOnly()); withZeroPrice(other.getWithZeroPrice()); withoutLinkedToPlan(other.getWithoutLinkedToPlan()); @@ -219,6 +253,23 @@ public Builder ids(List ids) { return this; } + /** + *

Filter products that are active

+ */ + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -241,6 +292,9 @@ public Builder name(String name) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -274,6 +328,23 @@ public Builder q(String q) { return this; } + /** + *

Filter products that are one time charges

+ */ + @JsonSetter(value = "with_one_time_charges", nulls = Nulls.SKIP) + public Builder withOneTimeCharges(Optional withOneTimeCharges) { + this.withOneTimeCharges = withOneTimeCharges; + return this; + } + + public Builder withOneTimeCharges(Boolean withOneTimeCharges) { + this.withOneTimeCharges = Optional.ofNullable(withOneTimeCharges); + return this; + } + + /** + *

Filter products that have prices

+ */ @JsonSetter(value = "with_prices_only", nulls = Nulls.SKIP) public Builder withPricesOnly(Optional withPricesOnly) { this.withPricesOnly = withPricesOnly; @@ -285,6 +356,9 @@ public Builder withPricesOnly(Boolean withPricesOnly) { return this; } + /** + *

Filter products that have zero price for free subscription type

+ */ @JsonSetter(value = "with_zero_price", nulls = Nulls.SKIP) public Builder withZeroPrice(Optional withZeroPrice) { this.withZeroPrice = withZeroPrice; @@ -296,6 +370,9 @@ public Builder withZeroPrice(Boolean withZeroPrice) { return this; } + /** + *

Filter products that are not linked to any plan

+ */ @JsonSetter(value = "without_linked_to_plan", nulls = Nulls.SKIP) public Builder withoutLinkedToPlan(Optional withoutLinkedToPlan) { this.withoutLinkedToPlan = withoutLinkedToPlan; @@ -310,11 +387,13 @@ public Builder withoutLinkedToPlan(Boolean withoutLinkedToPlan) { public ListProductPricesParams build() { return new ListProductPricesParams( ids, + isActive, limit, name, offset, priceUsageType, q, + withOneTimeCharges, withPricesOnly, withZeroPrice, withoutLinkedToPlan, diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesRequestPriceUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesRequestPriceUsageType.java index 085d59d..ec1594a 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesRequestPriceUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesRequestPriceUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListProductPricesRequestPriceUsageType { - LICENSED("licensed"), +public final class ListProductPricesRequestPriceUsageType { + public static final ListProductPricesRequestPriceUsageType METERED = + new ListProductPricesRequestPriceUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final ListProductPricesRequestPriceUsageType LICENSED = + new ListProductPricesRequestPriceUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - ListProductPricesRequestPriceUsageType(String value) { + private final String string; + + ListProductPricesRequestPriceUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListProductPricesRequestPriceUsageType + && this.string.equals(((ListProductPricesRequestPriceUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListProductPricesRequestPriceUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new ListProductPricesRequestPriceUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesResponse.java b/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesResponse.java index ebb789a..70032cb 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesResponse.java @@ -38,9 +38,6 @@ private ListProductPricesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListProductPricesParams params); Builder from(ListProductPricesResponse other); @@ -118,6 +118,7 @@ public Builder from(ListProductPricesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListProductPricesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(BillingPriceResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(BillingPriceResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesResponseParamsPriceUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesResponseParamsPriceUsageType.java index 8f5236b..987dae9 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesResponseParamsPriceUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/ListProductPricesResponseParamsPriceUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListProductPricesResponseParamsPriceUsageType { - LICENSED("licensed"), +public final class ListProductPricesResponseParamsPriceUsageType { + public static final ListProductPricesResponseParamsPriceUsageType METERED = + new ListProductPricesResponseParamsPriceUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final ListProductPricesResponseParamsPriceUsageType LICENSED = + new ListProductPricesResponseParamsPriceUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - ListProductPricesResponseParamsPriceUsageType(String value) { + private final String string; + + ListProductPricesResponseParamsPriceUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListProductPricesResponseParamsPriceUsageType + && this.string.equals(((ListProductPricesResponseParamsPriceUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListProductPricesResponseParamsPriceUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new ListProductPricesResponseParamsPriceUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesParams.java b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesParams.java index f280c70..ddf7f05 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesParams.java +++ b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesParams.java @@ -21,6 +21,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SearchBillingPricesParams.Builder.class) public final class SearchBillingPricesParams { + private final Optional forInitialPlan; + + private final Optional forTrialExpiryPlan; + private final Optional> ids; private final Optional interval; @@ -31,31 +35,63 @@ public final class SearchBillingPricesParams { private final Optional price; + private final Optional productId; + private final Optional q; + private final Optional requiresPaymentMethod; + + private final Optional tiersMode; + private final Optional usageType; private final Map additionalProperties; private SearchBillingPricesParams( + Optional forInitialPlan, + Optional forTrialExpiryPlan, Optional> ids, Optional interval, Optional limit, Optional offset, Optional price, + Optional productId, Optional q, + Optional requiresPaymentMethod, + Optional tiersMode, Optional usageType, Map additionalProperties) { + this.forInitialPlan = forInitialPlan; + this.forTrialExpiryPlan = forTrialExpiryPlan; this.ids = ids; this.interval = interval; this.limit = limit; this.offset = offset; this.price = price; + this.productId = productId; this.q = q; + this.requiresPaymentMethod = requiresPaymentMethod; + this.tiersMode = tiersMode; this.usageType = usageType; this.additionalProperties = additionalProperties; } + /** + * @return Filter for prices valid for initial plans (free prices only) + */ + @JsonProperty("for_initial_plan") + public Optional getForInitialPlan() { + return forInitialPlan; + } + + /** + * @return Filter for prices valid for trial expiry plans (free prices only) + */ + @JsonProperty("for_trial_expiry_plan") + public Optional getForTrialExpiryPlan() { + return forTrialExpiryPlan; + } + @JsonProperty("ids") public Optional> getIds() { return ids; @@ -87,11 +123,29 @@ public Optional getPrice() { return price; } + @JsonProperty("product_id") + public Optional getProductId() { + return productId; + } + @JsonProperty("q") public Optional getQ() { return q; } + /** + * @return Filter for prices that require a payment method (inverse of ForInitialPlan) + */ + @JsonProperty("requires_payment_method") + public Optional getRequiresPaymentMethod() { + return requiresPaymentMethod; + } + + @JsonProperty("tiers_mode") + public Optional getTiersMode() { + return tiersMode; + } + @JsonProperty("usage_type") public Optional getUsageType() { return usageType; @@ -109,18 +163,35 @@ public Map getAdditionalProperties() { } private boolean equalTo(SearchBillingPricesParams other) { - return ids.equals(other.ids) + return forInitialPlan.equals(other.forInitialPlan) + && forTrialExpiryPlan.equals(other.forTrialExpiryPlan) + && ids.equals(other.ids) && interval.equals(other.interval) && limit.equals(other.limit) && offset.equals(other.offset) && price.equals(other.price) + && productId.equals(other.productId) && q.equals(other.q) + && requiresPaymentMethod.equals(other.requiresPaymentMethod) + && tiersMode.equals(other.tiersMode) && usageType.equals(other.usageType); } @java.lang.Override public int hashCode() { - return Objects.hash(this.ids, this.interval, this.limit, this.offset, this.price, this.q, this.usageType); + return Objects.hash( + this.forInitialPlan, + this.forTrialExpiryPlan, + this.ids, + this.interval, + this.limit, + this.offset, + this.price, + this.productId, + this.q, + this.requiresPaymentMethod, + this.tiersMode, + this.usageType); } @java.lang.Override @@ -134,6 +205,10 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional forInitialPlan = Optional.empty(); + + private Optional forTrialExpiryPlan = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional interval = Optional.empty(); @@ -144,8 +219,14 @@ public static final class Builder { private Optional price = Optional.empty(); + private Optional productId = Optional.empty(); + private Optional q = Optional.empty(); + private Optional requiresPaymentMethod = Optional.empty(); + + private Optional tiersMode = Optional.empty(); + private Optional usageType = Optional.empty(); @JsonAnySetter @@ -154,16 +235,49 @@ public static final class Builder { private Builder() {} public Builder from(SearchBillingPricesParams other) { + forInitialPlan(other.getForInitialPlan()); + forTrialExpiryPlan(other.getForTrialExpiryPlan()); ids(other.getIds()); interval(other.getInterval()); limit(other.getLimit()); offset(other.getOffset()); price(other.getPrice()); + productId(other.getProductId()); q(other.getQ()); + requiresPaymentMethod(other.getRequiresPaymentMethod()); + tiersMode(other.getTiersMode()); usageType(other.getUsageType()); return this; } + /** + *

Filter for prices valid for initial plans (free prices only)

+ */ + @JsonSetter(value = "for_initial_plan", nulls = Nulls.SKIP) + public Builder forInitialPlan(Optional forInitialPlan) { + this.forInitialPlan = forInitialPlan; + return this; + } + + public Builder forInitialPlan(Boolean forInitialPlan) { + this.forInitialPlan = Optional.ofNullable(forInitialPlan); + return this; + } + + /** + *

Filter for prices valid for trial expiry plans (free prices only)

+ */ + @JsonSetter(value = "for_trial_expiry_plan", nulls = Nulls.SKIP) + public Builder forTrialExpiryPlan(Optional forTrialExpiryPlan) { + this.forTrialExpiryPlan = forTrialExpiryPlan; + return this; + } + + public Builder forTrialExpiryPlan(Boolean forTrialExpiryPlan) { + this.forTrialExpiryPlan = Optional.ofNullable(forTrialExpiryPlan); + return this; + } + @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -186,6 +300,9 @@ public Builder interval(String interval) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -197,6 +314,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -219,6 +339,17 @@ public Builder price(Integer price) { return this; } + @JsonSetter(value = "product_id", nulls = Nulls.SKIP) + public Builder productId(Optional productId) { + this.productId = productId; + return this; + } + + public Builder productId(String productId) { + this.productId = Optional.ofNullable(productId); + return this; + } + @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -230,6 +361,31 @@ public Builder q(String q) { return this; } + /** + *

Filter for prices that require a payment method (inverse of ForInitialPlan)

+ */ + @JsonSetter(value = "requires_payment_method", nulls = Nulls.SKIP) + public Builder requiresPaymentMethod(Optional requiresPaymentMethod) { + this.requiresPaymentMethod = requiresPaymentMethod; + return this; + } + + public Builder requiresPaymentMethod(Boolean requiresPaymentMethod) { + this.requiresPaymentMethod = Optional.ofNullable(requiresPaymentMethod); + return this; + } + + @JsonSetter(value = "tiers_mode", nulls = Nulls.SKIP) + public Builder tiersMode(Optional tiersMode) { + this.tiersMode = tiersMode; + return this; + } + + public Builder tiersMode(SearchBillingPricesResponseParamsTiersMode tiersMode) { + this.tiersMode = Optional.ofNullable(tiersMode); + return this; + } + @JsonSetter(value = "usage_type", nulls = Nulls.SKIP) public Builder usageType(Optional usageType) { this.usageType = usageType; @@ -243,7 +399,19 @@ public Builder usageType(SearchBillingPricesResponseParamsUsageType usageType) { public SearchBillingPricesParams build() { return new SearchBillingPricesParams( - ids, interval, limit, offset, price, q, usageType, additionalProperties); + forInitialPlan, + forTrialExpiryPlan, + ids, + interval, + limit, + offset, + price, + productId, + q, + requiresPaymentMethod, + tiersMode, + usageType, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesRequestTiersMode.java b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesRequestTiersMode.java new file mode 100644 index 0000000..9fb8dbe --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesRequestTiersMode.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class SearchBillingPricesRequestTiersMode { + public static final SearchBillingPricesRequestTiersMode GRADUATED = + new SearchBillingPricesRequestTiersMode(Value.GRADUATED, "graduated"); + + public static final SearchBillingPricesRequestTiersMode VOLUME = + new SearchBillingPricesRequestTiersMode(Value.VOLUME, "volume"); + + private final Value value; + + private final String string; + + SearchBillingPricesRequestTiersMode(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SearchBillingPricesRequestTiersMode + && this.string.equals(((SearchBillingPricesRequestTiersMode) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case GRADUATED: + return visitor.visitGraduated(); + case VOLUME: + return visitor.visitVolume(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SearchBillingPricesRequestTiersMode valueOf(String value) { + switch (value) { + case "graduated": + return GRADUATED; + case "volume": + return VOLUME; + default: + return new SearchBillingPricesRequestTiersMode(Value.UNKNOWN, value); + } + } + + public enum Value { + VOLUME, + + GRADUATED, + + UNKNOWN + } + + public interface Visitor { + T visitVolume(); + + T visitGraduated(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesRequestUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesRequestUsageType.java index 984e27e..f10f0cd 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesRequestUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesRequestUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum SearchBillingPricesRequestUsageType { - LICENSED("licensed"), +public final class SearchBillingPricesRequestUsageType { + public static final SearchBillingPricesRequestUsageType METERED = + new SearchBillingPricesRequestUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final SearchBillingPricesRequestUsageType LICENSED = + new SearchBillingPricesRequestUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - SearchBillingPricesRequestUsageType(String value) { + private final String string; + + SearchBillingPricesRequestUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SearchBillingPricesRequestUsageType + && this.string.equals(((SearchBillingPricesRequestUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SearchBillingPricesRequestUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new SearchBillingPricesRequestUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponse.java b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponse.java index 4ea5e3f..08e82ac 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponse.java @@ -36,9 +36,6 @@ private SearchBillingPricesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull SearchBillingPricesParams params); Builder from(SearchBillingPricesResponse other); @@ -116,6 +116,7 @@ public Builder from(SearchBillingPricesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull SearchBillingPricesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(BillingPriceView data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(BillingPriceView data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponseParamsTiersMode.java b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponseParamsTiersMode.java new file mode 100644 index 0000000..02b14a7 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponseParamsTiersMode.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.billing.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class SearchBillingPricesResponseParamsTiersMode { + public static final SearchBillingPricesResponseParamsTiersMode GRADUATED = + new SearchBillingPricesResponseParamsTiersMode(Value.GRADUATED, "graduated"); + + public static final SearchBillingPricesResponseParamsTiersMode VOLUME = + new SearchBillingPricesResponseParamsTiersMode(Value.VOLUME, "volume"); + + private final Value value; + + private final String string; + + SearchBillingPricesResponseParamsTiersMode(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SearchBillingPricesResponseParamsTiersMode + && this.string.equals(((SearchBillingPricesResponseParamsTiersMode) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case GRADUATED: + return visitor.visitGraduated(); + case VOLUME: + return visitor.visitVolume(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SearchBillingPricesResponseParamsTiersMode valueOf(String value) { + switch (value) { + case "graduated": + return GRADUATED; + case "volume": + return VOLUME; + default: + return new SearchBillingPricesResponseParamsTiersMode(Value.UNKNOWN, value); + } + } + + public enum Value { + VOLUME, + + GRADUATED, + + UNKNOWN + } + + public interface Visitor { + T visitVolume(); + + T visitGraduated(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponseParamsUsageType.java b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponseParamsUsageType.java index a4b38f2..9e7a5be 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponseParamsUsageType.java +++ b/src/main/java/com/schematic/api/resources/billing/types/SearchBillingPricesResponseParamsUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.billing.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum SearchBillingPricesResponseParamsUsageType { - LICENSED("licensed"), +public final class SearchBillingPricesResponseParamsUsageType { + public static final SearchBillingPricesResponseParamsUsageType METERED = + new SearchBillingPricesResponseParamsUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final SearchBillingPricesResponseParamsUsageType LICENSED = + new SearchBillingPricesResponseParamsUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - SearchBillingPricesResponseParamsUsageType(String value) { + private final String string; + + SearchBillingPricesResponseParamsUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SearchBillingPricesResponseParamsUsageType + && this.string.equals(((SearchBillingPricesResponseParamsUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SearchBillingPricesResponseParamsUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new SearchBillingPricesResponseParamsUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingCouponResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingCouponResponse.java index c19af89..792f6fa 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingCouponResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingCouponResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertBillingCouponResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingCustomerResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingCustomerResponse.java index a88bfeb..39eb042 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingCustomerResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingCustomerResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertBillingCustomerResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingMeterResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingMeterResponse.java index 6d0e678..46f16fc 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingMeterResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingMeterResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertBillingMeterResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingPriceResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingPriceResponse.java index d6f1c18..3327379 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingPriceResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingPriceResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertBillingPriceResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingProductResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingProductResponse.java index 90654ee..d6dc744 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingProductResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingProductResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertBillingProductResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingSubscriptionResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingSubscriptionResponse.java index 95b9478..7536296 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingSubscriptionResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/UpsertBillingSubscriptionResponse.java @@ -89,6 +89,9 @@ public interface DataStage { public interface _FinalStage { UpsertBillingSubscriptionResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -137,15 +140,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpsertInvoiceResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpsertInvoiceResponse.java index 6de71b8..8ac5365 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/UpsertInvoiceResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/UpsertInvoiceResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertInvoiceResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/billing/types/UpsertPaymentMethodResponse.java b/src/main/java/com/schematic/api/resources/billing/types/UpsertPaymentMethodResponse.java index 10f1255..5d8f8a6 100644 --- a/src/main/java/com/schematic/api/resources/billing/types/UpsertPaymentMethodResponse.java +++ b/src/main/java/com/schematic/api/resources/billing/types/UpsertPaymentMethodResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertPaymentMethodResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/checkout/AsyncCheckoutClient.java b/src/main/java/com/schematic/api/resources/checkout/AsyncCheckoutClient.java new file mode 100644 index 0000000..fc0b9b9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/checkout/AsyncCheckoutClient.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.checkout; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.checkout.requests.CheckoutDataRequestBody; +import com.schematic.api.resources.checkout.requests.UpdateTrialEndRequestBody; +import com.schematic.api.resources.checkout.types.CheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.GetCheckoutDataResponse; +import com.schematic.api.resources.checkout.types.ManagePlanResponse; +import com.schematic.api.resources.checkout.types.PreviewCheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.PreviewManagePlanResponse; +import com.schematic.api.resources.checkout.types.UpdateCustomerSubscriptionTrialEndResponse; +import com.schematic.api.types.ChangeSubscriptionInternalRequestBody; +import com.schematic.api.types.ManagePlanRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncCheckoutClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCheckoutClient rawClient; + + public AsyncCheckoutClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCheckoutClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCheckoutClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture internal(ChangeSubscriptionInternalRequestBody request) { + return this.rawClient.internal(request).thenApply(response -> response.body()); + } + + public CompletableFuture internal( + ChangeSubscriptionInternalRequestBody request, RequestOptions requestOptions) { + return this.rawClient.internal(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getCheckoutData(CheckoutDataRequestBody request) { + return this.rawClient.getCheckoutData(request).thenApply(response -> response.body()); + } + + public CompletableFuture getCheckoutData( + CheckoutDataRequestBody request, RequestOptions requestOptions) { + return this.rawClient.getCheckoutData(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture previewCheckoutInternal( + ChangeSubscriptionInternalRequestBody request) { + return this.rawClient.previewCheckoutInternal(request).thenApply(response -> response.body()); + } + + public CompletableFuture previewCheckoutInternal( + ChangeSubscriptionInternalRequestBody request, RequestOptions requestOptions) { + return this.rawClient.previewCheckoutInternal(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture managePlan(ManagePlanRequest request) { + return this.rawClient.managePlan(request).thenApply(response -> response.body()); + } + + public CompletableFuture managePlan(ManagePlanRequest request, RequestOptions requestOptions) { + return this.rawClient.managePlan(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture previewManagePlan(ManagePlanRequest request) { + return this.rawClient.previewManagePlan(request).thenApply(response -> response.body()); + } + + public CompletableFuture previewManagePlan( + ManagePlanRequest request, RequestOptions requestOptions) { + return this.rawClient.previewManagePlan(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateCustomerSubscriptionTrialEnd( + String subscriptionId) { + return this.rawClient.updateCustomerSubscriptionTrialEnd(subscriptionId).thenApply(response -> response.body()); + } + + public CompletableFuture updateCustomerSubscriptionTrialEnd( + String subscriptionId, UpdateTrialEndRequestBody request) { + return this.rawClient + .updateCustomerSubscriptionTrialEnd(subscriptionId, request) + .thenApply(response -> response.body()); + } + + public CompletableFuture updateCustomerSubscriptionTrialEnd( + String subscriptionId, UpdateTrialEndRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCustomerSubscriptionTrialEnd(subscriptionId, request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/checkout/AsyncRawCheckoutClient.java b/src/main/java/com/schematic/api/resources/checkout/AsyncRawCheckoutClient.java new file mode 100644 index 0000000..6155c83 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/checkout/AsyncRawCheckoutClient.java @@ -0,0 +1,610 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.checkout; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.checkout.requests.CheckoutDataRequestBody; +import com.schematic.api.resources.checkout.requests.UpdateTrialEndRequestBody; +import com.schematic.api.resources.checkout.types.CheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.GetCheckoutDataResponse; +import com.schematic.api.resources.checkout.types.ManagePlanResponse; +import com.schematic.api.resources.checkout.types.PreviewCheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.PreviewManagePlanResponse; +import com.schematic.api.resources.checkout.types.UpdateCustomerSubscriptionTrialEndResponse; +import com.schematic.api.types.ApiError; +import com.schematic.api.types.ChangeSubscriptionInternalRequestBody; +import com.schematic.api.types.ManagePlanRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCheckoutClient { + protected final ClientOptions clientOptions; + + public AsyncRawCheckoutClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> internal( + ChangeSubscriptionInternalRequestBody request) { + return internal(request, null); + } + + public CompletableFuture> internal( + ChangeSubscriptionInternalRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("checkout-internal") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CheckoutInternalResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getCheckoutData( + CheckoutDataRequestBody request) { + return getCheckoutData(request, null); + } + + public CompletableFuture> getCheckoutData( + CheckoutDataRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("checkout-internal/data") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetCheckoutDataResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> previewCheckoutInternal( + ChangeSubscriptionInternalRequestBody request) { + return previewCheckoutInternal(request, null); + } + + public CompletableFuture> previewCheckoutInternal( + ChangeSubscriptionInternalRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("checkout-internal/preview") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PreviewCheckoutInternalResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> managePlan(ManagePlanRequest request) { + return managePlan(request, null); + } + + public CompletableFuture> managePlan( + ManagePlanRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("manage-plan") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ManagePlanResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> previewManagePlan( + ManagePlanRequest request) { + return previewManagePlan(request, null); + } + + public CompletableFuture> previewManagePlan( + ManagePlanRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("manage-plan/preview") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PreviewManagePlanResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + updateCustomerSubscriptionTrialEnd(String subscriptionId) { + return updateCustomerSubscriptionTrialEnd( + subscriptionId, UpdateTrialEndRequestBody.builder().build()); + } + + public CompletableFuture> + updateCustomerSubscriptionTrialEnd(String subscriptionId, UpdateTrialEndRequestBody request) { + return updateCustomerSubscriptionTrialEnd(subscriptionId, request, null); + } + + public CompletableFuture> + updateCustomerSubscriptionTrialEnd( + String subscriptionId, UpdateTrialEndRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("subscription") + .addPathSegment(subscriptionId) + .addPathSegments("edit-trial-end") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateCustomerSubscriptionTrialEndResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/checkout/CheckoutClient.java b/src/main/java/com/schematic/api/resources/checkout/CheckoutClient.java index f440d05..ce31ded 100644 --- a/src/main/java/com/schematic/api/resources/checkout/CheckoutClient.java +++ b/src/main/java/com/schematic/api/resources/checkout/CheckoutClient.java @@ -3,295 +3,93 @@ */ package com.schematic.api.resources.checkout; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.NotFoundError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.checkout.requests.CheckoutDataRequestBody; import com.schematic.api.resources.checkout.requests.UpdateTrialEndRequestBody; import com.schematic.api.resources.checkout.types.CheckoutInternalResponse; import com.schematic.api.resources.checkout.types.GetCheckoutDataResponse; +import com.schematic.api.resources.checkout.types.ManagePlanResponse; import com.schematic.api.resources.checkout.types.PreviewCheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.PreviewManagePlanResponse; import com.schematic.api.resources.checkout.types.UpdateCustomerSubscriptionTrialEndResponse; -import com.schematic.api.types.ApiError; import com.schematic.api.types.ChangeSubscriptionInternalRequestBody; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; +import com.schematic.api.types.ManagePlanRequest; public class CheckoutClient { protected final ClientOptions clientOptions; + private final RawCheckoutClient rawClient; + public CheckoutClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCheckoutClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCheckoutClient withRawResponse() { + return this.rawClient; } public CheckoutInternalResponse internal(ChangeSubscriptionInternalRequestBody request) { - return internal(request, null); + return this.rawClient.internal(request).body(); } public CheckoutInternalResponse internal( ChangeSubscriptionInternalRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("checkout-internal") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckoutInternalResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.internal(request, requestOptions).body(); } public GetCheckoutDataResponse getCheckoutData(CheckoutDataRequestBody request) { - return getCheckoutData(request, null); + return this.rawClient.getCheckoutData(request).body(); } public GetCheckoutDataResponse getCheckoutData(CheckoutDataRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("checkout-internal/data") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetCheckoutDataResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getCheckoutData(request, requestOptions).body(); } public PreviewCheckoutInternalResponse previewCheckoutInternal(ChangeSubscriptionInternalRequestBody request) { - return previewCheckoutInternal(request, null); + return this.rawClient.previewCheckoutInternal(request).body(); } public PreviewCheckoutInternalResponse previewCheckoutInternal( ChangeSubscriptionInternalRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("checkout-internal/preview") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PreviewCheckoutInternalResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.previewCheckoutInternal(request, requestOptions).body(); + } + + public ManagePlanResponse managePlan(ManagePlanRequest request) { + return this.rawClient.managePlan(request).body(); + } + + public ManagePlanResponse managePlan(ManagePlanRequest request, RequestOptions requestOptions) { + return this.rawClient.managePlan(request, requestOptions).body(); + } + + public PreviewManagePlanResponse previewManagePlan(ManagePlanRequest request) { + return this.rawClient.previewManagePlan(request).body(); + } + + public PreviewManagePlanResponse previewManagePlan(ManagePlanRequest request, RequestOptions requestOptions) { + return this.rawClient.previewManagePlan(request, requestOptions).body(); } public UpdateCustomerSubscriptionTrialEndResponse updateCustomerSubscriptionTrialEnd(String subscriptionId) { - return updateCustomerSubscriptionTrialEnd( - subscriptionId, UpdateTrialEndRequestBody.builder().build()); + return this.rawClient.updateCustomerSubscriptionTrialEnd(subscriptionId).body(); } public UpdateCustomerSubscriptionTrialEndResponse updateCustomerSubscriptionTrialEnd( String subscriptionId, UpdateTrialEndRequestBody request) { - return updateCustomerSubscriptionTrialEnd(subscriptionId, request, null); + return this.rawClient + .updateCustomerSubscriptionTrialEnd(subscriptionId, request) + .body(); } public UpdateCustomerSubscriptionTrialEndResponse updateCustomerSubscriptionTrialEnd( String subscriptionId, UpdateTrialEndRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("subscription") - .addPathSegment(subscriptionId) - .addPathSegments("edit-trial-end") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), UpdateCustomerSubscriptionTrialEndResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient + .updateCustomerSubscriptionTrialEnd(subscriptionId, request, requestOptions) + .body(); } } diff --git a/src/main/java/com/schematic/api/resources/checkout/RawCheckoutClient.java b/src/main/java/com/schematic/api/resources/checkout/RawCheckoutClient.java new file mode 100644 index 0000000..a4435e9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/checkout/RawCheckoutClient.java @@ -0,0 +1,458 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.checkout; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.checkout.requests.CheckoutDataRequestBody; +import com.schematic.api.resources.checkout.requests.UpdateTrialEndRequestBody; +import com.schematic.api.resources.checkout.types.CheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.GetCheckoutDataResponse; +import com.schematic.api.resources.checkout.types.ManagePlanResponse; +import com.schematic.api.resources.checkout.types.PreviewCheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.PreviewManagePlanResponse; +import com.schematic.api.resources.checkout.types.UpdateCustomerSubscriptionTrialEndResponse; +import com.schematic.api.types.ApiError; +import com.schematic.api.types.ChangeSubscriptionInternalRequestBody; +import com.schematic.api.types.ManagePlanRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCheckoutClient { + protected final ClientOptions clientOptions; + + public RawCheckoutClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse internal(ChangeSubscriptionInternalRequestBody request) { + return internal(request, null); + } + + public BaseSchematicHttpResponse internal( + ChangeSubscriptionInternalRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("checkout-internal") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckoutInternalResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getCheckoutData(CheckoutDataRequestBody request) { + return getCheckoutData(request, null); + } + + public BaseSchematicHttpResponse getCheckoutData( + CheckoutDataRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("checkout-internal/data") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetCheckoutDataResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse previewCheckoutInternal( + ChangeSubscriptionInternalRequestBody request) { + return previewCheckoutInternal(request, null); + } + + public BaseSchematicHttpResponse previewCheckoutInternal( + ChangeSubscriptionInternalRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("checkout-internal/preview") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PreviewCheckoutInternalResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse managePlan(ManagePlanRequest request) { + return managePlan(request, null); + } + + public BaseSchematicHttpResponse managePlan( + ManagePlanRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("manage-plan") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ManagePlanResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse previewManagePlan(ManagePlanRequest request) { + return previewManagePlan(request, null); + } + + public BaseSchematicHttpResponse previewManagePlan( + ManagePlanRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("manage-plan/preview") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PreviewManagePlanResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateCustomerSubscriptionTrialEnd( + String subscriptionId) { + return updateCustomerSubscriptionTrialEnd( + subscriptionId, UpdateTrialEndRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse updateCustomerSubscriptionTrialEnd( + String subscriptionId, UpdateTrialEndRequestBody request) { + return updateCustomerSubscriptionTrialEnd(subscriptionId, request, null); + } + + public BaseSchematicHttpResponse updateCustomerSubscriptionTrialEnd( + String subscriptionId, UpdateTrialEndRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("subscription") + .addPathSegment(subscriptionId) + .addPathSegments("edit-trial-end") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateCustomerSubscriptionTrialEndResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/checkout/types/CheckoutInternalResponse.java b/src/main/java/com/schematic/api/resources/checkout/types/CheckoutInternalResponse.java index 81a4ac0..e02d09b 100644 --- a/src/main/java/com/schematic/api/resources/checkout/types/CheckoutInternalResponse.java +++ b/src/main/java/com/schematic/api/resources/checkout/types/CheckoutInternalResponse.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import com.schematic.api.types.BillingSubscriptionResponseData; +import com.schematic.api.types.CheckoutSubscription; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -23,23 +23,21 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CheckoutInternalResponse.Builder.class) public final class CheckoutInternalResponse { - private final BillingSubscriptionResponseData data; + private final CheckoutSubscription data; private final Map params; private final Map additionalProperties; private CheckoutInternalResponse( - BillingSubscriptionResponseData data, - Map params, - Map additionalProperties) { + CheckoutSubscription data, Map params, Map additionalProperties) { this.data = data; this.params = params; this.additionalProperties = additionalProperties; } @JsonProperty("data") - public BillingSubscriptionResponseData getData() { + public CheckoutSubscription getData() { return data; } @@ -81,7 +79,7 @@ public static DataStage builder() { } public interface DataStage { - _FinalStage data(@NotNull BillingSubscriptionResponseData data); + _FinalStage data(@NotNull CheckoutSubscription data); Builder from(CheckoutInternalResponse other); } @@ -89,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CheckoutInternalResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -98,7 +99,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements DataStage, _FinalStage { - private BillingSubscriptionResponseData data; + private CheckoutSubscription data; private Map params = new LinkedHashMap<>(); @@ -116,7 +117,7 @@ public Builder from(CheckoutInternalResponse other) { @java.lang.Override @JsonSetter("data") - public _FinalStage data(@NotNull BillingSubscriptionResponseData data) { + public _FinalStage data(@NotNull CheckoutSubscription data) { this.data = Objects.requireNonNull(data, "data must not be null"); return this; } @@ -137,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/checkout/types/GetCheckoutDataResponse.java b/src/main/java/com/schematic/api/resources/checkout/types/GetCheckoutDataResponse.java index bb79648..7ddcddc 100644 --- a/src/main/java/com/schematic/api/resources/checkout/types/GetCheckoutDataResponse.java +++ b/src/main/java/com/schematic/api/resources/checkout/types/GetCheckoutDataResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetCheckoutDataResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/UpdateAudienceResponse.java b/src/main/java/com/schematic/api/resources/checkout/types/ManagePlanResponse.java similarity index 74% rename from src/main/java/com/schematic/api/resources/plans/types/UpdateAudienceResponse.java rename to src/main/java/com/schematic/api/resources/checkout/types/ManagePlanResponse.java index c52de62..6fb75b7 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/UpdateAudienceResponse.java +++ b/src/main/java/com/schematic/api/resources/checkout/types/ManagePlanResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.schematic.api.resources.plans.types; +package com.schematic.api.resources.checkout.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import com.schematic.api.types.PlanAudienceDetailResponseData; +import com.schematic.api.types.ManagePlanResponseResponseData; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -21,16 +21,16 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = UpdateAudienceResponse.Builder.class) -public final class UpdateAudienceResponse { - private final PlanAudienceDetailResponseData data; +@JsonDeserialize(builder = ManagePlanResponse.Builder.class) +public final class ManagePlanResponse { + private final ManagePlanResponseResponseData data; private final Map params; private final Map additionalProperties; - private UpdateAudienceResponse( - PlanAudienceDetailResponseData data, + private ManagePlanResponse( + ManagePlanResponseResponseData data, Map params, Map additionalProperties) { this.data = data; @@ -39,7 +39,7 @@ private UpdateAudienceResponse( } @JsonProperty("data") - public PlanAudienceDetailResponseData getData() { + public ManagePlanResponseResponseData getData() { return data; } @@ -54,7 +54,7 @@ public Map getParams() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof UpdateAudienceResponse && equalTo((UpdateAudienceResponse) other); + return other instanceof ManagePlanResponse && equalTo((ManagePlanResponse) other); } @JsonAnyGetter @@ -62,7 +62,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(UpdateAudienceResponse other) { + private boolean equalTo(ManagePlanResponse other) { return data.equals(other.data) && params.equals(other.params); } @@ -81,14 +81,17 @@ public static DataStage builder() { } public interface DataStage { - _FinalStage data(@NotNull PlanAudienceDetailResponseData data); + _FinalStage data(@NotNull ManagePlanResponseResponseData data); - Builder from(UpdateAudienceResponse other); + Builder from(ManagePlanResponse other); } public interface _FinalStage { - UpdateAudienceResponse build(); + ManagePlanResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -98,7 +101,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements DataStage, _FinalStage { - private PlanAudienceDetailResponseData data; + private ManagePlanResponseResponseData data; private Map params = new LinkedHashMap<>(); @@ -108,7 +111,7 @@ public static final class Builder implements DataStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(UpdateAudienceResponse other) { + public Builder from(ManagePlanResponse other) { data(other.getData()); params(other.getParams()); return this; @@ -116,7 +119,7 @@ public Builder from(UpdateAudienceResponse other) { @java.lang.Override @JsonSetter("data") - public _FinalStage data(@NotNull PlanAudienceDetailResponseData data) { + public _FinalStage data(@NotNull ManagePlanResponseResponseData data) { this.data = Objects.requireNonNull(data, "data must not be null"); return this; } @@ -137,21 +140,28 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } @java.lang.Override - public UpdateAudienceResponse build() { - return new UpdateAudienceResponse(data, params, additionalProperties); + public ManagePlanResponse build() { + return new ManagePlanResponse(data, params, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/checkout/types/PreviewCheckoutInternalResponse.java b/src/main/java/com/schematic/api/resources/checkout/types/PreviewCheckoutInternalResponse.java index a6fb305..2c0c27f 100644 --- a/src/main/java/com/schematic/api/resources/checkout/types/PreviewCheckoutInternalResponse.java +++ b/src/main/java/com/schematic/api/resources/checkout/types/PreviewCheckoutInternalResponse.java @@ -89,6 +89,9 @@ public interface DataStage { public interface _FinalStage { PreviewCheckoutInternalResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -137,15 +140,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/checkout/types/PreviewManagePlanResponse.java b/src/main/java/com/schematic/api/resources/checkout/types/PreviewManagePlanResponse.java new file mode 100644 index 0000000..ad92c2b --- /dev/null +++ b/src/main/java/com/schematic/api/resources/checkout/types/PreviewManagePlanResponse.java @@ -0,0 +1,167 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.checkout.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.ManagePlanPreviewResponseResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PreviewManagePlanResponse.Builder.class) +public final class PreviewManagePlanResponse { + private final ManagePlanPreviewResponseResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private PreviewManagePlanResponse( + ManagePlanPreviewResponseResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public ManagePlanPreviewResponseResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PreviewManagePlanResponse && equalTo((PreviewManagePlanResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PreviewManagePlanResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull ManagePlanPreviewResponseResponseData data); + + Builder from(PreviewManagePlanResponse other); + } + + public interface _FinalStage { + PreviewManagePlanResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private ManagePlanPreviewResponseResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PreviewManagePlanResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull ManagePlanPreviewResponseResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public PreviewManagePlanResponse build() { + return new PreviewManagePlanResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/checkout/types/UpdateCustomerSubscriptionTrialEndResponse.java b/src/main/java/com/schematic/api/resources/checkout/types/UpdateCustomerSubscriptionTrialEndResponse.java index 02f0b6a..c809edf 100644 --- a/src/main/java/com/schematic/api/resources/checkout/types/UpdateCustomerSubscriptionTrialEndResponse.java +++ b/src/main/java/com/schematic/api/resources/checkout/types/UpdateCustomerSubscriptionTrialEndResponse.java @@ -88,6 +88,9 @@ public interface DataStage { public interface _FinalStage { UpdateCustomerSubscriptionTrialEndResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -136,15 +139,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/AsyncCompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/AsyncCompaniesClient.java new file mode 100644 index 0000000..4a306b4 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/AsyncCompaniesClient.java @@ -0,0 +1,566 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.companies.requests.CountCompaniesForAdvancedFilterRequest; +import com.schematic.api.resources.companies.requests.CountCompaniesRequest; +import com.schematic.api.resources.companies.requests.CountEntityKeyDefinitionsRequest; +import com.schematic.api.resources.companies.requests.CountEntityTraitDefinitionsRequest; +import com.schematic.api.resources.companies.requests.CountPlanTraitsRequest; +import com.schematic.api.resources.companies.requests.CountUsersRequest; +import com.schematic.api.resources.companies.requests.CreateEntityTraitDefinitionRequestBody; +import com.schematic.api.resources.companies.requests.CreatePlanTraitRequestBody; +import com.schematic.api.resources.companies.requests.GetActiveCompanySubscriptionRequest; +import com.schematic.api.resources.companies.requests.GetActiveDealsRequest; +import com.schematic.api.resources.companies.requests.GetEntityTraitValuesRequest; +import com.schematic.api.resources.companies.requests.GetOrCreateCompanyMembershipRequestBody; +import com.schematic.api.resources.companies.requests.ListCompaniesForAdvancedFilterRequest; +import com.schematic.api.resources.companies.requests.ListCompaniesRequest; +import com.schematic.api.resources.companies.requests.ListCompanyMembershipsRequest; +import com.schematic.api.resources.companies.requests.ListEntityKeyDefinitionsRequest; +import com.schematic.api.resources.companies.requests.ListEntityTraitDefinitionsRequest; +import com.schematic.api.resources.companies.requests.ListPlanChangesRequest; +import com.schematic.api.resources.companies.requests.ListPlanTraitsRequest; +import com.schematic.api.resources.companies.requests.ListUsersRequest; +import com.schematic.api.resources.companies.requests.LookupCompanyRequest; +import com.schematic.api.resources.companies.requests.LookupUserRequest; +import com.schematic.api.resources.companies.requests.UpdateEntityTraitDefinitionRequestBody; +import com.schematic.api.resources.companies.requests.UpdatePlanTraitBulkRequestBody; +import com.schematic.api.resources.companies.requests.UpdatePlanTraitRequestBody; +import com.schematic.api.resources.companies.types.CountCompaniesForAdvancedFilterResponse; +import com.schematic.api.resources.companies.types.CountCompaniesResponse; +import com.schematic.api.resources.companies.types.CountEntityKeyDefinitionsResponse; +import com.schematic.api.resources.companies.types.CountEntityTraitDefinitionsResponse; +import com.schematic.api.resources.companies.types.CountPlanTraitsResponse; +import com.schematic.api.resources.companies.types.CountUsersResponse; +import com.schematic.api.resources.companies.types.CreateCompanyResponse; +import com.schematic.api.resources.companies.types.CreatePlanTraitResponse; +import com.schematic.api.resources.companies.types.CreateUserResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyByKeysResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyMembershipResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyResponse; +import com.schematic.api.resources.companies.types.DeletePlanTraitResponse; +import com.schematic.api.resources.companies.types.DeleteUserByKeysResponse; +import com.schematic.api.resources.companies.types.DeleteUserResponse; +import com.schematic.api.resources.companies.types.GetActiveCompanySubscriptionResponse; +import com.schematic.api.resources.companies.types.GetActiveDealsResponse; +import com.schematic.api.resources.companies.types.GetCompanyResponse; +import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.GetEntityTraitValuesResponse; +import com.schematic.api.resources.companies.types.GetOrCreateCompanyMembershipResponse; +import com.schematic.api.resources.companies.types.GetOrCreateEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.GetPlanChangeResponse; +import com.schematic.api.resources.companies.types.GetPlanTraitResponse; +import com.schematic.api.resources.companies.types.GetUserResponse; +import com.schematic.api.resources.companies.types.ListCompaniesForAdvancedFilterResponse; +import com.schematic.api.resources.companies.types.ListCompaniesResponse; +import com.schematic.api.resources.companies.types.ListCompanyMembershipsResponse; +import com.schematic.api.resources.companies.types.ListEntityKeyDefinitionsResponse; +import com.schematic.api.resources.companies.types.ListEntityTraitDefinitionsResponse; +import com.schematic.api.resources.companies.types.ListPlanChangesResponse; +import com.schematic.api.resources.companies.types.ListPlanTraitsResponse; +import com.schematic.api.resources.companies.types.ListUsersResponse; +import com.schematic.api.resources.companies.types.LookupCompanyResponse; +import com.schematic.api.resources.companies.types.LookupUserResponse; +import com.schematic.api.resources.companies.types.UpdateEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.UpdatePlanTraitResponse; +import com.schematic.api.resources.companies.types.UpdatePlanTraitsBulkResponse; +import com.schematic.api.resources.companies.types.UpsertCompanyResponse; +import com.schematic.api.resources.companies.types.UpsertCompanyTraitResponse; +import com.schematic.api.resources.companies.types.UpsertUserResponse; +import com.schematic.api.resources.companies.types.UpsertUserTraitResponse; +import com.schematic.api.types.KeysRequestBody; +import com.schematic.api.types.UpsertCompanyRequestBody; +import com.schematic.api.types.UpsertTraitRequestBody; +import com.schematic.api.types.UpsertUserRequestBody; +import java.util.concurrent.CompletableFuture; + +public class AsyncCompaniesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCompaniesClient rawClient; + + public AsyncCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCompaniesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCompaniesClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture listCompanies() { + return this.rawClient.listCompanies().thenApply(response -> response.body()); + } + + public CompletableFuture listCompanies(ListCompaniesRequest request) { + return this.rawClient.listCompanies(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCompanies( + ListCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient.listCompanies(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertCompany(UpsertCompanyRequestBody request) { + return this.rawClient.upsertCompany(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertCompany( + UpsertCompanyRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertCompany(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getCompany(String companyId) { + return this.rawClient.getCompany(companyId).thenApply(response -> response.body()); + } + + public CompletableFuture getCompany(String companyId, RequestOptions requestOptions) { + return this.rawClient.getCompany(companyId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteCompany(String companyId) { + return this.rawClient.deleteCompany(companyId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteCompany(String companyId, RequestOptions requestOptions) { + return this.rawClient.deleteCompany(companyId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countCompanies() { + return this.rawClient.countCompanies().thenApply(response -> response.body()); + } + + public CompletableFuture countCompanies(CountCompaniesRequest request) { + return this.rawClient.countCompanies(request).thenApply(response -> response.body()); + } + + public CompletableFuture countCompanies( + CountCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient.countCompanies(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countCompaniesForAdvancedFilter() { + return this.rawClient.countCompaniesForAdvancedFilter().thenApply(response -> response.body()); + } + + public CompletableFuture countCompaniesForAdvancedFilter( + CountCompaniesForAdvancedFilterRequest request) { + return this.rawClient.countCompaniesForAdvancedFilter(request).thenApply(response -> response.body()); + } + + public CompletableFuture countCompaniesForAdvancedFilter( + CountCompaniesForAdvancedFilterRequest request, RequestOptions requestOptions) { + return this.rawClient + .countCompaniesForAdvancedFilter(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture createCompany(UpsertCompanyRequestBody request) { + return this.rawClient.createCompany(request).thenApply(response -> response.body()); + } + + public CompletableFuture createCompany( + UpsertCompanyRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createCompany(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteCompanyByKeys(KeysRequestBody request) { + return this.rawClient.deleteCompanyByKeys(request).thenApply(response -> response.body()); + } + + public CompletableFuture deleteCompanyByKeys( + KeysRequestBody request, RequestOptions requestOptions) { + return this.rawClient.deleteCompanyByKeys(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listCompaniesForAdvancedFilter() { + return this.rawClient.listCompaniesForAdvancedFilter().thenApply(response -> response.body()); + } + + public CompletableFuture listCompaniesForAdvancedFilter( + ListCompaniesForAdvancedFilterRequest request) { + return this.rawClient.listCompaniesForAdvancedFilter(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCompaniesForAdvancedFilter( + ListCompaniesForAdvancedFilterRequest request, RequestOptions requestOptions) { + return this.rawClient + .listCompaniesForAdvancedFilter(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture lookupCompany(LookupCompanyRequest request) { + return this.rawClient.lookupCompany(request).thenApply(response -> response.body()); + } + + public CompletableFuture lookupCompany( + LookupCompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.lookupCompany(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getActiveDeals(GetActiveDealsRequest request) { + return this.rawClient.getActiveDeals(request).thenApply(response -> response.body()); + } + + public CompletableFuture getActiveDeals( + GetActiveDealsRequest request, RequestOptions requestOptions) { + return this.rawClient.getActiveDeals(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyMemberships() { + return this.rawClient.listCompanyMemberships().thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyMemberships( + ListCompanyMembershipsRequest request) { + return this.rawClient.listCompanyMemberships(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyMemberships( + ListCompanyMembershipsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCompanyMemberships(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getOrCreateCompanyMembership( + GetOrCreateCompanyMembershipRequestBody request) { + return this.rawClient.getOrCreateCompanyMembership(request).thenApply(response -> response.body()); + } + + public CompletableFuture getOrCreateCompanyMembership( + GetOrCreateCompanyMembershipRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .getOrCreateCompanyMembership(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deleteCompanyMembership(String companyMembershipId) { + return this.rawClient.deleteCompanyMembership(companyMembershipId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteCompanyMembership( + String companyMembershipId, RequestOptions requestOptions) { + return this.rawClient + .deleteCompanyMembership(companyMembershipId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture getActiveCompanySubscription() { + return this.rawClient.getActiveCompanySubscription().thenApply(response -> response.body()); + } + + public CompletableFuture getActiveCompanySubscription( + GetActiveCompanySubscriptionRequest request) { + return this.rawClient.getActiveCompanySubscription(request).thenApply(response -> response.body()); + } + + public CompletableFuture getActiveCompanySubscription( + GetActiveCompanySubscriptionRequest request, RequestOptions requestOptions) { + return this.rawClient + .getActiveCompanySubscription(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture upsertCompanyTrait(UpsertTraitRequestBody request) { + return this.rawClient.upsertCompanyTrait(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertCompanyTrait( + UpsertTraitRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertCompanyTrait(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listEntityKeyDefinitions() { + return this.rawClient.listEntityKeyDefinitions().thenApply(response -> response.body()); + } + + public CompletableFuture listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest request) { + return this.rawClient.listEntityKeyDefinitions(request).thenApply(response -> response.body()); + } + + public CompletableFuture listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest request, RequestOptions requestOptions) { + return this.rawClient.listEntityKeyDefinitions(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countEntityKeyDefinitions() { + return this.rawClient.countEntityKeyDefinitions().thenApply(response -> response.body()); + } + + public CompletableFuture countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest request) { + return this.rawClient.countEntityKeyDefinitions(request).thenApply(response -> response.body()); + } + + public CompletableFuture countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest request, RequestOptions requestOptions) { + return this.rawClient.countEntityKeyDefinitions(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listEntityTraitDefinitions() { + return this.rawClient.listEntityTraitDefinitions().thenApply(response -> response.body()); + } + + public CompletableFuture listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest request) { + return this.rawClient.listEntityTraitDefinitions(request).thenApply(response -> response.body()); + } + + public CompletableFuture listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest request, RequestOptions requestOptions) { + return this.rawClient + .listEntityTraitDefinitions(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture getOrCreateEntityTraitDefinition( + CreateEntityTraitDefinitionRequestBody request) { + return this.rawClient.getOrCreateEntityTraitDefinition(request).thenApply(response -> response.body()); + } + + public CompletableFuture getOrCreateEntityTraitDefinition( + CreateEntityTraitDefinitionRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .getOrCreateEntityTraitDefinition(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture getEntityTraitDefinition( + String entityTraitDefinitionId) { + return this.rawClient.getEntityTraitDefinition(entityTraitDefinitionId).thenApply(response -> response.body()); + } + + public CompletableFuture getEntityTraitDefinition( + String entityTraitDefinitionId, RequestOptions requestOptions) { + return this.rawClient + .getEntityTraitDefinition(entityTraitDefinitionId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture updateEntityTraitDefinition( + String entityTraitDefinitionId, UpdateEntityTraitDefinitionRequestBody request) { + return this.rawClient + .updateEntityTraitDefinition(entityTraitDefinitionId, request) + .thenApply(response -> response.body()); + } + + public CompletableFuture updateEntityTraitDefinition( + String entityTraitDefinitionId, + UpdateEntityTraitDefinitionRequestBody request, + RequestOptions requestOptions) { + return this.rawClient + .updateEntityTraitDefinition(entityTraitDefinitionId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture countEntityTraitDefinitions() { + return this.rawClient.countEntityTraitDefinitions().thenApply(response -> response.body()); + } + + public CompletableFuture countEntityTraitDefinitions( + CountEntityTraitDefinitionsRequest request) { + return this.rawClient.countEntityTraitDefinitions(request).thenApply(response -> response.body()); + } + + public CompletableFuture countEntityTraitDefinitions( + CountEntityTraitDefinitionsRequest request, RequestOptions requestOptions) { + return this.rawClient + .countEntityTraitDefinitions(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture getEntityTraitValues(GetEntityTraitValuesRequest request) { + return this.rawClient.getEntityTraitValues(request).thenApply(response -> response.body()); + } + + public CompletableFuture getEntityTraitValues( + GetEntityTraitValuesRequest request, RequestOptions requestOptions) { + return this.rawClient.getEntityTraitValues(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listPlanChanges() { + return this.rawClient.listPlanChanges().thenApply(response -> response.body()); + } + + public CompletableFuture listPlanChanges(ListPlanChangesRequest request) { + return this.rawClient.listPlanChanges(request).thenApply(response -> response.body()); + } + + public CompletableFuture listPlanChanges( + ListPlanChangesRequest request, RequestOptions requestOptions) { + return this.rawClient.listPlanChanges(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getPlanChange(String planChangeId) { + return this.rawClient.getPlanChange(planChangeId).thenApply(response -> response.body()); + } + + public CompletableFuture getPlanChange(String planChangeId, RequestOptions requestOptions) { + return this.rawClient.getPlanChange(planChangeId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listPlanTraits() { + return this.rawClient.listPlanTraits().thenApply(response -> response.body()); + } + + public CompletableFuture listPlanTraits(ListPlanTraitsRequest request) { + return this.rawClient.listPlanTraits(request).thenApply(response -> response.body()); + } + + public CompletableFuture listPlanTraits( + ListPlanTraitsRequest request, RequestOptions requestOptions) { + return this.rawClient.listPlanTraits(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createPlanTrait(CreatePlanTraitRequestBody request) { + return this.rawClient.createPlanTrait(request).thenApply(response -> response.body()); + } + + public CompletableFuture createPlanTrait( + CreatePlanTraitRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createPlanTrait(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getPlanTrait(String planTraitId) { + return this.rawClient.getPlanTrait(planTraitId).thenApply(response -> response.body()); + } + + public CompletableFuture getPlanTrait(String planTraitId, RequestOptions requestOptions) { + return this.rawClient.getPlanTrait(planTraitId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlanTrait( + String planTraitId, UpdatePlanTraitRequestBody request) { + return this.rawClient.updatePlanTrait(planTraitId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlanTrait( + String planTraitId, UpdatePlanTraitRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updatePlanTrait(planTraitId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deletePlanTrait(String planTraitId) { + return this.rawClient.deletePlanTrait(planTraitId).thenApply(response -> response.body()); + } + + public CompletableFuture deletePlanTrait( + String planTraitId, RequestOptions requestOptions) { + return this.rawClient.deletePlanTrait(planTraitId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlanTraitsBulk( + UpdatePlanTraitBulkRequestBody request) { + return this.rawClient.updatePlanTraitsBulk(request).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlanTraitsBulk( + UpdatePlanTraitBulkRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updatePlanTraitsBulk(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countPlanTraits() { + return this.rawClient.countPlanTraits().thenApply(response -> response.body()); + } + + public CompletableFuture countPlanTraits(CountPlanTraitsRequest request) { + return this.rawClient.countPlanTraits(request).thenApply(response -> response.body()); + } + + public CompletableFuture countPlanTraits( + CountPlanTraitsRequest request, RequestOptions requestOptions) { + return this.rawClient.countPlanTraits(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertUserTrait(UpsertTraitRequestBody request) { + return this.rawClient.upsertUserTrait(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertUserTrait( + UpsertTraitRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertUserTrait(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listUsers() { + return this.rawClient.listUsers().thenApply(response -> response.body()); + } + + public CompletableFuture listUsers(ListUsersRequest request) { + return this.rawClient.listUsers(request).thenApply(response -> response.body()); + } + + public CompletableFuture listUsers(ListUsersRequest request, RequestOptions requestOptions) { + return this.rawClient.listUsers(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertUser(UpsertUserRequestBody request) { + return this.rawClient.upsertUser(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertUser( + UpsertUserRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertUser(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getUser(String userId) { + return this.rawClient.getUser(userId).thenApply(response -> response.body()); + } + + public CompletableFuture getUser(String userId, RequestOptions requestOptions) { + return this.rawClient.getUser(userId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteUser(String userId) { + return this.rawClient.deleteUser(userId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteUser(String userId, RequestOptions requestOptions) { + return this.rawClient.deleteUser(userId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countUsers() { + return this.rawClient.countUsers().thenApply(response -> response.body()); + } + + public CompletableFuture countUsers(CountUsersRequest request) { + return this.rawClient.countUsers(request).thenApply(response -> response.body()); + } + + public CompletableFuture countUsers(CountUsersRequest request, RequestOptions requestOptions) { + return this.rawClient.countUsers(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createUser(UpsertUserRequestBody request) { + return this.rawClient.createUser(request).thenApply(response -> response.body()); + } + + public CompletableFuture createUser( + UpsertUserRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createUser(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteUserByKeys(KeysRequestBody request) { + return this.rawClient.deleteUserByKeys(request).thenApply(response -> response.body()); + } + + public CompletableFuture deleteUserByKeys( + KeysRequestBody request, RequestOptions requestOptions) { + return this.rawClient.deleteUserByKeys(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture lookupUser(LookupUserRequest request) { + return this.rawClient.lookupUser(request).thenApply(response -> response.body()); + } + + public CompletableFuture lookupUser(LookupUserRequest request, RequestOptions requestOptions) { + return this.rawClient.lookupUser(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java new file mode 100644 index 0000000..bf011bb --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/AsyncRawCompaniesClient.java @@ -0,0 +1,4245 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.companies.requests.CountCompaniesForAdvancedFilterRequest; +import com.schematic.api.resources.companies.requests.CountCompaniesRequest; +import com.schematic.api.resources.companies.requests.CountEntityKeyDefinitionsRequest; +import com.schematic.api.resources.companies.requests.CountEntityTraitDefinitionsRequest; +import com.schematic.api.resources.companies.requests.CountPlanTraitsRequest; +import com.schematic.api.resources.companies.requests.CountUsersRequest; +import com.schematic.api.resources.companies.requests.CreateEntityTraitDefinitionRequestBody; +import com.schematic.api.resources.companies.requests.CreatePlanTraitRequestBody; +import com.schematic.api.resources.companies.requests.GetActiveCompanySubscriptionRequest; +import com.schematic.api.resources.companies.requests.GetActiveDealsRequest; +import com.schematic.api.resources.companies.requests.GetEntityTraitValuesRequest; +import com.schematic.api.resources.companies.requests.GetOrCreateCompanyMembershipRequestBody; +import com.schematic.api.resources.companies.requests.ListCompaniesForAdvancedFilterRequest; +import com.schematic.api.resources.companies.requests.ListCompaniesRequest; +import com.schematic.api.resources.companies.requests.ListCompanyMembershipsRequest; +import com.schematic.api.resources.companies.requests.ListEntityKeyDefinitionsRequest; +import com.schematic.api.resources.companies.requests.ListEntityTraitDefinitionsRequest; +import com.schematic.api.resources.companies.requests.ListPlanChangesRequest; +import com.schematic.api.resources.companies.requests.ListPlanTraitsRequest; +import com.schematic.api.resources.companies.requests.ListUsersRequest; +import com.schematic.api.resources.companies.requests.LookupCompanyRequest; +import com.schematic.api.resources.companies.requests.LookupUserRequest; +import com.schematic.api.resources.companies.requests.UpdateEntityTraitDefinitionRequestBody; +import com.schematic.api.resources.companies.requests.UpdatePlanTraitBulkRequestBody; +import com.schematic.api.resources.companies.requests.UpdatePlanTraitRequestBody; +import com.schematic.api.resources.companies.types.CountCompaniesForAdvancedFilterResponse; +import com.schematic.api.resources.companies.types.CountCompaniesResponse; +import com.schematic.api.resources.companies.types.CountEntityKeyDefinitionsResponse; +import com.schematic.api.resources.companies.types.CountEntityTraitDefinitionsResponse; +import com.schematic.api.resources.companies.types.CountPlanTraitsResponse; +import com.schematic.api.resources.companies.types.CountUsersResponse; +import com.schematic.api.resources.companies.types.CreateCompanyResponse; +import com.schematic.api.resources.companies.types.CreatePlanTraitResponse; +import com.schematic.api.resources.companies.types.CreateUserResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyByKeysResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyMembershipResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyResponse; +import com.schematic.api.resources.companies.types.DeletePlanTraitResponse; +import com.schematic.api.resources.companies.types.DeleteUserByKeysResponse; +import com.schematic.api.resources.companies.types.DeleteUserResponse; +import com.schematic.api.resources.companies.types.GetActiveCompanySubscriptionResponse; +import com.schematic.api.resources.companies.types.GetActiveDealsResponse; +import com.schematic.api.resources.companies.types.GetCompanyResponse; +import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.GetEntityTraitValuesResponse; +import com.schematic.api.resources.companies.types.GetOrCreateCompanyMembershipResponse; +import com.schematic.api.resources.companies.types.GetOrCreateEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.GetPlanChangeResponse; +import com.schematic.api.resources.companies.types.GetPlanTraitResponse; +import com.schematic.api.resources.companies.types.GetUserResponse; +import com.schematic.api.resources.companies.types.ListCompaniesForAdvancedFilterResponse; +import com.schematic.api.resources.companies.types.ListCompaniesResponse; +import com.schematic.api.resources.companies.types.ListCompanyMembershipsResponse; +import com.schematic.api.resources.companies.types.ListEntityKeyDefinitionsResponse; +import com.schematic.api.resources.companies.types.ListEntityTraitDefinitionsResponse; +import com.schematic.api.resources.companies.types.ListPlanChangesResponse; +import com.schematic.api.resources.companies.types.ListPlanTraitsResponse; +import com.schematic.api.resources.companies.types.ListUsersResponse; +import com.schematic.api.resources.companies.types.LookupCompanyResponse; +import com.schematic.api.resources.companies.types.LookupUserResponse; +import com.schematic.api.resources.companies.types.UpdateEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.UpdatePlanTraitResponse; +import com.schematic.api.resources.companies.types.UpdatePlanTraitsBulkResponse; +import com.schematic.api.resources.companies.types.UpsertCompanyResponse; +import com.schematic.api.resources.companies.types.UpsertCompanyTraitResponse; +import com.schematic.api.resources.companies.types.UpsertUserResponse; +import com.schematic.api.resources.companies.types.UpsertUserTraitResponse; +import com.schematic.api.types.ApiError; +import com.schematic.api.types.KeysRequestBody; +import com.schematic.api.types.UpsertCompanyRequestBody; +import com.schematic.api.types.UpsertTraitRequestBody; +import com.schematic.api.types.UpsertUserRequestBody; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCompaniesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> listCompanies() { + return listCompanies(ListCompaniesRequest.builder().build()); + } + + public CompletableFuture> listCompanies( + ListCompaniesRequest request) { + return listCompanies(request, null); + } + + public CompletableFuture> listCompanies( + ListCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies"); + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutFeatureOverrideFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_feature_override_for", + request.getWithoutFeatureOverrideFor().get(), + false); + } + if (request.getWithoutPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_plan", request.getWithoutPlan().get(), false); + } + if (request.getWithSubscription().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_subscription", request.getWithSubscription().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCompaniesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertCompany( + UpsertCompanyRequestBody request) { + return upsertCompany(request, null); + } + + public CompletableFuture> upsertCompany( + UpsertCompanyRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertCompanyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getCompany(String companyId) { + return getCompany(companyId, null); + } + + public CompletableFuture> getCompany( + String companyId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(companyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetCompanyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteCompany(String companyId) { + return deleteCompany(companyId, null); + } + + public CompletableFuture> deleteCompany( + String companyId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(companyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteCompanyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countCompanies() { + return countCompanies(CountCompaniesRequest.builder().build()); + } + + public CompletableFuture> countCompanies( + CountCompaniesRequest request) { + return countCompanies(request, null); + } + + public CompletableFuture> countCompanies( + CountCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/count"); + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutFeatureOverrideFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_feature_override_for", + request.getWithoutFeatureOverrideFor().get(), + false); + } + if (request.getWithoutPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_plan", request.getWithoutPlan().get(), false); + } + if (request.getWithSubscription().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_subscription", request.getWithSubscription().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountCompaniesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + countCompaniesForAdvancedFilter() { + return countCompaniesForAdvancedFilter( + CountCompaniesForAdvancedFilterRequest.builder().build()); + } + + public CompletableFuture> + countCompaniesForAdvancedFilter(CountCompaniesForAdvancedFilterRequest request) { + return countCompaniesForAdvancedFilter(request, null); + } + + public CompletableFuture> + countCompaniesForAdvancedFilter( + CountCompaniesForAdvancedFilterRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/count2"); + if (request.getMonetizedSubscriptions().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "monetized_subscriptions", + request.getMonetizedSubscriptions().get(), + false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_plan", request.getWithoutPlan().get(), false); + } + if (request.getWithoutSubscription().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_subscription", + request.getWithoutSubscription().get(), + false); + } + if (request.getSortOrderColumn().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sort_order_column", request.getSortOrderColumn().get(), false); + } + if (request.getSortOrderDirection().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "sort_order_direction", + request.getSortOrderDirection().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getCreditTypeIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_type_ids", request.getCreditTypeIds().get(), true); + } + if (request.getSubscriptionStatuses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "subscription_statuses", + request.getSubscriptionStatuses().get(), + true); + } + if (request.getSubscriptionTypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "subscription_types", + request.getSubscriptionTypes().get(), + true); + } + if (request.getDisplayProperties().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "display_properties", + request.getDisplayProperties().get(), + true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountCompaniesForAdvancedFilterResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createCompany( + UpsertCompanyRequestBody request) { + return createCompany(request, null); + } + + public CompletableFuture> createCompany( + UpsertCompanyRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/create") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateCompanyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteCompanyByKeys( + KeysRequestBody request) { + return deleteCompanyByKeys(request, null); + } + + public CompletableFuture> deleteCompanyByKeys( + KeysRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/delete") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteCompanyByKeysResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + listCompaniesForAdvancedFilter() { + return listCompaniesForAdvancedFilter( + ListCompaniesForAdvancedFilterRequest.builder().build()); + } + + public CompletableFuture> + listCompaniesForAdvancedFilter(ListCompaniesForAdvancedFilterRequest request) { + return listCompaniesForAdvancedFilter(request, null); + } + + public CompletableFuture> + listCompaniesForAdvancedFilter( + ListCompaniesForAdvancedFilterRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/list2"); + if (request.getMonetizedSubscriptions().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "monetized_subscriptions", + request.getMonetizedSubscriptions().get(), + false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_plan", request.getWithoutPlan().get(), false); + } + if (request.getWithoutSubscription().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_subscription", + request.getWithoutSubscription().get(), + false); + } + if (request.getSortOrderColumn().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sort_order_column", request.getSortOrderColumn().get(), false); + } + if (request.getSortOrderDirection().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "sort_order_direction", + request.getSortOrderDirection().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getCreditTypeIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_type_ids", request.getCreditTypeIds().get(), true); + } + if (request.getSubscriptionStatuses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "subscription_statuses", + request.getSubscriptionStatuses().get(), + true); + } + if (request.getSubscriptionTypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "subscription_types", + request.getSubscriptionTypes().get(), + true); + } + if (request.getDisplayProperties().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "display_properties", + request.getDisplayProperties().get(), + true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCompaniesForAdvancedFilterResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> lookupCompany( + LookupCompanyRequest request) { + return lookupCompany(request, null); + } + + public CompletableFuture> lookupCompany( + LookupCompanyRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/lookup"); + QueryStringMapper.addQueryParameter(httpUrl, "keys", request.getKeys(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LookupCompanyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getActiveDeals( + GetActiveDealsRequest request) { + return getActiveDeals(request, null); + } + + public CompletableFuture> getActiveDeals( + GetActiveDealsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-crm-deals"); + QueryStringMapper.addQueryParameter(httpUrl, "company_id", request.getCompanyId(), false); + QueryStringMapper.addQueryParameter(httpUrl, "deal_stage", request.getDealStage(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetActiveDealsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listCompanyMemberships() { + return listCompanyMemberships(ListCompanyMembershipsRequest.builder().build()); + } + + public CompletableFuture> listCompanyMemberships( + ListCompanyMembershipsRequest request) { + return listCompanyMemberships(request, null); + } + + public CompletableFuture> listCompanyMemberships( + ListCompanyMembershipsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-memberships"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCompanyMembershipsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + getOrCreateCompanyMembership(GetOrCreateCompanyMembershipRequestBody request) { + return getOrCreateCompanyMembership(request, null); + } + + public CompletableFuture> + getOrCreateCompanyMembership( + GetOrCreateCompanyMembershipRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-memberships") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetOrCreateCompanyMembershipResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteCompanyMembership( + String companyMembershipId) { + return deleteCompanyMembership(companyMembershipId, null); + } + + public CompletableFuture> deleteCompanyMembership( + String companyMembershipId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-memberships") + .addPathSegment(companyMembershipId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteCompanyMembershipResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + getActiveCompanySubscription() { + return getActiveCompanySubscription( + GetActiveCompanySubscriptionRequest.builder().build()); + } + + public CompletableFuture> + getActiveCompanySubscription(GetActiveCompanySubscriptionRequest request) { + return getActiveCompanySubscription(request, null); + } + + public CompletableFuture> + getActiveCompanySubscription(GetActiveCompanySubscriptionRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-subscriptions"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetActiveCompanySubscriptionResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertCompanyTrait( + UpsertTraitRequestBody request) { + return upsertCompanyTrait(request, null); + } + + public CompletableFuture> upsertCompanyTrait( + UpsertTraitRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-traits") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertCompanyTraitResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listEntityKeyDefinitions() { + return listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest.builder().build()); + } + + public CompletableFuture> listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest request) { + return listEntityKeyDefinitions(request, null); + } + + public CompletableFuture> listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-key-definitions"); + if (request.getEntityType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "entity_type", request.getEntityType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListEntityKeyDefinitionsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countEntityKeyDefinitions() { + return countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest.builder().build()); + } + + public CompletableFuture> countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest request) { + return countEntityKeyDefinitions(request, null); + } + + public CompletableFuture> countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-key-definitions/count"); + if (request.getEntityType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "entity_type", request.getEntityType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountEntityKeyDefinitionsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + listEntityTraitDefinitions() { + return listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest.builder().build()); + } + + public CompletableFuture> listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest request) { + return listEntityTraitDefinitions(request, null); + } + + public CompletableFuture> listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions"); + if (request.getEntityType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "entity_type", request.getEntityType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getTraitType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_type", request.getTraitType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListEntityTraitDefinitionsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + getOrCreateEntityTraitDefinition(CreateEntityTraitDefinitionRequestBody request) { + return getOrCreateEntityTraitDefinition(request, null); + } + + public CompletableFuture> + getOrCreateEntityTraitDefinition( + CreateEntityTraitDefinitionRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetOrCreateEntityTraitDefinitionResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getEntityTraitDefinition( + String entityTraitDefinitionId) { + return getEntityTraitDefinition(entityTraitDefinitionId, null); + } + + public CompletableFuture> getEntityTraitDefinition( + String entityTraitDefinitionId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions") + .addPathSegment(entityTraitDefinitionId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetEntityTraitDefinitionResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + updateEntityTraitDefinition( + String entityTraitDefinitionId, UpdateEntityTraitDefinitionRequestBody request) { + return updateEntityTraitDefinition(entityTraitDefinitionId, request, null); + } + + public CompletableFuture> + updateEntityTraitDefinition( + String entityTraitDefinitionId, + UpdateEntityTraitDefinitionRequestBody request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions") + .addPathSegment(entityTraitDefinitionId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateEntityTraitDefinitionResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + countEntityTraitDefinitions() { + return countEntityTraitDefinitions( + CountEntityTraitDefinitionsRequest.builder().build()); + } + + public CompletableFuture> + countEntityTraitDefinitions(CountEntityTraitDefinitionsRequest request) { + return countEntityTraitDefinitions(request, null); + } + + public CompletableFuture> + countEntityTraitDefinitions(CountEntityTraitDefinitionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions/count"); + if (request.getEntityType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "entity_type", request.getEntityType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getTraitType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_type", request.getTraitType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountEntityTraitDefinitionsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getEntityTraitValues( + GetEntityTraitValuesRequest request) { + return getEntityTraitValues(request, null); + } + + public CompletableFuture> getEntityTraitValues( + GetEntityTraitValuesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-values"); + QueryStringMapper.addQueryParameter(httpUrl, "definition_id", request.getDefinitionId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetEntityTraitValuesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listPlanChanges() { + return listPlanChanges(ListPlanChangesRequest.builder().build()); + } + + public CompletableFuture> listPlanChanges( + ListPlanChangesRequest request) { + return listPlanChanges(request, null); + } + + public CompletableFuture> listPlanChanges( + ListPlanChangesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-changes"); + if (request.getAction().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "action", request.getAction().get(), false); + } + if (request.getBasePlanAction().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "base_plan_action", request.getBasePlanAction().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListPlanChangesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getPlanChange(String planChangeId) { + return getPlanChange(planChangeId, null); + } + + public CompletableFuture> getPlanChange( + String planChangeId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-changes") + .addPathSegment(planChangeId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanChangeResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listPlanTraits() { + return listPlanTraits(ListPlanTraitsRequest.builder().build()); + } + + public CompletableFuture> listPlanTraits( + ListPlanTraitsRequest request) { + return listPlanTraits(request, null); + } + + public CompletableFuture> listPlanTraits( + ListPlanTraitsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits"); + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getTraitId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_id", request.getTraitId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getTraitIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_ids", request.getTraitIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListPlanTraitsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createPlanTrait( + CreatePlanTraitRequestBody request) { + return createPlanTrait(request, null); + } + + public CompletableFuture> createPlanTrait( + CreatePlanTraitRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreatePlanTraitResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getPlanTrait(String planTraitId) { + return getPlanTrait(planTraitId, null); + } + + public CompletableFuture> getPlanTrait( + String planTraitId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits") + .addPathSegment(planTraitId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanTraitResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updatePlanTrait( + String planTraitId, UpdatePlanTraitRequestBody request) { + return updatePlanTrait(planTraitId, request, null); + } + + public CompletableFuture> updatePlanTrait( + String planTraitId, UpdatePlanTraitRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits") + .addPathSegment(planTraitId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdatePlanTraitResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deletePlanTrait(String planTraitId) { + return deletePlanTrait(planTraitId, null); + } + + public CompletableFuture> deletePlanTrait( + String planTraitId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits") + .addPathSegment(planTraitId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeletePlanTraitResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updatePlanTraitsBulk( + UpdatePlanTraitBulkRequestBody request) { + return updatePlanTraitsBulk(request, null); + } + + public CompletableFuture> updatePlanTraitsBulk( + UpdatePlanTraitBulkRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits/bulk") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdatePlanTraitsBulkResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countPlanTraits() { + return countPlanTraits(CountPlanTraitsRequest.builder().build()); + } + + public CompletableFuture> countPlanTraits( + CountPlanTraitsRequest request) { + return countPlanTraits(request, null); + } + + public CompletableFuture> countPlanTraits( + CountPlanTraitsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits/count"); + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getTraitId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_id", request.getTraitId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getTraitIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_ids", request.getTraitIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountPlanTraitsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertUserTrait( + UpsertTraitRequestBody request) { + return upsertUserTrait(request, null); + } + + public CompletableFuture> upsertUserTrait( + UpsertTraitRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("user-traits") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertUserTraitResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listUsers() { + return listUsers(ListUsersRequest.builder().build()); + } + + public CompletableFuture> listUsers(ListUsersRequest request) { + return listUsers(request, null); + } + + public CompletableFuture> listUsers( + ListUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListUsersResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertUser(UpsertUserRequestBody request) { + return upsertUser(request, null); + } + + public CompletableFuture> upsertUser( + UpsertUserRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertUserResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getUser(String userId) { + return getUser(userId, null); + } + + public CompletableFuture> getUser( + String userId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(userId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetUserResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteUser(String userId) { + return deleteUser(userId, null); + } + + public CompletableFuture> deleteUser( + String userId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(userId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteUserResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countUsers() { + return countUsers(CountUsersRequest.builder().build()); + } + + public CompletableFuture> countUsers(CountUsersRequest request) { + return countUsers(request, null); + } + + public CompletableFuture> countUsers( + CountUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users/count"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountUsersResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createUser(UpsertUserRequestBody request) { + return createUser(request, null); + } + + public CompletableFuture> createUser( + UpsertUserRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users/create") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateUserResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteUserByKeys( + KeysRequestBody request) { + return deleteUserByKeys(request, null); + } + + public CompletableFuture> deleteUserByKeys( + KeysRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users/delete") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteUserByKeysResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> lookupUser(LookupUserRequest request) { + return lookupUser(request, null); + } + + public CompletableFuture> lookupUser( + LookupUserRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users/lookup"); + QueryStringMapper.addQueryParameter(httpUrl, "keys", request.getKeys(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LookupUserResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java b/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java new file mode 100644 index 0000000..7ec93f3 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/RawCompaniesClient.java @@ -0,0 +1,3227 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.companies.requests.CountCompaniesForAdvancedFilterRequest; +import com.schematic.api.resources.companies.requests.CountCompaniesRequest; +import com.schematic.api.resources.companies.requests.CountEntityKeyDefinitionsRequest; +import com.schematic.api.resources.companies.requests.CountEntityTraitDefinitionsRequest; +import com.schematic.api.resources.companies.requests.CountPlanTraitsRequest; +import com.schematic.api.resources.companies.requests.CountUsersRequest; +import com.schematic.api.resources.companies.requests.CreateEntityTraitDefinitionRequestBody; +import com.schematic.api.resources.companies.requests.CreatePlanTraitRequestBody; +import com.schematic.api.resources.companies.requests.GetActiveCompanySubscriptionRequest; +import com.schematic.api.resources.companies.requests.GetActiveDealsRequest; +import com.schematic.api.resources.companies.requests.GetEntityTraitValuesRequest; +import com.schematic.api.resources.companies.requests.GetOrCreateCompanyMembershipRequestBody; +import com.schematic.api.resources.companies.requests.ListCompaniesForAdvancedFilterRequest; +import com.schematic.api.resources.companies.requests.ListCompaniesRequest; +import com.schematic.api.resources.companies.requests.ListCompanyMembershipsRequest; +import com.schematic.api.resources.companies.requests.ListEntityKeyDefinitionsRequest; +import com.schematic.api.resources.companies.requests.ListEntityTraitDefinitionsRequest; +import com.schematic.api.resources.companies.requests.ListPlanChangesRequest; +import com.schematic.api.resources.companies.requests.ListPlanTraitsRequest; +import com.schematic.api.resources.companies.requests.ListUsersRequest; +import com.schematic.api.resources.companies.requests.LookupCompanyRequest; +import com.schematic.api.resources.companies.requests.LookupUserRequest; +import com.schematic.api.resources.companies.requests.UpdateEntityTraitDefinitionRequestBody; +import com.schematic.api.resources.companies.requests.UpdatePlanTraitBulkRequestBody; +import com.schematic.api.resources.companies.requests.UpdatePlanTraitRequestBody; +import com.schematic.api.resources.companies.types.CountCompaniesForAdvancedFilterResponse; +import com.schematic.api.resources.companies.types.CountCompaniesResponse; +import com.schematic.api.resources.companies.types.CountEntityKeyDefinitionsResponse; +import com.schematic.api.resources.companies.types.CountEntityTraitDefinitionsResponse; +import com.schematic.api.resources.companies.types.CountPlanTraitsResponse; +import com.schematic.api.resources.companies.types.CountUsersResponse; +import com.schematic.api.resources.companies.types.CreateCompanyResponse; +import com.schematic.api.resources.companies.types.CreatePlanTraitResponse; +import com.schematic.api.resources.companies.types.CreateUserResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyByKeysResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyMembershipResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyResponse; +import com.schematic.api.resources.companies.types.DeletePlanTraitResponse; +import com.schematic.api.resources.companies.types.DeleteUserByKeysResponse; +import com.schematic.api.resources.companies.types.DeleteUserResponse; +import com.schematic.api.resources.companies.types.GetActiveCompanySubscriptionResponse; +import com.schematic.api.resources.companies.types.GetActiveDealsResponse; +import com.schematic.api.resources.companies.types.GetCompanyResponse; +import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.GetEntityTraitValuesResponse; +import com.schematic.api.resources.companies.types.GetOrCreateCompanyMembershipResponse; +import com.schematic.api.resources.companies.types.GetOrCreateEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.GetPlanChangeResponse; +import com.schematic.api.resources.companies.types.GetPlanTraitResponse; +import com.schematic.api.resources.companies.types.GetUserResponse; +import com.schematic.api.resources.companies.types.ListCompaniesForAdvancedFilterResponse; +import com.schematic.api.resources.companies.types.ListCompaniesResponse; +import com.schematic.api.resources.companies.types.ListCompanyMembershipsResponse; +import com.schematic.api.resources.companies.types.ListEntityKeyDefinitionsResponse; +import com.schematic.api.resources.companies.types.ListEntityTraitDefinitionsResponse; +import com.schematic.api.resources.companies.types.ListPlanChangesResponse; +import com.schematic.api.resources.companies.types.ListPlanTraitsResponse; +import com.schematic.api.resources.companies.types.ListUsersResponse; +import com.schematic.api.resources.companies.types.LookupCompanyResponse; +import com.schematic.api.resources.companies.types.LookupUserResponse; +import com.schematic.api.resources.companies.types.UpdateEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.UpdatePlanTraitResponse; +import com.schematic.api.resources.companies.types.UpdatePlanTraitsBulkResponse; +import com.schematic.api.resources.companies.types.UpsertCompanyResponse; +import com.schematic.api.resources.companies.types.UpsertCompanyTraitResponse; +import com.schematic.api.resources.companies.types.UpsertUserResponse; +import com.schematic.api.resources.companies.types.UpsertUserTraitResponse; +import com.schematic.api.types.ApiError; +import com.schematic.api.types.KeysRequestBody; +import com.schematic.api.types.UpsertCompanyRequestBody; +import com.schematic.api.types.UpsertTraitRequestBody; +import com.schematic.api.types.UpsertUserRequestBody; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCompaniesClient { + protected final ClientOptions clientOptions; + + public RawCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse listCompanies() { + return listCompanies(ListCompaniesRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCompanies(ListCompaniesRequest request) { + return listCompanies(request, null); + } + + public BaseSchematicHttpResponse listCompanies( + ListCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies"); + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutFeatureOverrideFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_feature_override_for", + request.getWithoutFeatureOverrideFor().get(), + false); + } + if (request.getWithoutPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_plan", request.getWithoutPlan().get(), false); + } + if (request.getWithSubscription().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_subscription", request.getWithSubscription().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCompaniesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertCompany(UpsertCompanyRequestBody request) { + return upsertCompany(request, null); + } + + public BaseSchematicHttpResponse upsertCompany( + UpsertCompanyRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertCompanyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getCompany(String companyId) { + return getCompany(companyId, null); + } + + public BaseSchematicHttpResponse getCompany(String companyId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(companyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetCompanyResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteCompany(String companyId) { + return deleteCompany(companyId, null); + } + + public BaseSchematicHttpResponse deleteCompany( + String companyId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(companyId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteCompanyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countCompanies() { + return countCompanies(CountCompaniesRequest.builder().build()); + } + + public BaseSchematicHttpResponse countCompanies(CountCompaniesRequest request) { + return countCompanies(request, null); + } + + public BaseSchematicHttpResponse countCompanies( + CountCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/count"); + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutFeatureOverrideFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_feature_override_for", + request.getWithoutFeatureOverrideFor().get(), + false); + } + if (request.getWithoutPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_plan", request.getWithoutPlan().get(), false); + } + if (request.getWithSubscription().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "with_subscription", request.getWithSubscription().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountCompaniesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countCompaniesForAdvancedFilter() { + return countCompaniesForAdvancedFilter( + CountCompaniesForAdvancedFilterRequest.builder().build()); + } + + public BaseSchematicHttpResponse countCompaniesForAdvancedFilter( + CountCompaniesForAdvancedFilterRequest request) { + return countCompaniesForAdvancedFilter(request, null); + } + + public BaseSchematicHttpResponse countCompaniesForAdvancedFilter( + CountCompaniesForAdvancedFilterRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/count2"); + if (request.getMonetizedSubscriptions().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "monetized_subscriptions", + request.getMonetizedSubscriptions().get(), + false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_plan", request.getWithoutPlan().get(), false); + } + if (request.getWithoutSubscription().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_subscription", + request.getWithoutSubscription().get(), + false); + } + if (request.getSortOrderColumn().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sort_order_column", request.getSortOrderColumn().get(), false); + } + if (request.getSortOrderDirection().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "sort_order_direction", + request.getSortOrderDirection().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getCreditTypeIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_type_ids", request.getCreditTypeIds().get(), true); + } + if (request.getSubscriptionStatuses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "subscription_statuses", + request.getSubscriptionStatuses().get(), + true); + } + if (request.getSubscriptionTypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "subscription_types", + request.getSubscriptionTypes().get(), + true); + } + if (request.getDisplayProperties().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "display_properties", + request.getDisplayProperties().get(), + true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountCompaniesForAdvancedFilterResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createCompany(UpsertCompanyRequestBody request) { + return createCompany(request, null); + } + + public BaseSchematicHttpResponse createCompany( + UpsertCompanyRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/create") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateCompanyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteCompanyByKeys(KeysRequestBody request) { + return deleteCompanyByKeys(request, null); + } + + public BaseSchematicHttpResponse deleteCompanyByKeys( + KeysRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/delete") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteCompanyByKeysResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listCompaniesForAdvancedFilter() { + return listCompaniesForAdvancedFilter( + ListCompaniesForAdvancedFilterRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCompaniesForAdvancedFilter( + ListCompaniesForAdvancedFilterRequest request) { + return listCompaniesForAdvancedFilter(request, null); + } + + public BaseSchematicHttpResponse listCompaniesForAdvancedFilter( + ListCompaniesForAdvancedFilterRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/list2"); + if (request.getMonetizedSubscriptions().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "monetized_subscriptions", + request.getMonetizedSubscriptions().get(), + false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_plan", request.getWithoutPlan().get(), false); + } + if (request.getWithoutSubscription().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_subscription", + request.getWithoutSubscription().get(), + false); + } + if (request.getSortOrderColumn().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sort_order_column", request.getSortOrderColumn().get(), false); + } + if (request.getSortOrderDirection().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "sort_order_direction", + request.getSortOrderDirection().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getCreditTypeIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_type_ids", request.getCreditTypeIds().get(), true); + } + if (request.getSubscriptionStatuses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "subscription_statuses", + request.getSubscriptionStatuses().get(), + true); + } + if (request.getSubscriptionTypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "subscription_types", + request.getSubscriptionTypes().get(), + true); + } + if (request.getDisplayProperties().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "display_properties", + request.getDisplayProperties().get(), + true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCompaniesForAdvancedFilterResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse lookupCompany(LookupCompanyRequest request) { + return lookupCompany(request, null); + } + + public BaseSchematicHttpResponse lookupCompany( + LookupCompanyRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/lookup"); + QueryStringMapper.addQueryParameter(httpUrl, "keys", request.getKeys(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LookupCompanyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getActiveDeals(GetActiveDealsRequest request) { + return getActiveDeals(request, null); + } + + public BaseSchematicHttpResponse getActiveDeals( + GetActiveDealsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-crm-deals"); + QueryStringMapper.addQueryParameter(httpUrl, "company_id", request.getCompanyId(), false); + QueryStringMapper.addQueryParameter(httpUrl, "deal_stage", request.getDealStage(), false); + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetActiveDealsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listCompanyMemberships() { + return listCompanyMemberships(ListCompanyMembershipsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCompanyMemberships( + ListCompanyMembershipsRequest request) { + return listCompanyMemberships(request, null); + } + + public BaseSchematicHttpResponse listCompanyMemberships( + ListCompanyMembershipsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-memberships"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCompanyMembershipsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getOrCreateCompanyMembership( + GetOrCreateCompanyMembershipRequestBody request) { + return getOrCreateCompanyMembership(request, null); + } + + public BaseSchematicHttpResponse getOrCreateCompanyMembership( + GetOrCreateCompanyMembershipRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-memberships") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetOrCreateCompanyMembershipResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteCompanyMembership( + String companyMembershipId) { + return deleteCompanyMembership(companyMembershipId, null); + } + + public BaseSchematicHttpResponse deleteCompanyMembership( + String companyMembershipId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-memberships") + .addPathSegment(companyMembershipId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteCompanyMembershipResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getActiveCompanySubscription() { + return getActiveCompanySubscription( + GetActiveCompanySubscriptionRequest.builder().build()); + } + + public BaseSchematicHttpResponse getActiveCompanySubscription( + GetActiveCompanySubscriptionRequest request) { + return getActiveCompanySubscription(request, null); + } + + public BaseSchematicHttpResponse getActiveCompanySubscription( + GetActiveCompanySubscriptionRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-subscriptions"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetActiveCompanySubscriptionResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertCompanyTrait(UpsertTraitRequestBody request) { + return upsertCompanyTrait(request, null); + } + + public BaseSchematicHttpResponse upsertCompanyTrait( + UpsertTraitRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-traits") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertCompanyTraitResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listEntityKeyDefinitions() { + return listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest request) { + return listEntityKeyDefinitions(request, null); + } + + public BaseSchematicHttpResponse listEntityKeyDefinitions( + ListEntityKeyDefinitionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-key-definitions"); + if (request.getEntityType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "entity_type", request.getEntityType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListEntityKeyDefinitionsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countEntityKeyDefinitions() { + return countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest request) { + return countEntityKeyDefinitions(request, null); + } + + public BaseSchematicHttpResponse countEntityKeyDefinitions( + CountEntityKeyDefinitionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-key-definitions/count"); + if (request.getEntityType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "entity_type", request.getEntityType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountEntityKeyDefinitionsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listEntityTraitDefinitions() { + return listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest request) { + return listEntityTraitDefinitions(request, null); + } + + public BaseSchematicHttpResponse listEntityTraitDefinitions( + ListEntityTraitDefinitionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions"); + if (request.getEntityType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "entity_type", request.getEntityType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getTraitType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_type", request.getTraitType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListEntityTraitDefinitionsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getOrCreateEntityTraitDefinition( + CreateEntityTraitDefinitionRequestBody request) { + return getOrCreateEntityTraitDefinition(request, null); + } + + public BaseSchematicHttpResponse getOrCreateEntityTraitDefinition( + CreateEntityTraitDefinitionRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetOrCreateEntityTraitDefinitionResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getEntityTraitDefinition( + String entityTraitDefinitionId) { + return getEntityTraitDefinition(entityTraitDefinitionId, null); + } + + public BaseSchematicHttpResponse getEntityTraitDefinition( + String entityTraitDefinitionId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions") + .addPathSegment(entityTraitDefinitionId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetEntityTraitDefinitionResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateEntityTraitDefinition( + String entityTraitDefinitionId, UpdateEntityTraitDefinitionRequestBody request) { + return updateEntityTraitDefinition(entityTraitDefinitionId, request, null); + } + + public BaseSchematicHttpResponse updateEntityTraitDefinition( + String entityTraitDefinitionId, + UpdateEntityTraitDefinitionRequestBody request, + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions") + .addPathSegment(entityTraitDefinitionId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateEntityTraitDefinitionResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countEntityTraitDefinitions() { + return countEntityTraitDefinitions( + CountEntityTraitDefinitionsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countEntityTraitDefinitions( + CountEntityTraitDefinitionsRequest request) { + return countEntityTraitDefinitions(request, null); + } + + public BaseSchematicHttpResponse countEntityTraitDefinitions( + CountEntityTraitDefinitionsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-definitions/count"); + if (request.getEntityType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "entity_type", request.getEntityType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getTraitType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_type", request.getTraitType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountEntityTraitDefinitionsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getEntityTraitValues( + GetEntityTraitValuesRequest request) { + return getEntityTraitValues(request, null); + } + + public BaseSchematicHttpResponse getEntityTraitValues( + GetEntityTraitValuesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("entity-trait-values"); + QueryStringMapper.addQueryParameter(httpUrl, "definition_id", request.getDefinitionId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetEntityTraitValuesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listPlanChanges() { + return listPlanChanges(ListPlanChangesRequest.builder().build()); + } + + public BaseSchematicHttpResponse listPlanChanges(ListPlanChangesRequest request) { + return listPlanChanges(request, null); + } + + public BaseSchematicHttpResponse listPlanChanges( + ListPlanChangesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-changes"); + if (request.getAction().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "action", request.getAction().get(), false); + } + if (request.getBasePlanAction().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "base_plan_action", request.getBasePlanAction().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPlanChangesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getPlanChange(String planChangeId) { + return getPlanChange(planChangeId, null); + } + + public BaseSchematicHttpResponse getPlanChange( + String planChangeId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-changes") + .addPathSegment(planChangeId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanChangeResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listPlanTraits() { + return listPlanTraits(ListPlanTraitsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listPlanTraits(ListPlanTraitsRequest request) { + return listPlanTraits(request, null); + } + + public BaseSchematicHttpResponse listPlanTraits( + ListPlanTraitsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits"); + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getTraitId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_id", request.getTraitId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getTraitIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_ids", request.getTraitIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPlanTraitsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createPlanTrait(CreatePlanTraitRequestBody request) { + return createPlanTrait(request, null); + } + + public BaseSchematicHttpResponse createPlanTrait( + CreatePlanTraitRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreatePlanTraitResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getPlanTrait(String planTraitId) { + return getPlanTrait(planTraitId, null); + } + + public BaseSchematicHttpResponse getPlanTrait( + String planTraitId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits") + .addPathSegment(planTraitId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanTraitResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updatePlanTrait( + String planTraitId, UpdatePlanTraitRequestBody request) { + return updatePlanTrait(planTraitId, request, null); + } + + public BaseSchematicHttpResponse updatePlanTrait( + String planTraitId, UpdatePlanTraitRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits") + .addPathSegment(planTraitId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdatePlanTraitResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deletePlanTrait(String planTraitId) { + return deletePlanTrait(planTraitId, null); + } + + public BaseSchematicHttpResponse deletePlanTrait( + String planTraitId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits") + .addPathSegment(planTraitId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletePlanTraitResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updatePlanTraitsBulk( + UpdatePlanTraitBulkRequestBody request) { + return updatePlanTraitsBulk(request, null); + } + + public BaseSchematicHttpResponse updatePlanTraitsBulk( + UpdatePlanTraitBulkRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits/bulk") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdatePlanTraitsBulkResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countPlanTraits() { + return countPlanTraits(CountPlanTraitsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countPlanTraits(CountPlanTraitsRequest request) { + return countPlanTraits(request, null); + } + + public BaseSchematicHttpResponse countPlanTraits( + CountPlanTraitsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-traits/count"); + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getTraitId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_id", request.getTraitId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getTraitIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "trait_ids", request.getTraitIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountPlanTraitsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertUserTrait(UpsertTraitRequestBody request) { + return upsertUserTrait(request, null); + } + + public BaseSchematicHttpResponse upsertUserTrait( + UpsertTraitRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("user-traits") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertUserTraitResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listUsers() { + return listUsers(ListUsersRequest.builder().build()); + } + + public BaseSchematicHttpResponse listUsers(ListUsersRequest request) { + return listUsers(request, null); + } + + public BaseSchematicHttpResponse listUsers( + ListUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListUsersResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertUser(UpsertUserRequestBody request) { + return upsertUser(request, null); + } + + public BaseSchematicHttpResponse upsertUser( + UpsertUserRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertUserResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getUser(String userId) { + return getUser(userId, null); + } + + public BaseSchematicHttpResponse getUser(String userId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(userId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetUserResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteUser(String userId) { + return deleteUser(userId, null); + } + + public BaseSchematicHttpResponse deleteUser(String userId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(userId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteUserResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countUsers() { + return countUsers(CountUsersRequest.builder().build()); + } + + public BaseSchematicHttpResponse countUsers(CountUsersRequest request) { + return countUsers(request, null); + } + + public BaseSchematicHttpResponse countUsers( + CountUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users/count"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountUsersResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createUser(UpsertUserRequestBody request) { + return createUser(request, null); + } + + public BaseSchematicHttpResponse createUser( + UpsertUserRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users/create") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateUserResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteUserByKeys(KeysRequestBody request) { + return deleteUserByKeys(request, null); + } + + public BaseSchematicHttpResponse deleteUserByKeys( + KeysRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users/delete") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteUserByKeysResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse lookupUser(LookupUserRequest request) { + return lookupUser(request, null); + } + + public BaseSchematicHttpResponse lookupUser( + LookupUserRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users/lookup"); + QueryStringMapper.addQueryParameter(httpUrl, "keys", request.getKeys(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LookupUserResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesForAdvancedFilterRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesForAdvancedFilterRequest.java new file mode 100644 index 0000000..9a28b84 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesForAdvancedFilterRequest.java @@ -0,0 +1,595 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.companies.types.CountCompaniesForAdvancedFilterRequestSortOrderDirection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCompaniesForAdvancedFilterRequest.Builder.class) +public final class CountCompaniesForAdvancedFilterRequest { + private final Optional> ids; + + private final Optional> planIds; + + private final Optional> featureIds; + + private final Optional> creditTypeIds; + + private final Optional> subscriptionStatuses; + + private final Optional> subscriptionTypes; + + private final Optional> displayProperties; + + private final Optional monetizedSubscriptions; + + private final Optional q; + + private final Optional withoutPlan; + + private final Optional withoutSubscription; + + private final Optional sortOrderColumn; + + private final Optional sortOrderDirection; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountCompaniesForAdvancedFilterRequest( + Optional> ids, + Optional> planIds, + Optional> featureIds, + Optional> creditTypeIds, + Optional> subscriptionStatuses, + Optional> subscriptionTypes, + Optional> displayProperties, + Optional monetizedSubscriptions, + Optional q, + Optional withoutPlan, + Optional withoutSubscription, + Optional sortOrderColumn, + Optional sortOrderDirection, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.planIds = planIds; + this.featureIds = featureIds; + this.creditTypeIds = creditTypeIds; + this.subscriptionStatuses = subscriptionStatuses; + this.subscriptionTypes = subscriptionTypes; + this.displayProperties = displayProperties; + this.monetizedSubscriptions = monetizedSubscriptions; + this.q = q; + this.withoutPlan = withoutPlan; + this.withoutSubscription = withoutSubscription; + this.sortOrderColumn = sortOrderColumn; + this.sortOrderDirection = sortOrderDirection; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter companies by multiple company IDs (starts with comp_) + */ + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Filter companies by one or more plan IDs (each ID starts with plan_) + */ + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + /** + * @return Filter companies by one or more feature IDs (each ID starts with feat_) + */ + @JsonProperty("feature_ids") + public Optional> getFeatureIds() { + return featureIds; + } + + /** + * @return Filter companies by one or more credit type IDs (each ID starts with bcrd_) + */ + @JsonProperty("credit_type_ids") + public Optional> getCreditTypeIds() { + return creditTypeIds; + } + + /** + * @return Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid) + */ + @JsonProperty("subscription_statuses") + public Optional> getSubscriptionStatuses() { + return subscriptionStatuses; + } + + /** + * @return Filter companies by one or more subscription types (paid, free, trial) + */ + @JsonProperty("subscription_types") + public Optional> getSubscriptionTypes() { + return subscriptionTypes; + } + + /** + * @return Select the display columns to return (e.g. plan, subscription, users, last_seen_at) + */ + @JsonProperty("display_properties") + public Optional> getDisplayProperties() { + return displayProperties; + } + + /** + * @return Filter companies that have monetized subscriptions + */ + @JsonProperty("monetized_subscriptions") + public Optional getMonetizedSubscriptions() { + return monetizedSubscriptions; + } + + /** + * @return Search for companies by name, keys or string traits + */ + @JsonProperty("q") + public Optional getQ() { + return q; + } + + /** + * @return Filter out companies that have a plan + */ + @JsonProperty("without_plan") + public Optional getWithoutPlan() { + return withoutPlan; + } + + /** + * @return Filter out companies that have a subscription + */ + @JsonProperty("without_subscription") + public Optional getWithoutSubscription() { + return withoutSubscription; + } + + /** + * @return Column to sort by (e.g. name, created_at, last_seen_at) + */ + @JsonProperty("sort_order_column") + public Optional getSortOrderColumn() { + return sortOrderColumn; + } + + /** + * @return Direction to sort by (asc or desc) + */ + @JsonProperty("sort_order_direction") + public Optional getSortOrderDirection() { + return sortOrderDirection; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCompaniesForAdvancedFilterRequest + && equalTo((CountCompaniesForAdvancedFilterRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCompaniesForAdvancedFilterRequest other) { + return ids.equals(other.ids) + && planIds.equals(other.planIds) + && featureIds.equals(other.featureIds) + && creditTypeIds.equals(other.creditTypeIds) + && subscriptionStatuses.equals(other.subscriptionStatuses) + && subscriptionTypes.equals(other.subscriptionTypes) + && displayProperties.equals(other.displayProperties) + && monetizedSubscriptions.equals(other.monetizedSubscriptions) + && q.equals(other.q) + && withoutPlan.equals(other.withoutPlan) + && withoutSubscription.equals(other.withoutSubscription) + && sortOrderColumn.equals(other.sortOrderColumn) + && sortOrderDirection.equals(other.sortOrderDirection) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ids, + this.planIds, + this.featureIds, + this.creditTypeIds, + this.subscriptionStatuses, + this.subscriptionTypes, + this.displayProperties, + this.monetizedSubscriptions, + this.q, + this.withoutPlan, + this.withoutSubscription, + this.sortOrderColumn, + this.sortOrderDirection, + this.limit, + this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional> planIds = Optional.empty(); + + private Optional> featureIds = Optional.empty(); + + private Optional> creditTypeIds = Optional.empty(); + + private Optional> subscriptionStatuses = Optional.empty(); + + private Optional> subscriptionTypes = Optional.empty(); + + private Optional> displayProperties = Optional.empty(); + + private Optional monetizedSubscriptions = Optional.empty(); + + private Optional q = Optional.empty(); + + private Optional withoutPlan = Optional.empty(); + + private Optional withoutSubscription = Optional.empty(); + + private Optional sortOrderColumn = Optional.empty(); + + private Optional sortOrderDirection = + Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountCompaniesForAdvancedFilterRequest other) { + ids(other.getIds()); + planIds(other.getPlanIds()); + featureIds(other.getFeatureIds()); + creditTypeIds(other.getCreditTypeIds()); + subscriptionStatuses(other.getSubscriptionStatuses()); + subscriptionTypes(other.getSubscriptionTypes()); + displayProperties(other.getDisplayProperties()); + monetizedSubscriptions(other.getMonetizedSubscriptions()); + q(other.getQ()); + withoutPlan(other.getWithoutPlan()); + withoutSubscription(other.getWithoutSubscription()); + sortOrderColumn(other.getSortOrderColumn()); + sortOrderDirection(other.getSortOrderDirection()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + /** + *

Filter companies by multiple company IDs (starts with comp_)

+ */ + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Filter companies by one or more plan IDs (each ID starts with plan_)

+ */ + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + public Builder planIds(String planIds) { + this.planIds = Optional.of(Collections.singletonList(planIds)); + return this; + } + + /** + *

Filter companies by one or more feature IDs (each ID starts with feat_)

+ */ + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; + return this; + } + + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); + return this; + } + + public Builder featureIds(String featureIds) { + this.featureIds = Optional.of(Collections.singletonList(featureIds)); + return this; + } + + /** + *

Filter companies by one or more credit type IDs (each ID starts with bcrd_)

+ */ + @JsonSetter(value = "credit_type_ids", nulls = Nulls.SKIP) + public Builder creditTypeIds(Optional> creditTypeIds) { + this.creditTypeIds = creditTypeIds; + return this; + } + + public Builder creditTypeIds(List creditTypeIds) { + this.creditTypeIds = Optional.ofNullable(creditTypeIds); + return this; + } + + public Builder creditTypeIds(String creditTypeIds) { + this.creditTypeIds = Optional.of(Collections.singletonList(creditTypeIds)); + return this; + } + + /** + *

Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid)

+ */ + @JsonSetter(value = "subscription_statuses", nulls = Nulls.SKIP) + public Builder subscriptionStatuses(Optional> subscriptionStatuses) { + this.subscriptionStatuses = subscriptionStatuses; + return this; + } + + public Builder subscriptionStatuses(List subscriptionStatuses) { + this.subscriptionStatuses = Optional.ofNullable(subscriptionStatuses); + return this; + } + + public Builder subscriptionStatuses(String subscriptionStatuses) { + this.subscriptionStatuses = Optional.of(Collections.singletonList(subscriptionStatuses)); + return this; + } + + /** + *

Filter companies by one or more subscription types (paid, free, trial)

+ */ + @JsonSetter(value = "subscription_types", nulls = Nulls.SKIP) + public Builder subscriptionTypes(Optional> subscriptionTypes) { + this.subscriptionTypes = subscriptionTypes; + return this; + } + + public Builder subscriptionTypes(List subscriptionTypes) { + this.subscriptionTypes = Optional.ofNullable(subscriptionTypes); + return this; + } + + public Builder subscriptionTypes(String subscriptionTypes) { + this.subscriptionTypes = Optional.of(Collections.singletonList(subscriptionTypes)); + return this; + } + + /** + *

Select the display columns to return (e.g. plan, subscription, users, last_seen_at)

+ */ + @JsonSetter(value = "display_properties", nulls = Nulls.SKIP) + public Builder displayProperties(Optional> displayProperties) { + this.displayProperties = displayProperties; + return this; + } + + public Builder displayProperties(List displayProperties) { + this.displayProperties = Optional.ofNullable(displayProperties); + return this; + } + + public Builder displayProperties(String displayProperties) { + this.displayProperties = Optional.of(Collections.singletonList(displayProperties)); + return this; + } + + /** + *

Filter companies that have monetized subscriptions

+ */ + @JsonSetter(value = "monetized_subscriptions", nulls = Nulls.SKIP) + public Builder monetizedSubscriptions(Optional monetizedSubscriptions) { + this.monetizedSubscriptions = monetizedSubscriptions; + return this; + } + + public Builder monetizedSubscriptions(Boolean monetizedSubscriptions) { + this.monetizedSubscriptions = Optional.ofNullable(monetizedSubscriptions); + return this; + } + + /** + *

Search for companies by name, keys or string traits

+ */ + @JsonSetter(value = "q", nulls = Nulls.SKIP) + public Builder q(Optional q) { + this.q = q; + return this; + } + + public Builder q(String q) { + this.q = Optional.ofNullable(q); + return this; + } + + /** + *

Filter out companies that have a plan

+ */ + @JsonSetter(value = "without_plan", nulls = Nulls.SKIP) + public Builder withoutPlan(Optional withoutPlan) { + this.withoutPlan = withoutPlan; + return this; + } + + public Builder withoutPlan(Boolean withoutPlan) { + this.withoutPlan = Optional.ofNullable(withoutPlan); + return this; + } + + /** + *

Filter out companies that have a subscription

+ */ + @JsonSetter(value = "without_subscription", nulls = Nulls.SKIP) + public Builder withoutSubscription(Optional withoutSubscription) { + this.withoutSubscription = withoutSubscription; + return this; + } + + public Builder withoutSubscription(Boolean withoutSubscription) { + this.withoutSubscription = Optional.ofNullable(withoutSubscription); + return this; + } + + /** + *

Column to sort by (e.g. name, created_at, last_seen_at)

+ */ + @JsonSetter(value = "sort_order_column", nulls = Nulls.SKIP) + public Builder sortOrderColumn(Optional sortOrderColumn) { + this.sortOrderColumn = sortOrderColumn; + return this; + } + + public Builder sortOrderColumn(String sortOrderColumn) { + this.sortOrderColumn = Optional.ofNullable(sortOrderColumn); + return this; + } + + /** + *

Direction to sort by (asc or desc)

+ */ + @JsonSetter(value = "sort_order_direction", nulls = Nulls.SKIP) + public Builder sortOrderDirection( + Optional sortOrderDirection) { + this.sortOrderDirection = sortOrderDirection; + return this; + } + + public Builder sortOrderDirection(CountCompaniesForAdvancedFilterRequestSortOrderDirection sortOrderDirection) { + this.sortOrderDirection = Optional.ofNullable(sortOrderDirection); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountCompaniesForAdvancedFilterRequest build() { + return new CountCompaniesForAdvancedFilterRequest( + ids, + planIds, + featureIds, + creditTypeIds, + subscriptionStatuses, + subscriptionTypes, + displayProperties, + monetizedSubscriptions, + q, + withoutPlan, + withoutSubscription, + sortOrderColumn, + sortOrderDirection, + limit, + offset, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesRequest.java index 6e7fe39..f0a6d40 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/CountCompaniesRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,7 +22,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountCompaniesRequest.Builder.class) public final class CountCompaniesRequest { - private final Optional ids; + private final Optional> ids; private final Optional planId; @@ -30,6 +32,8 @@ public final class CountCompaniesRequest { private final Optional withoutPlan; + private final Optional withSubscription; + private final Optional limit; private final Optional offset; @@ -37,11 +41,12 @@ public final class CountCompaniesRequest { private final Map additionalProperties; private CountCompaniesRequest( - Optional ids, + Optional> ids, Optional planId, Optional q, Optional withoutFeatureOverrideFor, Optional withoutPlan, + Optional withSubscription, Optional limit, Optional offset, Map additionalProperties) { @@ -50,6 +55,7 @@ private CountCompaniesRequest( this.q = q; this.withoutFeatureOverrideFor = withoutFeatureOverrideFor; this.withoutPlan = withoutPlan; + this.withSubscription = withSubscription; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; @@ -59,7 +65,7 @@ private CountCompaniesRequest( * @return Filter companies by multiple company IDs (starts with comp_) */ @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -95,6 +101,14 @@ public Optional getWithoutPlan() { return withoutPlan; } + /** + * @return Filter companies that have a subscription + */ + @JsonProperty("with_subscription") + public Optional getWithSubscription() { + return withSubscription; + } + /** * @return Page limit (default 100) */ @@ -128,6 +142,7 @@ private boolean equalTo(CountCompaniesRequest other) { && q.equals(other.q) && withoutFeatureOverrideFor.equals(other.withoutFeatureOverrideFor) && withoutPlan.equals(other.withoutPlan) + && withSubscription.equals(other.withSubscription) && limit.equals(other.limit) && offset.equals(other.offset); } @@ -140,6 +155,7 @@ public int hashCode() { this.q, this.withoutFeatureOverrideFor, this.withoutPlan, + this.withSubscription, this.limit, this.offset); } @@ -155,7 +171,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional planId = Optional.empty(); @@ -165,6 +181,8 @@ public static final class Builder { private Optional withoutPlan = Optional.empty(); + private Optional withSubscription = Optional.empty(); + private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); @@ -180,22 +198,34 @@ public Builder from(CountCompaniesRequest other) { q(other.getQ()); withoutFeatureOverrideFor(other.getWithoutFeatureOverrideFor()); withoutPlan(other.getWithoutPlan()); + withSubscription(other.getWithSubscription()); limit(other.getLimit()); offset(other.getOffset()); return this; } + /** + *

Filter companies by multiple company IDs (starts with comp_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Filter companies by plan ID (starts with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -207,6 +237,9 @@ public Builder planId(String planId) { return this; } + /** + *

Search for companies by name, keys or string traits

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -218,6 +251,9 @@ public Builder q(String q) { return this; } + /** + *

Filter out companies that already have a company override for the specified feature ID

+ */ @JsonSetter(value = "without_feature_override_for", nulls = Nulls.SKIP) public Builder withoutFeatureOverrideFor(Optional withoutFeatureOverrideFor) { this.withoutFeatureOverrideFor = withoutFeatureOverrideFor; @@ -229,6 +265,9 @@ public Builder withoutFeatureOverrideFor(String withoutFeatureOverrideFor) { return this; } + /** + *

Filter out companies that have a plan

+ */ @JsonSetter(value = "without_plan", nulls = Nulls.SKIP) public Builder withoutPlan(Optional withoutPlan) { this.withoutPlan = withoutPlan; @@ -240,6 +279,23 @@ public Builder withoutPlan(Boolean withoutPlan) { return this; } + /** + *

Filter companies that have a subscription

+ */ + @JsonSetter(value = "with_subscription", nulls = Nulls.SKIP) + public Builder withSubscription(Optional withSubscription) { + this.withSubscription = withSubscription; + return this; + } + + public Builder withSubscription(Boolean withSubscription) { + this.withSubscription = Optional.ofNullable(withSubscription); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -251,6 +307,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -264,7 +323,15 @@ public Builder offset(Integer offset) { public CountCompaniesRequest build() { return new CountCompaniesRequest( - ids, planId, q, withoutFeatureOverrideFor, withoutPlan, limit, offset, additionalProperties); + ids, + planId, + q, + withoutFeatureOverrideFor, + withoutPlan, + withSubscription, + limit, + offset, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CountEntityKeyDefinitionsRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/CountEntityKeyDefinitionsRequest.java index f420f8a..f78db03 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/CountEntityKeyDefinitionsRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/CountEntityKeyDefinitionsRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.companies.types.CountEntityKeyDefinitionsRequestEntityType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,9 +23,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountEntityKeyDefinitionsRequest.Builder.class) public final class CountEntityKeyDefinitionsRequest { - private final Optional entityType; + private final Optional> ids; - private final Optional ids; + private final Optional entityType; private final Optional q; @@ -34,30 +36,30 @@ public final class CountEntityKeyDefinitionsRequest { private final Map additionalProperties; private CountEntityKeyDefinitionsRequest( + Optional> ids, Optional entityType, - Optional ids, Optional q, Optional limit, Optional offset, Map additionalProperties) { - this.entityType = entityType; this.ids = ids; + this.entityType = entityType; this.q = q; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + @JsonProperty("entity_type") public Optional getEntityType() { return entityType; } - @JsonProperty("ids") - public Optional getIds() { - return ids; - } - @JsonProperty("q") public Optional getQ() { return q; @@ -91,8 +93,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountEntityKeyDefinitionsRequest other) { - return entityType.equals(other.entityType) - && ids.equals(other.ids) + return ids.equals(other.ids) + && entityType.equals(other.entityType) && q.equals(other.q) && limit.equals(other.limit) && offset.equals(other.offset); @@ -100,7 +102,7 @@ private boolean equalTo(CountEntityKeyDefinitionsRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.entityType, this.ids, this.q, this.limit, this.offset); + return Objects.hash(this.ids, this.entityType, this.q, this.limit, this.offset); } @java.lang.Override @@ -114,9 +116,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional entityType = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional entityType = Optional.empty(); private Optional q = Optional.empty(); @@ -130,33 +132,38 @@ public static final class Builder { private Builder() {} public Builder from(CountEntityKeyDefinitionsRequest other) { - entityType(other.getEntityType()); ids(other.getIds()); + entityType(other.getEntityType()); q(other.getQ()); limit(other.getLimit()); offset(other.getOffset()); return this; } - @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) - public Builder entityType(Optional entityType) { - this.entityType = entityType; + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder entityType(CountEntityKeyDefinitionsRequestEntityType entityType) { - this.entityType = Optional.ofNullable(entityType); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) + public Builder entityType(Optional entityType) { + this.entityType = entityType; + return this; + } + + public Builder entityType(CountEntityKeyDefinitionsRequestEntityType entityType) { + this.entityType = Optional.ofNullable(entityType); return this; } @@ -171,6 +178,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -182,6 +192,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -194,7 +207,7 @@ public Builder offset(Integer offset) { } public CountEntityKeyDefinitionsRequest build() { - return new CountEntityKeyDefinitionsRequest(entityType, ids, q, limit, offset, additionalProperties); + return new CountEntityKeyDefinitionsRequest(ids, entityType, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CountEntityTraitDefinitionsRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/CountEntityTraitDefinitionsRequest.java index 8bffa4b..47ee499 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/CountEntityTraitDefinitionsRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/CountEntityTraitDefinitionsRequest.java @@ -14,7 +14,9 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.companies.types.CountEntityTraitDefinitionsRequestEntityType; import com.schematic.api.resources.companies.types.CountEntityTraitDefinitionsRequestTraitType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,9 +24,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountEntityTraitDefinitionsRequest.Builder.class) public final class CountEntityTraitDefinitionsRequest { - private final Optional entityType; + private final Optional> ids; - private final Optional ids; + private final Optional entityType; private final Optional q; @@ -37,15 +39,15 @@ public final class CountEntityTraitDefinitionsRequest { private final Map additionalProperties; private CountEntityTraitDefinitionsRequest( + Optional> ids, Optional entityType, - Optional ids, Optional q, Optional traitType, Optional limit, Optional offset, Map additionalProperties) { - this.entityType = entityType; this.ids = ids; + this.entityType = entityType; this.q = q; this.traitType = traitType; this.limit = limit; @@ -53,16 +55,16 @@ private CountEntityTraitDefinitionsRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + @JsonProperty("entity_type") public Optional getEntityType() { return entityType; } - @JsonProperty("ids") - public Optional getIds() { - return ids; - } - @JsonProperty("q") public Optional getQ() { return q; @@ -102,8 +104,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountEntityTraitDefinitionsRequest other) { - return entityType.equals(other.entityType) - && ids.equals(other.ids) + return ids.equals(other.ids) + && entityType.equals(other.entityType) && q.equals(other.q) && traitType.equals(other.traitType) && limit.equals(other.limit) @@ -112,7 +114,7 @@ private boolean equalTo(CountEntityTraitDefinitionsRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.entityType, this.ids, this.q, this.traitType, this.limit, this.offset); + return Objects.hash(this.ids, this.entityType, this.q, this.traitType, this.limit, this.offset); } @java.lang.Override @@ -126,9 +128,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional entityType = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional entityType = Optional.empty(); private Optional q = Optional.empty(); @@ -144,8 +146,8 @@ public static final class Builder { private Builder() {} public Builder from(CountEntityTraitDefinitionsRequest other) { - entityType(other.getEntityType()); ids(other.getIds()); + entityType(other.getEntityType()); q(other.getQ()); traitType(other.getTraitType()); limit(other.getLimit()); @@ -153,25 +155,30 @@ public Builder from(CountEntityTraitDefinitionsRequest other) { return this; } - @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) - public Builder entityType(Optional entityType) { - this.entityType = entityType; + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder entityType(CountEntityTraitDefinitionsRequestEntityType entityType) { - this.entityType = Optional.ofNullable(entityType); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) + public Builder entityType(Optional entityType) { + this.entityType = entityType; + return this; + } + + public Builder entityType(CountEntityTraitDefinitionsRequestEntityType entityType) { + this.entityType = Optional.ofNullable(entityType); return this; } @@ -197,6 +204,9 @@ public Builder traitType(CountEntityTraitDefinitionsRequestTraitType traitType) return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -208,6 +218,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -221,7 +234,7 @@ public Builder offset(Integer offset) { public CountEntityTraitDefinitionsRequest build() { return new CountEntityTraitDefinitionsRequest( - entityType, ids, q, traitType, limit, offset, additionalProperties); + ids, entityType, q, traitType, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CountPlanTraitsRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/CountPlanTraitsRequest.java new file mode 100644 index 0000000..bf1ecca --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/CountPlanTraitsRequest.java @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountPlanTraitsRequest.Builder.class) +public final class CountPlanTraitsRequest { + private final Optional> ids; + + private final Optional> traitIds; + + private final Optional planId; + + private final Optional traitId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountPlanTraitsRequest( + Optional> ids, + Optional> traitIds, + Optional planId, + Optional traitId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.traitIds = traitIds; + this.planId = planId; + this.traitId = traitId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("trait_ids") + public Optional> getTraitIds() { + return traitIds; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @JsonProperty("trait_id") + public Optional getTraitId() { + return traitId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountPlanTraitsRequest && equalTo((CountPlanTraitsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountPlanTraitsRequest other) { + return ids.equals(other.ids) + && traitIds.equals(other.traitIds) + && planId.equals(other.planId) + && traitId.equals(other.traitId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.traitIds, this.planId, this.traitId, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional> traitIds = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional traitId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountPlanTraitsRequest other) { + ids(other.getIds()); + traitIds(other.getTraitIds()); + planId(other.getPlanId()); + traitId(other.getTraitId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "trait_ids", nulls = Nulls.SKIP) + public Builder traitIds(Optional> traitIds) { + this.traitIds = traitIds; + return this; + } + + public Builder traitIds(List traitIds) { + this.traitIds = Optional.ofNullable(traitIds); + return this; + } + + public Builder traitIds(String traitIds) { + this.traitIds = Optional.of(Collections.singletonList(traitIds)); + return this; + } + + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + @JsonSetter(value = "trait_id", nulls = Nulls.SKIP) + public Builder traitId(Optional traitId) { + this.traitId = traitId; + return this; + } + + public Builder traitId(String traitId) { + this.traitId = Optional.ofNullable(traitId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountPlanTraitsRequest build() { + return new CountPlanTraitsRequest(ids, traitIds, planId, traitId, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CountUsersRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/CountUsersRequest.java index 0f95ab1..63aaeb7 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/CountUsersRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/CountUsersRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,9 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountUsersRequest.Builder.class) public final class CountUsersRequest { - private final Optional companyId; + private final Optional> ids; - private final Optional ids; + private final Optional companyId; private final Optional planId; @@ -35,15 +37,15 @@ public final class CountUsersRequest { private final Map additionalProperties; private CountUsersRequest( + Optional> ids, Optional companyId, - Optional ids, Optional planId, Optional q, Optional limit, Optional offset, Map additionalProperties) { - this.companyId = companyId; this.ids = ids; + this.companyId = companyId; this.planId = planId; this.q = q; this.limit = limit; @@ -52,19 +54,19 @@ private CountUsersRequest( } /** - * @return Filter users by company ID (starts with comp_) + * @return Filter users by multiple user IDs (starts with user_) */ - @JsonProperty("company_id") - public Optional getCompanyId() { - return companyId; + @JsonProperty("ids") + public Optional> getIds() { + return ids; } /** - * @return Filter users by multiple user IDs (starts with user_) + * @return Filter users by company ID (starts with comp_) */ - @JsonProperty("ids") - public Optional getIds() { - return ids; + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; } /** @@ -111,8 +113,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountUsersRequest other) { - return companyId.equals(other.companyId) - && ids.equals(other.ids) + return ids.equals(other.ids) + && companyId.equals(other.companyId) && planId.equals(other.planId) && q.equals(other.q) && limit.equals(other.limit) @@ -121,7 +123,7 @@ private boolean equalTo(CountUsersRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.companyId, this.ids, this.planId, this.q, this.limit, this.offset); + return Objects.hash(this.ids, this.companyId, this.planId, this.q, this.limit, this.offset); } @java.lang.Override @@ -135,9 +137,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional companyId = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional planId = Optional.empty(); @@ -153,8 +155,8 @@ public static final class Builder { private Builder() {} public Builder from(CountUsersRequest other) { - companyId(other.getCompanyId()); ids(other.getIds()); + companyId(other.getCompanyId()); planId(other.getPlanId()); q(other.getQ()); limit(other.getLimit()); @@ -162,28 +164,42 @@ public Builder from(CountUsersRequest other) { return this; } - @JsonSetter(value = "company_id", nulls = Nulls.SKIP) - public Builder companyId(Optional companyId) { - this.companyId = companyId; + /** + *

Filter users by multiple user IDs (starts with user_)

+ */ + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder companyId(String companyId) { - this.companyId = Optional.ofNullable(companyId); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + /** + *

Filter users by company ID (starts with comp_)

+ */ + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); return this; } + /** + *

Filter users by plan ID (starts with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -195,6 +211,9 @@ public Builder planId(String planId) { return this; } + /** + *

Search for users by name, keys or string traits

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -206,6 +225,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -217,6 +239,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -229,7 +254,7 @@ public Builder offset(Integer offset) { } public CountUsersRequest build() { - return new CountUsersRequest(companyId, ids, planId, q, limit, offset, additionalProperties); + return new CountUsersRequest(ids, companyId, planId, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CreateEntityTraitDefinitionRequestBody.java b/src/main/java/com/schematic/api/resources/companies/requests/CreateEntityTraitDefinitionRequestBody.java index 915262b..a87979d 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/CreateEntityTraitDefinitionRequestBody.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/CreateEntityTraitDefinitionRequestBody.java @@ -165,7 +165,9 @@ public _FinalStage traitType(@NotNull CreateEntityTraitDefinitionRequestBodyTrai @java.lang.Override public _FinalStage addAllHierarchy(List hierarchy) { - this.hierarchy.addAll(hierarchy); + if (hierarchy != null) { + this.hierarchy.addAll(hierarchy); + } return this; } @@ -179,7 +181,9 @@ public _FinalStage addHierarchy(String hierarchy) { @JsonSetter(value = "hierarchy", nulls = Nulls.SKIP) public _FinalStage hierarchy(List hierarchy) { this.hierarchy.clear(); - this.hierarchy.addAll(hierarchy); + if (hierarchy != null) { + this.hierarchy.addAll(hierarchy); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/CreatePlanTraitRequestBody.java b/src/main/java/com/schematic/api/resources/companies/requests/CreatePlanTraitRequestBody.java new file mode 100644 index 0000000..60b2a52 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/CreatePlanTraitRequestBody.java @@ -0,0 +1,147 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreatePlanTraitRequestBody.Builder.class) +public final class CreatePlanTraitRequestBody { + private final String planId; + + private final String traitId; + + private final String traitValue; + + private final Map additionalProperties; + + private CreatePlanTraitRequestBody( + String planId, String traitId, String traitValue, Map additionalProperties) { + this.planId = planId; + this.traitId = traitId; + this.traitValue = traitValue; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @JsonProperty("trait_id") + public String getTraitId() { + return traitId; + } + + @JsonProperty("trait_value") + public String getTraitValue() { + return traitValue; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreatePlanTraitRequestBody && equalTo((CreatePlanTraitRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreatePlanTraitRequestBody other) { + return planId.equals(other.planId) && traitId.equals(other.traitId) && traitValue.equals(other.traitValue); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.planId, this.traitId, this.traitValue); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PlanIdStage builder() { + return new Builder(); + } + + public interface PlanIdStage { + TraitIdStage planId(@NotNull String planId); + + Builder from(CreatePlanTraitRequestBody other); + } + + public interface TraitIdStage { + TraitValueStage traitId(@NotNull String traitId); + } + + public interface TraitValueStage { + _FinalStage traitValue(@NotNull String traitValue); + } + + public interface _FinalStage { + CreatePlanTraitRequestBody build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PlanIdStage, TraitIdStage, TraitValueStage, _FinalStage { + private String planId; + + private String traitId; + + private String traitValue; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreatePlanTraitRequestBody other) { + planId(other.getPlanId()); + traitId(other.getTraitId()); + traitValue(other.getTraitValue()); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public TraitIdStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_id") + public TraitValueStage traitId(@NotNull String traitId) { + this.traitId = Objects.requireNonNull(traitId, "traitId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_value") + public _FinalStage traitValue(@NotNull String traitValue) { + this.traitValue = Objects.requireNonNull(traitValue, "traitValue must not be null"); + return this; + } + + @java.lang.Override + public CreatePlanTraitRequestBody build() { + return new CreatePlanTraitRequestBody(planId, traitId, traitValue, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/requests/GetActiveCompanySubscriptionRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/GetActiveCompanySubscriptionRequest.java index a1cb198..66dc2de 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/GetActiveCompanySubscriptionRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/GetActiveCompanySubscriptionRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,9 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GetActiveCompanySubscriptionRequest.Builder.class) public final class GetActiveCompanySubscriptionRequest { - private final Optional companyId; + private final Optional> companyIds; - private final Optional companyIds; + private final Optional companyId; private final Optional limit; @@ -31,28 +33,28 @@ public final class GetActiveCompanySubscriptionRequest { private final Map additionalProperties; private GetActiveCompanySubscriptionRequest( + Optional> companyIds, Optional companyId, - Optional companyIds, Optional limit, Optional offset, Map additionalProperties) { - this.companyId = companyId; this.companyIds = companyIds; + this.companyId = companyId; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + @JsonProperty("company_id") public Optional getCompanyId() { return companyId; } - @JsonProperty("company_ids") - public Optional getCompanyIds() { - return companyIds; - } - /** * @return Page limit (default 100) */ @@ -82,15 +84,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(GetActiveCompanySubscriptionRequest other) { - return companyId.equals(other.companyId) - && companyIds.equals(other.companyIds) + return companyIds.equals(other.companyIds) + && companyId.equals(other.companyId) && limit.equals(other.limit) && offset.equals(other.offset); } @java.lang.Override public int hashCode() { - return Objects.hash(this.companyId, this.companyIds, this.limit, this.offset); + return Objects.hash(this.companyIds, this.companyId, this.limit, this.offset); } @java.lang.Override @@ -104,9 +106,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional companyId = Optional.empty(); + private Optional> companyIds = Optional.empty(); - private Optional companyIds = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional limit = Optional.empty(); @@ -118,35 +120,43 @@ public static final class Builder { private Builder() {} public Builder from(GetActiveCompanySubscriptionRequest other) { - companyId(other.getCompanyId()); companyIds(other.getCompanyIds()); + companyId(other.getCompanyId()); limit(other.getLimit()); offset(other.getOffset()); return this; } - @JsonSetter(value = "company_id", nulls = Nulls.SKIP) - public Builder companyId(Optional companyId) { - this.companyId = companyId; + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; return this; } - public Builder companyId(String companyId) { - this.companyId = Optional.ofNullable(companyId); + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); return this; } - @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) - public Builder companyIds(Optional companyIds) { - this.companyIds = companyIds; + public Builder companyIds(String companyIds) { + this.companyIds = Optional.of(Collections.singletonList(companyIds)); return this; } - public Builder companyIds(String companyIds) { - this.companyIds = Optional.ofNullable(companyIds); + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -158,6 +168,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -170,7 +183,7 @@ public Builder offset(Integer offset) { } public GetActiveCompanySubscriptionRequest build() { - return new GetActiveCompanySubscriptionRequest(companyId, companyIds, limit, offset, additionalProperties); + return new GetActiveCompanySubscriptionRequest(companyIds, companyId, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/GetActiveDealsRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/GetActiveDealsRequest.java index 794f86c..3a57b57 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/GetActiveDealsRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/GetActiveDealsRequest.java @@ -115,10 +115,16 @@ public interface DealStageStage { public interface _FinalStage { GetActiveDealsRequest build(); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -172,6 +178,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -189,6 +198,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/companies/requests/GetEntityTraitValuesRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/GetEntityTraitValuesRequest.java index 5d5d7a7..ac4430a 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/GetEntityTraitValuesRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/GetEntityTraitValuesRequest.java @@ -115,10 +115,16 @@ public interface _FinalStage { _FinalStage q(String q); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -165,6 +171,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -182,6 +191,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesForAdvancedFilterRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesForAdvancedFilterRequest.java new file mode 100644 index 0000000..850e2de --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesForAdvancedFilterRequest.java @@ -0,0 +1,594 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.companies.types.ListCompaniesForAdvancedFilterRequestSortOrderDirection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompaniesForAdvancedFilterRequest.Builder.class) +public final class ListCompaniesForAdvancedFilterRequest { + private final Optional> ids; + + private final Optional> planIds; + + private final Optional> featureIds; + + private final Optional> creditTypeIds; + + private final Optional> subscriptionStatuses; + + private final Optional> subscriptionTypes; + + private final Optional> displayProperties; + + private final Optional monetizedSubscriptions; + + private final Optional q; + + private final Optional withoutPlan; + + private final Optional withoutSubscription; + + private final Optional sortOrderColumn; + + private final Optional sortOrderDirection; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListCompaniesForAdvancedFilterRequest( + Optional> ids, + Optional> planIds, + Optional> featureIds, + Optional> creditTypeIds, + Optional> subscriptionStatuses, + Optional> subscriptionTypes, + Optional> displayProperties, + Optional monetizedSubscriptions, + Optional q, + Optional withoutPlan, + Optional withoutSubscription, + Optional sortOrderColumn, + Optional sortOrderDirection, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.planIds = planIds; + this.featureIds = featureIds; + this.creditTypeIds = creditTypeIds; + this.subscriptionStatuses = subscriptionStatuses; + this.subscriptionTypes = subscriptionTypes; + this.displayProperties = displayProperties; + this.monetizedSubscriptions = monetizedSubscriptions; + this.q = q; + this.withoutPlan = withoutPlan; + this.withoutSubscription = withoutSubscription; + this.sortOrderColumn = sortOrderColumn; + this.sortOrderDirection = sortOrderDirection; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter companies by multiple company IDs (starts with comp_) + */ + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Filter companies by one or more plan IDs (each ID starts with plan_) + */ + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + /** + * @return Filter companies by one or more feature IDs (each ID starts with feat_) + */ + @JsonProperty("feature_ids") + public Optional> getFeatureIds() { + return featureIds; + } + + /** + * @return Filter companies by one or more credit type IDs (each ID starts with bcrd_) + */ + @JsonProperty("credit_type_ids") + public Optional> getCreditTypeIds() { + return creditTypeIds; + } + + /** + * @return Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid) + */ + @JsonProperty("subscription_statuses") + public Optional> getSubscriptionStatuses() { + return subscriptionStatuses; + } + + /** + * @return Filter companies by one or more subscription types (paid, free, trial) + */ + @JsonProperty("subscription_types") + public Optional> getSubscriptionTypes() { + return subscriptionTypes; + } + + /** + * @return Select the display columns to return (e.g. plan, subscription, users, last_seen_at) + */ + @JsonProperty("display_properties") + public Optional> getDisplayProperties() { + return displayProperties; + } + + /** + * @return Filter companies that have monetized subscriptions + */ + @JsonProperty("monetized_subscriptions") + public Optional getMonetizedSubscriptions() { + return monetizedSubscriptions; + } + + /** + * @return Search for companies by name, keys or string traits + */ + @JsonProperty("q") + public Optional getQ() { + return q; + } + + /** + * @return Filter out companies that have a plan + */ + @JsonProperty("without_plan") + public Optional getWithoutPlan() { + return withoutPlan; + } + + /** + * @return Filter out companies that have a subscription + */ + @JsonProperty("without_subscription") + public Optional getWithoutSubscription() { + return withoutSubscription; + } + + /** + * @return Column to sort by (e.g. name, created_at, last_seen_at) + */ + @JsonProperty("sort_order_column") + public Optional getSortOrderColumn() { + return sortOrderColumn; + } + + /** + * @return Direction to sort by (asc or desc) + */ + @JsonProperty("sort_order_direction") + public Optional getSortOrderDirection() { + return sortOrderDirection; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompaniesForAdvancedFilterRequest + && equalTo((ListCompaniesForAdvancedFilterRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompaniesForAdvancedFilterRequest other) { + return ids.equals(other.ids) + && planIds.equals(other.planIds) + && featureIds.equals(other.featureIds) + && creditTypeIds.equals(other.creditTypeIds) + && subscriptionStatuses.equals(other.subscriptionStatuses) + && subscriptionTypes.equals(other.subscriptionTypes) + && displayProperties.equals(other.displayProperties) + && monetizedSubscriptions.equals(other.monetizedSubscriptions) + && q.equals(other.q) + && withoutPlan.equals(other.withoutPlan) + && withoutSubscription.equals(other.withoutSubscription) + && sortOrderColumn.equals(other.sortOrderColumn) + && sortOrderDirection.equals(other.sortOrderDirection) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ids, + this.planIds, + this.featureIds, + this.creditTypeIds, + this.subscriptionStatuses, + this.subscriptionTypes, + this.displayProperties, + this.monetizedSubscriptions, + this.q, + this.withoutPlan, + this.withoutSubscription, + this.sortOrderColumn, + this.sortOrderDirection, + this.limit, + this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional> planIds = Optional.empty(); + + private Optional> featureIds = Optional.empty(); + + private Optional> creditTypeIds = Optional.empty(); + + private Optional> subscriptionStatuses = Optional.empty(); + + private Optional> subscriptionTypes = Optional.empty(); + + private Optional> displayProperties = Optional.empty(); + + private Optional monetizedSubscriptions = Optional.empty(); + + private Optional q = Optional.empty(); + + private Optional withoutPlan = Optional.empty(); + + private Optional withoutSubscription = Optional.empty(); + + private Optional sortOrderColumn = Optional.empty(); + + private Optional sortOrderDirection = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCompaniesForAdvancedFilterRequest other) { + ids(other.getIds()); + planIds(other.getPlanIds()); + featureIds(other.getFeatureIds()); + creditTypeIds(other.getCreditTypeIds()); + subscriptionStatuses(other.getSubscriptionStatuses()); + subscriptionTypes(other.getSubscriptionTypes()); + displayProperties(other.getDisplayProperties()); + monetizedSubscriptions(other.getMonetizedSubscriptions()); + q(other.getQ()); + withoutPlan(other.getWithoutPlan()); + withoutSubscription(other.getWithoutSubscription()); + sortOrderColumn(other.getSortOrderColumn()); + sortOrderDirection(other.getSortOrderDirection()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + /** + *

Filter companies by multiple company IDs (starts with comp_)

+ */ + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Filter companies by one or more plan IDs (each ID starts with plan_)

+ */ + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + public Builder planIds(String planIds) { + this.planIds = Optional.of(Collections.singletonList(planIds)); + return this; + } + + /** + *

Filter companies by one or more feature IDs (each ID starts with feat_)

+ */ + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; + return this; + } + + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); + return this; + } + + public Builder featureIds(String featureIds) { + this.featureIds = Optional.of(Collections.singletonList(featureIds)); + return this; + } + + /** + *

Filter companies by one or more credit type IDs (each ID starts with bcrd_)

+ */ + @JsonSetter(value = "credit_type_ids", nulls = Nulls.SKIP) + public Builder creditTypeIds(Optional> creditTypeIds) { + this.creditTypeIds = creditTypeIds; + return this; + } + + public Builder creditTypeIds(List creditTypeIds) { + this.creditTypeIds = Optional.ofNullable(creditTypeIds); + return this; + } + + public Builder creditTypeIds(String creditTypeIds) { + this.creditTypeIds = Optional.of(Collections.singletonList(creditTypeIds)); + return this; + } + + /** + *

Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid)

+ */ + @JsonSetter(value = "subscription_statuses", nulls = Nulls.SKIP) + public Builder subscriptionStatuses(Optional> subscriptionStatuses) { + this.subscriptionStatuses = subscriptionStatuses; + return this; + } + + public Builder subscriptionStatuses(List subscriptionStatuses) { + this.subscriptionStatuses = Optional.ofNullable(subscriptionStatuses); + return this; + } + + public Builder subscriptionStatuses(String subscriptionStatuses) { + this.subscriptionStatuses = Optional.of(Collections.singletonList(subscriptionStatuses)); + return this; + } + + /** + *

Filter companies by one or more subscription types (paid, free, trial)

+ */ + @JsonSetter(value = "subscription_types", nulls = Nulls.SKIP) + public Builder subscriptionTypes(Optional> subscriptionTypes) { + this.subscriptionTypes = subscriptionTypes; + return this; + } + + public Builder subscriptionTypes(List subscriptionTypes) { + this.subscriptionTypes = Optional.ofNullable(subscriptionTypes); + return this; + } + + public Builder subscriptionTypes(String subscriptionTypes) { + this.subscriptionTypes = Optional.of(Collections.singletonList(subscriptionTypes)); + return this; + } + + /** + *

Select the display columns to return (e.g. plan, subscription, users, last_seen_at)

+ */ + @JsonSetter(value = "display_properties", nulls = Nulls.SKIP) + public Builder displayProperties(Optional> displayProperties) { + this.displayProperties = displayProperties; + return this; + } + + public Builder displayProperties(List displayProperties) { + this.displayProperties = Optional.ofNullable(displayProperties); + return this; + } + + public Builder displayProperties(String displayProperties) { + this.displayProperties = Optional.of(Collections.singletonList(displayProperties)); + return this; + } + + /** + *

Filter companies that have monetized subscriptions

+ */ + @JsonSetter(value = "monetized_subscriptions", nulls = Nulls.SKIP) + public Builder monetizedSubscriptions(Optional monetizedSubscriptions) { + this.monetizedSubscriptions = monetizedSubscriptions; + return this; + } + + public Builder monetizedSubscriptions(Boolean monetizedSubscriptions) { + this.monetizedSubscriptions = Optional.ofNullable(monetizedSubscriptions); + return this; + } + + /** + *

Search for companies by name, keys or string traits

+ */ + @JsonSetter(value = "q", nulls = Nulls.SKIP) + public Builder q(Optional q) { + this.q = q; + return this; + } + + public Builder q(String q) { + this.q = Optional.ofNullable(q); + return this; + } + + /** + *

Filter out companies that have a plan

+ */ + @JsonSetter(value = "without_plan", nulls = Nulls.SKIP) + public Builder withoutPlan(Optional withoutPlan) { + this.withoutPlan = withoutPlan; + return this; + } + + public Builder withoutPlan(Boolean withoutPlan) { + this.withoutPlan = Optional.ofNullable(withoutPlan); + return this; + } + + /** + *

Filter out companies that have a subscription

+ */ + @JsonSetter(value = "without_subscription", nulls = Nulls.SKIP) + public Builder withoutSubscription(Optional withoutSubscription) { + this.withoutSubscription = withoutSubscription; + return this; + } + + public Builder withoutSubscription(Boolean withoutSubscription) { + this.withoutSubscription = Optional.ofNullable(withoutSubscription); + return this; + } + + /** + *

Column to sort by (e.g. name, created_at, last_seen_at)

+ */ + @JsonSetter(value = "sort_order_column", nulls = Nulls.SKIP) + public Builder sortOrderColumn(Optional sortOrderColumn) { + this.sortOrderColumn = sortOrderColumn; + return this; + } + + public Builder sortOrderColumn(String sortOrderColumn) { + this.sortOrderColumn = Optional.ofNullable(sortOrderColumn); + return this; + } + + /** + *

Direction to sort by (asc or desc)

+ */ + @JsonSetter(value = "sort_order_direction", nulls = Nulls.SKIP) + public Builder sortOrderDirection( + Optional sortOrderDirection) { + this.sortOrderDirection = sortOrderDirection; + return this; + } + + public Builder sortOrderDirection(ListCompaniesForAdvancedFilterRequestSortOrderDirection sortOrderDirection) { + this.sortOrderDirection = Optional.ofNullable(sortOrderDirection); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListCompaniesForAdvancedFilterRequest build() { + return new ListCompaniesForAdvancedFilterRequest( + ids, + planIds, + featureIds, + creditTypeIds, + subscriptionStatuses, + subscriptionTypes, + displayProperties, + monetizedSubscriptions, + q, + withoutPlan, + withoutSubscription, + sortOrderColumn, + sortOrderDirection, + limit, + offset, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesRequest.java index e278c03..6e72f6a 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListCompaniesRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,7 +22,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListCompaniesRequest.Builder.class) public final class ListCompaniesRequest { - private final Optional ids; + private final Optional> ids; private final Optional planId; @@ -30,6 +32,8 @@ public final class ListCompaniesRequest { private final Optional withoutPlan; + private final Optional withSubscription; + private final Optional limit; private final Optional offset; @@ -37,11 +41,12 @@ public final class ListCompaniesRequest { private final Map additionalProperties; private ListCompaniesRequest( - Optional ids, + Optional> ids, Optional planId, Optional q, Optional withoutFeatureOverrideFor, Optional withoutPlan, + Optional withSubscription, Optional limit, Optional offset, Map additionalProperties) { @@ -50,6 +55,7 @@ private ListCompaniesRequest( this.q = q; this.withoutFeatureOverrideFor = withoutFeatureOverrideFor; this.withoutPlan = withoutPlan; + this.withSubscription = withSubscription; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; @@ -59,7 +65,7 @@ private ListCompaniesRequest( * @return Filter companies by multiple company IDs (starts with comp_) */ @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -95,6 +101,14 @@ public Optional getWithoutPlan() { return withoutPlan; } + /** + * @return Filter companies that have a subscription + */ + @JsonProperty("with_subscription") + public Optional getWithSubscription() { + return withSubscription; + } + /** * @return Page limit (default 100) */ @@ -128,6 +142,7 @@ private boolean equalTo(ListCompaniesRequest other) { && q.equals(other.q) && withoutFeatureOverrideFor.equals(other.withoutFeatureOverrideFor) && withoutPlan.equals(other.withoutPlan) + && withSubscription.equals(other.withSubscription) && limit.equals(other.limit) && offset.equals(other.offset); } @@ -140,6 +155,7 @@ public int hashCode() { this.q, this.withoutFeatureOverrideFor, this.withoutPlan, + this.withSubscription, this.limit, this.offset); } @@ -155,7 +171,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional planId = Optional.empty(); @@ -165,6 +181,8 @@ public static final class Builder { private Optional withoutPlan = Optional.empty(); + private Optional withSubscription = Optional.empty(); + private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); @@ -180,22 +198,34 @@ public Builder from(ListCompaniesRequest other) { q(other.getQ()); withoutFeatureOverrideFor(other.getWithoutFeatureOverrideFor()); withoutPlan(other.getWithoutPlan()); + withSubscription(other.getWithSubscription()); limit(other.getLimit()); offset(other.getOffset()); return this; } + /** + *

Filter companies by multiple company IDs (starts with comp_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Filter companies by plan ID (starts with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -207,6 +237,9 @@ public Builder planId(String planId) { return this; } + /** + *

Search for companies by name, keys or string traits

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -218,6 +251,9 @@ public Builder q(String q) { return this; } + /** + *

Filter out companies that already have a company override for the specified feature ID

+ */ @JsonSetter(value = "without_feature_override_for", nulls = Nulls.SKIP) public Builder withoutFeatureOverrideFor(Optional withoutFeatureOverrideFor) { this.withoutFeatureOverrideFor = withoutFeatureOverrideFor; @@ -229,6 +265,9 @@ public Builder withoutFeatureOverrideFor(String withoutFeatureOverrideFor) { return this; } + /** + *

Filter out companies that have a plan

+ */ @JsonSetter(value = "without_plan", nulls = Nulls.SKIP) public Builder withoutPlan(Optional withoutPlan) { this.withoutPlan = withoutPlan; @@ -240,6 +279,23 @@ public Builder withoutPlan(Boolean withoutPlan) { return this; } + /** + *

Filter companies that have a subscription

+ */ + @JsonSetter(value = "with_subscription", nulls = Nulls.SKIP) + public Builder withSubscription(Optional withSubscription) { + this.withSubscription = withSubscription; + return this; + } + + public Builder withSubscription(Boolean withSubscription) { + this.withSubscription = Optional.ofNullable(withSubscription); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -251,6 +307,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -264,7 +323,15 @@ public Builder offset(Integer offset) { public ListCompaniesRequest build() { return new ListCompaniesRequest( - ids, planId, q, withoutFeatureOverrideFor, withoutPlan, limit, offset, additionalProperties); + ids, + planId, + q, + withoutFeatureOverrideFor, + withoutPlan, + withSubscription, + limit, + offset, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/ListCompanyMembershipsRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListCompanyMembershipsRequest.java index 81f737a..528c711 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/ListCompanyMembershipsRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListCompanyMembershipsRequest.java @@ -146,6 +146,9 @@ public Builder userId(String userId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -157,6 +160,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/requests/ListEntityKeyDefinitionsRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListEntityKeyDefinitionsRequest.java index c6dcd04..c013408 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/ListEntityKeyDefinitionsRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListEntityKeyDefinitionsRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.companies.types.ListEntityKeyDefinitionsRequestEntityType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,9 +23,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListEntityKeyDefinitionsRequest.Builder.class) public final class ListEntityKeyDefinitionsRequest { - private final Optional entityType; + private final Optional> ids; - private final Optional ids; + private final Optional entityType; private final Optional q; @@ -34,30 +36,30 @@ public final class ListEntityKeyDefinitionsRequest { private final Map additionalProperties; private ListEntityKeyDefinitionsRequest( + Optional> ids, Optional entityType, - Optional ids, Optional q, Optional limit, Optional offset, Map additionalProperties) { - this.entityType = entityType; this.ids = ids; + this.entityType = entityType; this.q = q; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + @JsonProperty("entity_type") public Optional getEntityType() { return entityType; } - @JsonProperty("ids") - public Optional getIds() { - return ids; - } - @JsonProperty("q") public Optional getQ() { return q; @@ -91,8 +93,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListEntityKeyDefinitionsRequest other) { - return entityType.equals(other.entityType) - && ids.equals(other.ids) + return ids.equals(other.ids) + && entityType.equals(other.entityType) && q.equals(other.q) && limit.equals(other.limit) && offset.equals(other.offset); @@ -100,7 +102,7 @@ private boolean equalTo(ListEntityKeyDefinitionsRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.entityType, this.ids, this.q, this.limit, this.offset); + return Objects.hash(this.ids, this.entityType, this.q, this.limit, this.offset); } @java.lang.Override @@ -114,9 +116,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional entityType = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional entityType = Optional.empty(); private Optional q = Optional.empty(); @@ -130,33 +132,38 @@ public static final class Builder { private Builder() {} public Builder from(ListEntityKeyDefinitionsRequest other) { - entityType(other.getEntityType()); ids(other.getIds()); + entityType(other.getEntityType()); q(other.getQ()); limit(other.getLimit()); offset(other.getOffset()); return this; } - @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) - public Builder entityType(Optional entityType) { - this.entityType = entityType; + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder entityType(ListEntityKeyDefinitionsRequestEntityType entityType) { - this.entityType = Optional.ofNullable(entityType); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) + public Builder entityType(Optional entityType) { + this.entityType = entityType; + return this; + } + + public Builder entityType(ListEntityKeyDefinitionsRequestEntityType entityType) { + this.entityType = Optional.ofNullable(entityType); return this; } @@ -171,6 +178,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -182,6 +192,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -194,7 +207,7 @@ public Builder offset(Integer offset) { } public ListEntityKeyDefinitionsRequest build() { - return new ListEntityKeyDefinitionsRequest(entityType, ids, q, limit, offset, additionalProperties); + return new ListEntityKeyDefinitionsRequest(ids, entityType, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/ListEntityTraitDefinitionsRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListEntityTraitDefinitionsRequest.java index c279e6d..4e7c088 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/ListEntityTraitDefinitionsRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListEntityTraitDefinitionsRequest.java @@ -14,7 +14,9 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.companies.types.ListEntityTraitDefinitionsRequestEntityType; import com.schematic.api.resources.companies.types.ListEntityTraitDefinitionsRequestTraitType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,9 +24,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListEntityTraitDefinitionsRequest.Builder.class) public final class ListEntityTraitDefinitionsRequest { - private final Optional entityType; + private final Optional> ids; - private final Optional ids; + private final Optional entityType; private final Optional q; @@ -37,15 +39,15 @@ public final class ListEntityTraitDefinitionsRequest { private final Map additionalProperties; private ListEntityTraitDefinitionsRequest( + Optional> ids, Optional entityType, - Optional ids, Optional q, Optional traitType, Optional limit, Optional offset, Map additionalProperties) { - this.entityType = entityType; this.ids = ids; + this.entityType = entityType; this.q = q; this.traitType = traitType; this.limit = limit; @@ -53,16 +55,16 @@ private ListEntityTraitDefinitionsRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + @JsonProperty("entity_type") public Optional getEntityType() { return entityType; } - @JsonProperty("ids") - public Optional getIds() { - return ids; - } - @JsonProperty("q") public Optional getQ() { return q; @@ -101,8 +103,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListEntityTraitDefinitionsRequest other) { - return entityType.equals(other.entityType) - && ids.equals(other.ids) + return ids.equals(other.ids) + && entityType.equals(other.entityType) && q.equals(other.q) && traitType.equals(other.traitType) && limit.equals(other.limit) @@ -111,7 +113,7 @@ private boolean equalTo(ListEntityTraitDefinitionsRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.entityType, this.ids, this.q, this.traitType, this.limit, this.offset); + return Objects.hash(this.ids, this.entityType, this.q, this.traitType, this.limit, this.offset); } @java.lang.Override @@ -125,9 +127,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional entityType = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional entityType = Optional.empty(); private Optional q = Optional.empty(); @@ -143,8 +145,8 @@ public static final class Builder { private Builder() {} public Builder from(ListEntityTraitDefinitionsRequest other) { - entityType(other.getEntityType()); ids(other.getIds()); + entityType(other.getEntityType()); q(other.getQ()); traitType(other.getTraitType()); limit(other.getLimit()); @@ -152,25 +154,30 @@ public Builder from(ListEntityTraitDefinitionsRequest other) { return this; } - @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) - public Builder entityType(Optional entityType) { - this.entityType = entityType; + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder entityType(ListEntityTraitDefinitionsRequestEntityType entityType) { - this.entityType = Optional.ofNullable(entityType); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + @JsonSetter(value = "entity_type", nulls = Nulls.SKIP) + public Builder entityType(Optional entityType) { + this.entityType = entityType; + return this; + } + + public Builder entityType(ListEntityTraitDefinitionsRequestEntityType entityType) { + this.entityType = Optional.ofNullable(entityType); return this; } @@ -196,6 +203,9 @@ public Builder traitType(ListEntityTraitDefinitionsRequestTraitType traitType) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -207,6 +217,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -220,7 +233,7 @@ public Builder offset(Integer offset) { public ListEntityTraitDefinitionsRequest build() { return new ListEntityTraitDefinitionsRequest( - entityType, ids, q, traitType, limit, offset, additionalProperties); + ids, entityType, q, traitType, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/ListPlanChangesRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListPlanChangesRequest.java new file mode 100644 index 0000000..a69b17a --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListPlanChangesRequest.java @@ -0,0 +1,273 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanChangesRequest.Builder.class) +public final class ListPlanChangesRequest { + private final Optional> companyIds; + + private final Optional> planIds; + + private final Optional action; + + private final Optional basePlanAction; + + private final Optional companyId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListPlanChangesRequest( + Optional> companyIds, + Optional> planIds, + Optional action, + Optional basePlanAction, + Optional companyId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.companyIds = companyIds; + this.planIds = planIds; + this.action = action; + this.basePlanAction = basePlanAction; + this.companyId = companyId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + @JsonProperty("action") + public Optional getAction() { + return action; + } + + @JsonProperty("base_plan_action") + public Optional getBasePlanAction() { + return basePlanAction; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanChangesRequest && equalTo((ListPlanChangesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanChangesRequest other) { + return companyIds.equals(other.companyIds) + && planIds.equals(other.planIds) + && action.equals(other.action) + && basePlanAction.equals(other.basePlanAction) + && companyId.equals(other.companyId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.companyIds, + this.planIds, + this.action, + this.basePlanAction, + this.companyId, + this.limit, + this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> companyIds = Optional.empty(); + + private Optional> planIds = Optional.empty(); + + private Optional action = Optional.empty(); + + private Optional basePlanAction = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListPlanChangesRequest other) { + companyIds(other.getCompanyIds()); + planIds(other.getPlanIds()); + action(other.getAction()); + basePlanAction(other.getBasePlanAction()); + companyId(other.getCompanyId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; + return this; + } + + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); + return this; + } + + public Builder companyIds(String companyIds) { + this.companyIds = Optional.of(Collections.singletonList(companyIds)); + return this; + } + + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + public Builder planIds(String planIds) { + this.planIds = Optional.of(Collections.singletonList(planIds)); + return this; + } + + @JsonSetter(value = "action", nulls = Nulls.SKIP) + public Builder action(Optional action) { + this.action = action; + return this; + } + + public Builder action(String action) { + this.action = Optional.ofNullable(action); + return this; + } + + @JsonSetter(value = "base_plan_action", nulls = Nulls.SKIP) + public Builder basePlanAction(Optional basePlanAction) { + this.basePlanAction = basePlanAction; + return this; + } + + public Builder basePlanAction(String basePlanAction) { + this.basePlanAction = Optional.ofNullable(basePlanAction); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListPlanChangesRequest build() { + return new ListPlanChangesRequest( + companyIds, planIds, action, basePlanAction, companyId, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/requests/ListPlanTraitsRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListPlanTraitsRequest.java new file mode 100644 index 0000000..98e6b92 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListPlanTraitsRequest.java @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanTraitsRequest.Builder.class) +public final class ListPlanTraitsRequest { + private final Optional> ids; + + private final Optional> traitIds; + + private final Optional planId; + + private final Optional traitId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListPlanTraitsRequest( + Optional> ids, + Optional> traitIds, + Optional planId, + Optional traitId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.traitIds = traitIds; + this.planId = planId; + this.traitId = traitId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("trait_ids") + public Optional> getTraitIds() { + return traitIds; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @JsonProperty("trait_id") + public Optional getTraitId() { + return traitId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanTraitsRequest && equalTo((ListPlanTraitsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanTraitsRequest other) { + return ids.equals(other.ids) + && traitIds.equals(other.traitIds) + && planId.equals(other.planId) + && traitId.equals(other.traitId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.traitIds, this.planId, this.traitId, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional> traitIds = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional traitId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListPlanTraitsRequest other) { + ids(other.getIds()); + traitIds(other.getTraitIds()); + planId(other.getPlanId()); + traitId(other.getTraitId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "trait_ids", nulls = Nulls.SKIP) + public Builder traitIds(Optional> traitIds) { + this.traitIds = traitIds; + return this; + } + + public Builder traitIds(List traitIds) { + this.traitIds = Optional.ofNullable(traitIds); + return this; + } + + public Builder traitIds(String traitIds) { + this.traitIds = Optional.of(Collections.singletonList(traitIds)); + return this; + } + + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + @JsonSetter(value = "trait_id", nulls = Nulls.SKIP) + public Builder traitId(Optional traitId) { + this.traitId = traitId; + return this; + } + + public Builder traitId(String traitId) { + this.traitId = Optional.ofNullable(traitId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListPlanTraitsRequest build() { + return new ListPlanTraitsRequest(ids, traitIds, planId, traitId, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/requests/ListUsersRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/ListUsersRequest.java index 9fc95fe..7a5a367 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/ListUsersRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/ListUsersRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,9 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListUsersRequest.Builder.class) public final class ListUsersRequest { - private final Optional companyId; + private final Optional> ids; - private final Optional ids; + private final Optional companyId; private final Optional planId; @@ -35,15 +37,15 @@ public final class ListUsersRequest { private final Map additionalProperties; private ListUsersRequest( + Optional> ids, Optional companyId, - Optional ids, Optional planId, Optional q, Optional limit, Optional offset, Map additionalProperties) { - this.companyId = companyId; this.ids = ids; + this.companyId = companyId; this.planId = planId; this.q = q; this.limit = limit; @@ -52,19 +54,19 @@ private ListUsersRequest( } /** - * @return Filter users by company ID (starts with comp_) + * @return Filter users by multiple user IDs (starts with user_) */ - @JsonProperty("company_id") - public Optional getCompanyId() { - return companyId; + @JsonProperty("ids") + public Optional> getIds() { + return ids; } /** - * @return Filter users by multiple user IDs (starts with user_) + * @return Filter users by company ID (starts with comp_) */ - @JsonProperty("ids") - public Optional getIds() { - return ids; + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; } /** @@ -111,8 +113,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListUsersRequest other) { - return companyId.equals(other.companyId) - && ids.equals(other.ids) + return ids.equals(other.ids) + && companyId.equals(other.companyId) && planId.equals(other.planId) && q.equals(other.q) && limit.equals(other.limit) @@ -121,7 +123,7 @@ private boolean equalTo(ListUsersRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.companyId, this.ids, this.planId, this.q, this.limit, this.offset); + return Objects.hash(this.ids, this.companyId, this.planId, this.q, this.limit, this.offset); } @java.lang.Override @@ -135,9 +137,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional companyId = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional planId = Optional.empty(); @@ -153,8 +155,8 @@ public static final class Builder { private Builder() {} public Builder from(ListUsersRequest other) { - companyId(other.getCompanyId()); ids(other.getIds()); + companyId(other.getCompanyId()); planId(other.getPlanId()); q(other.getQ()); limit(other.getLimit()); @@ -162,28 +164,42 @@ public Builder from(ListUsersRequest other) { return this; } - @JsonSetter(value = "company_id", nulls = Nulls.SKIP) - public Builder companyId(Optional companyId) { - this.companyId = companyId; + /** + *

Filter users by multiple user IDs (starts with user_)

+ */ + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder companyId(String companyId) { - this.companyId = Optional.ofNullable(companyId); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + /** + *

Filter users by company ID (starts with comp_)

+ */ + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); return this; } + /** + *

Filter users by plan ID (starts with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -195,6 +211,9 @@ public Builder planId(String planId) { return this; } + /** + *

Search for users by name, keys or string traits

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -206,6 +225,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -217,6 +239,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -229,7 +254,7 @@ public Builder offset(Integer offset) { } public ListUsersRequest build() { - return new ListUsersRequest(companyId, ids, planId, q, limit, offset, additionalProperties); + return new ListUsersRequest(ids, companyId, planId, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/LookupCompanyRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/LookupCompanyRequest.java index d1dde2a..84280b3 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/LookupCompanyRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/LookupCompanyRequest.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; @@ -21,11 +20,11 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LookupCompanyRequest.Builder.class) public final class LookupCompanyRequest { - private final Map keys; + private final Map keys; private final Map additionalProperties; - private LookupCompanyRequest(Map keys, Map additionalProperties) { + private LookupCompanyRequest(Map keys, Map additionalProperties) { this.keys = keys; this.additionalProperties = additionalProperties; } @@ -34,7 +33,7 @@ private LookupCompanyRequest(Map keys, Map add * @return Key/value pairs */ @JsonProperty("keys") - public Map getKeys() { + public Map getKeys() { return keys; } @@ -69,7 +68,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Map keys = new LinkedHashMap<>(); + private Map keys = new LinkedHashMap<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -81,19 +80,26 @@ public Builder from(LookupCompanyRequest other) { return this; } + /** + *

Key/value pairs

+ */ @JsonSetter(value = "keys", nulls = Nulls.SKIP) - public Builder keys(Map keys) { + public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } - public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + public Builder putAllKeys(Map keys) { + if (keys != null) { + this.keys.putAll(keys); + } return this; } - public Builder keys(String key, JsonNode value) { + public Builder keys(String key, String value) { this.keys.put(key, value); return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/LookupUserRequest.java b/src/main/java/com/schematic/api/resources/companies/requests/LookupUserRequest.java index c24f4e7..3dfb734 100644 --- a/src/main/java/com/schematic/api/resources/companies/requests/LookupUserRequest.java +++ b/src/main/java/com/schematic/api/resources/companies/requests/LookupUserRequest.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; @@ -21,11 +20,11 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LookupUserRequest.Builder.class) public final class LookupUserRequest { - private final Map keys; + private final Map keys; private final Map additionalProperties; - private LookupUserRequest(Map keys, Map additionalProperties) { + private LookupUserRequest(Map keys, Map additionalProperties) { this.keys = keys; this.additionalProperties = additionalProperties; } @@ -34,7 +33,7 @@ private LookupUserRequest(Map keys, Map additi * @return Key/value pairs */ @JsonProperty("keys") - public Map getKeys() { + public Map getKeys() { return keys; } @@ -69,7 +68,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Map keys = new LinkedHashMap<>(); + private Map keys = new LinkedHashMap<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -81,19 +80,26 @@ public Builder from(LookupUserRequest other) { return this; } + /** + *

Key/value pairs

+ */ @JsonSetter(value = "keys", nulls = Nulls.SKIP) - public Builder keys(Map keys) { + public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } - public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + public Builder putAllKeys(Map keys) { + if (keys != null) { + this.keys.putAll(keys); + } return this; } - public Builder keys(String key, JsonNode value) { + public Builder keys(String key, String value) { this.keys.put(key, value); return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/requests/UpdatePlanTraitBulkRequestBody.java b/src/main/java/com/schematic/api/resources/companies/requests/UpdatePlanTraitBulkRequestBody.java new file mode 100644 index 0000000..9a61f69 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/UpdatePlanTraitBulkRequestBody.java @@ -0,0 +1,148 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.UpdatePlanTraitTraitRequestBody; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdatePlanTraitBulkRequestBody.Builder.class) +public final class UpdatePlanTraitBulkRequestBody { + private final String planId; + + private final List traits; + + private final Map additionalProperties; + + private UpdatePlanTraitBulkRequestBody( + String planId, List traits, Map additionalProperties) { + this.planId = planId; + this.traits = traits; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @JsonProperty("traits") + public List getTraits() { + return traits; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdatePlanTraitBulkRequestBody && equalTo((UpdatePlanTraitBulkRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdatePlanTraitBulkRequestBody other) { + return planId.equals(other.planId) && traits.equals(other.traits); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.planId, this.traits); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PlanIdStage builder() { + return new Builder(); + } + + public interface PlanIdStage { + _FinalStage planId(@NotNull String planId); + + Builder from(UpdatePlanTraitBulkRequestBody other); + } + + public interface _FinalStage { + UpdatePlanTraitBulkRequestBody build(); + + _FinalStage traits(List traits); + + _FinalStage addTraits(UpdatePlanTraitTraitRequestBody traits); + + _FinalStage addAllTraits(List traits); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PlanIdStage, _FinalStage { + private String planId; + + private List traits = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdatePlanTraitBulkRequestBody other) { + planId(other.getPlanId()); + traits(other.getTraits()); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public _FinalStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllTraits(List traits) { + if (traits != null) { + this.traits.addAll(traits); + } + return this; + } + + @java.lang.Override + public _FinalStage addTraits(UpdatePlanTraitTraitRequestBody traits) { + this.traits.add(traits); + return this; + } + + @java.lang.Override + @JsonSetter(value = "traits", nulls = Nulls.SKIP) + public _FinalStage traits(List traits) { + this.traits.clear(); + if (traits != null) { + this.traits.addAll(traits); + } + return this; + } + + @java.lang.Override + public UpdatePlanTraitBulkRequestBody build() { + return new UpdatePlanTraitBulkRequestBody(planId, traits, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/requests/UpdatePlanTraitRequestBody.java b/src/main/java/com/schematic/api/resources/companies/requests/UpdatePlanTraitRequestBody.java new file mode 100644 index 0000000..243e967 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/requests/UpdatePlanTraitRequestBody.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdatePlanTraitRequestBody.Builder.class) +public final class UpdatePlanTraitRequestBody { + private final String planId; + + private final String traitValue; + + private final Map additionalProperties; + + private UpdatePlanTraitRequestBody(String planId, String traitValue, Map additionalProperties) { + this.planId = planId; + this.traitValue = traitValue; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @JsonProperty("trait_value") + public String getTraitValue() { + return traitValue; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdatePlanTraitRequestBody && equalTo((UpdatePlanTraitRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdatePlanTraitRequestBody other) { + return planId.equals(other.planId) && traitValue.equals(other.traitValue); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.planId, this.traitValue); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PlanIdStage builder() { + return new Builder(); + } + + public interface PlanIdStage { + TraitValueStage planId(@NotNull String planId); + + Builder from(UpdatePlanTraitRequestBody other); + } + + public interface TraitValueStage { + _FinalStage traitValue(@NotNull String traitValue); + } + + public interface _FinalStage { + UpdatePlanTraitRequestBody build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PlanIdStage, TraitValueStage, _FinalStage { + private String planId; + + private String traitValue; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdatePlanTraitRequestBody other) { + planId(other.getPlanId()); + traitValue(other.getTraitValue()); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public TraitValueStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_value") + public _FinalStage traitValue(@NotNull String traitValue) { + this.traitValue = Objects.requireNonNull(traitValue, "traitValue must not be null"); + return this; + } + + @java.lang.Override + public UpdatePlanTraitRequestBody build() { + return new UpdatePlanTraitRequestBody(planId, traitValue, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterParams.java b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterParams.java new file mode 100644 index 0000000..6cc2f53 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterParams.java @@ -0,0 +1,559 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCompaniesForAdvancedFilterParams.Builder.class) +public final class CountCompaniesForAdvancedFilterParams { + private final Optional> creditTypeIds; + + private final Optional> displayProperties; + + private final Optional> featureIds; + + private final Optional> ids; + + private final Optional limit; + + private final Optional monetizedSubscriptions; + + private final Optional offset; + + private final Optional> planIds; + + private final Optional q; + + private final Optional sortOrderColumn; + + private final Optional sortOrderDirection; + + private final Optional> subscriptionStatuses; + + private final Optional> subscriptionTypes; + + private final Optional withoutPlan; + + private final Optional withoutSubscription; + + private final Map additionalProperties; + + private CountCompaniesForAdvancedFilterParams( + Optional> creditTypeIds, + Optional> displayProperties, + Optional> featureIds, + Optional> ids, + Optional limit, + Optional monetizedSubscriptions, + Optional offset, + Optional> planIds, + Optional q, + Optional sortOrderColumn, + Optional sortOrderDirection, + Optional> subscriptionStatuses, + Optional> subscriptionTypes, + Optional withoutPlan, + Optional withoutSubscription, + Map additionalProperties) { + this.creditTypeIds = creditTypeIds; + this.displayProperties = displayProperties; + this.featureIds = featureIds; + this.ids = ids; + this.limit = limit; + this.monetizedSubscriptions = monetizedSubscriptions; + this.offset = offset; + this.planIds = planIds; + this.q = q; + this.sortOrderColumn = sortOrderColumn; + this.sortOrderDirection = sortOrderDirection; + this.subscriptionStatuses = subscriptionStatuses; + this.subscriptionTypes = subscriptionTypes; + this.withoutPlan = withoutPlan; + this.withoutSubscription = withoutSubscription; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter companies by one or more credit type IDs (each ID starts with bcrd_) + */ + @JsonProperty("credit_type_ids") + public Optional> getCreditTypeIds() { + return creditTypeIds; + } + + /** + * @return Select the display columns to return (e.g. plan, subscription, users, last_seen_at) + */ + @JsonProperty("display_properties") + public Optional> getDisplayProperties() { + return displayProperties; + } + + /** + * @return Filter companies by one or more feature IDs (each ID starts with feat_) + */ + @JsonProperty("feature_ids") + public Optional> getFeatureIds() { + return featureIds; + } + + /** + * @return Filter companies by multiple company IDs (starts with comp_) + */ + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Filter companies that have monetized subscriptions + */ + @JsonProperty("monetized_subscriptions") + public Optional getMonetizedSubscriptions() { + return monetizedSubscriptions; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + /** + * @return Filter companies by one or more plan IDs (each ID starts with plan_) + */ + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + /** + * @return Search for companies by name, keys or string traits + */ + @JsonProperty("q") + public Optional getQ() { + return q; + } + + /** + * @return Column to sort by (e.g. name, created_at, last_seen_at) + */ + @JsonProperty("sort_order_column") + public Optional getSortOrderColumn() { + return sortOrderColumn; + } + + /** + * @return Direction to sort by (asc or desc) + */ + @JsonProperty("sort_order_direction") + public Optional getSortOrderDirection() { + return sortOrderDirection; + } + + /** + * @return Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid) + */ + @JsonProperty("subscription_statuses") + public Optional> getSubscriptionStatuses() { + return subscriptionStatuses; + } + + /** + * @return Filter companies by one or more subscription types (paid, free, trial) + */ + @JsonProperty("subscription_types") + public Optional> getSubscriptionTypes() { + return subscriptionTypes; + } + + /** + * @return Filter out companies that have a plan + */ + @JsonProperty("without_plan") + public Optional getWithoutPlan() { + return withoutPlan; + } + + /** + * @return Filter out companies that have a subscription + */ + @JsonProperty("without_subscription") + public Optional getWithoutSubscription() { + return withoutSubscription; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCompaniesForAdvancedFilterParams + && equalTo((CountCompaniesForAdvancedFilterParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCompaniesForAdvancedFilterParams other) { + return creditTypeIds.equals(other.creditTypeIds) + && displayProperties.equals(other.displayProperties) + && featureIds.equals(other.featureIds) + && ids.equals(other.ids) + && limit.equals(other.limit) + && monetizedSubscriptions.equals(other.monetizedSubscriptions) + && offset.equals(other.offset) + && planIds.equals(other.planIds) + && q.equals(other.q) + && sortOrderColumn.equals(other.sortOrderColumn) + && sortOrderDirection.equals(other.sortOrderDirection) + && subscriptionStatuses.equals(other.subscriptionStatuses) + && subscriptionTypes.equals(other.subscriptionTypes) + && withoutPlan.equals(other.withoutPlan) + && withoutSubscription.equals(other.withoutSubscription); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.creditTypeIds, + this.displayProperties, + this.featureIds, + this.ids, + this.limit, + this.monetizedSubscriptions, + this.offset, + this.planIds, + this.q, + this.sortOrderColumn, + this.sortOrderDirection, + this.subscriptionStatuses, + this.subscriptionTypes, + this.withoutPlan, + this.withoutSubscription); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> creditTypeIds = Optional.empty(); + + private Optional> displayProperties = Optional.empty(); + + private Optional> featureIds = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional monetizedSubscriptions = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional> planIds = Optional.empty(); + + private Optional q = Optional.empty(); + + private Optional sortOrderColumn = Optional.empty(); + + private Optional sortOrderDirection = + Optional.empty(); + + private Optional> subscriptionStatuses = Optional.empty(); + + private Optional> subscriptionTypes = Optional.empty(); + + private Optional withoutPlan = Optional.empty(); + + private Optional withoutSubscription = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountCompaniesForAdvancedFilterParams other) { + creditTypeIds(other.getCreditTypeIds()); + displayProperties(other.getDisplayProperties()); + featureIds(other.getFeatureIds()); + ids(other.getIds()); + limit(other.getLimit()); + monetizedSubscriptions(other.getMonetizedSubscriptions()); + offset(other.getOffset()); + planIds(other.getPlanIds()); + q(other.getQ()); + sortOrderColumn(other.getSortOrderColumn()); + sortOrderDirection(other.getSortOrderDirection()); + subscriptionStatuses(other.getSubscriptionStatuses()); + subscriptionTypes(other.getSubscriptionTypes()); + withoutPlan(other.getWithoutPlan()); + withoutSubscription(other.getWithoutSubscription()); + return this; + } + + /** + *

Filter companies by one or more credit type IDs (each ID starts with bcrd_)

+ */ + @JsonSetter(value = "credit_type_ids", nulls = Nulls.SKIP) + public Builder creditTypeIds(Optional> creditTypeIds) { + this.creditTypeIds = creditTypeIds; + return this; + } + + public Builder creditTypeIds(List creditTypeIds) { + this.creditTypeIds = Optional.ofNullable(creditTypeIds); + return this; + } + + /** + *

Select the display columns to return (e.g. plan, subscription, users, last_seen_at)

+ */ + @JsonSetter(value = "display_properties", nulls = Nulls.SKIP) + public Builder displayProperties(Optional> displayProperties) { + this.displayProperties = displayProperties; + return this; + } + + public Builder displayProperties(List displayProperties) { + this.displayProperties = Optional.ofNullable(displayProperties); + return this; + } + + /** + *

Filter companies by one or more feature IDs (each ID starts with feat_)

+ */ + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; + return this; + } + + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); + return this; + } + + /** + *

Filter companies by multiple company IDs (starts with comp_)

+ */ + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Filter companies that have monetized subscriptions

+ */ + @JsonSetter(value = "monetized_subscriptions", nulls = Nulls.SKIP) + public Builder monetizedSubscriptions(Optional monetizedSubscriptions) { + this.monetizedSubscriptions = monetizedSubscriptions; + return this; + } + + public Builder monetizedSubscriptions(Boolean monetizedSubscriptions) { + this.monetizedSubscriptions = Optional.ofNullable(monetizedSubscriptions); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + /** + *

Filter companies by one or more plan IDs (each ID starts with plan_)

+ */ + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + /** + *

Search for companies by name, keys or string traits

+ */ + @JsonSetter(value = "q", nulls = Nulls.SKIP) + public Builder q(Optional q) { + this.q = q; + return this; + } + + public Builder q(String q) { + this.q = Optional.ofNullable(q); + return this; + } + + /** + *

Column to sort by (e.g. name, created_at, last_seen_at)

+ */ + @JsonSetter(value = "sort_order_column", nulls = Nulls.SKIP) + public Builder sortOrderColumn(Optional sortOrderColumn) { + this.sortOrderColumn = sortOrderColumn; + return this; + } + + public Builder sortOrderColumn(String sortOrderColumn) { + this.sortOrderColumn = Optional.ofNullable(sortOrderColumn); + return this; + } + + /** + *

Direction to sort by (asc or desc)

+ */ + @JsonSetter(value = "sort_order_direction", nulls = Nulls.SKIP) + public Builder sortOrderDirection( + Optional sortOrderDirection) { + this.sortOrderDirection = sortOrderDirection; + return this; + } + + public Builder sortOrderDirection( + CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection sortOrderDirection) { + this.sortOrderDirection = Optional.ofNullable(sortOrderDirection); + return this; + } + + /** + *

Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid)

+ */ + @JsonSetter(value = "subscription_statuses", nulls = Nulls.SKIP) + public Builder subscriptionStatuses(Optional> subscriptionStatuses) { + this.subscriptionStatuses = subscriptionStatuses; + return this; + } + + public Builder subscriptionStatuses(List subscriptionStatuses) { + this.subscriptionStatuses = Optional.ofNullable(subscriptionStatuses); + return this; + } + + /** + *

Filter companies by one or more subscription types (paid, free, trial)

+ */ + @JsonSetter(value = "subscription_types", nulls = Nulls.SKIP) + public Builder subscriptionTypes(Optional> subscriptionTypes) { + this.subscriptionTypes = subscriptionTypes; + return this; + } + + public Builder subscriptionTypes(List subscriptionTypes) { + this.subscriptionTypes = Optional.ofNullable(subscriptionTypes); + return this; + } + + /** + *

Filter out companies that have a plan

+ */ + @JsonSetter(value = "without_plan", nulls = Nulls.SKIP) + public Builder withoutPlan(Optional withoutPlan) { + this.withoutPlan = withoutPlan; + return this; + } + + public Builder withoutPlan(Boolean withoutPlan) { + this.withoutPlan = Optional.ofNullable(withoutPlan); + return this; + } + + /** + *

Filter out companies that have a subscription

+ */ + @JsonSetter(value = "without_subscription", nulls = Nulls.SKIP) + public Builder withoutSubscription(Optional withoutSubscription) { + this.withoutSubscription = withoutSubscription; + return this; + } + + public Builder withoutSubscription(Boolean withoutSubscription) { + this.withoutSubscription = Optional.ofNullable(withoutSubscription); + return this; + } + + public CountCompaniesForAdvancedFilterParams build() { + return new CountCompaniesForAdvancedFilterParams( + creditTypeIds, + displayProperties, + featureIds, + ids, + limit, + monetizedSubscriptions, + offset, + planIds, + q, + sortOrderColumn, + sortOrderDirection, + subscriptionStatuses, + subscriptionTypes, + withoutPlan, + withoutSubscription, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterRequestSortOrderDirection.java b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterRequestSortOrderDirection.java new file mode 100644 index 0000000..2e651ff --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterRequestSortOrderDirection.java @@ -0,0 +1,87 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CountCompaniesForAdvancedFilterRequestSortOrderDirection { + public static final CountCompaniesForAdvancedFilterRequestSortOrderDirection ASC = + new CountCompaniesForAdvancedFilterRequestSortOrderDirection(Value.ASC, "asc"); + + public static final CountCompaniesForAdvancedFilterRequestSortOrderDirection DESC = + new CountCompaniesForAdvancedFilterRequestSortOrderDirection(Value.DESC, "desc"); + + private final Value value; + + private final String string; + + CountCompaniesForAdvancedFilterRequestSortOrderDirection(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountCompaniesForAdvancedFilterRequestSortOrderDirection + && this.string.equals( + ((CountCompaniesForAdvancedFilterRequestSortOrderDirection) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASC: + return visitor.visitAsc(); + case DESC: + return visitor.visitDesc(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountCompaniesForAdvancedFilterRequestSortOrderDirection valueOf(String value) { + switch (value) { + case "asc": + return ASC; + case "desc": + return DESC; + default: + return new CountCompaniesForAdvancedFilterRequestSortOrderDirection(Value.UNKNOWN, value); + } + } + + public enum Value { + ASC, + + DESC, + + UNKNOWN + } + + public interface Visitor { + T visitAsc(); + + T visitDesc(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterResponse.java new file mode 100644 index 0000000..cf08811 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterResponse.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CountResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCompaniesForAdvancedFilterResponse.Builder.class) +public final class CountCompaniesForAdvancedFilterResponse { + private final CountResponse data; + + private final CountCompaniesForAdvancedFilterParams params; + + private final Map additionalProperties; + + private CountCompaniesForAdvancedFilterResponse( + CountResponse data, + CountCompaniesForAdvancedFilterParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CountResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public CountCompaniesForAdvancedFilterParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCompaniesForAdvancedFilterResponse + && equalTo((CountCompaniesForAdvancedFilterResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCompaniesForAdvancedFilterResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + ParamsStage data(@NotNull CountResponse data); + + Builder from(CountCompaniesForAdvancedFilterResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull CountCompaniesForAdvancedFilterParams params); + } + + public interface _FinalStage { + CountCompaniesForAdvancedFilterResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CountResponse data; + + private CountCompaniesForAdvancedFilterParams params; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountCompaniesForAdvancedFilterResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CountResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull CountCompaniesForAdvancedFilterParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public CountCompaniesForAdvancedFilterResponse build() { + return new CountCompaniesForAdvancedFilterResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection.java b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection.java new file mode 100644 index 0000000..4ffea4c --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection.java @@ -0,0 +1,87 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection { + public static final CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection ASC = + new CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection(Value.ASC, "asc"); + + public static final CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection DESC = + new CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection(Value.DESC, "desc"); + + private final Value value; + + private final String string; + + CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection + && this.string.equals( + ((CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASC: + return visitor.visitAsc(); + case DESC: + return visitor.visitDesc(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection valueOf(String value) { + switch (value) { + case "asc": + return ASC; + case "desc": + return DESC; + default: + return new CountCompaniesForAdvancedFilterResponseParamsSortOrderDirection(Value.UNKNOWN, value); + } + } + + public enum Value { + ASC, + + DESC, + + UNKNOWN + } + + public interface Visitor { + T visitAsc(); + + T visitDesc(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesParams.java b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesParams.java index 1cad4b1..f0409cb 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesParams.java @@ -31,6 +31,8 @@ public final class CountCompaniesParams { private final Optional q; + private final Optional withSubscription; + private final Optional withoutFeatureOverrideFor; private final Optional withoutPlan; @@ -43,6 +45,7 @@ private CountCompaniesParams( Optional offset, Optional planId, Optional q, + Optional withSubscription, Optional withoutFeatureOverrideFor, Optional withoutPlan, Map additionalProperties) { @@ -51,6 +54,7 @@ private CountCompaniesParams( this.offset = offset; this.planId = planId; this.q = q; + this.withSubscription = withSubscription; this.withoutFeatureOverrideFor = withoutFeatureOverrideFor; this.withoutPlan = withoutPlan; this.additionalProperties = additionalProperties; @@ -96,6 +100,14 @@ public Optional getQ() { return q; } + /** + * @return Filter companies that have a subscription + */ + @JsonProperty("with_subscription") + public Optional getWithSubscription() { + return withSubscription; + } + /** * @return Filter out companies that already have a company override for the specified feature ID */ @@ -129,6 +141,7 @@ private boolean equalTo(CountCompaniesParams other) { && offset.equals(other.offset) && planId.equals(other.planId) && q.equals(other.q) + && withSubscription.equals(other.withSubscription) && withoutFeatureOverrideFor.equals(other.withoutFeatureOverrideFor) && withoutPlan.equals(other.withoutPlan); } @@ -141,6 +154,7 @@ public int hashCode() { this.offset, this.planId, this.q, + this.withSubscription, this.withoutFeatureOverrideFor, this.withoutPlan); } @@ -166,6 +180,8 @@ public static final class Builder { private Optional q = Optional.empty(); + private Optional withSubscription = Optional.empty(); + private Optional withoutFeatureOverrideFor = Optional.empty(); private Optional withoutPlan = Optional.empty(); @@ -181,11 +197,15 @@ public Builder from(CountCompaniesParams other) { offset(other.getOffset()); planId(other.getPlanId()); q(other.getQ()); + withSubscription(other.getWithSubscription()); withoutFeatureOverrideFor(other.getWithoutFeatureOverrideFor()); withoutPlan(other.getWithoutPlan()); return this; } + /** + *

Filter companies by multiple company IDs (starts with comp_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -197,6 +217,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -208,6 +231,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -219,6 +245,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Filter companies by plan ID (starts with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -230,6 +259,9 @@ public Builder planId(String planId) { return this; } + /** + *

Search for companies by name, keys or string traits

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -241,6 +273,23 @@ public Builder q(String q) { return this; } + /** + *

Filter companies that have a subscription

+ */ + @JsonSetter(value = "with_subscription", nulls = Nulls.SKIP) + public Builder withSubscription(Optional withSubscription) { + this.withSubscription = withSubscription; + return this; + } + + public Builder withSubscription(Boolean withSubscription) { + this.withSubscription = Optional.ofNullable(withSubscription); + return this; + } + + /** + *

Filter out companies that already have a company override for the specified feature ID

+ */ @JsonSetter(value = "without_feature_override_for", nulls = Nulls.SKIP) public Builder withoutFeatureOverrideFor(Optional withoutFeatureOverrideFor) { this.withoutFeatureOverrideFor = withoutFeatureOverrideFor; @@ -252,6 +301,9 @@ public Builder withoutFeatureOverrideFor(String withoutFeatureOverrideFor) { return this; } + /** + *

Filter out companies that have a plan

+ */ @JsonSetter(value = "without_plan", nulls = Nulls.SKIP) public Builder withoutPlan(Optional withoutPlan) { this.withoutPlan = withoutPlan; @@ -265,7 +317,15 @@ public Builder withoutPlan(Boolean withoutPlan) { public CountCompaniesParams build() { return new CountCompaniesParams( - ids, limit, offset, planId, q, withoutFeatureOverrideFor, withoutPlan, additionalProperties); + ids, + limit, + offset, + planId, + q, + withSubscription, + withoutFeatureOverrideFor, + withoutPlan, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesResponse.java index 72c290b..05d3333 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountCompaniesResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountCompaniesParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsParams.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsParams.java index b0418a9..066e399 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsParams.java @@ -160,6 +160,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -171,6 +174,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsRequestEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsRequestEntityType.java index 4f7ef7c..edf9349 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsRequestEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsRequestEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountEntityKeyDefinitionsRequestEntityType { - COMPANY("company"), +public final class CountEntityKeyDefinitionsRequestEntityType { + public static final CountEntityKeyDefinitionsRequestEntityType USER = + new CountEntityKeyDefinitionsRequestEntityType(Value.USER, "user"); - USER("user"); + public static final CountEntityKeyDefinitionsRequestEntityType COMPANY = + new CountEntityKeyDefinitionsRequestEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - CountEntityKeyDefinitionsRequestEntityType(String value) { + private final String string; + + CountEntityKeyDefinitionsRequestEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountEntityKeyDefinitionsRequestEntityType + && this.string.equals(((CountEntityKeyDefinitionsRequestEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountEntityKeyDefinitionsRequestEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new CountEntityKeyDefinitionsRequestEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponse.java index 1f753ea..7e61659 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountEntityKeyDefinitionsParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponseParamsEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponseParamsEntityType.java index 5db91a7..af6bd58 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponseParamsEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityKeyDefinitionsResponseParamsEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountEntityKeyDefinitionsResponseParamsEntityType { - COMPANY("company"), +public final class CountEntityKeyDefinitionsResponseParamsEntityType { + public static final CountEntityKeyDefinitionsResponseParamsEntityType USER = + new CountEntityKeyDefinitionsResponseParamsEntityType(Value.USER, "user"); - USER("user"); + public static final CountEntityKeyDefinitionsResponseParamsEntityType COMPANY = + new CountEntityKeyDefinitionsResponseParamsEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - CountEntityKeyDefinitionsResponseParamsEntityType(String value) { + private final String string; + + CountEntityKeyDefinitionsResponseParamsEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountEntityKeyDefinitionsResponseParamsEntityType + && this.string.equals(((CountEntityKeyDefinitionsResponseParamsEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountEntityKeyDefinitionsResponseParamsEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new CountEntityKeyDefinitionsResponseParamsEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsParams.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsParams.java index 58f6d96..a137a65 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsParams.java @@ -173,6 +173,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -184,6 +187,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsRequestEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsRequestEntityType.java index 1201832..06eeb61 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsRequestEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsRequestEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountEntityTraitDefinitionsRequestEntityType { - COMPANY("company"), +public final class CountEntityTraitDefinitionsRequestEntityType { + public static final CountEntityTraitDefinitionsRequestEntityType USER = + new CountEntityTraitDefinitionsRequestEntityType(Value.USER, "user"); - USER("user"); + public static final CountEntityTraitDefinitionsRequestEntityType COMPANY = + new CountEntityTraitDefinitionsRequestEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - CountEntityTraitDefinitionsRequestEntityType(String value) { + private final String string; + + CountEntityTraitDefinitionsRequestEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountEntityTraitDefinitionsRequestEntityType + && this.string.equals(((CountEntityTraitDefinitionsRequestEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountEntityTraitDefinitionsRequestEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new CountEntityTraitDefinitionsRequestEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsRequestTraitType.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsRequestTraitType.java index d9a6897..f29c161 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsRequestTraitType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsRequestTraitType.java @@ -3,30 +3,128 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountEntityTraitDefinitionsRequestTraitType { - BOOLEAN("boolean"), +public final class CountEntityTraitDefinitionsRequestTraitType { + public static final CountEntityTraitDefinitionsRequestTraitType NUMBER = + new CountEntityTraitDefinitionsRequestTraitType(Value.NUMBER, "number"); - CURRENCY("currency"), + public static final CountEntityTraitDefinitionsRequestTraitType STRING = + new CountEntityTraitDefinitionsRequestTraitType(Value.STRING, "string"); - DATE("date"), + public static final CountEntityTraitDefinitionsRequestTraitType BOOLEAN = + new CountEntityTraitDefinitionsRequestTraitType(Value.BOOLEAN, "boolean"); - NUMBER("number"), + public static final CountEntityTraitDefinitionsRequestTraitType CURRENCY = + new CountEntityTraitDefinitionsRequestTraitType(Value.CURRENCY, "currency"); - STRING("string"), + public static final CountEntityTraitDefinitionsRequestTraitType DATE = + new CountEntityTraitDefinitionsRequestTraitType(Value.DATE, "date"); - URL("url"); + public static final CountEntityTraitDefinitionsRequestTraitType URL = + new CountEntityTraitDefinitionsRequestTraitType(Value.URL, "url"); - private final String value; + private final Value value; - CountEntityTraitDefinitionsRequestTraitType(String value) { + private final String string; + + CountEntityTraitDefinitionsRequestTraitType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountEntityTraitDefinitionsRequestTraitType + && this.string.equals(((CountEntityTraitDefinitionsRequestTraitType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMBER: + return visitor.visitNumber(); + case STRING: + return visitor.visitString(); + case BOOLEAN: + return visitor.visitBoolean(); + case CURRENCY: + return visitor.visitCurrency(); + case DATE: + return visitor.visitDate(); + case URL: + return visitor.visitUrl(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountEntityTraitDefinitionsRequestTraitType valueOf(String value) { + switch (value) { + case "number": + return NUMBER; + case "string": + return STRING; + case "boolean": + return BOOLEAN; + case "currency": + return CURRENCY; + case "date": + return DATE; + case "url": + return URL; + default: + return new CountEntityTraitDefinitionsRequestTraitType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CURRENCY, + + DATE, + + NUMBER, + + STRING, + + URL, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCurrency(); + + T visitDate(); + + T visitNumber(); + + T visitString(); + + T visitUrl(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponse.java index 3d8f0b3..916d285 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponse.java @@ -83,6 +83,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountEntityTraitDefinitionsParams params); } @@ -116,6 +119,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponseParamsEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponseParamsEntityType.java index 60cca74..1838c0e 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponseParamsEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponseParamsEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountEntityTraitDefinitionsResponseParamsEntityType { - COMPANY("company"), +public final class CountEntityTraitDefinitionsResponseParamsEntityType { + public static final CountEntityTraitDefinitionsResponseParamsEntityType USER = + new CountEntityTraitDefinitionsResponseParamsEntityType(Value.USER, "user"); - USER("user"); + public static final CountEntityTraitDefinitionsResponseParamsEntityType COMPANY = + new CountEntityTraitDefinitionsResponseParamsEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - CountEntityTraitDefinitionsResponseParamsEntityType(String value) { + private final String string; + + CountEntityTraitDefinitionsResponseParamsEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountEntityTraitDefinitionsResponseParamsEntityType + && this.string.equals(((CountEntityTraitDefinitionsResponseParamsEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountEntityTraitDefinitionsResponseParamsEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new CountEntityTraitDefinitionsResponseParamsEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponseParamsTraitType.java b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponseParamsTraitType.java index 800cb85..30bcfcd 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponseParamsTraitType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountEntityTraitDefinitionsResponseParamsTraitType.java @@ -3,30 +3,128 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountEntityTraitDefinitionsResponseParamsTraitType { - BOOLEAN("boolean"), +public final class CountEntityTraitDefinitionsResponseParamsTraitType { + public static final CountEntityTraitDefinitionsResponseParamsTraitType NUMBER = + new CountEntityTraitDefinitionsResponseParamsTraitType(Value.NUMBER, "number"); - CURRENCY("currency"), + public static final CountEntityTraitDefinitionsResponseParamsTraitType STRING = + new CountEntityTraitDefinitionsResponseParamsTraitType(Value.STRING, "string"); - DATE("date"), + public static final CountEntityTraitDefinitionsResponseParamsTraitType BOOLEAN = + new CountEntityTraitDefinitionsResponseParamsTraitType(Value.BOOLEAN, "boolean"); - NUMBER("number"), + public static final CountEntityTraitDefinitionsResponseParamsTraitType CURRENCY = + new CountEntityTraitDefinitionsResponseParamsTraitType(Value.CURRENCY, "currency"); - STRING("string"), + public static final CountEntityTraitDefinitionsResponseParamsTraitType DATE = + new CountEntityTraitDefinitionsResponseParamsTraitType(Value.DATE, "date"); - URL("url"); + public static final CountEntityTraitDefinitionsResponseParamsTraitType URL = + new CountEntityTraitDefinitionsResponseParamsTraitType(Value.URL, "url"); - private final String value; + private final Value value; - CountEntityTraitDefinitionsResponseParamsTraitType(String value) { + private final String string; + + CountEntityTraitDefinitionsResponseParamsTraitType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountEntityTraitDefinitionsResponseParamsTraitType + && this.string.equals(((CountEntityTraitDefinitionsResponseParamsTraitType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMBER: + return visitor.visitNumber(); + case STRING: + return visitor.visitString(); + case BOOLEAN: + return visitor.visitBoolean(); + case CURRENCY: + return visitor.visitCurrency(); + case DATE: + return visitor.visitDate(); + case URL: + return visitor.visitUrl(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountEntityTraitDefinitionsResponseParamsTraitType valueOf(String value) { + switch (value) { + case "number": + return NUMBER; + case "string": + return STRING; + case "boolean": + return BOOLEAN; + case "currency": + return CURRENCY; + case "date": + return DATE; + case "url": + return URL; + default: + return new CountEntityTraitDefinitionsResponseParamsTraitType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CURRENCY, + + DATE, + + NUMBER, + + STRING, + + URL, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCurrency(); + + T visitDate(); + + T visitNumber(); + + T visitString(); + + T visitUrl(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/AudienceRequestBody.java b/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsParams.java similarity index 50% rename from src/main/java/com/schematic/api/types/AudienceRequestBody.java rename to src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsParams.java index 1fc2e76..59e26a5 100644 --- a/src/main/java/com/schematic/api/types/AudienceRequestBody.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsParams.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.schematic.api.types; +package com.schematic.api.resources.companies.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -12,7 +12,6 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,43 +19,42 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AudienceRequestBody.Builder.class) -public final class AudienceRequestBody { - private final List conditionGroups; - - private final List conditions; +@JsonDeserialize(builder = CountPlanTraitsParams.Builder.class) +public final class CountPlanTraitsParams { + private final Optional> ids; private final Optional limit; private final Optional offset; - private final Optional q; + private final Optional planId; + + private final Optional traitId; + + private final Optional> traitIds; private final Map additionalProperties; - private AudienceRequestBody( - List conditionGroups, - List conditions, + private CountPlanTraitsParams( + Optional> ids, Optional limit, Optional offset, - Optional q, + Optional planId, + Optional traitId, + Optional> traitIds, Map additionalProperties) { - this.conditionGroups = conditionGroups; - this.conditions = conditions; + this.ids = ids; this.limit = limit; this.offset = offset; - this.q = q; + this.planId = planId; + this.traitId = traitId; + this.traitIds = traitIds; this.additionalProperties = additionalProperties; } - @JsonProperty("condition_groups") - public List getConditionGroups() { - return conditionGroups; - } - - @JsonProperty("conditions") - public List getConditions() { - return conditions; + @JsonProperty("ids") + public Optional> getIds() { + return ids; } /** @@ -75,15 +73,25 @@ public Optional getOffset() { return offset; } - @JsonProperty("q") - public Optional getQ() { - return q; + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @JsonProperty("trait_id") + public Optional getTraitId() { + return traitId; + } + + @JsonProperty("trait_ids") + public Optional> getTraitIds() { + return traitIds; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AudienceRequestBody && equalTo((AudienceRequestBody) other); + return other instanceof CountPlanTraitsParams && equalTo((CountPlanTraitsParams) other); } @JsonAnyGetter @@ -91,17 +99,18 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(AudienceRequestBody other) { - return conditionGroups.equals(other.conditionGroups) - && conditions.equals(other.conditions) + private boolean equalTo(CountPlanTraitsParams other) { + return ids.equals(other.ids) && limit.equals(other.limit) && offset.equals(other.offset) - && q.equals(other.q); + && planId.equals(other.planId) + && traitId.equals(other.traitId) + && traitIds.equals(other.traitIds); } @java.lang.Override public int hashCode() { - return Objects.hash(this.conditionGroups, this.conditions, this.limit, this.offset, this.q); + return Objects.hash(this.ids, this.limit, this.offset, this.planId, this.traitId, this.traitIds); } @java.lang.Override @@ -115,99 +124,107 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List conditionGroups = new ArrayList<>(); - - private List conditions = new ArrayList<>(); + private Optional> ids = Optional.empty(); private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); - private Optional q = Optional.empty(); + private Optional planId = Optional.empty(); + + private Optional traitId = Optional.empty(); + + private Optional> traitIds = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(AudienceRequestBody other) { - conditionGroups(other.getConditionGroups()); - conditions(other.getConditions()); + public Builder from(CountPlanTraitsParams other) { + ids(other.getIds()); limit(other.getLimit()); offset(other.getOffset()); - q(other.getQ()); + planId(other.getPlanId()); + traitId(other.getTraitId()); + traitIds(other.getTraitIds()); return this; } - @JsonSetter(value = "condition_groups", nulls = Nulls.SKIP) - public Builder conditionGroups(List conditionGroups) { - this.conditionGroups.clear(); - this.conditionGroups.addAll(conditionGroups); + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder addConditionGroups(CreateOrUpdateConditionGroupRequestBody conditionGroups) { - this.conditionGroups.add(conditionGroups); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - public Builder addAllConditionGroups(List conditionGroups) { - this.conditionGroups.addAll(conditionGroups); + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; return this; } - @JsonSetter(value = "conditions", nulls = Nulls.SKIP) - public Builder conditions(List conditions) { - this.conditions.clear(); - this.conditions.addAll(conditions); + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); return this; } - public Builder addConditions(CreateOrUpdateConditionRequestBody conditions) { - this.conditions.add(conditions); + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; return this; } - public Builder addAllConditions(List conditions) { - this.conditions.addAll(conditions); + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); return this; } - @JsonSetter(value = "limit", nulls = Nulls.SKIP) - public Builder limit(Optional limit) { - this.limit = limit; + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; return this; } - public Builder limit(Integer limit) { - this.limit = Optional.ofNullable(limit); + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); return this; } - @JsonSetter(value = "offset", nulls = Nulls.SKIP) - public Builder offset(Optional offset) { - this.offset = offset; + @JsonSetter(value = "trait_id", nulls = Nulls.SKIP) + public Builder traitId(Optional traitId) { + this.traitId = traitId; return this; } - public Builder offset(Integer offset) { - this.offset = Optional.ofNullable(offset); + public Builder traitId(String traitId) { + this.traitId = Optional.ofNullable(traitId); return this; } - @JsonSetter(value = "q", nulls = Nulls.SKIP) - public Builder q(Optional q) { - this.q = q; + @JsonSetter(value = "trait_ids", nulls = Nulls.SKIP) + public Builder traitIds(Optional> traitIds) { + this.traitIds = traitIds; return this; } - public Builder q(String q) { - this.q = Optional.ofNullable(q); + public Builder traitIds(List traitIds) { + this.traitIds = Optional.ofNullable(traitIds); return this; } - public AudienceRequestBody build() { - return new AudienceRequestBody(conditionGroups, conditions, limit, offset, q, additionalProperties); + public CountPlanTraitsParams build() { + return new CountPlanTraitsParams(ids, limit, offset, planId, traitId, traitIds, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsResponse.java new file mode 100644 index 0000000..d258c46 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/CountPlanTraitsResponse.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CountResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountPlanTraitsResponse.Builder.class) +public final class CountPlanTraitsResponse { + private final CountResponse data; + + private final CountPlanTraitsParams params; + + private final Map additionalProperties; + + private CountPlanTraitsResponse( + CountResponse data, CountPlanTraitsParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CountResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public CountPlanTraitsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountPlanTraitsResponse && equalTo((CountPlanTraitsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountPlanTraitsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + ParamsStage data(@NotNull CountResponse data); + + Builder from(CountPlanTraitsResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull CountPlanTraitsParams params); + } + + public interface _FinalStage { + CountPlanTraitsResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CountResponse data; + + private CountPlanTraitsParams params; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountPlanTraitsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CountResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull CountPlanTraitsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public CountPlanTraitsResponse build() { + return new CountPlanTraitsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountUsersParams.java b/src/main/java/com/schematic/api/resources/companies/types/CountUsersParams.java index 1027580..070d3b9 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountUsersParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountUsersParams.java @@ -163,6 +163,9 @@ public Builder from(CountUsersParams other) { return this; } + /** + *

Filter users by company ID (starts with comp_)

+ */ @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -174,6 +177,9 @@ public Builder companyId(String companyId) { return this; } + /** + *

Filter users by multiple user IDs (starts with user_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -185,6 +191,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -196,6 +205,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -207,6 +219,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Filter users by plan ID (starts with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -218,6 +233,9 @@ public Builder planId(String planId) { return this; } + /** + *

Search for users by name, keys or string traits

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; diff --git a/src/main/java/com/schematic/api/resources/companies/types/CountUsersResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CountUsersResponse.java index fe7df3d..3a068e8 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CountUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CountUsersResponse.java @@ -81,6 +81,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountUsersParams params); } @@ -114,6 +117,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/CreateCompanyResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CreateCompanyResponse.java index 44fcb28..bb4d742 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CreateCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CreateCompanyResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateCompanyResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CreateEntityTraitDefinitionRequestBodyEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/CreateEntityTraitDefinitionRequestBodyEntityType.java index 1229e14..c867a82 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CreateEntityTraitDefinitionRequestBodyEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CreateEntityTraitDefinitionRequestBodyEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateEntityTraitDefinitionRequestBodyEntityType { - COMPANY("company"), +public final class CreateEntityTraitDefinitionRequestBodyEntityType { + public static final CreateEntityTraitDefinitionRequestBodyEntityType USER = + new CreateEntityTraitDefinitionRequestBodyEntityType(Value.USER, "user"); - USER("user"); + public static final CreateEntityTraitDefinitionRequestBodyEntityType COMPANY = + new CreateEntityTraitDefinitionRequestBodyEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - CreateEntityTraitDefinitionRequestBodyEntityType(String value) { + private final String string; + + CreateEntityTraitDefinitionRequestBodyEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateEntityTraitDefinitionRequestBodyEntityType + && this.string.equals(((CreateEntityTraitDefinitionRequestBodyEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateEntityTraitDefinitionRequestBodyEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new CreateEntityTraitDefinitionRequestBodyEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CreateEntityTraitDefinitionRequestBodyTraitType.java b/src/main/java/com/schematic/api/resources/companies/types/CreateEntityTraitDefinitionRequestBodyTraitType.java index 64bda6a..4cc92b2 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CreateEntityTraitDefinitionRequestBodyTraitType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CreateEntityTraitDefinitionRequestBodyTraitType.java @@ -3,30 +3,128 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateEntityTraitDefinitionRequestBodyTraitType { - BOOLEAN("boolean"), +public final class CreateEntityTraitDefinitionRequestBodyTraitType { + public static final CreateEntityTraitDefinitionRequestBodyTraitType NUMBER = + new CreateEntityTraitDefinitionRequestBodyTraitType(Value.NUMBER, "number"); - CURRENCY("currency"), + public static final CreateEntityTraitDefinitionRequestBodyTraitType STRING = + new CreateEntityTraitDefinitionRequestBodyTraitType(Value.STRING, "string"); - DATE("date"), + public static final CreateEntityTraitDefinitionRequestBodyTraitType BOOLEAN = + new CreateEntityTraitDefinitionRequestBodyTraitType(Value.BOOLEAN, "boolean"); - NUMBER("number"), + public static final CreateEntityTraitDefinitionRequestBodyTraitType CURRENCY = + new CreateEntityTraitDefinitionRequestBodyTraitType(Value.CURRENCY, "currency"); - STRING("string"), + public static final CreateEntityTraitDefinitionRequestBodyTraitType DATE = + new CreateEntityTraitDefinitionRequestBodyTraitType(Value.DATE, "date"); - URL("url"); + public static final CreateEntityTraitDefinitionRequestBodyTraitType URL = + new CreateEntityTraitDefinitionRequestBodyTraitType(Value.URL, "url"); - private final String value; + private final Value value; - CreateEntityTraitDefinitionRequestBodyTraitType(String value) { + private final String string; + + CreateEntityTraitDefinitionRequestBodyTraitType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateEntityTraitDefinitionRequestBodyTraitType + && this.string.equals(((CreateEntityTraitDefinitionRequestBodyTraitType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMBER: + return visitor.visitNumber(); + case STRING: + return visitor.visitString(); + case BOOLEAN: + return visitor.visitBoolean(); + case CURRENCY: + return visitor.visitCurrency(); + case DATE: + return visitor.visitDate(); + case URL: + return visitor.visitUrl(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateEntityTraitDefinitionRequestBodyTraitType valueOf(String value) { + switch (value) { + case "number": + return NUMBER; + case "string": + return STRING; + case "boolean": + return BOOLEAN; + case "currency": + return CURRENCY; + case "date": + return DATE; + case "url": + return URL; + default: + return new CreateEntityTraitDefinitionRequestBodyTraitType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CURRENCY, + + DATE, + + NUMBER, + + STRING, + + URL, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCurrency(); + + T visitDate(); + + T visitNumber(); + + T visitString(); + + T visitUrl(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/CreatePlanTraitResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CreatePlanTraitResponse.java new file mode 100644 index 0000000..0dfc239 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/CreatePlanTraitResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.PlanTraitResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreatePlanTraitResponse.Builder.class) +public final class CreatePlanTraitResponse { + private final PlanTraitResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private CreatePlanTraitResponse( + PlanTraitResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public PlanTraitResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreatePlanTraitResponse && equalTo((CreatePlanTraitResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreatePlanTraitResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull PlanTraitResponseData data); + + Builder from(CreatePlanTraitResponse other); + } + + public interface _FinalStage { + CreatePlanTraitResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private PlanTraitResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreatePlanTraitResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull PlanTraitResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public CreatePlanTraitResponse build() { + return new CreatePlanTraitResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/CreateUserResponse.java b/src/main/java/com/schematic/api/resources/companies/types/CreateUserResponse.java index 00a9490..41c3f83 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/CreateUserResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/CreateUserResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateUserResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyByKeysResponse.java b/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyByKeysResponse.java index 0afb35a..5fa1946 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyByKeysResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyByKeysResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteCompanyByKeysResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyMembershipResponse.java b/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyMembershipResponse.java index 221ed83..ec1849e 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyMembershipResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyMembershipResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteCompanyMembershipResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyResponse.java b/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyResponse.java index 186586c..26d3082 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/DeleteCompanyResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteCompanyResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/DeleteAudienceResponse.java b/src/main/java/com/schematic/api/resources/companies/types/DeletePlanTraitResponse.java similarity index 80% rename from src/main/java/com/schematic/api/resources/plans/types/DeleteAudienceResponse.java rename to src/main/java/com/schematic/api/resources/companies/types/DeletePlanTraitResponse.java index 79fcd13..fd00396 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/DeleteAudienceResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/DeletePlanTraitResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.schematic.api.resources.plans.types; +package com.schematic.api.resources.companies.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -21,15 +21,15 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DeleteAudienceResponse.Builder.class) -public final class DeleteAudienceResponse { +@JsonDeserialize(builder = DeletePlanTraitResponse.Builder.class) +public final class DeletePlanTraitResponse { private final DeleteResponse data; private final Map params; private final Map additionalProperties; - private DeleteAudienceResponse( + private DeletePlanTraitResponse( DeleteResponse data, Map params, Map additionalProperties) { this.data = data; this.params = params; @@ -52,7 +52,7 @@ public Map getParams() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof DeleteAudienceResponse && equalTo((DeleteAudienceResponse) other); + return other instanceof DeletePlanTraitResponse && equalTo((DeletePlanTraitResponse) other); } @JsonAnyGetter @@ -60,7 +60,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(DeleteAudienceResponse other) { + private boolean equalTo(DeletePlanTraitResponse other) { return data.equals(other.data) && params.equals(other.params); } @@ -81,12 +81,15 @@ public static DataStage builder() { public interface DataStage { _FinalStage data(@NotNull DeleteResponse data); - Builder from(DeleteAudienceResponse other); + Builder from(DeletePlanTraitResponse other); } public interface _FinalStage { - DeleteAudienceResponse build(); + DeletePlanTraitResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -106,7 +109,7 @@ public static final class Builder implements DataStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(DeleteAudienceResponse other) { + public Builder from(DeletePlanTraitResponse other) { data(other.getData()); params(other.getParams()); return this; @@ -135,21 +138,28 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } @java.lang.Override - public DeleteAudienceResponse build() { - return new DeleteAudienceResponse(data, params, additionalProperties); + public DeletePlanTraitResponse build() { + return new DeletePlanTraitResponse(data, params, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/DeleteUserByKeysResponse.java b/src/main/java/com/schematic/api/resources/companies/types/DeleteUserByKeysResponse.java index 12c7bb0..055a184 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/DeleteUserByKeysResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/DeleteUserByKeysResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteUserByKeysResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/DeleteUserResponse.java b/src/main/java/com/schematic/api/resources/companies/types/DeleteUserResponse.java index 10fae78..76e25b0 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/DeleteUserResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/DeleteUserResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteUserResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionParams.java b/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionParams.java index 0d9979d..4fdd985 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionParams.java @@ -148,6 +148,9 @@ public Builder companyIds(List companyIds) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -159,6 +162,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionResponse.java index fc35ad2..255ee96 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetActiveCompanySubscriptionResponse.java @@ -38,9 +38,6 @@ private GetActiveCompanySubscriptionResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -85,6 +82,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull GetActiveCompanySubscriptionParams params); Builder from(GetActiveCompanySubscriptionResponse other); @@ -119,6 +119,7 @@ public Builder from(GetActiveCompanySubscriptionResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -129,20 +130,14 @@ public _FinalStage params(@NotNull GetActiveCompanySubscriptionParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(CompanySubscriptionResponseData data) { this.data.add(data); @@ -153,7 +148,9 @@ public _FinalStage addData(CompanySubscriptionResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetActiveDealsParams.java b/src/main/java/com/schematic/api/resources/companies/types/GetActiveDealsParams.java index 39e7587..4ca062e 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetActiveDealsParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetActiveDealsParams.java @@ -146,6 +146,9 @@ public Builder dealStage(String dealStage) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -157,6 +160,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetActiveDealsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetActiveDealsResponse.java index dda811c..14b4306 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetActiveDealsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetActiveDealsResponse.java @@ -38,9 +38,6 @@ private GetActiveDealsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull GetActiveDealsParams params); Builder from(GetActiveDealsResponse other); @@ -118,6 +118,7 @@ public Builder from(GetActiveDealsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull GetActiveDealsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(CompanyCrmDealsResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(CompanyCrmDealsResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetCompanyResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetCompanyResponse.java index 677ed3f..cbb2968 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetCompanyResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetCompanyResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitDefinitionResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitDefinitionResponse.java index 669bab4..2d4916e 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitDefinitionResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitDefinitionResponse.java @@ -89,6 +89,9 @@ public interface DataStage { public interface _FinalStage { GetEntityTraitDefinitionResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -137,15 +140,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesParams.java b/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesParams.java index f5c6034..8e5b495 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesParams.java @@ -135,6 +135,9 @@ public Builder definitionId(String definitionId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesResponse.java index 95f6282..ac604f1 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetEntityTraitValuesResponse.java @@ -36,9 +36,6 @@ private GetEntityTraitValuesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull GetEntityTraitValuesParams params); Builder from(GetEntityTraitValuesResponse other); @@ -116,6 +116,7 @@ public Builder from(GetEntityTraitValuesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull GetEntityTraitValuesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(EntityTraitValue data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(EntityTraitValue data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetOrCreateCompanyMembershipResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetOrCreateCompanyMembershipResponse.java index f19ca5e..d1ff370 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetOrCreateCompanyMembershipResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetOrCreateCompanyMembershipResponse.java @@ -90,6 +90,9 @@ public interface DataStage { public interface _FinalStage { GetOrCreateCompanyMembershipResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -138,15 +141,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetOrCreateEntityTraitDefinitionResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetOrCreateEntityTraitDefinitionResponse.java index 53e6a26..9520612 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetOrCreateEntityTraitDefinitionResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetOrCreateEntityTraitDefinitionResponse.java @@ -90,6 +90,9 @@ public interface DataStage { public interface _FinalStage { GetOrCreateEntityTraitDefinitionResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -138,15 +141,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetPlanChangeResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetPlanChangeResponse.java new file mode 100644 index 0000000..82e7b21 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/GetPlanChangeResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.PlanChangeResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetPlanChangeResponse.Builder.class) +public final class GetPlanChangeResponse { + private final PlanChangeResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private GetPlanChangeResponse( + PlanChangeResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public PlanChangeResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetPlanChangeResponse && equalTo((GetPlanChangeResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetPlanChangeResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull PlanChangeResponseData data); + + Builder from(GetPlanChangeResponse other); + } + + public interface _FinalStage { + GetPlanChangeResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private PlanChangeResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetPlanChangeResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull PlanChangeResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public GetPlanChangeResponse build() { + return new GetPlanChangeResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/features/types/CountAudienceCompaniesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetPlanTraitResponse.java similarity index 72% rename from src/main/java/com/schematic/api/resources/features/types/CountAudienceCompaniesResponse.java rename to src/main/java/com/schematic/api/resources/companies/types/GetPlanTraitResponse.java index cd11fa2..68b0e26 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CountAudienceCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetPlanTraitResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.schematic.api.resources.features.types; +package com.schematic.api.resources.companies.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import com.schematic.api.types.CountResponse; +import com.schematic.api.types.PlanTraitResponseData; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -21,23 +21,23 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = CountAudienceCompaniesResponse.Builder.class) -public final class CountAudienceCompaniesResponse { - private final CountResponse data; +@JsonDeserialize(builder = GetPlanTraitResponse.Builder.class) +public final class GetPlanTraitResponse { + private final PlanTraitResponseData data; private final Map params; private final Map additionalProperties; - private CountAudienceCompaniesResponse( - CountResponse data, Map params, Map additionalProperties) { + private GetPlanTraitResponse( + PlanTraitResponseData data, Map params, Map additionalProperties) { this.data = data; this.params = params; this.additionalProperties = additionalProperties; } @JsonProperty("data") - public CountResponse getData() { + public PlanTraitResponseData getData() { return data; } @@ -52,7 +52,7 @@ public Map getParams() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CountAudienceCompaniesResponse && equalTo((CountAudienceCompaniesResponse) other); + return other instanceof GetPlanTraitResponse && equalTo((GetPlanTraitResponse) other); } @JsonAnyGetter @@ -60,7 +60,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CountAudienceCompaniesResponse other) { + private boolean equalTo(GetPlanTraitResponse other) { return data.equals(other.data) && params.equals(other.params); } @@ -79,14 +79,17 @@ public static DataStage builder() { } public interface DataStage { - _FinalStage data(@NotNull CountResponse data); + _FinalStage data(@NotNull PlanTraitResponseData data); - Builder from(CountAudienceCompaniesResponse other); + Builder from(GetPlanTraitResponse other); } public interface _FinalStage { - CountAudienceCompaniesResponse build(); + GetPlanTraitResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -96,7 +99,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements DataStage, _FinalStage { - private CountResponse data; + private PlanTraitResponseData data; private Map params = new LinkedHashMap<>(); @@ -106,7 +109,7 @@ public static final class Builder implements DataStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(CountAudienceCompaniesResponse other) { + public Builder from(GetPlanTraitResponse other) { data(other.getData()); params(other.getParams()); return this; @@ -114,7 +117,7 @@ public Builder from(CountAudienceCompaniesResponse other) { @java.lang.Override @JsonSetter("data") - public _FinalStage data(@NotNull CountResponse data) { + public _FinalStage data(@NotNull PlanTraitResponseData data) { this.data = Objects.requireNonNull(data, "data must not be null"); return this; } @@ -135,21 +138,28 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } @java.lang.Override - public CountAudienceCompaniesResponse build() { - return new CountAudienceCompaniesResponse(data, params, additionalProperties); + public GetPlanTraitResponse build() { + return new GetPlanTraitResponse(data, params, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/GetUserResponse.java b/src/main/java/com/schematic/api/resources/companies/types/GetUserResponse.java index 86e1f98..af65346 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/GetUserResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/GetUserResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetUserResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterParams.java new file mode 100644 index 0000000..76d863e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterParams.java @@ -0,0 +1,559 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompaniesForAdvancedFilterParams.Builder.class) +public final class ListCompaniesForAdvancedFilterParams { + private final Optional> creditTypeIds; + + private final Optional> displayProperties; + + private final Optional> featureIds; + + private final Optional> ids; + + private final Optional limit; + + private final Optional monetizedSubscriptions; + + private final Optional offset; + + private final Optional> planIds; + + private final Optional q; + + private final Optional sortOrderColumn; + + private final Optional sortOrderDirection; + + private final Optional> subscriptionStatuses; + + private final Optional> subscriptionTypes; + + private final Optional withoutPlan; + + private final Optional withoutSubscription; + + private final Map additionalProperties; + + private ListCompaniesForAdvancedFilterParams( + Optional> creditTypeIds, + Optional> displayProperties, + Optional> featureIds, + Optional> ids, + Optional limit, + Optional monetizedSubscriptions, + Optional offset, + Optional> planIds, + Optional q, + Optional sortOrderColumn, + Optional sortOrderDirection, + Optional> subscriptionStatuses, + Optional> subscriptionTypes, + Optional withoutPlan, + Optional withoutSubscription, + Map additionalProperties) { + this.creditTypeIds = creditTypeIds; + this.displayProperties = displayProperties; + this.featureIds = featureIds; + this.ids = ids; + this.limit = limit; + this.monetizedSubscriptions = monetizedSubscriptions; + this.offset = offset; + this.planIds = planIds; + this.q = q; + this.sortOrderColumn = sortOrderColumn; + this.sortOrderDirection = sortOrderDirection; + this.subscriptionStatuses = subscriptionStatuses; + this.subscriptionTypes = subscriptionTypes; + this.withoutPlan = withoutPlan; + this.withoutSubscription = withoutSubscription; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter companies by one or more credit type IDs (each ID starts with bcrd_) + */ + @JsonProperty("credit_type_ids") + public Optional> getCreditTypeIds() { + return creditTypeIds; + } + + /** + * @return Select the display columns to return (e.g. plan, subscription, users, last_seen_at) + */ + @JsonProperty("display_properties") + public Optional> getDisplayProperties() { + return displayProperties; + } + + /** + * @return Filter companies by one or more feature IDs (each ID starts with feat_) + */ + @JsonProperty("feature_ids") + public Optional> getFeatureIds() { + return featureIds; + } + + /** + * @return Filter companies by multiple company IDs (starts with comp_) + */ + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Filter companies that have monetized subscriptions + */ + @JsonProperty("monetized_subscriptions") + public Optional getMonetizedSubscriptions() { + return monetizedSubscriptions; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + /** + * @return Filter companies by one or more plan IDs (each ID starts with plan_) + */ + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + /** + * @return Search for companies by name, keys or string traits + */ + @JsonProperty("q") + public Optional getQ() { + return q; + } + + /** + * @return Column to sort by (e.g. name, created_at, last_seen_at) + */ + @JsonProperty("sort_order_column") + public Optional getSortOrderColumn() { + return sortOrderColumn; + } + + /** + * @return Direction to sort by (asc or desc) + */ + @JsonProperty("sort_order_direction") + public Optional getSortOrderDirection() { + return sortOrderDirection; + } + + /** + * @return Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid) + */ + @JsonProperty("subscription_statuses") + public Optional> getSubscriptionStatuses() { + return subscriptionStatuses; + } + + /** + * @return Filter companies by one or more subscription types (paid, free, trial) + */ + @JsonProperty("subscription_types") + public Optional> getSubscriptionTypes() { + return subscriptionTypes; + } + + /** + * @return Filter out companies that have a plan + */ + @JsonProperty("without_plan") + public Optional getWithoutPlan() { + return withoutPlan; + } + + /** + * @return Filter out companies that have a subscription + */ + @JsonProperty("without_subscription") + public Optional getWithoutSubscription() { + return withoutSubscription; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompaniesForAdvancedFilterParams + && equalTo((ListCompaniesForAdvancedFilterParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompaniesForAdvancedFilterParams other) { + return creditTypeIds.equals(other.creditTypeIds) + && displayProperties.equals(other.displayProperties) + && featureIds.equals(other.featureIds) + && ids.equals(other.ids) + && limit.equals(other.limit) + && monetizedSubscriptions.equals(other.monetizedSubscriptions) + && offset.equals(other.offset) + && planIds.equals(other.planIds) + && q.equals(other.q) + && sortOrderColumn.equals(other.sortOrderColumn) + && sortOrderDirection.equals(other.sortOrderDirection) + && subscriptionStatuses.equals(other.subscriptionStatuses) + && subscriptionTypes.equals(other.subscriptionTypes) + && withoutPlan.equals(other.withoutPlan) + && withoutSubscription.equals(other.withoutSubscription); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.creditTypeIds, + this.displayProperties, + this.featureIds, + this.ids, + this.limit, + this.monetizedSubscriptions, + this.offset, + this.planIds, + this.q, + this.sortOrderColumn, + this.sortOrderDirection, + this.subscriptionStatuses, + this.subscriptionTypes, + this.withoutPlan, + this.withoutSubscription); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> creditTypeIds = Optional.empty(); + + private Optional> displayProperties = Optional.empty(); + + private Optional> featureIds = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional monetizedSubscriptions = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional> planIds = Optional.empty(); + + private Optional q = Optional.empty(); + + private Optional sortOrderColumn = Optional.empty(); + + private Optional sortOrderDirection = + Optional.empty(); + + private Optional> subscriptionStatuses = Optional.empty(); + + private Optional> subscriptionTypes = Optional.empty(); + + private Optional withoutPlan = Optional.empty(); + + private Optional withoutSubscription = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCompaniesForAdvancedFilterParams other) { + creditTypeIds(other.getCreditTypeIds()); + displayProperties(other.getDisplayProperties()); + featureIds(other.getFeatureIds()); + ids(other.getIds()); + limit(other.getLimit()); + monetizedSubscriptions(other.getMonetizedSubscriptions()); + offset(other.getOffset()); + planIds(other.getPlanIds()); + q(other.getQ()); + sortOrderColumn(other.getSortOrderColumn()); + sortOrderDirection(other.getSortOrderDirection()); + subscriptionStatuses(other.getSubscriptionStatuses()); + subscriptionTypes(other.getSubscriptionTypes()); + withoutPlan(other.getWithoutPlan()); + withoutSubscription(other.getWithoutSubscription()); + return this; + } + + /** + *

Filter companies by one or more credit type IDs (each ID starts with bcrd_)

+ */ + @JsonSetter(value = "credit_type_ids", nulls = Nulls.SKIP) + public Builder creditTypeIds(Optional> creditTypeIds) { + this.creditTypeIds = creditTypeIds; + return this; + } + + public Builder creditTypeIds(List creditTypeIds) { + this.creditTypeIds = Optional.ofNullable(creditTypeIds); + return this; + } + + /** + *

Select the display columns to return (e.g. plan, subscription, users, last_seen_at)

+ */ + @JsonSetter(value = "display_properties", nulls = Nulls.SKIP) + public Builder displayProperties(Optional> displayProperties) { + this.displayProperties = displayProperties; + return this; + } + + public Builder displayProperties(List displayProperties) { + this.displayProperties = Optional.ofNullable(displayProperties); + return this; + } + + /** + *

Filter companies by one or more feature IDs (each ID starts with feat_)

+ */ + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; + return this; + } + + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); + return this; + } + + /** + *

Filter companies by multiple company IDs (starts with comp_)

+ */ + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Filter companies that have monetized subscriptions

+ */ + @JsonSetter(value = "monetized_subscriptions", nulls = Nulls.SKIP) + public Builder monetizedSubscriptions(Optional monetizedSubscriptions) { + this.monetizedSubscriptions = monetizedSubscriptions; + return this; + } + + public Builder monetizedSubscriptions(Boolean monetizedSubscriptions) { + this.monetizedSubscriptions = Optional.ofNullable(monetizedSubscriptions); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + /** + *

Filter companies by one or more plan IDs (each ID starts with plan_)

+ */ + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + /** + *

Search for companies by name, keys or string traits

+ */ + @JsonSetter(value = "q", nulls = Nulls.SKIP) + public Builder q(Optional q) { + this.q = q; + return this; + } + + public Builder q(String q) { + this.q = Optional.ofNullable(q); + return this; + } + + /** + *

Column to sort by (e.g. name, created_at, last_seen_at)

+ */ + @JsonSetter(value = "sort_order_column", nulls = Nulls.SKIP) + public Builder sortOrderColumn(Optional sortOrderColumn) { + this.sortOrderColumn = sortOrderColumn; + return this; + } + + public Builder sortOrderColumn(String sortOrderColumn) { + this.sortOrderColumn = Optional.ofNullable(sortOrderColumn); + return this; + } + + /** + *

Direction to sort by (asc or desc)

+ */ + @JsonSetter(value = "sort_order_direction", nulls = Nulls.SKIP) + public Builder sortOrderDirection( + Optional sortOrderDirection) { + this.sortOrderDirection = sortOrderDirection; + return this; + } + + public Builder sortOrderDirection( + ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection sortOrderDirection) { + this.sortOrderDirection = Optional.ofNullable(sortOrderDirection); + return this; + } + + /** + *

Filter companies by one or more subscription statuses (active, canceled, expired, incomplete, incomplete_expired, past_due, paused, trialing, unpaid)

+ */ + @JsonSetter(value = "subscription_statuses", nulls = Nulls.SKIP) + public Builder subscriptionStatuses(Optional> subscriptionStatuses) { + this.subscriptionStatuses = subscriptionStatuses; + return this; + } + + public Builder subscriptionStatuses(List subscriptionStatuses) { + this.subscriptionStatuses = Optional.ofNullable(subscriptionStatuses); + return this; + } + + /** + *

Filter companies by one or more subscription types (paid, free, trial)

+ */ + @JsonSetter(value = "subscription_types", nulls = Nulls.SKIP) + public Builder subscriptionTypes(Optional> subscriptionTypes) { + this.subscriptionTypes = subscriptionTypes; + return this; + } + + public Builder subscriptionTypes(List subscriptionTypes) { + this.subscriptionTypes = Optional.ofNullable(subscriptionTypes); + return this; + } + + /** + *

Filter out companies that have a plan

+ */ + @JsonSetter(value = "without_plan", nulls = Nulls.SKIP) + public Builder withoutPlan(Optional withoutPlan) { + this.withoutPlan = withoutPlan; + return this; + } + + public Builder withoutPlan(Boolean withoutPlan) { + this.withoutPlan = Optional.ofNullable(withoutPlan); + return this; + } + + /** + *

Filter out companies that have a subscription

+ */ + @JsonSetter(value = "without_subscription", nulls = Nulls.SKIP) + public Builder withoutSubscription(Optional withoutSubscription) { + this.withoutSubscription = withoutSubscription; + return this; + } + + public Builder withoutSubscription(Boolean withoutSubscription) { + this.withoutSubscription = Optional.ofNullable(withoutSubscription); + return this; + } + + public ListCompaniesForAdvancedFilterParams build() { + return new ListCompaniesForAdvancedFilterParams( + creditTypeIds, + displayProperties, + featureIds, + ids, + limit, + monetizedSubscriptions, + offset, + planIds, + q, + sortOrderColumn, + sortOrderDirection, + subscriptionStatuses, + subscriptionTypes, + withoutPlan, + withoutSubscription, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterRequestSortOrderDirection.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterRequestSortOrderDirection.java new file mode 100644 index 0000000..1fa2420 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterRequestSortOrderDirection.java @@ -0,0 +1,87 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListCompaniesForAdvancedFilterRequestSortOrderDirection { + public static final ListCompaniesForAdvancedFilterRequestSortOrderDirection ASC = + new ListCompaniesForAdvancedFilterRequestSortOrderDirection(Value.ASC, "asc"); + + public static final ListCompaniesForAdvancedFilterRequestSortOrderDirection DESC = + new ListCompaniesForAdvancedFilterRequestSortOrderDirection(Value.DESC, "desc"); + + private final Value value; + + private final String string; + + ListCompaniesForAdvancedFilterRequestSortOrderDirection(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListCompaniesForAdvancedFilterRequestSortOrderDirection + && this.string.equals( + ((ListCompaniesForAdvancedFilterRequestSortOrderDirection) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASC: + return visitor.visitAsc(); + case DESC: + return visitor.visitDesc(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCompaniesForAdvancedFilterRequestSortOrderDirection valueOf(String value) { + switch (value) { + case "asc": + return ASC; + case "desc": + return DESC; + default: + return new ListCompaniesForAdvancedFilterRequestSortOrderDirection(Value.UNKNOWN, value); + } + } + + public enum Value { + ASC, + + DESC, + + UNKNOWN + } + + public interface Visitor { + T visitAsc(); + + T visitDesc(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterResponse.java new file mode 100644 index 0000000..f99c32d --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterResponse.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CompanyViewWithFeatureUsageResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompaniesForAdvancedFilterResponse.Builder.class) +public final class ListCompaniesForAdvancedFilterResponse { + private final List data; + + private final ListCompaniesForAdvancedFilterParams params; + + private final Map additionalProperties; + + private ListCompaniesForAdvancedFilterResponse( + List data, + ListCompaniesForAdvancedFilterParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListCompaniesForAdvancedFilterParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompaniesForAdvancedFilterResponse + && equalTo((ListCompaniesForAdvancedFilterResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompaniesForAdvancedFilterResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListCompaniesForAdvancedFilterParams params); + + Builder from(ListCompaniesForAdvancedFilterResponse other); + } + + public interface _FinalStage { + ListCompaniesForAdvancedFilterResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(CompanyViewWithFeatureUsageResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListCompaniesForAdvancedFilterParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListCompaniesForAdvancedFilterResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListCompaniesForAdvancedFilterParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(CompanyViewWithFeatureUsageResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListCompaniesForAdvancedFilterResponse build() { + return new ListCompaniesForAdvancedFilterResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection.java new file mode 100644 index 0000000..5e699a0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection.java @@ -0,0 +1,87 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection { + public static final ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection ASC = + new ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection(Value.ASC, "asc"); + + public static final ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection DESC = + new ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection(Value.DESC, "desc"); + + private final Value value; + + private final String string; + + ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection + && this.string.equals( + ((ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASC: + return visitor.visitAsc(); + case DESC: + return visitor.visitDesc(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection valueOf(String value) { + switch (value) { + case "asc": + return ASC; + case "desc": + return DESC; + default: + return new ListCompaniesForAdvancedFilterResponseParamsSortOrderDirection(Value.UNKNOWN, value); + } + } + + public enum Value { + ASC, + + DESC, + + UNKNOWN + } + + public interface Visitor { + T visitAsc(); + + T visitDesc(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesParams.java index 5c9fc0d..c871420 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesParams.java @@ -31,6 +31,8 @@ public final class ListCompaniesParams { private final Optional q; + private final Optional withSubscription; + private final Optional withoutFeatureOverrideFor; private final Optional withoutPlan; @@ -43,6 +45,7 @@ private ListCompaniesParams( Optional offset, Optional planId, Optional q, + Optional withSubscription, Optional withoutFeatureOverrideFor, Optional withoutPlan, Map additionalProperties) { @@ -51,6 +54,7 @@ private ListCompaniesParams( this.offset = offset; this.planId = planId; this.q = q; + this.withSubscription = withSubscription; this.withoutFeatureOverrideFor = withoutFeatureOverrideFor; this.withoutPlan = withoutPlan; this.additionalProperties = additionalProperties; @@ -96,6 +100,14 @@ public Optional getQ() { return q; } + /** + * @return Filter companies that have a subscription + */ + @JsonProperty("with_subscription") + public Optional getWithSubscription() { + return withSubscription; + } + /** * @return Filter out companies that already have a company override for the specified feature ID */ @@ -129,6 +141,7 @@ private boolean equalTo(ListCompaniesParams other) { && offset.equals(other.offset) && planId.equals(other.planId) && q.equals(other.q) + && withSubscription.equals(other.withSubscription) && withoutFeatureOverrideFor.equals(other.withoutFeatureOverrideFor) && withoutPlan.equals(other.withoutPlan); } @@ -141,6 +154,7 @@ public int hashCode() { this.offset, this.planId, this.q, + this.withSubscription, this.withoutFeatureOverrideFor, this.withoutPlan); } @@ -166,6 +180,8 @@ public static final class Builder { private Optional q = Optional.empty(); + private Optional withSubscription = Optional.empty(); + private Optional withoutFeatureOverrideFor = Optional.empty(); private Optional withoutPlan = Optional.empty(); @@ -181,11 +197,15 @@ public Builder from(ListCompaniesParams other) { offset(other.getOffset()); planId(other.getPlanId()); q(other.getQ()); + withSubscription(other.getWithSubscription()); withoutFeatureOverrideFor(other.getWithoutFeatureOverrideFor()); withoutPlan(other.getWithoutPlan()); return this; } + /** + *

Filter companies by multiple company IDs (starts with comp_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -197,6 +217,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -208,6 +231,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -219,6 +245,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Filter companies by plan ID (starts with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -230,6 +259,9 @@ public Builder planId(String planId) { return this; } + /** + *

Search for companies by name, keys or string traits

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -241,6 +273,23 @@ public Builder q(String q) { return this; } + /** + *

Filter companies that have a subscription

+ */ + @JsonSetter(value = "with_subscription", nulls = Nulls.SKIP) + public Builder withSubscription(Optional withSubscription) { + this.withSubscription = withSubscription; + return this; + } + + public Builder withSubscription(Boolean withSubscription) { + this.withSubscription = Optional.ofNullable(withSubscription); + return this; + } + + /** + *

Filter out companies that already have a company override for the specified feature ID

+ */ @JsonSetter(value = "without_feature_override_for", nulls = Nulls.SKIP) public Builder withoutFeatureOverrideFor(Optional withoutFeatureOverrideFor) { this.withoutFeatureOverrideFor = withoutFeatureOverrideFor; @@ -252,6 +301,9 @@ public Builder withoutFeatureOverrideFor(String withoutFeatureOverrideFor) { return this; } + /** + *

Filter out companies that have a plan

+ */ @JsonSetter(value = "without_plan", nulls = Nulls.SKIP) public Builder withoutPlan(Optional withoutPlan) { this.withoutPlan = withoutPlan; @@ -265,7 +317,15 @@ public Builder withoutPlan(Boolean withoutPlan) { public ListCompaniesParams build() { return new ListCompaniesParams( - ids, limit, offset, planId, q, withoutFeatureOverrideFor, withoutPlan, additionalProperties); + ids, + limit, + offset, + planId, + q, + withSubscription, + withoutFeatureOverrideFor, + withoutPlan, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesResponse.java index b72d4ca..af8a83e 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompaniesResponse.java @@ -38,9 +38,6 @@ private ListCompaniesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListCompaniesParams params); Builder from(ListCompaniesResponse other); @@ -118,6 +118,7 @@ public Builder from(ListCompaniesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListCompaniesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(CompanyDetailResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(CompanyDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsParams.java index b2288b9..e49f151 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsParams.java @@ -135,6 +135,9 @@ public Builder companyId(String companyId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsResponse.java index b0be90f..3b8a1b2 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListCompanyMembershipsResponse.java @@ -38,9 +38,6 @@ private ListCompanyMembershipsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListCompanyMembershipsParams params); Builder from(ListCompanyMembershipsResponse other); @@ -118,6 +118,7 @@ public Builder from(ListCompanyMembershipsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListCompanyMembershipsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(CompanyMembershipDetailResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(CompanyMembershipDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsParams.java index 86ce159..c39dbdc 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsParams.java @@ -160,6 +160,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -171,6 +174,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsRequestEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsRequestEntityType.java index cca57f2..a028b3c 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsRequestEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsRequestEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListEntityKeyDefinitionsRequestEntityType { - COMPANY("company"), +public final class ListEntityKeyDefinitionsRequestEntityType { + public static final ListEntityKeyDefinitionsRequestEntityType USER = + new ListEntityKeyDefinitionsRequestEntityType(Value.USER, "user"); - USER("user"); + public static final ListEntityKeyDefinitionsRequestEntityType COMPANY = + new ListEntityKeyDefinitionsRequestEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - ListEntityKeyDefinitionsRequestEntityType(String value) { + private final String string; + + ListEntityKeyDefinitionsRequestEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListEntityKeyDefinitionsRequestEntityType + && this.string.equals(((ListEntityKeyDefinitionsRequestEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListEntityKeyDefinitionsRequestEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new ListEntityKeyDefinitionsRequestEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponse.java index 11934f0..eaf66ff 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponse.java @@ -38,9 +38,6 @@ private ListEntityKeyDefinitionsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListEntityKeyDefinitionsParams params); Builder from(ListEntityKeyDefinitionsResponse other); @@ -118,6 +118,7 @@ public Builder from(ListEntityKeyDefinitionsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListEntityKeyDefinitionsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(EntityKeyDefinitionResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(EntityKeyDefinitionResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponseParamsEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponseParamsEntityType.java index 2c93a68..0906ca0 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponseParamsEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityKeyDefinitionsResponseParamsEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListEntityKeyDefinitionsResponseParamsEntityType { - COMPANY("company"), +public final class ListEntityKeyDefinitionsResponseParamsEntityType { + public static final ListEntityKeyDefinitionsResponseParamsEntityType USER = + new ListEntityKeyDefinitionsResponseParamsEntityType(Value.USER, "user"); - USER("user"); + public static final ListEntityKeyDefinitionsResponseParamsEntityType COMPANY = + new ListEntityKeyDefinitionsResponseParamsEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - ListEntityKeyDefinitionsResponseParamsEntityType(String value) { + private final String string; + + ListEntityKeyDefinitionsResponseParamsEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListEntityKeyDefinitionsResponseParamsEntityType + && this.string.equals(((ListEntityKeyDefinitionsResponseParamsEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListEntityKeyDefinitionsResponseParamsEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new ListEntityKeyDefinitionsResponseParamsEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsParams.java index fe45270..2720255 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsParams.java @@ -173,6 +173,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -184,6 +187,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsRequestEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsRequestEntityType.java index af8c417..3d1157e 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsRequestEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsRequestEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListEntityTraitDefinitionsRequestEntityType { - COMPANY("company"), +public final class ListEntityTraitDefinitionsRequestEntityType { + public static final ListEntityTraitDefinitionsRequestEntityType USER = + new ListEntityTraitDefinitionsRequestEntityType(Value.USER, "user"); - USER("user"); + public static final ListEntityTraitDefinitionsRequestEntityType COMPANY = + new ListEntityTraitDefinitionsRequestEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - ListEntityTraitDefinitionsRequestEntityType(String value) { + private final String string; + + ListEntityTraitDefinitionsRequestEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListEntityTraitDefinitionsRequestEntityType + && this.string.equals(((ListEntityTraitDefinitionsRequestEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListEntityTraitDefinitionsRequestEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new ListEntityTraitDefinitionsRequestEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsRequestTraitType.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsRequestTraitType.java index 48ea42c..45fad88 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsRequestTraitType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsRequestTraitType.java @@ -3,30 +3,128 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListEntityTraitDefinitionsRequestTraitType { - BOOLEAN("boolean"), +public final class ListEntityTraitDefinitionsRequestTraitType { + public static final ListEntityTraitDefinitionsRequestTraitType NUMBER = + new ListEntityTraitDefinitionsRequestTraitType(Value.NUMBER, "number"); - CURRENCY("currency"), + public static final ListEntityTraitDefinitionsRequestTraitType STRING = + new ListEntityTraitDefinitionsRequestTraitType(Value.STRING, "string"); - DATE("date"), + public static final ListEntityTraitDefinitionsRequestTraitType BOOLEAN = + new ListEntityTraitDefinitionsRequestTraitType(Value.BOOLEAN, "boolean"); - NUMBER("number"), + public static final ListEntityTraitDefinitionsRequestTraitType CURRENCY = + new ListEntityTraitDefinitionsRequestTraitType(Value.CURRENCY, "currency"); - STRING("string"), + public static final ListEntityTraitDefinitionsRequestTraitType DATE = + new ListEntityTraitDefinitionsRequestTraitType(Value.DATE, "date"); - URL("url"); + public static final ListEntityTraitDefinitionsRequestTraitType URL = + new ListEntityTraitDefinitionsRequestTraitType(Value.URL, "url"); - private final String value; + private final Value value; - ListEntityTraitDefinitionsRequestTraitType(String value) { + private final String string; + + ListEntityTraitDefinitionsRequestTraitType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListEntityTraitDefinitionsRequestTraitType + && this.string.equals(((ListEntityTraitDefinitionsRequestTraitType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMBER: + return visitor.visitNumber(); + case STRING: + return visitor.visitString(); + case BOOLEAN: + return visitor.visitBoolean(); + case CURRENCY: + return visitor.visitCurrency(); + case DATE: + return visitor.visitDate(); + case URL: + return visitor.visitUrl(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListEntityTraitDefinitionsRequestTraitType valueOf(String value) { + switch (value) { + case "number": + return NUMBER; + case "string": + return STRING; + case "boolean": + return BOOLEAN; + case "currency": + return CURRENCY; + case "date": + return DATE; + case "url": + return URL; + default: + return new ListEntityTraitDefinitionsRequestTraitType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CURRENCY, + + DATE, + + NUMBER, + + STRING, + + URL, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCurrency(); + + T visitDate(); + + T visitNumber(); + + T visitString(); + + T visitUrl(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponse.java index cd7000d..f1e2a41 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponse.java @@ -38,9 +38,6 @@ private ListEntityTraitDefinitionsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -85,6 +82,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListEntityTraitDefinitionsParams params); Builder from(ListEntityTraitDefinitionsResponse other); @@ -119,6 +119,7 @@ public Builder from(ListEntityTraitDefinitionsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -129,20 +130,14 @@ public _FinalStage params(@NotNull ListEntityTraitDefinitionsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(EntityTraitDefinitionResponseData data) { this.data.add(data); @@ -153,7 +148,9 @@ public _FinalStage addData(EntityTraitDefinitionResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponseParamsEntityType.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponseParamsEntityType.java index 662e7a4..272fa38 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponseParamsEntityType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponseParamsEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListEntityTraitDefinitionsResponseParamsEntityType { - COMPANY("company"), +public final class ListEntityTraitDefinitionsResponseParamsEntityType { + public static final ListEntityTraitDefinitionsResponseParamsEntityType USER = + new ListEntityTraitDefinitionsResponseParamsEntityType(Value.USER, "user"); - USER("user"); + public static final ListEntityTraitDefinitionsResponseParamsEntityType COMPANY = + new ListEntityTraitDefinitionsResponseParamsEntityType(Value.COMPANY, "company"); - private final String value; + private final Value value; - ListEntityTraitDefinitionsResponseParamsEntityType(String value) { + private final String string; + + ListEntityTraitDefinitionsResponseParamsEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListEntityTraitDefinitionsResponseParamsEntityType + && this.string.equals(((ListEntityTraitDefinitionsResponseParamsEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListEntityTraitDefinitionsResponseParamsEntityType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "company": + return COMPANY; + default: + return new ListEntityTraitDefinitionsResponseParamsEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitUser(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponseParamsTraitType.java b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponseParamsTraitType.java index 295ddf6..806e485 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponseParamsTraitType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListEntityTraitDefinitionsResponseParamsTraitType.java @@ -3,30 +3,128 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListEntityTraitDefinitionsResponseParamsTraitType { - BOOLEAN("boolean"), +public final class ListEntityTraitDefinitionsResponseParamsTraitType { + public static final ListEntityTraitDefinitionsResponseParamsTraitType NUMBER = + new ListEntityTraitDefinitionsResponseParamsTraitType(Value.NUMBER, "number"); - CURRENCY("currency"), + public static final ListEntityTraitDefinitionsResponseParamsTraitType STRING = + new ListEntityTraitDefinitionsResponseParamsTraitType(Value.STRING, "string"); - DATE("date"), + public static final ListEntityTraitDefinitionsResponseParamsTraitType BOOLEAN = + new ListEntityTraitDefinitionsResponseParamsTraitType(Value.BOOLEAN, "boolean"); - NUMBER("number"), + public static final ListEntityTraitDefinitionsResponseParamsTraitType CURRENCY = + new ListEntityTraitDefinitionsResponseParamsTraitType(Value.CURRENCY, "currency"); - STRING("string"), + public static final ListEntityTraitDefinitionsResponseParamsTraitType DATE = + new ListEntityTraitDefinitionsResponseParamsTraitType(Value.DATE, "date"); - URL("url"); + public static final ListEntityTraitDefinitionsResponseParamsTraitType URL = + new ListEntityTraitDefinitionsResponseParamsTraitType(Value.URL, "url"); - private final String value; + private final Value value; - ListEntityTraitDefinitionsResponseParamsTraitType(String value) { + private final String string; + + ListEntityTraitDefinitionsResponseParamsTraitType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListEntityTraitDefinitionsResponseParamsTraitType + && this.string.equals(((ListEntityTraitDefinitionsResponseParamsTraitType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMBER: + return visitor.visitNumber(); + case STRING: + return visitor.visitString(); + case BOOLEAN: + return visitor.visitBoolean(); + case CURRENCY: + return visitor.visitCurrency(); + case DATE: + return visitor.visitDate(); + case URL: + return visitor.visitUrl(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListEntityTraitDefinitionsResponseParamsTraitType valueOf(String value) { + switch (value) { + case "number": + return NUMBER; + case "string": + return STRING; + case "boolean": + return BOOLEAN; + case "currency": + return CURRENCY; + case "date": + return DATE; + case "url": + return URL; + default: + return new ListEntityTraitDefinitionsResponseParamsTraitType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CURRENCY, + + DATE, + + NUMBER, + + STRING, + + URL, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCurrency(); + + T visitDate(); + + T visitNumber(); + + T visitString(); + + T visitUrl(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesParams.java new file mode 100644 index 0000000..2ff1fb9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesParams.java @@ -0,0 +1,262 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanChangesParams.Builder.class) +public final class ListPlanChangesParams { + private final Optional action; + + private final Optional basePlanAction; + + private final Optional companyId; + + private final Optional> companyIds; + + private final Optional limit; + + private final Optional offset; + + private final Optional> planIds; + + private final Map additionalProperties; + + private ListPlanChangesParams( + Optional action, + Optional basePlanAction, + Optional companyId, + Optional> companyIds, + Optional limit, + Optional offset, + Optional> planIds, + Map additionalProperties) { + this.action = action; + this.basePlanAction = basePlanAction; + this.companyId = companyId; + this.companyIds = companyIds; + this.limit = limit; + this.offset = offset; + this.planIds = planIds; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("action") + public Optional getAction() { + return action; + } + + @JsonProperty("base_plan_action") + public Optional getBasePlanAction() { + return basePlanAction; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanChangesParams && equalTo((ListPlanChangesParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanChangesParams other) { + return action.equals(other.action) + && basePlanAction.equals(other.basePlanAction) + && companyId.equals(other.companyId) + && companyIds.equals(other.companyIds) + && limit.equals(other.limit) + && offset.equals(other.offset) + && planIds.equals(other.planIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.action, + this.basePlanAction, + this.companyId, + this.companyIds, + this.limit, + this.offset, + this.planIds); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional action = Optional.empty(); + + private Optional basePlanAction = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional> companyIds = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional> planIds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListPlanChangesParams other) { + action(other.getAction()); + basePlanAction(other.getBasePlanAction()); + companyId(other.getCompanyId()); + companyIds(other.getCompanyIds()); + limit(other.getLimit()); + offset(other.getOffset()); + planIds(other.getPlanIds()); + return this; + } + + @JsonSetter(value = "action", nulls = Nulls.SKIP) + public Builder action(Optional action) { + this.action = action; + return this; + } + + public Builder action(String action) { + this.action = Optional.ofNullable(action); + return this; + } + + @JsonSetter(value = "base_plan_action", nulls = Nulls.SKIP) + public Builder basePlanAction(Optional basePlanAction) { + this.basePlanAction = basePlanAction; + return this; + } + + public Builder basePlanAction(String basePlanAction) { + this.basePlanAction = Optional.ofNullable(basePlanAction); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; + return this; + } + + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + public ListPlanChangesParams build() { + return new ListPlanChangesParams( + action, basePlanAction, companyId, companyIds, limit, offset, planIds, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesResponse.java new file mode 100644 index 0000000..3a88339 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/ListPlanChangesResponse.java @@ -0,0 +1,159 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.PlanChangeResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanChangesResponse.Builder.class) +public final class ListPlanChangesResponse { + private final List data; + + private final ListPlanChangesParams params; + + private final Map additionalProperties; + + private ListPlanChangesResponse( + List data, ListPlanChangesParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListPlanChangesParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanChangesResponse && equalTo((ListPlanChangesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanChangesResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListPlanChangesParams params); + + Builder from(ListPlanChangesResponse other); + } + + public interface _FinalStage { + ListPlanChangesResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(PlanChangeResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListPlanChangesParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListPlanChangesResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListPlanChangesParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(PlanChangeResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListPlanChangesResponse build() { + return new ListPlanChangesResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsParams.java new file mode 100644 index 0000000..502e65a --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsParams.java @@ -0,0 +1,230 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanTraitsParams.Builder.class) +public final class ListPlanTraitsParams { + private final Optional> ids; + + private final Optional limit; + + private final Optional offset; + + private final Optional planId; + + private final Optional traitId; + + private final Optional> traitIds; + + private final Map additionalProperties; + + private ListPlanTraitsParams( + Optional> ids, + Optional limit, + Optional offset, + Optional planId, + Optional traitId, + Optional> traitIds, + Map additionalProperties) { + this.ids = ids; + this.limit = limit; + this.offset = offset; + this.planId = planId; + this.traitId = traitId; + this.traitIds = traitIds; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @JsonProperty("trait_id") + public Optional getTraitId() { + return traitId; + } + + @JsonProperty("trait_ids") + public Optional> getTraitIds() { + return traitIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanTraitsParams && equalTo((ListPlanTraitsParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanTraitsParams other) { + return ids.equals(other.ids) + && limit.equals(other.limit) + && offset.equals(other.offset) + && planId.equals(other.planId) + && traitId.equals(other.traitId) + && traitIds.equals(other.traitIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.limit, this.offset, this.planId, this.traitId, this.traitIds); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional traitId = Optional.empty(); + + private Optional> traitIds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListPlanTraitsParams other) { + ids(other.getIds()); + limit(other.getLimit()); + offset(other.getOffset()); + planId(other.getPlanId()); + traitId(other.getTraitId()); + traitIds(other.getTraitIds()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + @JsonSetter(value = "trait_id", nulls = Nulls.SKIP) + public Builder traitId(Optional traitId) { + this.traitId = traitId; + return this; + } + + public Builder traitId(String traitId) { + this.traitId = Optional.ofNullable(traitId); + return this; + } + + @JsonSetter(value = "trait_ids", nulls = Nulls.SKIP) + public Builder traitIds(Optional> traitIds) { + this.traitIds = traitIds; + return this; + } + + public Builder traitIds(List traitIds) { + this.traitIds = Optional.ofNullable(traitIds); + return this; + } + + public ListPlanTraitsParams build() { + return new ListPlanTraitsParams(ids, limit, offset, planId, traitId, traitIds, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsResponse.java new file mode 100644 index 0000000..05040aa --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/ListPlanTraitsResponse.java @@ -0,0 +1,159 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.PlanTraitResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanTraitsResponse.Builder.class) +public final class ListPlanTraitsResponse { + private final List data; + + private final ListPlanTraitsParams params; + + private final Map additionalProperties; + + private ListPlanTraitsResponse( + List data, ListPlanTraitsParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListPlanTraitsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanTraitsResponse && equalTo((ListPlanTraitsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanTraitsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListPlanTraitsParams params); + + Builder from(ListPlanTraitsResponse other); + } + + public interface _FinalStage { + ListPlanTraitsResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(PlanTraitResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListPlanTraitsParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListPlanTraitsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListPlanTraitsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(PlanTraitResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListPlanTraitsResponse build() { + return new ListPlanTraitsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListUsersParams.java b/src/main/java/com/schematic/api/resources/companies/types/ListUsersParams.java index 7461225..fe12e81 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListUsersParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListUsersParams.java @@ -163,6 +163,9 @@ public Builder from(ListUsersParams other) { return this; } + /** + *

Filter users by company ID (starts with comp_)

+ */ @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -174,6 +177,9 @@ public Builder companyId(String companyId) { return this; } + /** + *

Filter users by multiple user IDs (starts with user_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -185,6 +191,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -196,6 +205,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -207,6 +219,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Filter users by plan ID (starts with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -218,6 +233,9 @@ public Builder planId(String planId) { return this; } + /** + *

Search for users by name, keys or string traits

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; diff --git a/src/main/java/com/schematic/api/resources/companies/types/ListUsersResponse.java b/src/main/java/com/schematic/api/resources/companies/types/ListUsersResponse.java index 2ebb8bb..7cb60ae 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/ListUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/ListUsersResponse.java @@ -36,9 +36,6 @@ private ListUsersResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListUsersParams params); Builder from(ListUsersResponse other); @@ -116,6 +116,7 @@ public Builder from(ListUsersResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListUsersParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(UserDetailResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(UserDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyParams.java b/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyParams.java index 05baddb..e197483 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyParams.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; @@ -21,17 +20,17 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LookupCompanyParams.Builder.class) public final class LookupCompanyParams { - private final Optional> keys; + private final Optional> keys; private final Map additionalProperties; - private LookupCompanyParams(Optional> keys, Map additionalProperties) { + private LookupCompanyParams(Optional> keys, Map additionalProperties) { this.keys = keys; this.additionalProperties = additionalProperties; } @JsonProperty("keys") - public Optional> getKeys() { + public Optional> getKeys() { return keys; } @@ -66,7 +65,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional> keys = Optional.empty(); + private Optional> keys = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -79,12 +78,12 @@ public Builder from(LookupCompanyParams other) { } @JsonSetter(value = "keys", nulls = Nulls.SKIP) - public Builder keys(Optional> keys) { + public Builder keys(Optional> keys) { this.keys = keys; return this; } - public Builder keys(Map keys) { + public Builder keys(Map keys) { this.keys = Optional.ofNullable(keys); return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyResponse.java b/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyResponse.java index 018e49e..f949c96 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/LookupCompanyResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull LookupCompanyParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CompanyDetailResponseData data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/LookupUserParams.java b/src/main/java/com/schematic/api/resources/companies/types/LookupUserParams.java index 93c2b15..e3386bf 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/LookupUserParams.java +++ b/src/main/java/com/schematic/api/resources/companies/types/LookupUserParams.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; @@ -21,17 +20,17 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LookupUserParams.Builder.class) public final class LookupUserParams { - private final Optional> keys; + private final Optional> keys; private final Map additionalProperties; - private LookupUserParams(Optional> keys, Map additionalProperties) { + private LookupUserParams(Optional> keys, Map additionalProperties) { this.keys = keys; this.additionalProperties = additionalProperties; } @JsonProperty("keys") - public Optional> getKeys() { + public Optional> getKeys() { return keys; } @@ -66,7 +65,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional> keys = Optional.empty(); + private Optional> keys = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -79,12 +78,12 @@ public Builder from(LookupUserParams other) { } @JsonSetter(value = "keys", nulls = Nulls.SKIP) - public Builder keys(Optional> keys) { + public Builder keys(Optional> keys) { this.keys = keys; return this; } - public Builder keys(Map keys) { + public Builder keys(Map keys) { this.keys = Optional.ofNullable(keys); return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/LookupUserResponse.java b/src/main/java/com/schematic/api/resources/companies/types/LookupUserResponse.java index 2e8e0de..f1a4520 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/LookupUserResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/LookupUserResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull LookupUserParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull UserDetailResponseData data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/companies/types/UpdateEntityTraitDefinitionRequestBodyTraitType.java b/src/main/java/com/schematic/api/resources/companies/types/UpdateEntityTraitDefinitionRequestBodyTraitType.java index 694168e..1f970c7 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/UpdateEntityTraitDefinitionRequestBodyTraitType.java +++ b/src/main/java/com/schematic/api/resources/companies/types/UpdateEntityTraitDefinitionRequestBodyTraitType.java @@ -3,30 +3,128 @@ */ package com.schematic.api.resources.companies.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateEntityTraitDefinitionRequestBodyTraitType { - BOOLEAN("boolean"), +public final class UpdateEntityTraitDefinitionRequestBodyTraitType { + public static final UpdateEntityTraitDefinitionRequestBodyTraitType NUMBER = + new UpdateEntityTraitDefinitionRequestBodyTraitType(Value.NUMBER, "number"); - CURRENCY("currency"), + public static final UpdateEntityTraitDefinitionRequestBodyTraitType STRING = + new UpdateEntityTraitDefinitionRequestBodyTraitType(Value.STRING, "string"); - DATE("date"), + public static final UpdateEntityTraitDefinitionRequestBodyTraitType BOOLEAN = + new UpdateEntityTraitDefinitionRequestBodyTraitType(Value.BOOLEAN, "boolean"); - NUMBER("number"), + public static final UpdateEntityTraitDefinitionRequestBodyTraitType CURRENCY = + new UpdateEntityTraitDefinitionRequestBodyTraitType(Value.CURRENCY, "currency"); - STRING("string"), + public static final UpdateEntityTraitDefinitionRequestBodyTraitType DATE = + new UpdateEntityTraitDefinitionRequestBodyTraitType(Value.DATE, "date"); - URL("url"); + public static final UpdateEntityTraitDefinitionRequestBodyTraitType URL = + new UpdateEntityTraitDefinitionRequestBodyTraitType(Value.URL, "url"); - private final String value; + private final Value value; - UpdateEntityTraitDefinitionRequestBodyTraitType(String value) { + private final String string; + + UpdateEntityTraitDefinitionRequestBodyTraitType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateEntityTraitDefinitionRequestBodyTraitType + && this.string.equals(((UpdateEntityTraitDefinitionRequestBodyTraitType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMBER: + return visitor.visitNumber(); + case STRING: + return visitor.visitString(); + case BOOLEAN: + return visitor.visitBoolean(); + case CURRENCY: + return visitor.visitCurrency(); + case DATE: + return visitor.visitDate(); + case URL: + return visitor.visitUrl(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateEntityTraitDefinitionRequestBodyTraitType valueOf(String value) { + switch (value) { + case "number": + return NUMBER; + case "string": + return STRING; + case "boolean": + return BOOLEAN; + case "currency": + return CURRENCY; + case "date": + return DATE; + case "url": + return URL; + default: + return new UpdateEntityTraitDefinitionRequestBodyTraitType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CURRENCY, + + DATE, + + NUMBER, + + STRING, + + URL, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCurrency(); + + T visitDate(); + + T visitNumber(); + + T visitString(); + + T visitUrl(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/UpdateEntityTraitDefinitionResponse.java b/src/main/java/com/schematic/api/resources/companies/types/UpdateEntityTraitDefinitionResponse.java index d53e6e1..d779677 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/UpdateEntityTraitDefinitionResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/UpdateEntityTraitDefinitionResponse.java @@ -90,6 +90,9 @@ public interface DataStage { public interface _FinalStage { UpdateEntityTraitDefinitionResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -138,15 +141,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/UpdatePlanTraitResponse.java b/src/main/java/com/schematic/api/resources/companies/types/UpdatePlanTraitResponse.java new file mode 100644 index 0000000..1b8fe94 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/companies/types/UpdatePlanTraitResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.PlanTraitResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdatePlanTraitResponse.Builder.class) +public final class UpdatePlanTraitResponse { + private final PlanTraitResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private UpdatePlanTraitResponse( + PlanTraitResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public PlanTraitResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdatePlanTraitResponse && equalTo((UpdatePlanTraitResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdatePlanTraitResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull PlanTraitResponseData data); + + Builder from(UpdatePlanTraitResponse other); + } + + public interface _FinalStage { + UpdatePlanTraitResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private PlanTraitResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdatePlanTraitResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull PlanTraitResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public UpdatePlanTraitResponse build() { + return new UpdatePlanTraitResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/features/types/ListAudienceCompaniesResponse.java b/src/main/java/com/schematic/api/resources/companies/types/UpdatePlanTraitsBulkResponse.java similarity index 65% rename from src/main/java/com/schematic/api/resources/features/types/ListAudienceCompaniesResponse.java rename to src/main/java/com/schematic/api/resources/companies/types/UpdatePlanTraitsBulkResponse.java index 54fa25f..3471e94 100644 --- a/src/main/java/com/schematic/api/resources/features/types/ListAudienceCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/UpdatePlanTraitsBulkResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.schematic.api.resources.features.types; +package com.schematic.api.resources.companies.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import com.schematic.api.types.CompanyDetailResponseData; +import com.schematic.api.types.PlanTraitResponseData; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -22,28 +22,23 @@ import java.util.Objects; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListAudienceCompaniesResponse.Builder.class) -public final class ListAudienceCompaniesResponse { - private final List data; +@JsonDeserialize(builder = UpdatePlanTraitsBulkResponse.Builder.class) +public final class UpdatePlanTraitsBulkResponse { + private final List data; private final Map params; private final Map additionalProperties; - private ListAudienceCompaniesResponse( - List data, - Map params, - Map additionalProperties) { + private UpdatePlanTraitsBulkResponse( + List data, Map params, Map additionalProperties) { this.data = data; this.params = params; this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") - public List getData() { + public List getData() { return data; } @@ -58,7 +53,7 @@ public Map getParams() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof ListAudienceCompaniesResponse && equalTo((ListAudienceCompaniesResponse) other); + return other instanceof UpdatePlanTraitsBulkResponse && equalTo((UpdatePlanTraitsBulkResponse) other); } @JsonAnyGetter @@ -66,7 +61,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(ListAudienceCompaniesResponse other) { + private boolean equalTo(UpdatePlanTraitsBulkResponse other) { return data.equals(other.data) && params.equals(other.params); } @@ -86,7 +81,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List data = new ArrayList<>(); + private List data = new ArrayList<>(); private Map params = new LinkedHashMap<>(); @@ -95,38 +90,49 @@ public static final class Builder { private Builder() {} - public Builder from(ListAudienceCompaniesResponse other) { + public Builder from(UpdatePlanTraitsBulkResponse other) { data(other.getData()); params(other.getParams()); return this; } @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(List data) { + public Builder data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - public Builder addData(CompanyDetailResponseData data) { + public Builder addData(PlanTraitResponseData data) { this.data.add(data); return this; } - public Builder addAllData(List data) { - this.data.addAll(data); + public Builder addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } return this; } + /** + *

Input parameters

+ */ @JsonSetter(value = "params", nulls = Nulls.SKIP) public Builder params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } public Builder putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } @@ -135,8 +141,8 @@ public Builder params(String key, JsonNode value) { return this; } - public ListAudienceCompaniesResponse build() { - return new ListAudienceCompaniesResponse(data, params, additionalProperties); + public UpdatePlanTraitsBulkResponse build() { + return new UpdatePlanTraitsBulkResponse(data, params, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/companies/types/UpsertCompanyResponse.java b/src/main/java/com/schematic/api/resources/companies/types/UpsertCompanyResponse.java index 2f7fe41..d70c0bb 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/UpsertCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/UpsertCompanyResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertCompanyResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/UpsertCompanyTraitResponse.java b/src/main/java/com/schematic/api/resources/companies/types/UpsertCompanyTraitResponse.java index 632d0b1..8b35a1d 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/UpsertCompanyTraitResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/UpsertCompanyTraitResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertCompanyTraitResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/UpsertUserResponse.java b/src/main/java/com/schematic/api/resources/companies/types/UpsertUserResponse.java index b93dba4..8ffaf1e 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/UpsertUserResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/UpsertUserResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertUserResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/companies/types/UpsertUserTraitResponse.java b/src/main/java/com/schematic/api/resources/companies/types/UpsertUserTraitResponse.java index 029b625..42b9b25 100644 --- a/src/main/java/com/schematic/api/resources/companies/types/UpsertUserTraitResponse.java +++ b/src/main/java/com/schematic/api/resources/companies/types/UpsertUserTraitResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertUserTraitResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/components/AsyncComponentsClient.java b/src/main/java/com/schematic/api/resources/components/AsyncComponentsClient.java new file mode 100644 index 0000000..c221b61 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/components/AsyncComponentsClient.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.components; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.components.requests.CountComponentsRequest; +import com.schematic.api.resources.components.requests.CreateComponentRequestBody; +import com.schematic.api.resources.components.requests.ListComponentsRequest; +import com.schematic.api.resources.components.requests.PreviewComponentDataRequest; +import com.schematic.api.resources.components.requests.UpdateComponentRequestBody; +import com.schematic.api.resources.components.types.CountComponentsResponse; +import com.schematic.api.resources.components.types.CreateComponentResponse; +import com.schematic.api.resources.components.types.DeleteComponentResponse; +import com.schematic.api.resources.components.types.GetComponentResponse; +import com.schematic.api.resources.components.types.ListComponentsResponse; +import com.schematic.api.resources.components.types.PreviewComponentDataResponse; +import com.schematic.api.resources.components.types.UpdateComponentResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncComponentsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawComponentsClient rawClient; + + public AsyncComponentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawComponentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawComponentsClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture listComponents() { + return this.rawClient.listComponents().thenApply(response -> response.body()); + } + + public CompletableFuture listComponents(ListComponentsRequest request) { + return this.rawClient.listComponents(request).thenApply(response -> response.body()); + } + + public CompletableFuture listComponents( + ListComponentsRequest request, RequestOptions requestOptions) { + return this.rawClient.listComponents(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createComponent(CreateComponentRequestBody request) { + return this.rawClient.createComponent(request).thenApply(response -> response.body()); + } + + public CompletableFuture createComponent( + CreateComponentRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createComponent(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getComponent(String componentId) { + return this.rawClient.getComponent(componentId).thenApply(response -> response.body()); + } + + public CompletableFuture getComponent(String componentId, RequestOptions requestOptions) { + return this.rawClient.getComponent(componentId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateComponent(String componentId) { + return this.rawClient.updateComponent(componentId).thenApply(response -> response.body()); + } + + public CompletableFuture updateComponent( + String componentId, UpdateComponentRequestBody request) { + return this.rawClient.updateComponent(componentId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateComponent( + String componentId, UpdateComponentRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateComponent(componentId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deleteComponent(String componentId) { + return this.rawClient.deleteComponent(componentId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteComponent( + String componentId, RequestOptions requestOptions) { + return this.rawClient.deleteComponent(componentId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countComponents() { + return this.rawClient.countComponents().thenApply(response -> response.body()); + } + + public CompletableFuture countComponents(CountComponentsRequest request) { + return this.rawClient.countComponents(request).thenApply(response -> response.body()); + } + + public CompletableFuture countComponents( + CountComponentsRequest request, RequestOptions requestOptions) { + return this.rawClient.countComponents(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture previewComponentData() { + return this.rawClient.previewComponentData().thenApply(response -> response.body()); + } + + public CompletableFuture previewComponentData(PreviewComponentDataRequest request) { + return this.rawClient.previewComponentData(request).thenApply(response -> response.body()); + } + + public CompletableFuture previewComponentData( + PreviewComponentDataRequest request, RequestOptions requestOptions) { + return this.rawClient.previewComponentData(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/components/AsyncRawComponentsClient.java b/src/main/java/com/schematic/api/resources/components/AsyncRawComponentsClient.java new file mode 100644 index 0000000..f64e026 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/components/AsyncRawComponentsClient.java @@ -0,0 +1,689 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.components; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.components.requests.CountComponentsRequest; +import com.schematic.api.resources.components.requests.CreateComponentRequestBody; +import com.schematic.api.resources.components.requests.ListComponentsRequest; +import com.schematic.api.resources.components.requests.PreviewComponentDataRequest; +import com.schematic.api.resources.components.requests.UpdateComponentRequestBody; +import com.schematic.api.resources.components.types.CountComponentsResponse; +import com.schematic.api.resources.components.types.CreateComponentResponse; +import com.schematic.api.resources.components.types.DeleteComponentResponse; +import com.schematic.api.resources.components.types.GetComponentResponse; +import com.schematic.api.resources.components.types.ListComponentsResponse; +import com.schematic.api.resources.components.types.PreviewComponentDataResponse; +import com.schematic.api.resources.components.types.UpdateComponentResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawComponentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawComponentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> listComponents() { + return listComponents(ListComponentsRequest.builder().build()); + } + + public CompletableFuture> listComponents( + ListComponentsRequest request) { + return listComponents(request, null); + } + + public CompletableFuture> listComponents( + ListComponentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListComponentsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createComponent( + CreateComponentRequestBody request) { + return createComponent(request, null); + } + + public CompletableFuture> createComponent( + CreateComponentRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateComponentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getComponent(String componentId) { + return getComponent(componentId, null); + } + + public CompletableFuture> getComponent( + String componentId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components") + .addPathSegment(componentId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateComponent(String componentId) { + return updateComponent(componentId, UpdateComponentRequestBody.builder().build()); + } + + public CompletableFuture> updateComponent( + String componentId, UpdateComponentRequestBody request) { + return updateComponent(componentId, request, null); + } + + public CompletableFuture> updateComponent( + String componentId, UpdateComponentRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components") + .addPathSegment(componentId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateComponentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteComponent(String componentId) { + return deleteComponent(componentId, null); + } + + public CompletableFuture> deleteComponent( + String componentId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components") + .addPathSegment(componentId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteComponentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countComponents() { + return countComponents(CountComponentsRequest.builder().build()); + } + + public CompletableFuture> countComponents( + CountComponentsRequest request) { + return countComponents(request, null); + } + + public CompletableFuture> countComponents( + CountComponentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountComponentsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> previewComponentData() { + return previewComponentData(PreviewComponentDataRequest.builder().build()); + } + + public CompletableFuture> previewComponentData( + PreviewComponentDataRequest request) { + return previewComponentData(request, null); + } + + public CompletableFuture> previewComponentData( + PreviewComponentDataRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components/preview-data"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getComponentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "component_id", request.getComponentId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PreviewComponentDataResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/components/ComponentsClient.java b/src/main/java/com/schematic/api/resources/components/ComponentsClient.java index 8984543..4710500 100644 --- a/src/main/java/com/schematic/api/resources/components/ComponentsClient.java +++ b/src/main/java/com/schematic/api/resources/components/ComponentsClient.java @@ -3,18 +3,8 @@ */ package com.schematic.api.resources.components; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.NotFoundError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.components.requests.CountComponentsRequest; import com.schematic.api.resources.components.requests.CreateComponentRequestBody; import com.schematic.api.resources.components.requests.ListComponentsRequest; @@ -27,450 +17,97 @@ import com.schematic.api.resources.components.types.ListComponentsResponse; import com.schematic.api.resources.components.types.PreviewComponentDataResponse; import com.schematic.api.resources.components.types.UpdateComponentResponse; -import com.schematic.api.types.ApiError; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ComponentsClient { protected final ClientOptions clientOptions; + private final RawComponentsClient rawClient; + public ComponentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawComponentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawComponentsClient withRawResponse() { + return this.rawClient; } public ListComponentsResponse listComponents() { - return listComponents(ListComponentsRequest.builder().build()); + return this.rawClient.listComponents().body(); } public ListComponentsResponse listComponents(ListComponentsRequest request) { - return listComponents(request, null); + return this.rawClient.listComponents(request).body(); } public ListComponentsResponse listComponents(ListComponentsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("components"); - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListComponentsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listComponents(request, requestOptions).body(); } public CreateComponentResponse createComponent(CreateComponentRequestBody request) { - return createComponent(request, null); + return this.rawClient.createComponent(request).body(); } public CreateComponentResponse createComponent(CreateComponentRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("components") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateComponentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.createComponent(request, requestOptions).body(); } public GetComponentResponse getComponent(String componentId) { - return getComponent(componentId, null); + return this.rawClient.getComponent(componentId).body(); } public GetComponentResponse getComponent(String componentId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("components") - .addPathSegment(componentId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getComponent(componentId, requestOptions).body(); } public UpdateComponentResponse updateComponent(String componentId) { - return updateComponent(componentId, UpdateComponentRequestBody.builder().build()); + return this.rawClient.updateComponent(componentId).body(); } public UpdateComponentResponse updateComponent(String componentId, UpdateComponentRequestBody request) { - return updateComponent(componentId, request, null); + return this.rawClient.updateComponent(componentId, request).body(); } public UpdateComponentResponse updateComponent( String componentId, UpdateComponentRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("components") - .addPathSegment(componentId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateComponentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient + .updateComponent(componentId, request, requestOptions) + .body(); } public DeleteComponentResponse deleteComponent(String componentId) { - return deleteComponent(componentId, null); + return this.rawClient.deleteComponent(componentId).body(); } public DeleteComponentResponse deleteComponent(String componentId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("components") - .addPathSegment(componentId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteComponentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.deleteComponent(componentId, requestOptions).body(); } public CountComponentsResponse countComponents() { - return countComponents(CountComponentsRequest.builder().build()); + return this.rawClient.countComponents().body(); } public CountComponentsResponse countComponents(CountComponentsRequest request) { - return countComponents(request, null); + return this.rawClient.countComponents(request).body(); } public CountComponentsResponse countComponents(CountComponentsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("components/count"); - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountComponentsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.countComponents(request, requestOptions).body(); } public PreviewComponentDataResponse previewComponentData() { - return previewComponentData(PreviewComponentDataRequest.builder().build()); + return this.rawClient.previewComponentData().body(); } public PreviewComponentDataResponse previewComponentData(PreviewComponentDataRequest request) { - return previewComponentData(request, null); + return this.rawClient.previewComponentData(request).body(); } public PreviewComponentDataResponse previewComponentData( PreviewComponentDataRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("components/preview-data"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getComponentId().isPresent()) { - httpUrl.addQueryParameter("component_id", request.getComponentId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PreviewComponentDataResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.previewComponentData(request, requestOptions).body(); } } diff --git a/src/main/java/com/schematic/api/resources/components/RawComponentsClient.java b/src/main/java/com/schematic/api/resources/components/RawComponentsClient.java new file mode 100644 index 0000000..c1f1249 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/components/RawComponentsClient.java @@ -0,0 +1,519 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.components; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.components.requests.CountComponentsRequest; +import com.schematic.api.resources.components.requests.CreateComponentRequestBody; +import com.schematic.api.resources.components.requests.ListComponentsRequest; +import com.schematic.api.resources.components.requests.PreviewComponentDataRequest; +import com.schematic.api.resources.components.requests.UpdateComponentRequestBody; +import com.schematic.api.resources.components.types.CountComponentsResponse; +import com.schematic.api.resources.components.types.CreateComponentResponse; +import com.schematic.api.resources.components.types.DeleteComponentResponse; +import com.schematic.api.resources.components.types.GetComponentResponse; +import com.schematic.api.resources.components.types.ListComponentsResponse; +import com.schematic.api.resources.components.types.PreviewComponentDataResponse; +import com.schematic.api.resources.components.types.UpdateComponentResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawComponentsClient { + protected final ClientOptions clientOptions; + + public RawComponentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse listComponents() { + return listComponents(ListComponentsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listComponents(ListComponentsRequest request) { + return listComponents(request, null); + } + + public BaseSchematicHttpResponse listComponents( + ListComponentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListComponentsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createComponent(CreateComponentRequestBody request) { + return createComponent(request, null); + } + + public BaseSchematicHttpResponse createComponent( + CreateComponentRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateComponentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getComponent(String componentId) { + return getComponent(componentId, null); + } + + public BaseSchematicHttpResponse getComponent( + String componentId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components") + .addPathSegment(componentId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetComponentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateComponent(String componentId) { + return updateComponent(componentId, UpdateComponentRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse updateComponent( + String componentId, UpdateComponentRequestBody request) { + return updateComponent(componentId, request, null); + } + + public BaseSchematicHttpResponse updateComponent( + String componentId, UpdateComponentRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components") + .addPathSegment(componentId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateComponentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteComponent(String componentId) { + return deleteComponent(componentId, null); + } + + public BaseSchematicHttpResponse deleteComponent( + String componentId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components") + .addPathSegment(componentId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteComponentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countComponents() { + return countComponents(CountComponentsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countComponents(CountComponentsRequest request) { + return countComponents(request, null); + } + + public BaseSchematicHttpResponse countComponents( + CountComponentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountComponentsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse previewComponentData() { + return previewComponentData(PreviewComponentDataRequest.builder().build()); + } + + public BaseSchematicHttpResponse previewComponentData( + PreviewComponentDataRequest request) { + return previewComponentData(request, null); + } + + public BaseSchematicHttpResponse previewComponentData( + PreviewComponentDataRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("components/preview-data"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getComponentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "component_id", request.getComponentId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PreviewComponentDataResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/components/requests/CountComponentsRequest.java b/src/main/java/com/schematic/api/resources/components/requests/CountComponentsRequest.java index c736360..4c4ffdb 100644 --- a/src/main/java/com/schematic/api/resources/components/requests/CountComponentsRequest.java +++ b/src/main/java/com/schematic/api/resources/components/requests/CountComponentsRequest.java @@ -120,6 +120,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -131,6 +134,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/components/requests/ListComponentsRequest.java b/src/main/java/com/schematic/api/resources/components/requests/ListComponentsRequest.java index ff2ecdd..a3dde72 100644 --- a/src/main/java/com/schematic/api/resources/components/requests/ListComponentsRequest.java +++ b/src/main/java/com/schematic/api/resources/components/requests/ListComponentsRequest.java @@ -120,6 +120,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -131,6 +134,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/components/types/CountComponentsParams.java b/src/main/java/com/schematic/api/resources/components/types/CountComponentsParams.java index 5660c98..cf846a7 100644 --- a/src/main/java/com/schematic/api/resources/components/types/CountComponentsParams.java +++ b/src/main/java/com/schematic/api/resources/components/types/CountComponentsParams.java @@ -109,6 +109,9 @@ public Builder from(CountComponentsParams other) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -120,6 +123,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/components/types/CountComponentsResponse.java b/src/main/java/com/schematic/api/resources/components/types/CountComponentsResponse.java index d52a63e..3c0b122 100644 --- a/src/main/java/com/schematic/api/resources/components/types/CountComponentsResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/CountComponentsResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountComponentsParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/components/types/CreateComponentRequestBodyEntityType.java b/src/main/java/com/schematic/api/resources/components/types/CreateComponentRequestBodyEntityType.java index 29e1a12..b69f0b7 100644 --- a/src/main/java/com/schematic/api/resources/components/types/CreateComponentRequestBodyEntityType.java +++ b/src/main/java/com/schematic/api/resources/components/types/CreateComponentRequestBodyEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.components.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateComponentRequestBodyEntityType { - ENTITLEMENT("entitlement"), +public final class CreateComponentRequestBodyEntityType { + public static final CreateComponentRequestBodyEntityType BILLING = + new CreateComponentRequestBodyEntityType(Value.BILLING, "billing"); - BILLING("billing"); + public static final CreateComponentRequestBodyEntityType ENTITLEMENT = + new CreateComponentRequestBodyEntityType(Value.ENTITLEMENT, "entitlement"); - private final String value; + private final Value value; - CreateComponentRequestBodyEntityType(String value) { + private final String string; + + CreateComponentRequestBodyEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateComponentRequestBodyEntityType + && this.string.equals(((CreateComponentRequestBodyEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BILLING: + return visitor.visitBilling(); + case ENTITLEMENT: + return visitor.visitEntitlement(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateComponentRequestBodyEntityType valueOf(String value) { + switch (value) { + case "billing": + return BILLING; + case "entitlement": + return ENTITLEMENT; + default: + return new CreateComponentRequestBodyEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + ENTITLEMENT, + + BILLING, + + UNKNOWN + } + + public interface Visitor { + T visitEntitlement(); + + T visitBilling(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/components/types/CreateComponentResponse.java b/src/main/java/com/schematic/api/resources/components/types/CreateComponentResponse.java index c7d45b3..4252eab 100644 --- a/src/main/java/com/schematic/api/resources/components/types/CreateComponentResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/CreateComponentResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateComponentResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/components/types/DeleteComponentResponse.java b/src/main/java/com/schematic/api/resources/components/types/DeleteComponentResponse.java index 220dfd4..c059941 100644 --- a/src/main/java/com/schematic/api/resources/components/types/DeleteComponentResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/DeleteComponentResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteComponentResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/components/types/GetComponentResponse.java b/src/main/java/com/schematic/api/resources/components/types/GetComponentResponse.java index 19d2baf..89a859d 100644 --- a/src/main/java/com/schematic/api/resources/components/types/GetComponentResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/GetComponentResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetComponentResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/components/types/ListComponentsParams.java b/src/main/java/com/schematic/api/resources/components/types/ListComponentsParams.java index b002f50..60132f1 100644 --- a/src/main/java/com/schematic/api/resources/components/types/ListComponentsParams.java +++ b/src/main/java/com/schematic/api/resources/components/types/ListComponentsParams.java @@ -109,6 +109,9 @@ public Builder from(ListComponentsParams other) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -120,6 +123,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/components/types/ListComponentsResponse.java b/src/main/java/com/schematic/api/resources/components/types/ListComponentsResponse.java index 3d0a562..8b69d69 100644 --- a/src/main/java/com/schematic/api/resources/components/types/ListComponentsResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/ListComponentsResponse.java @@ -36,9 +36,6 @@ private ListComponentsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListComponentsParams params); Builder from(ListComponentsResponse other); @@ -116,6 +116,7 @@ public Builder from(ListComponentsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListComponentsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(ComponentResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(ComponentResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/components/types/PreviewComponentDataResponse.java b/src/main/java/com/schematic/api/resources/components/types/PreviewComponentDataResponse.java index b627c35..4e404c3 100644 --- a/src/main/java/com/schematic/api/resources/components/types/PreviewComponentDataResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/PreviewComponentDataResponse.java @@ -84,6 +84,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull PreviewComponentDataParams params); } @@ -117,6 +120,7 @@ public ParamsStage data(@NotNull ComponentPreviewResponseData data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/components/types/UpdateComponentRequestBodyEntityType.java b/src/main/java/com/schematic/api/resources/components/types/UpdateComponentRequestBodyEntityType.java index a2d42b0..0a18ff0 100644 --- a/src/main/java/com/schematic/api/resources/components/types/UpdateComponentRequestBodyEntityType.java +++ b/src/main/java/com/schematic/api/resources/components/types/UpdateComponentRequestBodyEntityType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.components.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateComponentRequestBodyEntityType { - ENTITLEMENT("entitlement"), +public final class UpdateComponentRequestBodyEntityType { + public static final UpdateComponentRequestBodyEntityType BILLING = + new UpdateComponentRequestBodyEntityType(Value.BILLING, "billing"); - BILLING("billing"); + public static final UpdateComponentRequestBodyEntityType ENTITLEMENT = + new UpdateComponentRequestBodyEntityType(Value.ENTITLEMENT, "entitlement"); - private final String value; + private final Value value; - UpdateComponentRequestBodyEntityType(String value) { + private final String string; + + UpdateComponentRequestBodyEntityType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateComponentRequestBodyEntityType + && this.string.equals(((UpdateComponentRequestBodyEntityType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BILLING: + return visitor.visitBilling(); + case ENTITLEMENT: + return visitor.visitEntitlement(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateComponentRequestBodyEntityType valueOf(String value) { + switch (value) { + case "billing": + return BILLING; + case "entitlement": + return ENTITLEMENT; + default: + return new UpdateComponentRequestBodyEntityType(Value.UNKNOWN, value); + } + } + + public enum Value { + ENTITLEMENT, + + BILLING, + + UNKNOWN + } + + public interface Visitor { + T visitEntitlement(); + + T visitBilling(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/components/types/UpdateComponentRequestBodyState.java b/src/main/java/com/schematic/api/resources/components/types/UpdateComponentRequestBodyState.java index 835a009..497e268 100644 --- a/src/main/java/com/schematic/api/resources/components/types/UpdateComponentRequestBodyState.java +++ b/src/main/java/com/schematic/api/resources/components/types/UpdateComponentRequestBodyState.java @@ -3,22 +3,83 @@ */ package com.schematic.api.resources.components.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateComponentRequestBodyState { - DRAFT("draft"), +public final class UpdateComponentRequestBodyState { + public static final UpdateComponentRequestBodyState LIVE = new UpdateComponentRequestBodyState(Value.LIVE, "live"); - LIVE("live"); + public static final UpdateComponentRequestBodyState DRAFT = + new UpdateComponentRequestBodyState(Value.DRAFT, "draft"); - private final String value; + private final Value value; - UpdateComponentRequestBodyState(String value) { + private final String string; + + UpdateComponentRequestBodyState(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateComponentRequestBodyState + && this.string.equals(((UpdateComponentRequestBodyState) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case LIVE: + return visitor.visitLive(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateComponentRequestBodyState valueOf(String value) { + switch (value) { + case "live": + return LIVE; + case "draft": + return DRAFT; + default: + return new UpdateComponentRequestBodyState(Value.UNKNOWN, value); + } + } + + public enum Value { + DRAFT, + + LIVE, + + UNKNOWN + } + + public interface Visitor { + T visitDraft(); + + T visitLive(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/components/types/UpdateComponentResponse.java b/src/main/java/com/schematic/api/resources/components/types/UpdateComponentResponse.java index 45002ca..e53a3d3 100644 --- a/src/main/java/com/schematic/api/resources/components/types/UpdateComponentResponse.java +++ b/src/main/java/com/schematic/api/resources/components/types/UpdateComponentResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateComponentResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/credits/AsyncCreditsClient.java b/src/main/java/com/schematic/api/resources/credits/AsyncCreditsClient.java new file mode 100644 index 0000000..1d38656 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/AsyncCreditsClient.java @@ -0,0 +1,335 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; +import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.CountCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.CreateBillingPlanCreditGrantRequestBody; +import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; +import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; +import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; +import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; +import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; +import com.schematic.api.resources.credits.types.CountCreditLedgerResponse; +import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; +import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; +import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; +import com.schematic.api.resources.credits.types.ListBillingCreditsResponse; +import com.schematic.api.resources.credits.types.ListBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; +import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; +import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncCreditsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCreditsClient rawClient; + + public AsyncCreditsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCreditsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCreditsClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture listBillingCredits() { + return this.rawClient.listBillingCredits().thenApply(response -> response.body()); + } + + public CompletableFuture listBillingCredits(ListBillingCreditsRequest request) { + return this.rawClient.listBillingCredits(request).thenApply(response -> response.body()); + } + + public CompletableFuture listBillingCredits( + ListBillingCreditsRequest request, RequestOptions requestOptions) { + return this.rawClient.listBillingCredits(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createBillingCredit(CreateBillingCreditRequestBody request) { + return this.rawClient.createBillingCredit(request).thenApply(response -> response.body()); + } + + public CompletableFuture createBillingCredit( + CreateBillingCreditRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createBillingCredit(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getSingleBillingCredit(String creditId) { + return this.rawClient.getSingleBillingCredit(creditId).thenApply(response -> response.body()); + } + + public CompletableFuture getSingleBillingCredit( + String creditId, RequestOptions requestOptions) { + return this.rawClient.getSingleBillingCredit(creditId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateBillingCredit( + String creditId, UpdateBillingCreditRequestBody request) { + return this.rawClient.updateBillingCredit(creditId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateBillingCredit( + String creditId, UpdateBillingCreditRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateBillingCredit(creditId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture softDeleteBillingCredit(String creditId) { + return this.rawClient.softDeleteBillingCredit(creditId).thenApply(response -> response.body()); + } + + public CompletableFuture softDeleteBillingCredit( + String creditId, RequestOptions requestOptions) { + return this.rawClient.softDeleteBillingCredit(creditId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listCreditBundles() { + return this.rawClient.listCreditBundles().thenApply(response -> response.body()); + } + + public CompletableFuture listCreditBundles(ListCreditBundlesRequest request) { + return this.rawClient.listCreditBundles(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCreditBundles( + ListCreditBundlesRequest request, RequestOptions requestOptions) { + return this.rawClient.listCreditBundles(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createCreditBundle(CreateCreditBundleRequestBody request) { + return this.rawClient.createCreditBundle(request).thenApply(response -> response.body()); + } + + public CompletableFuture createCreditBundle( + CreateCreditBundleRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createCreditBundle(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getCreditBundle(String bundleId) { + return this.rawClient.getCreditBundle(bundleId).thenApply(response -> response.body()); + } + + public CompletableFuture getCreditBundle(String bundleId, RequestOptions requestOptions) { + return this.rawClient.getCreditBundle(bundleId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateCreditBundleDetails( + String bundleId, UpdateCreditBundleDetailsRequestBody request) { + return this.rawClient.updateCreditBundleDetails(bundleId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateCreditBundleDetails( + String bundleId, UpdateCreditBundleDetailsRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCreditBundleDetails(bundleId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deleteCreditBundle(String bundleId) { + return this.rawClient.deleteCreditBundle(bundleId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteCreditBundle( + String bundleId, RequestOptions requestOptions) { + return this.rawClient.deleteCreditBundle(bundleId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countCreditBundles() { + return this.rawClient.countCreditBundles().thenApply(response -> response.body()); + } + + public CompletableFuture countCreditBundles(CountCreditBundlesRequest request) { + return this.rawClient.countCreditBundles(request).thenApply(response -> response.body()); + } + + public CompletableFuture countCreditBundles( + CountCreditBundlesRequest request, RequestOptions requestOptions) { + return this.rawClient.countCreditBundles(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countBillingCredits() { + return this.rawClient.countBillingCredits().thenApply(response -> response.body()); + } + + public CompletableFuture countBillingCredits(CountBillingCreditsRequest request) { + return this.rawClient.countBillingCredits(request).thenApply(response -> response.body()); + } + + public CompletableFuture countBillingCredits( + CountBillingCreditsRequest request, RequestOptions requestOptions) { + return this.rawClient.countBillingCredits(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture zeroOutGrant(String grantId) { + return this.rawClient.zeroOutGrant(grantId).thenApply(response -> response.body()); + } + + public CompletableFuture zeroOutGrant(String grantId, ZeroOutGrantRequestBody request) { + return this.rawClient.zeroOutGrant(grantId, request).thenApply(response -> response.body()); + } + + public CompletableFuture zeroOutGrant( + String grantId, ZeroOutGrantRequestBody request, RequestOptions requestOptions) { + return this.rawClient.zeroOutGrant(grantId, request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture grantBillingCreditsToCompany( + CreateCompanyCreditGrant request) { + return this.rawClient.grantBillingCreditsToCompany(request).thenApply(response -> response.body()); + } + + public CompletableFuture grantBillingCreditsToCompany( + CreateCompanyCreditGrant request, RequestOptions requestOptions) { + return this.rawClient + .grantBillingCreditsToCompany(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyGrants() { + return this.rawClient.listCompanyGrants().thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyGrants(ListCompanyGrantsRequest request) { + return this.rawClient.listCompanyGrants(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyGrants( + ListCompanyGrantsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCompanyGrants(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countBillingCreditsGrants() { + return this.rawClient.countBillingCreditsGrants().thenApply(response -> response.body()); + } + + public CompletableFuture countBillingCreditsGrants( + CountBillingCreditsGrantsRequest request) { + return this.rawClient.countBillingCreditsGrants(request).thenApply(response -> response.body()); + } + + public CompletableFuture countBillingCreditsGrants( + CountBillingCreditsGrantsRequest request, RequestOptions requestOptions) { + return this.rawClient.countBillingCreditsGrants(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listGrantsForCredit() { + return this.rawClient.listGrantsForCredit().thenApply(response -> response.body()); + } + + public CompletableFuture listGrantsForCredit(ListGrantsForCreditRequest request) { + return this.rawClient.listGrantsForCredit(request).thenApply(response -> response.body()); + } + + public CompletableFuture listGrantsForCredit( + ListGrantsForCreditRequest request, RequestOptions requestOptions) { + return this.rawClient.listGrantsForCredit(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getEnrichedCreditLedger( + GetEnrichedCreditLedgerRequest request) { + return this.rawClient.getEnrichedCreditLedger(request).thenApply(response -> response.body()); + } + + public CompletableFuture getEnrichedCreditLedger( + GetEnrichedCreditLedgerRequest request, RequestOptions requestOptions) { + return this.rawClient.getEnrichedCreditLedger(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countCreditLedger(CountCreditLedgerRequest request) { + return this.rawClient.countCreditLedger(request).thenApply(response -> response.body()); + } + + public CompletableFuture countCreditLedger( + CountCreditLedgerRequest request, RequestOptions requestOptions) { + return this.rawClient.countCreditLedger(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listBillingPlanCreditGrants() { + return this.rawClient.listBillingPlanCreditGrants().thenApply(response -> response.body()); + } + + public CompletableFuture listBillingPlanCreditGrants( + ListBillingPlanCreditGrantsRequest request) { + return this.rawClient.listBillingPlanCreditGrants(request).thenApply(response -> response.body()); + } + + public CompletableFuture listBillingPlanCreditGrants( + ListBillingPlanCreditGrantsRequest request, RequestOptions requestOptions) { + return this.rawClient + .listBillingPlanCreditGrants(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture createBillingPlanCreditGrant( + CreateBillingPlanCreditGrantRequestBody request) { + return this.rawClient.createBillingPlanCreditGrant(request).thenApply(response -> response.body()); + } + + public CompletableFuture createBillingPlanCreditGrant( + CreateBillingPlanCreditGrantRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .createBillingPlanCreditGrant(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deleteBillingPlanCreditGrant(String planGrantId) { + return this.rawClient.deleteBillingPlanCreditGrant(planGrantId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteBillingPlanCreditGrant( + String planGrantId, RequestOptions requestOptions) { + return this.rawClient + .deleteBillingPlanCreditGrant(planGrantId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture countBillingPlanCreditGrants() { + return this.rawClient.countBillingPlanCreditGrants().thenApply(response -> response.body()); + } + + public CompletableFuture countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest request) { + return this.rawClient.countBillingPlanCreditGrants(request).thenApply(response -> response.body()); + } + + public CompletableFuture countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest request, RequestOptions requestOptions) { + return this.rawClient + .countBillingPlanCreditGrants(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java b/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java new file mode 100644 index 0000000..cd6c911 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/AsyncRawCreditsClient.java @@ -0,0 +1,2333 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; +import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.CountCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.CreateBillingPlanCreditGrantRequestBody; +import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; +import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; +import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; +import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; +import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; +import com.schematic.api.resources.credits.types.CountCreditLedgerResponse; +import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; +import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; +import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; +import com.schematic.api.resources.credits.types.ListBillingCreditsResponse; +import com.schematic.api.resources.credits.types.ListBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; +import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; +import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCreditsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCreditsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> listBillingCredits() { + return listBillingCredits(ListBillingCreditsRequest.builder().build()); + } + + public CompletableFuture> listBillingCredits( + ListBillingCreditsRequest request) { + return listBillingCredits(request, null); + } + + public CompletableFuture> listBillingCredits( + ListBillingCreditsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListBillingCreditsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createBillingCredit( + CreateBillingCreditRequestBody request) { + return createBillingCredit(request, null); + } + + public CompletableFuture> createBillingCredit( + CreateBillingCreditRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateBillingCreditResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getSingleBillingCredit( + String creditId) { + return getSingleBillingCredit(creditId, null); + } + + public CompletableFuture> getSingleBillingCredit( + String creditId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits") + .addPathSegment(creditId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetSingleBillingCreditResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateBillingCredit( + String creditId, UpdateBillingCreditRequestBody request) { + return updateBillingCredit(creditId, request, null); + } + + public CompletableFuture> updateBillingCredit( + String creditId, UpdateBillingCreditRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits") + .addPathSegment(creditId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateBillingCreditResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> softDeleteBillingCredit( + String creditId) { + return softDeleteBillingCredit(creditId, null); + } + + public CompletableFuture> softDeleteBillingCredit( + String creditId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits") + .addPathSegment(creditId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SoftDeleteBillingCreditResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listCreditBundles() { + return listCreditBundles(ListCreditBundlesRequest.builder().build()); + } + + public CompletableFuture> listCreditBundles( + ListCreditBundlesRequest request) { + return listCreditBundles(request, null); + } + + public CompletableFuture> listCreditBundles( + ListCreditBundlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getBundleType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "bundle_type", request.getBundleType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCreditBundlesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createCreditBundle( + CreateCreditBundleRequestBody request) { + return createCreditBundle(request, null); + } + + public CompletableFuture> createCreditBundle( + CreateCreditBundleRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateCreditBundleResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getCreditBundle(String bundleId) { + return getCreditBundle(bundleId, null); + } + + public CompletableFuture> getCreditBundle( + String bundleId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles") + .addPathSegment(bundleId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetCreditBundleResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateCreditBundleDetails( + String bundleId, UpdateCreditBundleDetailsRequestBody request) { + return updateCreditBundleDetails(bundleId, request, null); + } + + public CompletableFuture> updateCreditBundleDetails( + String bundleId, UpdateCreditBundleDetailsRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles") + .addPathSegment(bundleId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateCreditBundleDetailsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteCreditBundle( + String bundleId) { + return deleteCreditBundle(bundleId, null); + } + + public CompletableFuture> deleteCreditBundle( + String bundleId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles") + .addPathSegment(bundleId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteCreditBundleResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countCreditBundles() { + return countCreditBundles(CountCreditBundlesRequest.builder().build()); + } + + public CompletableFuture> countCreditBundles( + CountCreditBundlesRequest request) { + return countCreditBundles(request, null); + } + + public CompletableFuture> countCreditBundles( + CountCreditBundlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles/count"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getBundleType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "bundle_type", request.getBundleType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountCreditBundlesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countBillingCredits() { + return countBillingCredits(CountBillingCreditsRequest.builder().build()); + } + + public CompletableFuture> countBillingCredits( + CountBillingCreditsRequest request) { + return countBillingCredits(request, null); + } + + public CompletableFuture> countBillingCredits( + CountBillingCreditsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/count"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountBillingCreditsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> zeroOutGrant(String grantId) { + return zeroOutGrant(grantId, ZeroOutGrantRequestBody.builder().build()); + } + + public CompletableFuture> zeroOutGrant( + String grantId, ZeroOutGrantRequestBody request) { + return zeroOutGrant(grantId, request, null); + } + + public CompletableFuture> zeroOutGrant( + String grantId, ZeroOutGrantRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants") + .addPathSegment(grantId) + .addPathSegments("zero-out") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ZeroOutGrantResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + grantBillingCreditsToCompany(CreateCompanyCreditGrant request) { + return grantBillingCreditsToCompany(request, null); + } + + public CompletableFuture> + grantBillingCreditsToCompany(CreateCompanyCreditGrant request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants/company") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GrantBillingCreditsToCompanyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listCompanyGrants() { + return listCompanyGrants(ListCompanyGrantsRequest.builder().build()); + } + + public CompletableFuture> listCompanyGrants( + ListCompanyGrantsRequest request) { + return listCompanyGrants(request, null); + } + + public CompletableFuture> listCompanyGrants( + ListCompanyGrantsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants/company/list"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getOrder().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order", request.getOrder().get(), false); + } + if (request.getDir().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "dir", request.getDir().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCompanyGrantsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countBillingCreditsGrants() { + return countBillingCreditsGrants( + CountBillingCreditsGrantsRequest.builder().build()); + } + + public CompletableFuture> countBillingCreditsGrants( + CountBillingCreditsGrantsRequest request) { + return countBillingCreditsGrants(request, null); + } + + public CompletableFuture> countBillingCreditsGrants( + CountBillingCreditsGrantsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants/count"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountBillingCreditsGrantsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listGrantsForCredit() { + return listGrantsForCredit(ListGrantsForCreditRequest.builder().build()); + } + + public CompletableFuture> listGrantsForCredit( + ListGrantsForCreditRequest request) { + return listGrantsForCredit(request, null); + } + + public CompletableFuture> listGrantsForCredit( + ListGrantsForCreditRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants/list"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListGrantsForCreditResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getEnrichedCreditLedger( + GetEnrichedCreditLedgerRequest request) { + return getEnrichedCreditLedger(request, null); + } + + public CompletableFuture> getEnrichedCreditLedger( + GetEnrichedCreditLedgerRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/ledger"); + QueryStringMapper.addQueryParameter(httpUrl, "company_id", request.getCompanyId(), false); + if (request.getBillingCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "billing_credit_id", request.getBillingCreditId().get(), false); + } + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "period", request.getPeriod(), false); + if (request.getStartTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_time", request.getStartTime().get(), false); + } + if (request.getEndTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_time", request.getEndTime().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetEnrichedCreditLedgerResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countCreditLedger( + CountCreditLedgerRequest request) { + return countCreditLedger(request, null); + } + + public CompletableFuture> countCreditLedger( + CountCreditLedgerRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/ledger/count"); + QueryStringMapper.addQueryParameter(httpUrl, "company_id", request.getCompanyId(), false); + if (request.getBillingCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "billing_credit_id", request.getBillingCreditId().get(), false); + } + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "period", request.getPeriod(), false); + if (request.getStartTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_time", request.getStartTime().get(), false); + } + if (request.getEndTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_time", request.getEndTime().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountCreditLedgerResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + listBillingPlanCreditGrants() { + return listBillingPlanCreditGrants( + ListBillingPlanCreditGrantsRequest.builder().build()); + } + + public CompletableFuture> + listBillingPlanCreditGrants(ListBillingPlanCreditGrantsRequest request) { + return listBillingPlanCreditGrants(request, null); + } + + public CompletableFuture> + listBillingPlanCreditGrants(ListBillingPlanCreditGrantsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/plan-grants"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListBillingPlanCreditGrantsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + createBillingPlanCreditGrant(CreateBillingPlanCreditGrantRequestBody request) { + return createBillingPlanCreditGrant(request, null); + } + + public CompletableFuture> + createBillingPlanCreditGrant( + CreateBillingPlanCreditGrantRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/plan-grants") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateBillingPlanCreditGrantResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + deleteBillingPlanCreditGrant(String planGrantId) { + return deleteBillingPlanCreditGrant(planGrantId, null); + } + + public CompletableFuture> + deleteBillingPlanCreditGrant(String planGrantId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/plan-grants") + .addPathSegment(planGrantId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteBillingPlanCreditGrantResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + countBillingPlanCreditGrants() { + return countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest.builder().build()); + } + + public CompletableFuture> + countBillingPlanCreditGrants(CountBillingPlanCreditGrantsRequest request) { + return countBillingPlanCreditGrants(request, null); + } + + public CompletableFuture> + countBillingPlanCreditGrants(CountBillingPlanCreditGrantsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/plan-grants/count"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountBillingPlanCreditGrantsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/CreditsClient.java b/src/main/java/com/schematic/api/resources/credits/CreditsClient.java new file mode 100644 index 0000000..7eabd90 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/CreditsClient.java @@ -0,0 +1,326 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; +import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.CountCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.CreateBillingPlanCreditGrantRequestBody; +import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; +import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; +import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; +import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; +import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; +import com.schematic.api.resources.credits.types.CountCreditLedgerResponse; +import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; +import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; +import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; +import com.schematic.api.resources.credits.types.ListBillingCreditsResponse; +import com.schematic.api.resources.credits.types.ListBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; +import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; +import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; + +public class CreditsClient { + protected final ClientOptions clientOptions; + + private final RawCreditsClient rawClient; + + public CreditsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCreditsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCreditsClient withRawResponse() { + return this.rawClient; + } + + public ListBillingCreditsResponse listBillingCredits() { + return this.rawClient.listBillingCredits().body(); + } + + public ListBillingCreditsResponse listBillingCredits(ListBillingCreditsRequest request) { + return this.rawClient.listBillingCredits(request).body(); + } + + public ListBillingCreditsResponse listBillingCredits( + ListBillingCreditsRequest request, RequestOptions requestOptions) { + return this.rawClient.listBillingCredits(request, requestOptions).body(); + } + + public CreateBillingCreditResponse createBillingCredit(CreateBillingCreditRequestBody request) { + return this.rawClient.createBillingCredit(request).body(); + } + + public CreateBillingCreditResponse createBillingCredit( + CreateBillingCreditRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createBillingCredit(request, requestOptions).body(); + } + + public GetSingleBillingCreditResponse getSingleBillingCredit(String creditId) { + return this.rawClient.getSingleBillingCredit(creditId).body(); + } + + public GetSingleBillingCreditResponse getSingleBillingCredit(String creditId, RequestOptions requestOptions) { + return this.rawClient.getSingleBillingCredit(creditId, requestOptions).body(); + } + + public UpdateBillingCreditResponse updateBillingCredit(String creditId, UpdateBillingCreditRequestBody request) { + return this.rawClient.updateBillingCredit(creditId, request).body(); + } + + public UpdateBillingCreditResponse updateBillingCredit( + String creditId, UpdateBillingCreditRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateBillingCredit(creditId, request, requestOptions) + .body(); + } + + public SoftDeleteBillingCreditResponse softDeleteBillingCredit(String creditId) { + return this.rawClient.softDeleteBillingCredit(creditId).body(); + } + + public SoftDeleteBillingCreditResponse softDeleteBillingCredit(String creditId, RequestOptions requestOptions) { + return this.rawClient.softDeleteBillingCredit(creditId, requestOptions).body(); + } + + public ListCreditBundlesResponse listCreditBundles() { + return this.rawClient.listCreditBundles().body(); + } + + public ListCreditBundlesResponse listCreditBundles(ListCreditBundlesRequest request) { + return this.rawClient.listCreditBundles(request).body(); + } + + public ListCreditBundlesResponse listCreditBundles( + ListCreditBundlesRequest request, RequestOptions requestOptions) { + return this.rawClient.listCreditBundles(request, requestOptions).body(); + } + + public CreateCreditBundleResponse createCreditBundle(CreateCreditBundleRequestBody request) { + return this.rawClient.createCreditBundle(request).body(); + } + + public CreateCreditBundleResponse createCreditBundle( + CreateCreditBundleRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createCreditBundle(request, requestOptions).body(); + } + + public GetCreditBundleResponse getCreditBundle(String bundleId) { + return this.rawClient.getCreditBundle(bundleId).body(); + } + + public GetCreditBundleResponse getCreditBundle(String bundleId, RequestOptions requestOptions) { + return this.rawClient.getCreditBundle(bundleId, requestOptions).body(); + } + + public UpdateCreditBundleDetailsResponse updateCreditBundleDetails( + String bundleId, UpdateCreditBundleDetailsRequestBody request) { + return this.rawClient.updateCreditBundleDetails(bundleId, request).body(); + } + + public UpdateCreditBundleDetailsResponse updateCreditBundleDetails( + String bundleId, UpdateCreditBundleDetailsRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCreditBundleDetails(bundleId, request, requestOptions) + .body(); + } + + public DeleteCreditBundleResponse deleteCreditBundle(String bundleId) { + return this.rawClient.deleteCreditBundle(bundleId).body(); + } + + public DeleteCreditBundleResponse deleteCreditBundle(String bundleId, RequestOptions requestOptions) { + return this.rawClient.deleteCreditBundle(bundleId, requestOptions).body(); + } + + public CountCreditBundlesResponse countCreditBundles() { + return this.rawClient.countCreditBundles().body(); + } + + public CountCreditBundlesResponse countCreditBundles(CountCreditBundlesRequest request) { + return this.rawClient.countCreditBundles(request).body(); + } + + public CountCreditBundlesResponse countCreditBundles( + CountCreditBundlesRequest request, RequestOptions requestOptions) { + return this.rawClient.countCreditBundles(request, requestOptions).body(); + } + + public CountBillingCreditsResponse countBillingCredits() { + return this.rawClient.countBillingCredits().body(); + } + + public CountBillingCreditsResponse countBillingCredits(CountBillingCreditsRequest request) { + return this.rawClient.countBillingCredits(request).body(); + } + + public CountBillingCreditsResponse countBillingCredits( + CountBillingCreditsRequest request, RequestOptions requestOptions) { + return this.rawClient.countBillingCredits(request, requestOptions).body(); + } + + public ZeroOutGrantResponse zeroOutGrant(String grantId) { + return this.rawClient.zeroOutGrant(grantId).body(); + } + + public ZeroOutGrantResponse zeroOutGrant(String grantId, ZeroOutGrantRequestBody request) { + return this.rawClient.zeroOutGrant(grantId, request).body(); + } + + public ZeroOutGrantResponse zeroOutGrant( + String grantId, ZeroOutGrantRequestBody request, RequestOptions requestOptions) { + return this.rawClient.zeroOutGrant(grantId, request, requestOptions).body(); + } + + public GrantBillingCreditsToCompanyResponse grantBillingCreditsToCompany(CreateCompanyCreditGrant request) { + return this.rawClient.grantBillingCreditsToCompany(request).body(); + } + + public GrantBillingCreditsToCompanyResponse grantBillingCreditsToCompany( + CreateCompanyCreditGrant request, RequestOptions requestOptions) { + return this.rawClient + .grantBillingCreditsToCompany(request, requestOptions) + .body(); + } + + public ListCompanyGrantsResponse listCompanyGrants() { + return this.rawClient.listCompanyGrants().body(); + } + + public ListCompanyGrantsResponse listCompanyGrants(ListCompanyGrantsRequest request) { + return this.rawClient.listCompanyGrants(request).body(); + } + + public ListCompanyGrantsResponse listCompanyGrants( + ListCompanyGrantsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCompanyGrants(request, requestOptions).body(); + } + + public CountBillingCreditsGrantsResponse countBillingCreditsGrants() { + return this.rawClient.countBillingCreditsGrants().body(); + } + + public CountBillingCreditsGrantsResponse countBillingCreditsGrants(CountBillingCreditsGrantsRequest request) { + return this.rawClient.countBillingCreditsGrants(request).body(); + } + + public CountBillingCreditsGrantsResponse countBillingCreditsGrants( + CountBillingCreditsGrantsRequest request, RequestOptions requestOptions) { + return this.rawClient.countBillingCreditsGrants(request, requestOptions).body(); + } + + public ListGrantsForCreditResponse listGrantsForCredit() { + return this.rawClient.listGrantsForCredit().body(); + } + + public ListGrantsForCreditResponse listGrantsForCredit(ListGrantsForCreditRequest request) { + return this.rawClient.listGrantsForCredit(request).body(); + } + + public ListGrantsForCreditResponse listGrantsForCredit( + ListGrantsForCreditRequest request, RequestOptions requestOptions) { + return this.rawClient.listGrantsForCredit(request, requestOptions).body(); + } + + public GetEnrichedCreditLedgerResponse getEnrichedCreditLedger(GetEnrichedCreditLedgerRequest request) { + return this.rawClient.getEnrichedCreditLedger(request).body(); + } + + public GetEnrichedCreditLedgerResponse getEnrichedCreditLedger( + GetEnrichedCreditLedgerRequest request, RequestOptions requestOptions) { + return this.rawClient.getEnrichedCreditLedger(request, requestOptions).body(); + } + + public CountCreditLedgerResponse countCreditLedger(CountCreditLedgerRequest request) { + return this.rawClient.countCreditLedger(request).body(); + } + + public CountCreditLedgerResponse countCreditLedger( + CountCreditLedgerRequest request, RequestOptions requestOptions) { + return this.rawClient.countCreditLedger(request, requestOptions).body(); + } + + public ListBillingPlanCreditGrantsResponse listBillingPlanCreditGrants() { + return this.rawClient.listBillingPlanCreditGrants().body(); + } + + public ListBillingPlanCreditGrantsResponse listBillingPlanCreditGrants(ListBillingPlanCreditGrantsRequest request) { + return this.rawClient.listBillingPlanCreditGrants(request).body(); + } + + public ListBillingPlanCreditGrantsResponse listBillingPlanCreditGrants( + ListBillingPlanCreditGrantsRequest request, RequestOptions requestOptions) { + return this.rawClient + .listBillingPlanCreditGrants(request, requestOptions) + .body(); + } + + public CreateBillingPlanCreditGrantResponse createBillingPlanCreditGrant( + CreateBillingPlanCreditGrantRequestBody request) { + return this.rawClient.createBillingPlanCreditGrant(request).body(); + } + + public CreateBillingPlanCreditGrantResponse createBillingPlanCreditGrant( + CreateBillingPlanCreditGrantRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .createBillingPlanCreditGrant(request, requestOptions) + .body(); + } + + public DeleteBillingPlanCreditGrantResponse deleteBillingPlanCreditGrant(String planGrantId) { + return this.rawClient.deleteBillingPlanCreditGrant(planGrantId).body(); + } + + public DeleteBillingPlanCreditGrantResponse deleteBillingPlanCreditGrant( + String planGrantId, RequestOptions requestOptions) { + return this.rawClient + .deleteBillingPlanCreditGrant(planGrantId, requestOptions) + .body(); + } + + public CountBillingPlanCreditGrantsResponse countBillingPlanCreditGrants() { + return this.rawClient.countBillingPlanCreditGrants().body(); + } + + public CountBillingPlanCreditGrantsResponse countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest request) { + return this.rawClient.countBillingPlanCreditGrants(request).body(); + } + + public CountBillingPlanCreditGrantsResponse countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest request, RequestOptions requestOptions) { + return this.rawClient + .countBillingPlanCreditGrants(request, requestOptions) + .body(); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java b/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java new file mode 100644 index 0000000..b7750a3 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/RawCreditsClient.java @@ -0,0 +1,1772 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; +import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.CountCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.CreateBillingPlanCreditGrantRequestBody; +import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; +import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; +import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; +import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; +import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; +import com.schematic.api.resources.credits.types.CountCreditLedgerResponse; +import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; +import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; +import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; +import com.schematic.api.resources.credits.types.ListBillingCreditsResponse; +import com.schematic.api.resources.credits.types.ListBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; +import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; +import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCreditsClient { + protected final ClientOptions clientOptions; + + public RawCreditsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse listBillingCredits() { + return listBillingCredits(ListBillingCreditsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listBillingCredits(ListBillingCreditsRequest request) { + return listBillingCredits(request, null); + } + + public BaseSchematicHttpResponse listBillingCredits( + ListBillingCreditsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListBillingCreditsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createBillingCredit( + CreateBillingCreditRequestBody request) { + return createBillingCredit(request, null); + } + + public BaseSchematicHttpResponse createBillingCredit( + CreateBillingCreditRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateBillingCreditResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getSingleBillingCredit(String creditId) { + return getSingleBillingCredit(creditId, null); + } + + public BaseSchematicHttpResponse getSingleBillingCredit( + String creditId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits") + .addPathSegment(creditId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetSingleBillingCreditResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateBillingCredit( + String creditId, UpdateBillingCreditRequestBody request) { + return updateBillingCredit(creditId, request, null); + } + + public BaseSchematicHttpResponse updateBillingCredit( + String creditId, UpdateBillingCreditRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits") + .addPathSegment(creditId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateBillingCreditResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse softDeleteBillingCredit(String creditId) { + return softDeleteBillingCredit(creditId, null); + } + + public BaseSchematicHttpResponse softDeleteBillingCredit( + String creditId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits") + .addPathSegment(creditId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), SoftDeleteBillingCreditResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listCreditBundles() { + return listCreditBundles(ListCreditBundlesRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCreditBundles(ListCreditBundlesRequest request) { + return listCreditBundles(request, null); + } + + public BaseSchematicHttpResponse listCreditBundles( + ListCreditBundlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getBundleType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "bundle_type", request.getBundleType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCreditBundlesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createCreditBundle( + CreateCreditBundleRequestBody request) { + return createCreditBundle(request, null); + } + + public BaseSchematicHttpResponse createCreditBundle( + CreateCreditBundleRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateCreditBundleResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getCreditBundle(String bundleId) { + return getCreditBundle(bundleId, null); + } + + public BaseSchematicHttpResponse getCreditBundle( + String bundleId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles") + .addPathSegment(bundleId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetCreditBundleResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateCreditBundleDetails( + String bundleId, UpdateCreditBundleDetailsRequestBody request) { + return updateCreditBundleDetails(bundleId, request, null); + } + + public BaseSchematicHttpResponse updateCreditBundleDetails( + String bundleId, UpdateCreditBundleDetailsRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles") + .addPathSegment(bundleId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateCreditBundleDetailsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteCreditBundle(String bundleId) { + return deleteCreditBundle(bundleId, null); + } + + public BaseSchematicHttpResponse deleteCreditBundle( + String bundleId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles") + .addPathSegment(bundleId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteCreditBundleResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countCreditBundles() { + return countCreditBundles(CountCreditBundlesRequest.builder().build()); + } + + public BaseSchematicHttpResponse countCreditBundles(CountCreditBundlesRequest request) { + return countCreditBundles(request, null); + } + + public BaseSchematicHttpResponse countCreditBundles( + CountCreditBundlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/bundles/count"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getBundleType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "bundle_type", request.getBundleType().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountCreditBundlesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countBillingCredits() { + return countBillingCredits(CountBillingCreditsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countBillingCredits( + CountBillingCreditsRequest request) { + return countBillingCredits(request, null); + } + + public BaseSchematicHttpResponse countBillingCredits( + CountBillingCreditsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/count"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountBillingCreditsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse zeroOutGrant(String grantId) { + return zeroOutGrant(grantId, ZeroOutGrantRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse zeroOutGrant( + String grantId, ZeroOutGrantRequestBody request) { + return zeroOutGrant(grantId, request, null); + } + + public BaseSchematicHttpResponse zeroOutGrant( + String grantId, ZeroOutGrantRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants") + .addPathSegment(grantId) + .addPathSegments("zero-out") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ZeroOutGrantResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse grantBillingCreditsToCompany( + CreateCompanyCreditGrant request) { + return grantBillingCreditsToCompany(request, null); + } + + public BaseSchematicHttpResponse grantBillingCreditsToCompany( + CreateCompanyCreditGrant request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants/company") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GrantBillingCreditsToCompanyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listCompanyGrants() { + return listCompanyGrants(ListCompanyGrantsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCompanyGrants(ListCompanyGrantsRequest request) { + return listCompanyGrants(request, null); + } + + public BaseSchematicHttpResponse listCompanyGrants( + ListCompanyGrantsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants/company/list"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getOrder().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order", request.getOrder().get(), false); + } + if (request.getDir().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "dir", request.getDir().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCompanyGrantsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countBillingCreditsGrants() { + return countBillingCreditsGrants( + CountBillingCreditsGrantsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countBillingCreditsGrants( + CountBillingCreditsGrantsRequest request) { + return countBillingCreditsGrants(request, null); + } + + public BaseSchematicHttpResponse countBillingCreditsGrants( + CountBillingCreditsGrantsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants/count"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountBillingCreditsGrantsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listGrantsForCredit() { + return listGrantsForCredit(ListGrantsForCreditRequest.builder().build()); + } + + public BaseSchematicHttpResponse listGrantsForCredit( + ListGrantsForCreditRequest request) { + return listGrantsForCredit(request, null); + } + + public BaseSchematicHttpResponse listGrantsForCredit( + ListGrantsForCreditRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/grants/list"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListGrantsForCreditResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getEnrichedCreditLedger( + GetEnrichedCreditLedgerRequest request) { + return getEnrichedCreditLedger(request, null); + } + + public BaseSchematicHttpResponse getEnrichedCreditLedger( + GetEnrichedCreditLedgerRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/ledger"); + QueryStringMapper.addQueryParameter(httpUrl, "company_id", request.getCompanyId(), false); + if (request.getBillingCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "billing_credit_id", request.getBillingCreditId().get(), false); + } + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "period", request.getPeriod(), false); + if (request.getStartTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_time", request.getStartTime().get(), false); + } + if (request.getEndTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_time", request.getEndTime().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetEnrichedCreditLedgerResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countCreditLedger(CountCreditLedgerRequest request) { + return countCreditLedger(request, null); + } + + public BaseSchematicHttpResponse countCreditLedger( + CountCreditLedgerRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/ledger/count"); + QueryStringMapper.addQueryParameter(httpUrl, "company_id", request.getCompanyId(), false); + if (request.getBillingCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "billing_credit_id", request.getBillingCreditId().get(), false); + } + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + QueryStringMapper.addQueryParameter(httpUrl, "period", request.getPeriod(), false); + if (request.getStartTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_time", request.getStartTime().get(), false); + } + if (request.getEndTime().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_time", request.getEndTime().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountCreditLedgerResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listBillingPlanCreditGrants() { + return listBillingPlanCreditGrants( + ListBillingPlanCreditGrantsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listBillingPlanCreditGrants( + ListBillingPlanCreditGrantsRequest request) { + return listBillingPlanCreditGrants(request, null); + } + + public BaseSchematicHttpResponse listBillingPlanCreditGrants( + ListBillingPlanCreditGrantsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/plan-grants"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListBillingPlanCreditGrantsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createBillingPlanCreditGrant( + CreateBillingPlanCreditGrantRequestBody request) { + return createBillingPlanCreditGrant(request, null); + } + + public BaseSchematicHttpResponse createBillingPlanCreditGrant( + CreateBillingPlanCreditGrantRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/plan-grants") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateBillingPlanCreditGrantResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteBillingPlanCreditGrant( + String planGrantId) { + return deleteBillingPlanCreditGrant(planGrantId, null); + } + + public BaseSchematicHttpResponse deleteBillingPlanCreditGrant( + String planGrantId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/plan-grants") + .addPathSegment(planGrantId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteBillingPlanCreditGrantResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countBillingPlanCreditGrants() { + return countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest request) { + return countBillingPlanCreditGrants(request, null); + } + + public BaseSchematicHttpResponse countBillingPlanCreditGrants( + CountBillingPlanCreditGrantsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("billing/credits/plan-grants/count"); + if (request.getCreditId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credit_id", request.getCreditId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountBillingPlanCreditGrantsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CountBillingCreditsGrantsRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/CountBillingCreditsGrantsRequest.java new file mode 100644 index 0000000..9ef4935 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CountBillingCreditsGrantsRequest.java @@ -0,0 +1,188 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingCreditsGrantsRequest.Builder.class) +public final class CountBillingCreditsGrantsRequest { + private final Optional> ids; + + private final Optional creditId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountBillingCreditsGrantsRequest( + Optional> ids, + Optional creditId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.creditId = creditId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingCreditsGrantsRequest && equalTo((CountBillingCreditsGrantsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingCreditsGrantsRequest other) { + return ids.equals(other.ids) + && creditId.equals(other.creditId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.creditId, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountBillingCreditsGrantsRequest other) { + ids(other.getIds()); + creditId(other.getCreditId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountBillingCreditsGrantsRequest build() { + return new CountBillingCreditsGrantsRequest(ids, creditId, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CountBillingCreditsRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/CountBillingCreditsRequest.java new file mode 100644 index 0000000..efa88dd --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CountBillingCreditsRequest.java @@ -0,0 +1,188 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingCreditsRequest.Builder.class) +public final class CountBillingCreditsRequest { + private final Optional> ids; + + private final Optional name; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountBillingCreditsRequest( + Optional> ids, + Optional name, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.name = name; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingCreditsRequest && equalTo((CountBillingCreditsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingCreditsRequest other) { + return ids.equals(other.ids) + && name.equals(other.name) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.name, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountBillingCreditsRequest other) { + ids(other.getIds()); + name(other.getName()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountBillingCreditsRequest build() { + return new CountBillingCreditsRequest(ids, name, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CountBillingPlanCreditGrantsRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/CountBillingPlanCreditGrantsRequest.java new file mode 100644 index 0000000..796dfc9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CountBillingPlanCreditGrantsRequest.java @@ -0,0 +1,243 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingPlanCreditGrantsRequest.Builder.class) +public final class CountBillingPlanCreditGrantsRequest { + private final Optional> planIds; + + private final Optional> ids; + + private final Optional creditId; + + private final Optional planId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountBillingPlanCreditGrantsRequest( + Optional> planIds, + Optional> ids, + Optional creditId, + Optional planId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.planIds = planIds; + this.ids = ids; + this.creditId = creditId; + this.planId = planId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingPlanCreditGrantsRequest + && equalTo((CountBillingPlanCreditGrantsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingPlanCreditGrantsRequest other) { + return planIds.equals(other.planIds) + && ids.equals(other.ids) + && creditId.equals(other.creditId) + && planId.equals(other.planId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.planIds, this.ids, this.creditId, this.planId, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> planIds = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountBillingPlanCreditGrantsRequest other) { + planIds(other.getPlanIds()); + ids(other.getIds()); + creditId(other.getCreditId()); + planId(other.getPlanId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + public Builder planIds(String planIds) { + this.planIds = Optional.of(Collections.singletonList(planIds)); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountBillingPlanCreditGrantsRequest build() { + return new CountBillingPlanCreditGrantsRequest( + planIds, ids, creditId, planId, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CountCreditBundlesRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/CountCreditBundlesRequest.java new file mode 100644 index 0000000..c704107 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CountCreditBundlesRequest.java @@ -0,0 +1,238 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.CountCreditBundlesRequestStatus; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditBundlesRequest.Builder.class) +public final class CountCreditBundlesRequest { + private final Optional> ids; + + private final Optional creditId; + + private final Optional status; + + private final Optional bundleType; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountCreditBundlesRequest( + Optional> ids, + Optional creditId, + Optional status, + Optional bundleType, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.creditId = creditId; + this.status = status; + this.bundleType = bundleType; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @JsonProperty("bundle_type") + public Optional getBundleType() { + return bundleType; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditBundlesRequest && equalTo((CountCreditBundlesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditBundlesRequest other) { + return ids.equals(other.ids) + && creditId.equals(other.creditId) + && status.equals(other.status) + && bundleType.equals(other.bundleType) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.creditId, this.status, this.bundleType, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional bundleType = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountCreditBundlesRequest other) { + ids(other.getIds()); + creditId(other.getCreditId()); + status(other.getStatus()); + bundleType(other.getBundleType()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(CountCreditBundlesRequestStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + @JsonSetter(value = "bundle_type", nulls = Nulls.SKIP) + public Builder bundleType(Optional bundleType) { + this.bundleType = bundleType; + return this; + } + + public Builder bundleType(String bundleType) { + this.bundleType = Optional.ofNullable(bundleType); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountCreditBundlesRequest build() { + return new CountCreditBundlesRequest( + ids, creditId, status, bundleType, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CountCreditLedgerRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/CountCreditLedgerRequest.java new file mode 100644 index 0000000..be58ad7 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CountCreditLedgerRequest.java @@ -0,0 +1,354 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.CountCreditLedgerRequestPeriod; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditLedgerRequest.Builder.class) +public final class CountCreditLedgerRequest { + private final String companyId; + + private final Optional billingCreditId; + + private final Optional featureId; + + private final CountCreditLedgerRequestPeriod period; + + private final Optional startTime; + + private final Optional endTime; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountCreditLedgerRequest( + String companyId, + Optional billingCreditId, + Optional featureId, + CountCreditLedgerRequestPeriod period, + Optional startTime, + Optional endTime, + Optional limit, + Optional offset, + Map additionalProperties) { + this.companyId = companyId; + this.billingCreditId = billingCreditId; + this.featureId = featureId; + this.period = period; + this.startTime = startTime; + this.endTime = endTime; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("billing_credit_id") + public Optional getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + + @JsonProperty("period") + public CountCreditLedgerRequestPeriod getPeriod() { + return period; + } + + @JsonProperty("start_time") + public Optional getStartTime() { + return startTime; + } + + @JsonProperty("end_time") + public Optional getEndTime() { + return endTime; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditLedgerRequest && equalTo((CountCreditLedgerRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditLedgerRequest other) { + return companyId.equals(other.companyId) + && billingCreditId.equals(other.billingCreditId) + && featureId.equals(other.featureId) + && period.equals(other.period) + && startTime.equals(other.startTime) + && endTime.equals(other.endTime) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.companyId, + this.billingCreditId, + this.featureId, + this.period, + this.startTime, + this.endTime, + this.limit, + this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + PeriodStage companyId(@NotNull String companyId); + + Builder from(CountCreditLedgerRequest other); + } + + public interface PeriodStage { + _FinalStage period(@NotNull CountCreditLedgerRequestPeriod period); + } + + public interface _FinalStage { + CountCreditLedgerRequest build(); + + _FinalStage billingCreditId(Optional billingCreditId); + + _FinalStage billingCreditId(String billingCreditId); + + _FinalStage featureId(Optional featureId); + + _FinalStage featureId(String featureId); + + _FinalStage startTime(Optional startTime); + + _FinalStage startTime(String startTime); + + _FinalStage endTime(Optional endTime); + + _FinalStage endTime(String endTime); + + /** + *

Page limit (default 100)

+ */ + _FinalStage limit(Optional limit); + + _FinalStage limit(Integer limit); + + /** + *

Page offset (default 0)

+ */ + _FinalStage offset(Optional offset); + + _FinalStage offset(Integer offset); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, PeriodStage, _FinalStage { + private String companyId; + + private CountCreditLedgerRequestPeriod period; + + private Optional offset = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional endTime = Optional.empty(); + + private Optional startTime = Optional.empty(); + + private Optional featureId = Optional.empty(); + + private Optional billingCreditId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountCreditLedgerRequest other) { + companyId(other.getCompanyId()); + billingCreditId(other.getBillingCreditId()); + featureId(other.getFeatureId()); + period(other.getPeriod()); + startTime(other.getStartTime()); + endTime(other.getEndTime()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public PeriodStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("period") + public _FinalStage period(@NotNull CountCreditLedgerRequestPeriod period) { + this.period = Objects.requireNonNull(period, "period must not be null"); + return this; + } + + /** + *

Page offset (default 0)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @java.lang.Override + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public _FinalStage offset(Optional offset) { + this.offset = offset; + return this; + } + + /** + *

Page limit (default 100)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @java.lang.Override + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public _FinalStage limit(Optional limit) { + this.limit = limit; + return this; + } + + @java.lang.Override + public _FinalStage endTime(String endTime) { + this.endTime = Optional.ofNullable(endTime); + return this; + } + + @java.lang.Override + @JsonSetter(value = "end_time", nulls = Nulls.SKIP) + public _FinalStage endTime(Optional endTime) { + this.endTime = endTime; + return this; + } + + @java.lang.Override + public _FinalStage startTime(String startTime) { + this.startTime = Optional.ofNullable(startTime); + return this; + } + + @java.lang.Override + @JsonSetter(value = "start_time", nulls = Nulls.SKIP) + public _FinalStage startTime(Optional startTime) { + this.startTime = startTime; + return this; + } + + @java.lang.Override + public _FinalStage featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public _FinalStage featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + @java.lang.Override + public _FinalStage billingCreditId(String billingCreditId) { + this.billingCreditId = Optional.ofNullable(billingCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_credit_id", nulls = Nulls.SKIP) + public _FinalStage billingCreditId(Optional billingCreditId) { + this.billingCreditId = billingCreditId; + return this; + } + + @java.lang.Override + public CountCreditLedgerRequest build() { + return new CountCreditLedgerRequest( + companyId, + billingCreditId, + featureId, + period, + startTime, + endTime, + limit, + offset, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CreateBillingCreditRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/CreateBillingCreditRequestBody.java new file mode 100644 index 0000000..8dc353f --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CreateBillingCreditRequestBody.java @@ -0,0 +1,454 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.CreateBillingCreditRequestBodyBurnStrategy; +import com.schematic.api.resources.credits.types.CreateBillingCreditRequestBodyDefaultRolloverPolicy; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateBillingCreditRequestBody.Builder.class) +public final class CreateBillingCreditRequestBody { + private final Optional burnStrategy; + + private final String currency; + + private final Optional defaultExpiryUnit; + + private final Optional defaultExpiryUnitCount; + + private final Optional defaultRolloverPolicy; + + private final String description; + + private final Optional icon; + + private final String name; + + private final Optional perUnitPrice; + + private final Optional perUnitPriceDecimal; + + private final Optional pluralName; + + private final Optional singularName; + + private final Map additionalProperties; + + private CreateBillingCreditRequestBody( + Optional burnStrategy, + String currency, + Optional defaultExpiryUnit, + Optional defaultExpiryUnitCount, + Optional defaultRolloverPolicy, + String description, + Optional icon, + String name, + Optional perUnitPrice, + Optional perUnitPriceDecimal, + Optional pluralName, + Optional singularName, + Map additionalProperties) { + this.burnStrategy = burnStrategy; + this.currency = currency; + this.defaultExpiryUnit = defaultExpiryUnit; + this.defaultExpiryUnitCount = defaultExpiryUnitCount; + this.defaultRolloverPolicy = defaultRolloverPolicy; + this.description = description; + this.icon = icon; + this.name = name; + this.perUnitPrice = perUnitPrice; + this.perUnitPriceDecimal = perUnitPriceDecimal; + this.pluralName = pluralName; + this.singularName = singularName; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("burn_strategy") + public Optional getBurnStrategy() { + return burnStrategy; + } + + @JsonProperty("currency") + public String getCurrency() { + return currency; + } + + @JsonProperty("default_expiry_unit") + public Optional getDefaultExpiryUnit() { + return defaultExpiryUnit; + } + + @JsonProperty("default_expiry_unit_count") + public Optional getDefaultExpiryUnitCount() { + return defaultExpiryUnitCount; + } + + @JsonProperty("default_rollover_policy") + public Optional getDefaultRolloverPolicy() { + return defaultRolloverPolicy; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("per_unit_price") + public Optional getPerUnitPrice() { + return perUnitPrice; + } + + @JsonProperty("per_unit_price_decimal") + public Optional getPerUnitPriceDecimal() { + return perUnitPriceDecimal; + } + + @JsonProperty("plural_name") + public Optional getPluralName() { + return pluralName; + } + + @JsonProperty("singular_name") + public Optional getSingularName() { + return singularName; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateBillingCreditRequestBody && equalTo((CreateBillingCreditRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateBillingCreditRequestBody other) { + return burnStrategy.equals(other.burnStrategy) + && currency.equals(other.currency) + && defaultExpiryUnit.equals(other.defaultExpiryUnit) + && defaultExpiryUnitCount.equals(other.defaultExpiryUnitCount) + && defaultRolloverPolicy.equals(other.defaultRolloverPolicy) + && description.equals(other.description) + && icon.equals(other.icon) + && name.equals(other.name) + && perUnitPrice.equals(other.perUnitPrice) + && perUnitPriceDecimal.equals(other.perUnitPriceDecimal) + && pluralName.equals(other.pluralName) + && singularName.equals(other.singularName); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.burnStrategy, + this.currency, + this.defaultExpiryUnit, + this.defaultExpiryUnitCount, + this.defaultRolloverPolicy, + this.description, + this.icon, + this.name, + this.perUnitPrice, + this.perUnitPriceDecimal, + this.pluralName, + this.singularName); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CurrencyStage builder() { + return new Builder(); + } + + public interface CurrencyStage { + DescriptionStage currency(@NotNull String currency); + + Builder from(CreateBillingCreditRequestBody other); + } + + public interface DescriptionStage { + NameStage description(@NotNull String description); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + CreateBillingCreditRequestBody build(); + + _FinalStage burnStrategy(Optional burnStrategy); + + _FinalStage burnStrategy(CreateBillingCreditRequestBodyBurnStrategy burnStrategy); + + _FinalStage defaultExpiryUnit(Optional defaultExpiryUnit); + + _FinalStage defaultExpiryUnit(String defaultExpiryUnit); + + _FinalStage defaultExpiryUnitCount(Optional defaultExpiryUnitCount); + + _FinalStage defaultExpiryUnitCount(Integer defaultExpiryUnitCount); + + _FinalStage defaultRolloverPolicy( + Optional defaultRolloverPolicy); + + _FinalStage defaultRolloverPolicy(CreateBillingCreditRequestBodyDefaultRolloverPolicy defaultRolloverPolicy); + + _FinalStage icon(Optional icon); + + _FinalStage icon(String icon); + + _FinalStage perUnitPrice(Optional perUnitPrice); + + _FinalStage perUnitPrice(Integer perUnitPrice); + + _FinalStage perUnitPriceDecimal(Optional perUnitPriceDecimal); + + _FinalStage perUnitPriceDecimal(String perUnitPriceDecimal); + + _FinalStage pluralName(Optional pluralName); + + _FinalStage pluralName(String pluralName); + + _FinalStage singularName(Optional singularName); + + _FinalStage singularName(String singularName); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CurrencyStage, DescriptionStage, NameStage, _FinalStage { + private String currency; + + private String description; + + private String name; + + private Optional singularName = Optional.empty(); + + private Optional pluralName = Optional.empty(); + + private Optional perUnitPriceDecimal = Optional.empty(); + + private Optional perUnitPrice = Optional.empty(); + + private Optional icon = Optional.empty(); + + private Optional defaultRolloverPolicy = Optional.empty(); + + private Optional defaultExpiryUnitCount = Optional.empty(); + + private Optional defaultExpiryUnit = Optional.empty(); + + private Optional burnStrategy = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateBillingCreditRequestBody other) { + burnStrategy(other.getBurnStrategy()); + currency(other.getCurrency()); + defaultExpiryUnit(other.getDefaultExpiryUnit()); + defaultExpiryUnitCount(other.getDefaultExpiryUnitCount()); + defaultRolloverPolicy(other.getDefaultRolloverPolicy()); + description(other.getDescription()); + icon(other.getIcon()); + name(other.getName()); + perUnitPrice(other.getPerUnitPrice()); + perUnitPriceDecimal(other.getPerUnitPriceDecimal()); + pluralName(other.getPluralName()); + singularName(other.getSingularName()); + return this; + } + + @java.lang.Override + @JsonSetter("currency") + public DescriptionStage currency(@NotNull String currency) { + this.currency = Objects.requireNonNull(currency, "currency must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("description") + public NameStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage singularName(String singularName) { + this.singularName = Optional.ofNullable(singularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "singular_name", nulls = Nulls.SKIP) + public _FinalStage singularName(Optional singularName) { + this.singularName = singularName; + return this; + } + + @java.lang.Override + public _FinalStage pluralName(String pluralName) { + this.pluralName = Optional.ofNullable(pluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plural_name", nulls = Nulls.SKIP) + public _FinalStage pluralName(Optional pluralName) { + this.pluralName = pluralName; + return this; + } + + @java.lang.Override + public _FinalStage perUnitPriceDecimal(String perUnitPriceDecimal) { + this.perUnitPriceDecimal = Optional.ofNullable(perUnitPriceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "per_unit_price_decimal", nulls = Nulls.SKIP) + public _FinalStage perUnitPriceDecimal(Optional perUnitPriceDecimal) { + this.perUnitPriceDecimal = perUnitPriceDecimal; + return this; + } + + @java.lang.Override + public _FinalStage perUnitPrice(Integer perUnitPrice) { + this.perUnitPrice = Optional.ofNullable(perUnitPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "per_unit_price", nulls = Nulls.SKIP) + public _FinalStage perUnitPrice(Optional perUnitPrice) { + this.perUnitPrice = perUnitPrice; + return this; + } + + @java.lang.Override + public _FinalStage icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public _FinalStage icon(Optional icon) { + this.icon = icon; + return this; + } + + @java.lang.Override + public _FinalStage defaultRolloverPolicy( + CreateBillingCreditRequestBodyDefaultRolloverPolicy defaultRolloverPolicy) { + this.defaultRolloverPolicy = Optional.ofNullable(defaultRolloverPolicy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_rollover_policy", nulls = Nulls.SKIP) + public _FinalStage defaultRolloverPolicy( + Optional defaultRolloverPolicy) { + this.defaultRolloverPolicy = defaultRolloverPolicy; + return this; + } + + @java.lang.Override + public _FinalStage defaultExpiryUnitCount(Integer defaultExpiryUnitCount) { + this.defaultExpiryUnitCount = Optional.ofNullable(defaultExpiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage defaultExpiryUnitCount(Optional defaultExpiryUnitCount) { + this.defaultExpiryUnitCount = defaultExpiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage defaultExpiryUnit(String defaultExpiryUnit) { + this.defaultExpiryUnit = Optional.ofNullable(defaultExpiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_expiry_unit", nulls = Nulls.SKIP) + public _FinalStage defaultExpiryUnit(Optional defaultExpiryUnit) { + this.defaultExpiryUnit = defaultExpiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage burnStrategy(CreateBillingCreditRequestBodyBurnStrategy burnStrategy) { + this.burnStrategy = Optional.ofNullable(burnStrategy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "burn_strategy", nulls = Nulls.SKIP) + public _FinalStage burnStrategy(Optional burnStrategy) { + this.burnStrategy = burnStrategy; + return this; + } + + @java.lang.Override + public CreateBillingCreditRequestBody build() { + return new CreateBillingCreditRequestBody( + burnStrategy, + currency, + defaultExpiryUnit, + defaultExpiryUnitCount, + defaultRolloverPolicy, + description, + icon, + name, + perUnitPrice, + perUnitPriceDecimal, + pluralName, + singularName, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CreateBillingPlanCreditGrantRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/CreateBillingPlanCreditGrantRequestBody.java new file mode 100644 index 0000000..161949e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CreateBillingPlanCreditGrantRequestBody.java @@ -0,0 +1,348 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantRequestBodyExpiryType; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantRequestBodyExpiryUnit; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantRequestBodyResetCadence; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantRequestBodyResetStart; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantRequestBodyResetType; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateBillingPlanCreditGrantRequestBody.Builder.class) +public final class CreateBillingPlanCreditGrantRequestBody { + private final int creditAmount; + + private final String creditId; + + private final Optional expiryType; + + private final Optional expiryUnit; + + private final Optional expiryUnitCount; + + private final String planId; + + private final CreateBillingPlanCreditGrantRequestBodyResetCadence resetCadence; + + private final CreateBillingPlanCreditGrantRequestBodyResetStart resetStart; + + private final Optional resetType; + + private final Map additionalProperties; + + private CreateBillingPlanCreditGrantRequestBody( + int creditAmount, + String creditId, + Optional expiryType, + Optional expiryUnit, + Optional expiryUnitCount, + String planId, + CreateBillingPlanCreditGrantRequestBodyResetCadence resetCadence, + CreateBillingPlanCreditGrantRequestBodyResetStart resetStart, + Optional resetType, + Map additionalProperties) { + this.creditAmount = creditAmount; + this.creditId = creditId; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.planId = planId; + this.resetCadence = resetCadence; + this.resetStart = resetStart; + this.resetType = resetType; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_amount") + public int getCreditAmount() { + return creditAmount; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @JsonProperty("expiry_type") + public Optional getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public Optional getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @JsonProperty("reset_cadence") + public CreateBillingPlanCreditGrantRequestBodyResetCadence getResetCadence() { + return resetCadence; + } + + @JsonProperty("reset_start") + public CreateBillingPlanCreditGrantRequestBodyResetStart getResetStart() { + return resetStart; + } + + @JsonProperty("reset_type") + public Optional getResetType() { + return resetType; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateBillingPlanCreditGrantRequestBody + && equalTo((CreateBillingPlanCreditGrantRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateBillingPlanCreditGrantRequestBody other) { + return creditAmount == other.creditAmount + && creditId.equals(other.creditId) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && planId.equals(other.planId) + && resetCadence.equals(other.resetCadence) + && resetStart.equals(other.resetStart) + && resetType.equals(other.resetType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.creditAmount, + this.creditId, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.planId, + this.resetCadence, + this.resetStart, + this.resetType); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreditAmountStage builder() { + return new Builder(); + } + + public interface CreditAmountStage { + CreditIdStage creditAmount(int creditAmount); + + Builder from(CreateBillingPlanCreditGrantRequestBody other); + } + + public interface CreditIdStage { + PlanIdStage creditId(@NotNull String creditId); + } + + public interface PlanIdStage { + ResetCadenceStage planId(@NotNull String planId); + } + + public interface ResetCadenceStage { + ResetStartStage resetCadence(@NotNull CreateBillingPlanCreditGrantRequestBodyResetCadence resetCadence); + } + + public interface ResetStartStage { + _FinalStage resetStart(@NotNull CreateBillingPlanCreditGrantRequestBodyResetStart resetStart); + } + + public interface _FinalStage { + CreateBillingPlanCreditGrantRequestBody build(); + + _FinalStage expiryType(Optional expiryType); + + _FinalStage expiryType(CreateBillingPlanCreditGrantRequestBodyExpiryType expiryType); + + _FinalStage expiryUnit(Optional expiryUnit); + + _FinalStage expiryUnit(CreateBillingPlanCreditGrantRequestBodyExpiryUnit expiryUnit); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + + _FinalStage resetType(Optional resetType); + + _FinalStage resetType(CreateBillingPlanCreditGrantRequestBodyResetType resetType); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CreditAmountStage, CreditIdStage, PlanIdStage, ResetCadenceStage, ResetStartStage, _FinalStage { + private int creditAmount; + + private String creditId; + + private String planId; + + private CreateBillingPlanCreditGrantRequestBodyResetCadence resetCadence; + + private CreateBillingPlanCreditGrantRequestBodyResetStart resetStart; + + private Optional resetType = Optional.empty(); + + private Optional expiryUnitCount = Optional.empty(); + + private Optional expiryUnit = Optional.empty(); + + private Optional expiryType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateBillingPlanCreditGrantRequestBody other) { + creditAmount(other.getCreditAmount()); + creditId(other.getCreditId()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + planId(other.getPlanId()); + resetCadence(other.getResetCadence()); + resetStart(other.getResetStart()); + resetType(other.getResetType()); + return this; + } + + @java.lang.Override + @JsonSetter("credit_amount") + public CreditIdStage creditAmount(int creditAmount) { + this.creditAmount = creditAmount; + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public PlanIdStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public ResetCadenceStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("reset_cadence") + public ResetStartStage resetCadence(@NotNull CreateBillingPlanCreditGrantRequestBodyResetCadence resetCadence) { + this.resetCadence = Objects.requireNonNull(resetCadence, "resetCadence must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("reset_start") + public _FinalStage resetStart(@NotNull CreateBillingPlanCreditGrantRequestBodyResetStart resetStart) { + this.resetStart = Objects.requireNonNull(resetStart, "resetStart must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage resetType(CreateBillingPlanCreditGrantRequestBodyResetType resetType) { + this.resetType = Optional.ofNullable(resetType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "reset_type", nulls = Nulls.SKIP) + public _FinalStage resetType(Optional resetType) { + this.resetType = resetType; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnit(CreateBillingPlanCreditGrantRequestBodyExpiryUnit expiryUnit) { + this.expiryUnit = Optional.ofNullable(expiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit", nulls = Nulls.SKIP) + public _FinalStage expiryUnit(Optional expiryUnit) { + this.expiryUnit = expiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage expiryType(CreateBillingPlanCreditGrantRequestBodyExpiryType expiryType) { + this.expiryType = Optional.ofNullable(expiryType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_type", nulls = Nulls.SKIP) + public _FinalStage expiryType(Optional expiryType) { + this.expiryType = expiryType; + return this; + } + + @java.lang.Override + public CreateBillingPlanCreditGrantRequestBody build() { + return new CreateBillingPlanCreditGrantRequestBody( + creditAmount, + creditId, + expiryType, + expiryUnit, + expiryUnitCount, + planId, + resetCadence, + resetStart, + resetType, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CreateCompanyCreditGrant.java b/src/main/java/com/schematic/api/resources/credits/requests/CreateCompanyCreditGrant.java new file mode 100644 index 0000000..9307cdc --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CreateCompanyCreditGrant.java @@ -0,0 +1,351 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.CreateCompanyCreditGrantExpiryType; +import com.schematic.api.resources.credits.types.CreateCompanyCreditGrantExpiryUnit; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateCompanyCreditGrant.Builder.class) +public final class CreateCompanyCreditGrant { + private final Optional billingPeriodsCount; + + private final String companyId; + + private final String creditId; + + private final Optional expiresAt; + + private final Optional expiryType; + + private final Optional expiryUnit; + + private final Optional expiryUnitCount; + + private final int quantity; + + private final String reason; + + private final Map additionalProperties; + + private CreateCompanyCreditGrant( + Optional billingPeriodsCount, + String companyId, + String creditId, + Optional expiresAt, + Optional expiryType, + Optional expiryUnit, + Optional expiryUnitCount, + int quantity, + String reason, + Map additionalProperties) { + this.billingPeriodsCount = billingPeriodsCount; + this.companyId = companyId; + this.creditId = creditId; + this.expiresAt = expiresAt; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.quantity = quantity; + this.reason = reason; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_periods_count") + public Optional getBillingPeriodsCount() { + return billingPeriodsCount; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @JsonProperty("expires_at") + public Optional getExpiresAt() { + return expiresAt; + } + + @JsonProperty("expiry_type") + public Optional getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public Optional getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("quantity") + public int getQuantity() { + return quantity; + } + + @JsonProperty("reason") + public String getReason() { + return reason; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateCompanyCreditGrant && equalTo((CreateCompanyCreditGrant) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateCompanyCreditGrant other) { + return billingPeriodsCount.equals(other.billingPeriodsCount) + && companyId.equals(other.companyId) + && creditId.equals(other.creditId) + && expiresAt.equals(other.expiresAt) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && quantity == other.quantity + && reason.equals(other.reason); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingPeriodsCount, + this.companyId, + this.creditId, + this.expiresAt, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.quantity, + this.reason); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + CreditIdStage companyId(@NotNull String companyId); + + Builder from(CreateCompanyCreditGrant other); + } + + public interface CreditIdStage { + QuantityStage creditId(@NotNull String creditId); + } + + public interface QuantityStage { + ReasonStage quantity(int quantity); + } + + public interface ReasonStage { + _FinalStage reason(@NotNull String reason); + } + + public interface _FinalStage { + CreateCompanyCreditGrant build(); + + _FinalStage billingPeriodsCount(Optional billingPeriodsCount); + + _FinalStage billingPeriodsCount(Integer billingPeriodsCount); + + _FinalStage expiresAt(Optional expiresAt); + + _FinalStage expiresAt(OffsetDateTime expiresAt); + + _FinalStage expiryType(Optional expiryType); + + _FinalStage expiryType(CreateCompanyCreditGrantExpiryType expiryType); + + _FinalStage expiryUnit(Optional expiryUnit); + + _FinalStage expiryUnit(CreateCompanyCreditGrantExpiryUnit expiryUnit); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CompanyIdStage, CreditIdStage, QuantityStage, ReasonStage, _FinalStage { + private String companyId; + + private String creditId; + + private int quantity; + + private String reason; + + private Optional expiryUnitCount = Optional.empty(); + + private Optional expiryUnit = Optional.empty(); + + private Optional expiryType = Optional.empty(); + + private Optional expiresAt = Optional.empty(); + + private Optional billingPeriodsCount = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateCompanyCreditGrant other) { + billingPeriodsCount(other.getBillingPeriodsCount()); + companyId(other.getCompanyId()); + creditId(other.getCreditId()); + expiresAt(other.getExpiresAt()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + quantity(other.getQuantity()); + reason(other.getReason()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public CreditIdStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public QuantityStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("quantity") + public ReasonStage quantity(int quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + @JsonSetter("reason") + public _FinalStage reason(@NotNull String reason) { + this.reason = Objects.requireNonNull(reason, "reason must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnit(CreateCompanyCreditGrantExpiryUnit expiryUnit) { + this.expiryUnit = Optional.ofNullable(expiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit", nulls = Nulls.SKIP) + public _FinalStage expiryUnit(Optional expiryUnit) { + this.expiryUnit = expiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage expiryType(CreateCompanyCreditGrantExpiryType expiryType) { + this.expiryType = Optional.ofNullable(expiryType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_type", nulls = Nulls.SKIP) + public _FinalStage expiryType(Optional expiryType) { + this.expiryType = expiryType; + return this; + } + + @java.lang.Override + public _FinalStage expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = Optional.ofNullable(expiresAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) + public _FinalStage expiresAt(Optional expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + @java.lang.Override + public _FinalStage billingPeriodsCount(Integer billingPeriodsCount) { + this.billingPeriodsCount = Optional.ofNullable(billingPeriodsCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_periods_count", nulls = Nulls.SKIP) + public _FinalStage billingPeriodsCount(Optional billingPeriodsCount) { + this.billingPeriodsCount = billingPeriodsCount; + return this; + } + + @java.lang.Override + public CreateCompanyCreditGrant build() { + return new CreateCompanyCreditGrant( + billingPeriodsCount, + companyId, + creditId, + expiresAt, + expiryType, + expiryUnit, + expiryUnitCount, + quantity, + reason, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/CreateCreditBundleRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/CreateCreditBundleRequestBody.java new file mode 100644 index 0000000..cf6be9f --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/CreateCreditBundleRequestBody.java @@ -0,0 +1,415 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.CreateCreditBundleRequestBodyExpiryType; +import com.schematic.api.resources.credits.types.CreateCreditBundleRequestBodyExpiryUnit; +import com.schematic.api.resources.credits.types.CreateCreditBundleRequestBodyStatus; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateCreditBundleRequestBody.Builder.class) +public final class CreateCreditBundleRequestBody { + private final String bundleName; + + private final Optional bundleType; + + private final String creditId; + + private final String currency; + + private final Optional expiryType; + + private final Optional expiryUnit; + + private final Optional expiryUnitCount; + + private final int pricePerUnit; + + private final Optional pricePerUnitDecimal; + + private final Optional quantity; + + private final Optional status; + + private final Map additionalProperties; + + private CreateCreditBundleRequestBody( + String bundleName, + Optional bundleType, + String creditId, + String currency, + Optional expiryType, + Optional expiryUnit, + Optional expiryUnitCount, + int pricePerUnit, + Optional pricePerUnitDecimal, + Optional quantity, + Optional status, + Map additionalProperties) { + this.bundleName = bundleName; + this.bundleType = bundleType; + this.creditId = creditId; + this.currency = currency; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.pricePerUnit = pricePerUnit; + this.pricePerUnitDecimal = pricePerUnitDecimal; + this.quantity = quantity; + this.status = status; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("bundle_name") + public String getBundleName() { + return bundleName; + } + + @JsonProperty("bundle_type") + public Optional getBundleType() { + return bundleType; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @JsonProperty("currency") + public String getCurrency() { + return currency; + } + + @JsonProperty("expiry_type") + public Optional getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public Optional getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("price_per_unit") + public int getPricePerUnit() { + return pricePerUnit; + } + + @JsonProperty("price_per_unit_decimal") + public Optional getPricePerUnitDecimal() { + return pricePerUnitDecimal; + } + + @JsonProperty("quantity") + public Optional getQuantity() { + return quantity; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateCreditBundleRequestBody && equalTo((CreateCreditBundleRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateCreditBundleRequestBody other) { + return bundleName.equals(other.bundleName) + && bundleType.equals(other.bundleType) + && creditId.equals(other.creditId) + && currency.equals(other.currency) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && pricePerUnit == other.pricePerUnit + && pricePerUnitDecimal.equals(other.pricePerUnitDecimal) + && quantity.equals(other.quantity) + && status.equals(other.status); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.bundleName, + this.bundleType, + this.creditId, + this.currency, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.pricePerUnit, + this.pricePerUnitDecimal, + this.quantity, + this.status); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BundleNameStage builder() { + return new Builder(); + } + + public interface BundleNameStage { + CreditIdStage bundleName(@NotNull String bundleName); + + Builder from(CreateCreditBundleRequestBody other); + } + + public interface CreditIdStage { + CurrencyStage creditId(@NotNull String creditId); + } + + public interface CurrencyStage { + PricePerUnitStage currency(@NotNull String currency); + } + + public interface PricePerUnitStage { + _FinalStage pricePerUnit(int pricePerUnit); + } + + public interface _FinalStage { + CreateCreditBundleRequestBody build(); + + _FinalStage bundleType(Optional bundleType); + + _FinalStage bundleType(String bundleType); + + _FinalStage expiryType(Optional expiryType); + + _FinalStage expiryType(CreateCreditBundleRequestBodyExpiryType expiryType); + + _FinalStage expiryUnit(Optional expiryUnit); + + _FinalStage expiryUnit(CreateCreditBundleRequestBodyExpiryUnit expiryUnit); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + + _FinalStage pricePerUnitDecimal(Optional pricePerUnitDecimal); + + _FinalStage pricePerUnitDecimal(String pricePerUnitDecimal); + + _FinalStage quantity(Optional quantity); + + _FinalStage quantity(Integer quantity); + + _FinalStage status(Optional status); + + _FinalStage status(CreateCreditBundleRequestBodyStatus status); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements BundleNameStage, CreditIdStage, CurrencyStage, PricePerUnitStage, _FinalStage { + private String bundleName; + + private String creditId; + + private String currency; + + private int pricePerUnit; + + private Optional status = Optional.empty(); + + private Optional quantity = Optional.empty(); + + private Optional pricePerUnitDecimal = Optional.empty(); + + private Optional expiryUnitCount = Optional.empty(); + + private Optional expiryUnit = Optional.empty(); + + private Optional expiryType = Optional.empty(); + + private Optional bundleType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateCreditBundleRequestBody other) { + bundleName(other.getBundleName()); + bundleType(other.getBundleType()); + creditId(other.getCreditId()); + currency(other.getCurrency()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + pricePerUnit(other.getPricePerUnit()); + pricePerUnitDecimal(other.getPricePerUnitDecimal()); + quantity(other.getQuantity()); + status(other.getStatus()); + return this; + } + + @java.lang.Override + @JsonSetter("bundle_name") + public CreditIdStage bundleName(@NotNull String bundleName) { + this.bundleName = Objects.requireNonNull(bundleName, "bundleName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public CurrencyStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("currency") + public PricePerUnitStage currency(@NotNull String currency) { + this.currency = Objects.requireNonNull(currency, "currency must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("price_per_unit") + public _FinalStage pricePerUnit(int pricePerUnit) { + this.pricePerUnit = pricePerUnit; + return this; + } + + @java.lang.Override + public _FinalStage status(CreateCreditBundleRequestBodyStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + @java.lang.Override + public _FinalStage quantity(Integer quantity) { + this.quantity = Optional.ofNullable(quantity); + return this; + } + + @java.lang.Override + @JsonSetter(value = "quantity", nulls = Nulls.SKIP) + public _FinalStage quantity(Optional quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + public _FinalStage pricePerUnitDecimal(String pricePerUnitDecimal) { + this.pricePerUnitDecimal = Optional.ofNullable(pricePerUnitDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_per_unit_decimal", nulls = Nulls.SKIP) + public _FinalStage pricePerUnitDecimal(Optional pricePerUnitDecimal) { + this.pricePerUnitDecimal = pricePerUnitDecimal; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnit(CreateCreditBundleRequestBodyExpiryUnit expiryUnit) { + this.expiryUnit = Optional.ofNullable(expiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit", nulls = Nulls.SKIP) + public _FinalStage expiryUnit(Optional expiryUnit) { + this.expiryUnit = expiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage expiryType(CreateCreditBundleRequestBodyExpiryType expiryType) { + this.expiryType = Optional.ofNullable(expiryType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_type", nulls = Nulls.SKIP) + public _FinalStage expiryType(Optional expiryType) { + this.expiryType = expiryType; + return this; + } + + @java.lang.Override + public _FinalStage bundleType(String bundleType) { + this.bundleType = Optional.ofNullable(bundleType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "bundle_type", nulls = Nulls.SKIP) + public _FinalStage bundleType(Optional bundleType) { + this.bundleType = bundleType; + return this; + } + + @java.lang.Override + public CreateCreditBundleRequestBody build() { + return new CreateCreditBundleRequestBody( + bundleName, + bundleType, + creditId, + currency, + expiryType, + expiryUnit, + expiryUnitCount, + pricePerUnit, + pricePerUnitDecimal, + quantity, + status, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/GetEnrichedCreditLedgerRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/GetEnrichedCreditLedgerRequest.java new file mode 100644 index 0000000..5c87973 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/GetEnrichedCreditLedgerRequest.java @@ -0,0 +1,354 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerRequestPeriod; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetEnrichedCreditLedgerRequest.Builder.class) +public final class GetEnrichedCreditLedgerRequest { + private final String companyId; + + private final Optional billingCreditId; + + private final Optional featureId; + + private final GetEnrichedCreditLedgerRequestPeriod period; + + private final Optional startTime; + + private final Optional endTime; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private GetEnrichedCreditLedgerRequest( + String companyId, + Optional billingCreditId, + Optional featureId, + GetEnrichedCreditLedgerRequestPeriod period, + Optional startTime, + Optional endTime, + Optional limit, + Optional offset, + Map additionalProperties) { + this.companyId = companyId; + this.billingCreditId = billingCreditId; + this.featureId = featureId; + this.period = period; + this.startTime = startTime; + this.endTime = endTime; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("billing_credit_id") + public Optional getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + + @JsonProperty("period") + public GetEnrichedCreditLedgerRequestPeriod getPeriod() { + return period; + } + + @JsonProperty("start_time") + public Optional getStartTime() { + return startTime; + } + + @JsonProperty("end_time") + public Optional getEndTime() { + return endTime; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetEnrichedCreditLedgerRequest && equalTo((GetEnrichedCreditLedgerRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetEnrichedCreditLedgerRequest other) { + return companyId.equals(other.companyId) + && billingCreditId.equals(other.billingCreditId) + && featureId.equals(other.featureId) + && period.equals(other.period) + && startTime.equals(other.startTime) + && endTime.equals(other.endTime) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.companyId, + this.billingCreditId, + this.featureId, + this.period, + this.startTime, + this.endTime, + this.limit, + this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + PeriodStage companyId(@NotNull String companyId); + + Builder from(GetEnrichedCreditLedgerRequest other); + } + + public interface PeriodStage { + _FinalStage period(@NotNull GetEnrichedCreditLedgerRequestPeriod period); + } + + public interface _FinalStage { + GetEnrichedCreditLedgerRequest build(); + + _FinalStage billingCreditId(Optional billingCreditId); + + _FinalStage billingCreditId(String billingCreditId); + + _FinalStage featureId(Optional featureId); + + _FinalStage featureId(String featureId); + + _FinalStage startTime(Optional startTime); + + _FinalStage startTime(String startTime); + + _FinalStage endTime(Optional endTime); + + _FinalStage endTime(String endTime); + + /** + *

Page limit (default 100)

+ */ + _FinalStage limit(Optional limit); + + _FinalStage limit(Integer limit); + + /** + *

Page offset (default 0)

+ */ + _FinalStage offset(Optional offset); + + _FinalStage offset(Integer offset); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, PeriodStage, _FinalStage { + private String companyId; + + private GetEnrichedCreditLedgerRequestPeriod period; + + private Optional offset = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional endTime = Optional.empty(); + + private Optional startTime = Optional.empty(); + + private Optional featureId = Optional.empty(); + + private Optional billingCreditId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetEnrichedCreditLedgerRequest other) { + companyId(other.getCompanyId()); + billingCreditId(other.getBillingCreditId()); + featureId(other.getFeatureId()); + period(other.getPeriod()); + startTime(other.getStartTime()); + endTime(other.getEndTime()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public PeriodStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("period") + public _FinalStage period(@NotNull GetEnrichedCreditLedgerRequestPeriod period) { + this.period = Objects.requireNonNull(period, "period must not be null"); + return this; + } + + /** + *

Page offset (default 0)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @java.lang.Override + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public _FinalStage offset(Optional offset) { + this.offset = offset; + return this; + } + + /** + *

Page limit (default 100)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @java.lang.Override + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public _FinalStage limit(Optional limit) { + this.limit = limit; + return this; + } + + @java.lang.Override + public _FinalStage endTime(String endTime) { + this.endTime = Optional.ofNullable(endTime); + return this; + } + + @java.lang.Override + @JsonSetter(value = "end_time", nulls = Nulls.SKIP) + public _FinalStage endTime(Optional endTime) { + this.endTime = endTime; + return this; + } + + @java.lang.Override + public _FinalStage startTime(String startTime) { + this.startTime = Optional.ofNullable(startTime); + return this; + } + + @java.lang.Override + @JsonSetter(value = "start_time", nulls = Nulls.SKIP) + public _FinalStage startTime(Optional startTime) { + this.startTime = startTime; + return this; + } + + @java.lang.Override + public _FinalStage featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public _FinalStage featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + @java.lang.Override + public _FinalStage billingCreditId(String billingCreditId) { + this.billingCreditId = Optional.ofNullable(billingCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_credit_id", nulls = Nulls.SKIP) + public _FinalStage billingCreditId(Optional billingCreditId) { + this.billingCreditId = billingCreditId; + return this; + } + + @java.lang.Override + public GetEnrichedCreditLedgerRequest build() { + return new GetEnrichedCreditLedgerRequest( + companyId, + billingCreditId, + featureId, + period, + startTime, + endTime, + limit, + offset, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/ListBillingCreditsRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/ListBillingCreditsRequest.java new file mode 100644 index 0000000..f30eda9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/ListBillingCreditsRequest.java @@ -0,0 +1,188 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListBillingCreditsRequest.Builder.class) +public final class ListBillingCreditsRequest { + private final Optional> ids; + + private final Optional name; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListBillingCreditsRequest( + Optional> ids, + Optional name, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.name = name; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListBillingCreditsRequest && equalTo((ListBillingCreditsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListBillingCreditsRequest other) { + return ids.equals(other.ids) + && name.equals(other.name) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.name, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListBillingCreditsRequest other) { + ids(other.getIds()); + name(other.getName()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListBillingCreditsRequest build() { + return new ListBillingCreditsRequest(ids, name, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/ListBillingPlanCreditGrantsRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/ListBillingPlanCreditGrantsRequest.java new file mode 100644 index 0000000..f5c0273 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/ListBillingPlanCreditGrantsRequest.java @@ -0,0 +1,243 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListBillingPlanCreditGrantsRequest.Builder.class) +public final class ListBillingPlanCreditGrantsRequest { + private final Optional> planIds; + + private final Optional> ids; + + private final Optional creditId; + + private final Optional planId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListBillingPlanCreditGrantsRequest( + Optional> planIds, + Optional> ids, + Optional creditId, + Optional planId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.planIds = planIds; + this.ids = ids; + this.creditId = creditId; + this.planId = planId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListBillingPlanCreditGrantsRequest + && equalTo((ListBillingPlanCreditGrantsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListBillingPlanCreditGrantsRequest other) { + return planIds.equals(other.planIds) + && ids.equals(other.ids) + && creditId.equals(other.creditId) + && planId.equals(other.planId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.planIds, this.ids, this.creditId, this.planId, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> planIds = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListBillingPlanCreditGrantsRequest other) { + planIds(other.getPlanIds()); + ids(other.getIds()); + creditId(other.getCreditId()); + planId(other.getPlanId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + public Builder planIds(String planIds) { + this.planIds = Optional.of(Collections.singletonList(planIds)); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListBillingPlanCreditGrantsRequest build() { + return new ListBillingPlanCreditGrantsRequest( + planIds, ids, creditId, planId, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/ListCompanyGrantsRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/ListCompanyGrantsRequest.java new file mode 100644 index 0000000..fd1849b --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/ListCompanyGrantsRequest.java @@ -0,0 +1,207 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.ListCompanyGrantsRequestDir; +import com.schematic.api.resources.credits.types.ListCompanyGrantsRequestOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompanyGrantsRequest.Builder.class) +public final class ListCompanyGrantsRequest { + private final Optional companyId; + + private final Optional order; + + private final Optional dir; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListCompanyGrantsRequest( + Optional companyId, + Optional order, + Optional dir, + Optional limit, + Optional offset, + Map additionalProperties) { + this.companyId = companyId; + this.order = order; + this.dir = dir; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("order") + public Optional getOrder() { + return order; + } + + @JsonProperty("dir") + public Optional getDir() { + return dir; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompanyGrantsRequest && equalTo((ListCompanyGrantsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompanyGrantsRequest other) { + return companyId.equals(other.companyId) + && order.equals(other.order) + && dir.equals(other.dir) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId, this.order, this.dir, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional companyId = Optional.empty(); + + private Optional order = Optional.empty(); + + private Optional dir = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCompanyGrantsRequest other) { + companyId(other.getCompanyId()); + order(other.getOrder()); + dir(other.getDir()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "order", nulls = Nulls.SKIP) + public Builder order(Optional order) { + this.order = order; + return this; + } + + public Builder order(ListCompanyGrantsRequestOrder order) { + this.order = Optional.ofNullable(order); + return this; + } + + @JsonSetter(value = "dir", nulls = Nulls.SKIP) + public Builder dir(Optional dir) { + this.dir = dir; + return this; + } + + public Builder dir(ListCompanyGrantsRequestDir dir) { + this.dir = Optional.ofNullable(dir); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListCompanyGrantsRequest build() { + return new ListCompanyGrantsRequest(companyId, order, dir, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/ListCreditBundlesRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/ListCreditBundlesRequest.java new file mode 100644 index 0000000..150f735 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/ListCreditBundlesRequest.java @@ -0,0 +1,237 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.ListCreditBundlesRequestStatus; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCreditBundlesRequest.Builder.class) +public final class ListCreditBundlesRequest { + private final Optional> ids; + + private final Optional creditId; + + private final Optional status; + + private final Optional bundleType; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListCreditBundlesRequest( + Optional> ids, + Optional creditId, + Optional status, + Optional bundleType, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.creditId = creditId; + this.status = status; + this.bundleType = bundleType; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @JsonProperty("bundle_type") + public Optional getBundleType() { + return bundleType; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCreditBundlesRequest && equalTo((ListCreditBundlesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCreditBundlesRequest other) { + return ids.equals(other.ids) + && creditId.equals(other.creditId) + && status.equals(other.status) + && bundleType.equals(other.bundleType) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.creditId, this.status, this.bundleType, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional bundleType = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCreditBundlesRequest other) { + ids(other.getIds()); + creditId(other.getCreditId()); + status(other.getStatus()); + bundleType(other.getBundleType()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(ListCreditBundlesRequestStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + @JsonSetter(value = "bundle_type", nulls = Nulls.SKIP) + public Builder bundleType(Optional bundleType) { + this.bundleType = bundleType; + return this; + } + + public Builder bundleType(String bundleType) { + this.bundleType = Optional.ofNullable(bundleType); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListCreditBundlesRequest build() { + return new ListCreditBundlesRequest(ids, creditId, status, bundleType, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/ListGrantsForCreditRequest.java b/src/main/java/com/schematic/api/resources/credits/requests/ListGrantsForCreditRequest.java new file mode 100644 index 0000000..36ac8bb --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/ListGrantsForCreditRequest.java @@ -0,0 +1,188 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListGrantsForCreditRequest.Builder.class) +public final class ListGrantsForCreditRequest { + private final Optional> ids; + + private final Optional creditId; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListGrantsForCreditRequest( + Optional> ids, + Optional creditId, + Optional limit, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.creditId = creditId; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListGrantsForCreditRequest && equalTo((ListGrantsForCreditRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListGrantsForCreditRequest other) { + return ids.equals(other.ids) + && creditId.equals(other.creditId) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.creditId, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListGrantsForCreditRequest other) { + ids(other.getIds()); + creditId(other.getCreditId()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListGrantsForCreditRequest build() { + return new ListGrantsForCreditRequest(ids, creditId, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/UpdateBillingCreditRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/UpdateBillingCreditRequestBody.java new file mode 100644 index 0000000..cb7fea2 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/UpdateBillingCreditRequestBody.java @@ -0,0 +1,428 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.UpdateBillingCreditRequestBodyBurnStrategy; +import com.schematic.api.resources.credits.types.UpdateBillingCreditRequestBodyDefaultRolloverPolicy; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateBillingCreditRequestBody.Builder.class) +public final class UpdateBillingCreditRequestBody { + private final Optional burnStrategy; + + private final Optional defaultExpiryUnit; + + private final Optional defaultExpiryUnitCount; + + private final Optional defaultRolloverPolicy; + + private final String description; + + private final Optional icon; + + private final String name; + + private final Optional perUnitPrice; + + private final Optional perUnitPriceDecimal; + + private final Optional pluralName; + + private final Optional singularName; + + private final Map additionalProperties; + + private UpdateBillingCreditRequestBody( + Optional burnStrategy, + Optional defaultExpiryUnit, + Optional defaultExpiryUnitCount, + Optional defaultRolloverPolicy, + String description, + Optional icon, + String name, + Optional perUnitPrice, + Optional perUnitPriceDecimal, + Optional pluralName, + Optional singularName, + Map additionalProperties) { + this.burnStrategy = burnStrategy; + this.defaultExpiryUnit = defaultExpiryUnit; + this.defaultExpiryUnitCount = defaultExpiryUnitCount; + this.defaultRolloverPolicy = defaultRolloverPolicy; + this.description = description; + this.icon = icon; + this.name = name; + this.perUnitPrice = perUnitPrice; + this.perUnitPriceDecimal = perUnitPriceDecimal; + this.pluralName = pluralName; + this.singularName = singularName; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("burn_strategy") + public Optional getBurnStrategy() { + return burnStrategy; + } + + @JsonProperty("default_expiry_unit") + public Optional getDefaultExpiryUnit() { + return defaultExpiryUnit; + } + + @JsonProperty("default_expiry_unit_count") + public Optional getDefaultExpiryUnitCount() { + return defaultExpiryUnitCount; + } + + @JsonProperty("default_rollover_policy") + public Optional getDefaultRolloverPolicy() { + return defaultRolloverPolicy; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("per_unit_price") + public Optional getPerUnitPrice() { + return perUnitPrice; + } + + @JsonProperty("per_unit_price_decimal") + public Optional getPerUnitPriceDecimal() { + return perUnitPriceDecimal; + } + + @JsonProperty("plural_name") + public Optional getPluralName() { + return pluralName; + } + + @JsonProperty("singular_name") + public Optional getSingularName() { + return singularName; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateBillingCreditRequestBody && equalTo((UpdateBillingCreditRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateBillingCreditRequestBody other) { + return burnStrategy.equals(other.burnStrategy) + && defaultExpiryUnit.equals(other.defaultExpiryUnit) + && defaultExpiryUnitCount.equals(other.defaultExpiryUnitCount) + && defaultRolloverPolicy.equals(other.defaultRolloverPolicy) + && description.equals(other.description) + && icon.equals(other.icon) + && name.equals(other.name) + && perUnitPrice.equals(other.perUnitPrice) + && perUnitPriceDecimal.equals(other.perUnitPriceDecimal) + && pluralName.equals(other.pluralName) + && singularName.equals(other.singularName); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.burnStrategy, + this.defaultExpiryUnit, + this.defaultExpiryUnitCount, + this.defaultRolloverPolicy, + this.description, + this.icon, + this.name, + this.perUnitPrice, + this.perUnitPriceDecimal, + this.pluralName, + this.singularName); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DescriptionStage builder() { + return new Builder(); + } + + public interface DescriptionStage { + NameStage description(@NotNull String description); + + Builder from(UpdateBillingCreditRequestBody other); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + UpdateBillingCreditRequestBody build(); + + _FinalStage burnStrategy(Optional burnStrategy); + + _FinalStage burnStrategy(UpdateBillingCreditRequestBodyBurnStrategy burnStrategy); + + _FinalStage defaultExpiryUnit(Optional defaultExpiryUnit); + + _FinalStage defaultExpiryUnit(String defaultExpiryUnit); + + _FinalStage defaultExpiryUnitCount(Optional defaultExpiryUnitCount); + + _FinalStage defaultExpiryUnitCount(Integer defaultExpiryUnitCount); + + _FinalStage defaultRolloverPolicy( + Optional defaultRolloverPolicy); + + _FinalStage defaultRolloverPolicy(UpdateBillingCreditRequestBodyDefaultRolloverPolicy defaultRolloverPolicy); + + _FinalStage icon(Optional icon); + + _FinalStage icon(String icon); + + _FinalStage perUnitPrice(Optional perUnitPrice); + + _FinalStage perUnitPrice(Integer perUnitPrice); + + _FinalStage perUnitPriceDecimal(Optional perUnitPriceDecimal); + + _FinalStage perUnitPriceDecimal(String perUnitPriceDecimal); + + _FinalStage pluralName(Optional pluralName); + + _FinalStage pluralName(String pluralName); + + _FinalStage singularName(Optional singularName); + + _FinalStage singularName(String singularName); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DescriptionStage, NameStage, _FinalStage { + private String description; + + private String name; + + private Optional singularName = Optional.empty(); + + private Optional pluralName = Optional.empty(); + + private Optional perUnitPriceDecimal = Optional.empty(); + + private Optional perUnitPrice = Optional.empty(); + + private Optional icon = Optional.empty(); + + private Optional defaultRolloverPolicy = Optional.empty(); + + private Optional defaultExpiryUnitCount = Optional.empty(); + + private Optional defaultExpiryUnit = Optional.empty(); + + private Optional burnStrategy = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateBillingCreditRequestBody other) { + burnStrategy(other.getBurnStrategy()); + defaultExpiryUnit(other.getDefaultExpiryUnit()); + defaultExpiryUnitCount(other.getDefaultExpiryUnitCount()); + defaultRolloverPolicy(other.getDefaultRolloverPolicy()); + description(other.getDescription()); + icon(other.getIcon()); + name(other.getName()); + perUnitPrice(other.getPerUnitPrice()); + perUnitPriceDecimal(other.getPerUnitPriceDecimal()); + pluralName(other.getPluralName()); + singularName(other.getSingularName()); + return this; + } + + @java.lang.Override + @JsonSetter("description") + public NameStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage singularName(String singularName) { + this.singularName = Optional.ofNullable(singularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "singular_name", nulls = Nulls.SKIP) + public _FinalStage singularName(Optional singularName) { + this.singularName = singularName; + return this; + } + + @java.lang.Override + public _FinalStage pluralName(String pluralName) { + this.pluralName = Optional.ofNullable(pluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plural_name", nulls = Nulls.SKIP) + public _FinalStage pluralName(Optional pluralName) { + this.pluralName = pluralName; + return this; + } + + @java.lang.Override + public _FinalStage perUnitPriceDecimal(String perUnitPriceDecimal) { + this.perUnitPriceDecimal = Optional.ofNullable(perUnitPriceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "per_unit_price_decimal", nulls = Nulls.SKIP) + public _FinalStage perUnitPriceDecimal(Optional perUnitPriceDecimal) { + this.perUnitPriceDecimal = perUnitPriceDecimal; + return this; + } + + @java.lang.Override + public _FinalStage perUnitPrice(Integer perUnitPrice) { + this.perUnitPrice = Optional.ofNullable(perUnitPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "per_unit_price", nulls = Nulls.SKIP) + public _FinalStage perUnitPrice(Optional perUnitPrice) { + this.perUnitPrice = perUnitPrice; + return this; + } + + @java.lang.Override + public _FinalStage icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public _FinalStage icon(Optional icon) { + this.icon = icon; + return this; + } + + @java.lang.Override + public _FinalStage defaultRolloverPolicy( + UpdateBillingCreditRequestBodyDefaultRolloverPolicy defaultRolloverPolicy) { + this.defaultRolloverPolicy = Optional.ofNullable(defaultRolloverPolicy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_rollover_policy", nulls = Nulls.SKIP) + public _FinalStage defaultRolloverPolicy( + Optional defaultRolloverPolicy) { + this.defaultRolloverPolicy = defaultRolloverPolicy; + return this; + } + + @java.lang.Override + public _FinalStage defaultExpiryUnitCount(Integer defaultExpiryUnitCount) { + this.defaultExpiryUnitCount = Optional.ofNullable(defaultExpiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage defaultExpiryUnitCount(Optional defaultExpiryUnitCount) { + this.defaultExpiryUnitCount = defaultExpiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage defaultExpiryUnit(String defaultExpiryUnit) { + this.defaultExpiryUnit = Optional.ofNullable(defaultExpiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_expiry_unit", nulls = Nulls.SKIP) + public _FinalStage defaultExpiryUnit(Optional defaultExpiryUnit) { + this.defaultExpiryUnit = defaultExpiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage burnStrategy(UpdateBillingCreditRequestBodyBurnStrategy burnStrategy) { + this.burnStrategy = Optional.ofNullable(burnStrategy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "burn_strategy", nulls = Nulls.SKIP) + public _FinalStage burnStrategy(Optional burnStrategy) { + this.burnStrategy = burnStrategy; + return this; + } + + @java.lang.Override + public UpdateBillingCreditRequestBody build() { + return new UpdateBillingCreditRequestBody( + burnStrategy, + defaultExpiryUnit, + defaultExpiryUnitCount, + defaultRolloverPolicy, + description, + icon, + name, + perUnitPrice, + perUnitPriceDecimal, + pluralName, + singularName, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/UpdateCreditBundleDetailsRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/UpdateCreditBundleDetailsRequestBody.java new file mode 100644 index 0000000..1007ae7 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/UpdateCreditBundleDetailsRequestBody.java @@ -0,0 +1,331 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsRequestBodyExpiryType; +import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsRequestBodyExpiryUnit; +import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsRequestBodyStatus; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateCreditBundleDetailsRequestBody.Builder.class) +public final class UpdateCreditBundleDetailsRequestBody { + private final String bundleName; + + private final Optional expiryType; + + private final Optional expiryUnit; + + private final Optional expiryUnitCount; + + private final int pricePerUnit; + + private final Optional pricePerUnitDecimal; + + private final Optional quantity; + + private final Optional status; + + private final Map additionalProperties; + + private UpdateCreditBundleDetailsRequestBody( + String bundleName, + Optional expiryType, + Optional expiryUnit, + Optional expiryUnitCount, + int pricePerUnit, + Optional pricePerUnitDecimal, + Optional quantity, + Optional status, + Map additionalProperties) { + this.bundleName = bundleName; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.pricePerUnit = pricePerUnit; + this.pricePerUnitDecimal = pricePerUnitDecimal; + this.quantity = quantity; + this.status = status; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("bundle_name") + public String getBundleName() { + return bundleName; + } + + @JsonProperty("expiry_type") + public Optional getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public Optional getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("price_per_unit") + public int getPricePerUnit() { + return pricePerUnit; + } + + @JsonProperty("price_per_unit_decimal") + public Optional getPricePerUnitDecimal() { + return pricePerUnitDecimal; + } + + @JsonProperty("quantity") + public Optional getQuantity() { + return quantity; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCreditBundleDetailsRequestBody + && equalTo((UpdateCreditBundleDetailsRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCreditBundleDetailsRequestBody other) { + return bundleName.equals(other.bundleName) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && pricePerUnit == other.pricePerUnit + && pricePerUnitDecimal.equals(other.pricePerUnitDecimal) + && quantity.equals(other.quantity) + && status.equals(other.status); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.bundleName, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.pricePerUnit, + this.pricePerUnitDecimal, + this.quantity, + this.status); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BundleNameStage builder() { + return new Builder(); + } + + public interface BundleNameStage { + PricePerUnitStage bundleName(@NotNull String bundleName); + + Builder from(UpdateCreditBundleDetailsRequestBody other); + } + + public interface PricePerUnitStage { + _FinalStage pricePerUnit(int pricePerUnit); + } + + public interface _FinalStage { + UpdateCreditBundleDetailsRequestBody build(); + + _FinalStage expiryType(Optional expiryType); + + _FinalStage expiryType(UpdateCreditBundleDetailsRequestBodyExpiryType expiryType); + + _FinalStage expiryUnit(Optional expiryUnit); + + _FinalStage expiryUnit(UpdateCreditBundleDetailsRequestBodyExpiryUnit expiryUnit); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + + _FinalStage pricePerUnitDecimal(Optional pricePerUnitDecimal); + + _FinalStage pricePerUnitDecimal(String pricePerUnitDecimal); + + _FinalStage quantity(Optional quantity); + + _FinalStage quantity(Integer quantity); + + _FinalStage status(Optional status); + + _FinalStage status(UpdateCreditBundleDetailsRequestBodyStatus status); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements BundleNameStage, PricePerUnitStage, _FinalStage { + private String bundleName; + + private int pricePerUnit; + + private Optional status = Optional.empty(); + + private Optional quantity = Optional.empty(); + + private Optional pricePerUnitDecimal = Optional.empty(); + + private Optional expiryUnitCount = Optional.empty(); + + private Optional expiryUnit = Optional.empty(); + + private Optional expiryType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCreditBundleDetailsRequestBody other) { + bundleName(other.getBundleName()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + pricePerUnit(other.getPricePerUnit()); + pricePerUnitDecimal(other.getPricePerUnitDecimal()); + quantity(other.getQuantity()); + status(other.getStatus()); + return this; + } + + @java.lang.Override + @JsonSetter("bundle_name") + public PricePerUnitStage bundleName(@NotNull String bundleName) { + this.bundleName = Objects.requireNonNull(bundleName, "bundleName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("price_per_unit") + public _FinalStage pricePerUnit(int pricePerUnit) { + this.pricePerUnit = pricePerUnit; + return this; + } + + @java.lang.Override + public _FinalStage status(UpdateCreditBundleDetailsRequestBodyStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + @java.lang.Override + public _FinalStage quantity(Integer quantity) { + this.quantity = Optional.ofNullable(quantity); + return this; + } + + @java.lang.Override + @JsonSetter(value = "quantity", nulls = Nulls.SKIP) + public _FinalStage quantity(Optional quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + public _FinalStage pricePerUnitDecimal(String pricePerUnitDecimal) { + this.pricePerUnitDecimal = Optional.ofNullable(pricePerUnitDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_per_unit_decimal", nulls = Nulls.SKIP) + public _FinalStage pricePerUnitDecimal(Optional pricePerUnitDecimal) { + this.pricePerUnitDecimal = pricePerUnitDecimal; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnit(UpdateCreditBundleDetailsRequestBodyExpiryUnit expiryUnit) { + this.expiryUnit = Optional.ofNullable(expiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit", nulls = Nulls.SKIP) + public _FinalStage expiryUnit(Optional expiryUnit) { + this.expiryUnit = expiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage expiryType(UpdateCreditBundleDetailsRequestBodyExpiryType expiryType) { + this.expiryType = Optional.ofNullable(expiryType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_type", nulls = Nulls.SKIP) + public _FinalStage expiryType(Optional expiryType) { + this.expiryType = expiryType; + return this; + } + + @java.lang.Override + public UpdateCreditBundleDetailsRequestBody build() { + return new UpdateCreditBundleDetailsRequestBody( + bundleName, + expiryType, + expiryUnit, + expiryUnitCount, + pricePerUnit, + pricePerUnitDecimal, + quantity, + status, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/requests/ZeroOutGrantRequestBody.java b/src/main/java/com/schematic/api/resources/credits/requests/ZeroOutGrantRequestBody.java new file mode 100644 index 0000000..81ede75 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/requests/ZeroOutGrantRequestBody.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.types.ZeroOutGrantRequestBodyReason; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ZeroOutGrantRequestBody.Builder.class) +public final class ZeroOutGrantRequestBody { + private final Optional reason; + + private final Map additionalProperties; + + private ZeroOutGrantRequestBody( + Optional reason, Map additionalProperties) { + this.reason = reason; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("reason") + public Optional getReason() { + return reason; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ZeroOutGrantRequestBody && equalTo((ZeroOutGrantRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ZeroOutGrantRequestBody other) { + return reason.equals(other.reason); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.reason); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional reason = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ZeroOutGrantRequestBody other) { + reason(other.getReason()); + return this; + } + + @JsonSetter(value = "reason", nulls = Nulls.SKIP) + public Builder reason(Optional reason) { + this.reason = reason; + return this; + } + + public Builder reason(ZeroOutGrantRequestBodyReason reason) { + this.reason = Optional.ofNullable(reason); + return this; + } + + public ZeroOutGrantRequestBody build() { + return new ZeroOutGrantRequestBody(reason, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsParams.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsParams.java new file mode 100644 index 0000000..fa25bc8 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsParams.java @@ -0,0 +1,182 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingCreditsGrantsParams.Builder.class) +public final class CountBillingCreditsGrantsParams { + private final Optional creditId; + + private final Optional> ids; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private CountBillingCreditsGrantsParams( + Optional creditId, + Optional> ids, + Optional limit, + Optional offset, + Map additionalProperties) { + this.creditId = creditId; + this.ids = ids; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingCreditsGrantsParams && equalTo((CountBillingCreditsGrantsParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingCreditsGrantsParams other) { + return creditId.equals(other.creditId) + && ids.equals(other.ids) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.creditId, this.ids, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional creditId = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountBillingCreditsGrantsParams other) { + creditId(other.getCreditId()); + ids(other.getIds()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountBillingCreditsGrantsParams build() { + return new CountBillingCreditsGrantsParams(creditId, ids, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsResponse.java new file mode 100644 index 0000000..010cede --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsGrantsResponse.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CountResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingCreditsGrantsResponse.Builder.class) +public final class CountBillingCreditsGrantsResponse { + private final CountResponse data; + + private final CountBillingCreditsGrantsParams params; + + private final Map additionalProperties; + + private CountBillingCreditsGrantsResponse( + CountResponse data, CountBillingCreditsGrantsParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CountResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public CountBillingCreditsGrantsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingCreditsGrantsResponse && equalTo((CountBillingCreditsGrantsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingCreditsGrantsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + ParamsStage data(@NotNull CountResponse data); + + Builder from(CountBillingCreditsGrantsResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull CountBillingCreditsGrantsParams params); + } + + public interface _FinalStage { + CountBillingCreditsGrantsResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CountResponse data; + + private CountBillingCreditsGrantsParams params; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountBillingCreditsGrantsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CountResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull CountBillingCreditsGrantsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public CountBillingCreditsGrantsResponse build() { + return new CountBillingCreditsGrantsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsParams.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsParams.java new file mode 100644 index 0000000..1fdb843 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsParams.java @@ -0,0 +1,182 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingCreditsParams.Builder.class) +public final class CountBillingCreditsParams { + private final Optional> ids; + + private final Optional limit; + + private final Optional name; + + private final Optional offset; + + private final Map additionalProperties; + + private CountBillingCreditsParams( + Optional> ids, + Optional limit, + Optional name, + Optional offset, + Map additionalProperties) { + this.ids = ids; + this.limit = limit; + this.name = name; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingCreditsParams && equalTo((CountBillingCreditsParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingCreditsParams other) { + return ids.equals(other.ids) + && limit.equals(other.limit) + && name.equals(other.name) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ids, this.limit, this.name, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountBillingCreditsParams other) { + ids(other.getIds()); + limit(other.getLimit()); + name(other.getName()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public CountBillingCreditsParams build() { + return new CountBillingCreditsParams(ids, limit, name, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsResponse.java new file mode 100644 index 0000000..e9304a0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingCreditsResponse.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CountResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingCreditsResponse.Builder.class) +public final class CountBillingCreditsResponse { + private final CountResponse data; + + private final CountBillingCreditsParams params; + + private final Map additionalProperties; + + private CountBillingCreditsResponse( + CountResponse data, CountBillingCreditsParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CountResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public CountBillingCreditsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingCreditsResponse && equalTo((CountBillingCreditsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingCreditsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + ParamsStage data(@NotNull CountResponse data); + + Builder from(CountBillingCreditsResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull CountBillingCreditsParams params); + } + + public interface _FinalStage { + CountBillingCreditsResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CountResponse data; + + private CountBillingCreditsParams params; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountBillingCreditsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CountResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull CountBillingCreditsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public CountBillingCreditsResponse build() { + return new CountBillingCreditsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsParams.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsParams.java new file mode 100644 index 0000000..1be80aa --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsParams.java @@ -0,0 +1,232 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingPlanCreditGrantsParams.Builder.class) +public final class CountBillingPlanCreditGrantsParams { + private final Optional creditId; + + private final Optional> ids; + + private final Optional limit; + + private final Optional offset; + + private final Optional planId; + + private final Optional> planIds; + + private final Map additionalProperties; + + private CountBillingPlanCreditGrantsParams( + Optional creditId, + Optional> ids, + Optional limit, + Optional offset, + Optional planId, + Optional> planIds, + Map additionalProperties) { + this.creditId = creditId; + this.ids = ids; + this.limit = limit; + this.offset = offset; + this.planId = planId; + this.planIds = planIds; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingPlanCreditGrantsParams + && equalTo((CountBillingPlanCreditGrantsParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingPlanCreditGrantsParams other) { + return creditId.equals(other.creditId) + && ids.equals(other.ids) + && limit.equals(other.limit) + && offset.equals(other.offset) + && planId.equals(other.planId) + && planIds.equals(other.planIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.creditId, this.ids, this.limit, this.offset, this.planId, this.planIds); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional creditId = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional> planIds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountBillingPlanCreditGrantsParams other) { + creditId(other.getCreditId()); + ids(other.getIds()); + limit(other.getLimit()); + offset(other.getOffset()); + planId(other.getPlanId()); + planIds(other.getPlanIds()); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + public CountBillingPlanCreditGrantsParams build() { + return new CountBillingPlanCreditGrantsParams( + creditId, ids, limit, offset, planId, planIds, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsResponse.java new file mode 100644 index 0000000..683c5ba --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountBillingPlanCreditGrantsResponse.java @@ -0,0 +1,138 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CountResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountBillingPlanCreditGrantsResponse.Builder.class) +public final class CountBillingPlanCreditGrantsResponse { + private final CountResponse data; + + private final CountBillingPlanCreditGrantsParams params; + + private final Map additionalProperties; + + private CountBillingPlanCreditGrantsResponse( + CountResponse data, CountBillingPlanCreditGrantsParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CountResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public CountBillingPlanCreditGrantsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountBillingPlanCreditGrantsResponse + && equalTo((CountBillingPlanCreditGrantsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountBillingPlanCreditGrantsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + ParamsStage data(@NotNull CountResponse data); + + Builder from(CountBillingPlanCreditGrantsResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull CountBillingPlanCreditGrantsParams params); + } + + public interface _FinalStage { + CountBillingPlanCreditGrantsResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CountResponse data; + + private CountBillingPlanCreditGrantsParams params; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountBillingPlanCreditGrantsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CountResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull CountBillingPlanCreditGrantsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public CountBillingPlanCreditGrantsResponse build() { + return new CountBillingPlanCreditGrantsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesParams.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesParams.java new file mode 100644 index 0000000..51dc60c --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesParams.java @@ -0,0 +1,230 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditBundlesParams.Builder.class) +public final class CountCreditBundlesParams { + private final Optional bundleType; + + private final Optional creditId; + + private final Optional> ids; + + private final Optional limit; + + private final Optional offset; + + private final Optional status; + + private final Map additionalProperties; + + private CountCreditBundlesParams( + Optional bundleType, + Optional creditId, + Optional> ids, + Optional limit, + Optional offset, + Optional status, + Map additionalProperties) { + this.bundleType = bundleType; + this.creditId = creditId; + this.ids = ids; + this.limit = limit; + this.offset = offset; + this.status = status; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("bundle_type") + public Optional getBundleType() { + return bundleType; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditBundlesParams && equalTo((CountCreditBundlesParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditBundlesParams other) { + return bundleType.equals(other.bundleType) + && creditId.equals(other.creditId) + && ids.equals(other.ids) + && limit.equals(other.limit) + && offset.equals(other.offset) + && status.equals(other.status); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.bundleType, this.creditId, this.ids, this.limit, this.offset, this.status); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional bundleType = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountCreditBundlesParams other) { + bundleType(other.getBundleType()); + creditId(other.getCreditId()); + ids(other.getIds()); + limit(other.getLimit()); + offset(other.getOffset()); + status(other.getStatus()); + return this; + } + + @JsonSetter(value = "bundle_type", nulls = Nulls.SKIP) + public Builder bundleType(Optional bundleType) { + this.bundleType = bundleType; + return this; + } + + public Builder bundleType(String bundleType) { + this.bundleType = Optional.ofNullable(bundleType); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(CountCreditBundlesResponseParamsStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + public CountCreditBundlesParams build() { + return new CountCreditBundlesParams(bundleType, creditId, ids, limit, offset, status, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesRequestStatus.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesRequestStatus.java new file mode 100644 index 0000000..ebf8744 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesRequestStatus.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CountCreditBundlesRequestStatus { + public static final CountCreditBundlesRequestStatus INACTIVE = + new CountCreditBundlesRequestStatus(Value.INACTIVE, "inactive"); + + public static final CountCreditBundlesRequestStatus ACTIVE = + new CountCreditBundlesRequestStatus(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + CountCreditBundlesRequestStatus(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountCreditBundlesRequestStatus + && this.string.equals(((CountCreditBundlesRequestStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case INACTIVE: + return visitor.visitInactive(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountCreditBundlesRequestStatus valueOf(String value) { + switch (value) { + case "inactive": + return INACTIVE; + case "active": + return ACTIVE; + default: + return new CountCreditBundlesRequestStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + INACTIVE, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitInactive(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponse.java new file mode 100644 index 0000000..99f11cb --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponse.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CountResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditBundlesResponse.Builder.class) +public final class CountCreditBundlesResponse { + private final CountResponse data; + + private final CountCreditBundlesParams params; + + private final Map additionalProperties; + + private CountCreditBundlesResponse( + CountResponse data, CountCreditBundlesParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CountResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public CountCreditBundlesParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditBundlesResponse && equalTo((CountCreditBundlesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditBundlesResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + ParamsStage data(@NotNull CountResponse data); + + Builder from(CountCreditBundlesResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull CountCreditBundlesParams params); + } + + public interface _FinalStage { + CountCreditBundlesResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CountResponse data; + + private CountCreditBundlesParams params; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountCreditBundlesResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CountResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull CountCreditBundlesParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public CountCreditBundlesResponse build() { + return new CountCreditBundlesResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponseParamsStatus.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponseParamsStatus.java new file mode 100644 index 0000000..e63ca3a --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditBundlesResponseParamsStatus.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CountCreditBundlesResponseParamsStatus { + public static final CountCreditBundlesResponseParamsStatus INACTIVE = + new CountCreditBundlesResponseParamsStatus(Value.INACTIVE, "inactive"); + + public static final CountCreditBundlesResponseParamsStatus ACTIVE = + new CountCreditBundlesResponseParamsStatus(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + CountCreditBundlesResponseParamsStatus(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountCreditBundlesResponseParamsStatus + && this.string.equals(((CountCreditBundlesResponseParamsStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case INACTIVE: + return visitor.visitInactive(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountCreditBundlesResponseParamsStatus valueOf(String value) { + switch (value) { + case "inactive": + return INACTIVE; + case "active": + return ACTIVE; + default: + return new CountCreditBundlesResponseParamsStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + INACTIVE, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitInactive(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerParams.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerParams.java new file mode 100644 index 0000000..9f9e139 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerParams.java @@ -0,0 +1,294 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditLedgerParams.Builder.class) +public final class CountCreditLedgerParams { + private final Optional billingCreditId; + + private final Optional companyId; + + private final Optional endTime; + + private final Optional featureId; + + private final Optional limit; + + private final Optional offset; + + private final Optional period; + + private final Optional startTime; + + private final Map additionalProperties; + + private CountCreditLedgerParams( + Optional billingCreditId, + Optional companyId, + Optional endTime, + Optional featureId, + Optional limit, + Optional offset, + Optional period, + Optional startTime, + Map additionalProperties) { + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.endTime = endTime; + this.featureId = featureId; + this.limit = limit; + this.offset = offset; + this.period = period; + this.startTime = startTime; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_credit_id") + public Optional getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("end_time") + public Optional getEndTime() { + return endTime; + } + + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("period") + public Optional getPeriod() { + return period; + } + + @JsonProperty("start_time") + public Optional getStartTime() { + return startTime; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditLedgerParams && equalTo((CountCreditLedgerParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditLedgerParams other) { + return billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && endTime.equals(other.endTime) + && featureId.equals(other.featureId) + && limit.equals(other.limit) + && offset.equals(other.offset) + && period.equals(other.period) + && startTime.equals(other.startTime); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingCreditId, + this.companyId, + this.endTime, + this.featureId, + this.limit, + this.offset, + this.period, + this.startTime); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional billingCreditId = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional endTime = Optional.empty(); + + private Optional featureId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional period = Optional.empty(); + + private Optional startTime = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CountCreditLedgerParams other) { + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + endTime(other.getEndTime()); + featureId(other.getFeatureId()); + limit(other.getLimit()); + offset(other.getOffset()); + period(other.getPeriod()); + startTime(other.getStartTime()); + return this; + } + + @JsonSetter(value = "billing_credit_id", nulls = Nulls.SKIP) + public Builder billingCreditId(Optional billingCreditId) { + this.billingCreditId = billingCreditId; + return this; + } + + public Builder billingCreditId(String billingCreditId) { + this.billingCreditId = Optional.ofNullable(billingCreditId); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "end_time", nulls = Nulls.SKIP) + public Builder endTime(Optional endTime) { + this.endTime = endTime; + return this; + } + + public Builder endTime(String endTime) { + this.endTime = Optional.ofNullable(endTime); + return this; + } + + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public Builder featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + public Builder featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "period", nulls = Nulls.SKIP) + public Builder period(Optional period) { + this.period = period; + return this; + } + + public Builder period(CountCreditLedgerResponseParamsPeriod period) { + this.period = Optional.ofNullable(period); + return this; + } + + @JsonSetter(value = "start_time", nulls = Nulls.SKIP) + public Builder startTime(Optional startTime) { + this.startTime = startTime; + return this; + } + + public Builder startTime(String startTime) { + this.startTime = Optional.ofNullable(startTime); + return this; + } + + public CountCreditLedgerParams build() { + return new CountCreditLedgerParams( + billingCreditId, + companyId, + endTime, + featureId, + limit, + offset, + period, + startTime, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerRequestPeriod.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerRequestPeriod.java new file mode 100644 index 0000000..eec7a49 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerRequestPeriod.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CountCreditLedgerRequestPeriod { + public static final CountCreditLedgerRequestPeriod RAW = new CountCreditLedgerRequestPeriod(Value.RAW, "raw"); + + public static final CountCreditLedgerRequestPeriod MONTHLY = + new CountCreditLedgerRequestPeriod(Value.MONTHLY, "monthly"); + + public static final CountCreditLedgerRequestPeriod DAILY = new CountCreditLedgerRequestPeriod(Value.DAILY, "daily"); + + public static final CountCreditLedgerRequestPeriod WEEKLY = + new CountCreditLedgerRequestPeriod(Value.WEEKLY, "weekly"); + + private final Value value; + + private final String string; + + CountCreditLedgerRequestPeriod(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountCreditLedgerRequestPeriod + && this.string.equals(((CountCreditLedgerRequestPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case RAW: + return visitor.visitRaw(); + case MONTHLY: + return visitor.visitMonthly(); + case DAILY: + return visitor.visitDaily(); + case WEEKLY: + return visitor.visitWeekly(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountCreditLedgerRequestPeriod valueOf(String value) { + switch (value) { + case "raw": + return RAW; + case "monthly": + return MONTHLY; + case "daily": + return DAILY; + case "weekly": + return WEEKLY; + default: + return new CountCreditLedgerRequestPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + DAILY, + + WEEKLY, + + MONTHLY, + + RAW, + + UNKNOWN + } + + public interface Visitor { + T visitDaily(); + + T visitWeekly(); + + T visitMonthly(); + + T visitRaw(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerResponse.java new file mode 100644 index 0000000..a0e67b4 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerResponse.java @@ -0,0 +1,137 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CountResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CountCreditLedgerResponse.Builder.class) +public final class CountCreditLedgerResponse { + private final CountResponse data; + + private final CountCreditLedgerParams params; + + private final Map additionalProperties; + + private CountCreditLedgerResponse( + CountResponse data, CountCreditLedgerParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public CountResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public CountCreditLedgerParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CountCreditLedgerResponse && equalTo((CountCreditLedgerResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CountCreditLedgerResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + ParamsStage data(@NotNull CountResponse data); + + Builder from(CountCreditLedgerResponse other); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull CountCreditLedgerParams params); + } + + public interface _FinalStage { + CountCreditLedgerResponse build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, ParamsStage, _FinalStage { + private CountResponse data; + + private CountCreditLedgerParams params; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CountCreditLedgerResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public ParamsStage data(@NotNull CountResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull CountCreditLedgerParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public CountCreditLedgerResponse build() { + return new CountCreditLedgerResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerResponseParamsPeriod.java b/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerResponseParamsPeriod.java new file mode 100644 index 0000000..ec448b4 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CountCreditLedgerResponseParamsPeriod.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CountCreditLedgerResponseParamsPeriod { + public static final CountCreditLedgerResponseParamsPeriod RAW = + new CountCreditLedgerResponseParamsPeriod(Value.RAW, "raw"); + + public static final CountCreditLedgerResponseParamsPeriod MONTHLY = + new CountCreditLedgerResponseParamsPeriod(Value.MONTHLY, "monthly"); + + public static final CountCreditLedgerResponseParamsPeriod DAILY = + new CountCreditLedgerResponseParamsPeriod(Value.DAILY, "daily"); + + public static final CountCreditLedgerResponseParamsPeriod WEEKLY = + new CountCreditLedgerResponseParamsPeriod(Value.WEEKLY, "weekly"); + + private final Value value; + + private final String string; + + CountCreditLedgerResponseParamsPeriod(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountCreditLedgerResponseParamsPeriod + && this.string.equals(((CountCreditLedgerResponseParamsPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case RAW: + return visitor.visitRaw(); + case MONTHLY: + return visitor.visitMonthly(); + case DAILY: + return visitor.visitDaily(); + case WEEKLY: + return visitor.visitWeekly(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountCreditLedgerResponseParamsPeriod valueOf(String value) { + switch (value) { + case "raw": + return RAW; + case "monthly": + return MONTHLY; + case "daily": + return DAILY; + case "weekly": + return WEEKLY; + default: + return new CountCreditLedgerResponseParamsPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + DAILY, + + WEEKLY, + + MONTHLY, + + RAW, + + UNKNOWN + } + + public interface Visitor { + T visitDaily(); + + T visitWeekly(); + + T visitMonthly(); + + T visitRaw(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditRequestBodyBurnStrategy.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditRequestBodyBurnStrategy.java new file mode 100644 index 0000000..9d93ad1 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditRequestBodyBurnStrategy.java @@ -0,0 +1,110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingCreditRequestBodyBurnStrategy { + public static final CreateBillingCreditRequestBodyBurnStrategy PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT = + new CreateBillingCreditRequestBodyBurnStrategy( + Value.PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT, + "plan_first_then_credit_bundles_first_in_first_out"); + + public static final CreateBillingCreditRequestBodyBurnStrategy FIRST_IN_FIRST_OUT = + new CreateBillingCreditRequestBodyBurnStrategy(Value.FIRST_IN_FIRST_OUT, "first_in_first_out"); + + public static final CreateBillingCreditRequestBodyBurnStrategy LAST_IN_FIRST_OUT = + new CreateBillingCreditRequestBodyBurnStrategy(Value.LAST_IN_FIRST_OUT, "last_in_first_out"); + + public static final CreateBillingCreditRequestBodyBurnStrategy EXPIRATION_PRIORITY = + new CreateBillingCreditRequestBodyBurnStrategy(Value.EXPIRATION_PRIORITY, "expiration_priority"); + + private final Value value; + + private final String string; + + CreateBillingCreditRequestBodyBurnStrategy(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingCreditRequestBodyBurnStrategy + && this.string.equals(((CreateBillingCreditRequestBodyBurnStrategy) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT: + return visitor.visitPlanFirstThenCreditBundlesFirstInFirstOut(); + case FIRST_IN_FIRST_OUT: + return visitor.visitFirstInFirstOut(); + case LAST_IN_FIRST_OUT: + return visitor.visitLastInFirstOut(); + case EXPIRATION_PRIORITY: + return visitor.visitExpirationPriority(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingCreditRequestBodyBurnStrategy valueOf(String value) { + switch (value) { + case "plan_first_then_credit_bundles_first_in_first_out": + return PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT; + case "first_in_first_out": + return FIRST_IN_FIRST_OUT; + case "last_in_first_out": + return LAST_IN_FIRST_OUT; + case "expiration_priority": + return EXPIRATION_PRIORITY; + default: + return new CreateBillingCreditRequestBodyBurnStrategy(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT, + + FIRST_IN_FIRST_OUT, + + LAST_IN_FIRST_OUT, + + EXPIRATION_PRIORITY, + + UNKNOWN + } + + public interface Visitor { + T visitPlanFirstThenCreditBundlesFirstInFirstOut(); + + T visitFirstInFirstOut(); + + T visitLastInFirstOut(); + + T visitExpirationPriority(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditRequestBodyDefaultRolloverPolicy.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditRequestBodyDefaultRolloverPolicy.java new file mode 100644 index 0000000..843a6e1 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditRequestBodyDefaultRolloverPolicy.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingCreditRequestBodyDefaultRolloverPolicy { + public static final CreateBillingCreditRequestBodyDefaultRolloverPolicy EXPIRE = + new CreateBillingCreditRequestBodyDefaultRolloverPolicy(Value.EXPIRE, "expire"); + + public static final CreateBillingCreditRequestBodyDefaultRolloverPolicy ROLLOVER = + new CreateBillingCreditRequestBodyDefaultRolloverPolicy(Value.ROLLOVER, "rollover"); + + public static final CreateBillingCreditRequestBodyDefaultRolloverPolicy NONE = + new CreateBillingCreditRequestBodyDefaultRolloverPolicy(Value.NONE, "none"); + + private final Value value; + + private final String string; + + CreateBillingCreditRequestBodyDefaultRolloverPolicy(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingCreditRequestBodyDefaultRolloverPolicy + && this.string.equals(((CreateBillingCreditRequestBodyDefaultRolloverPolicy) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case EXPIRE: + return visitor.visitExpire(); + case ROLLOVER: + return visitor.visitRollover(); + case NONE: + return visitor.visitNone(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingCreditRequestBodyDefaultRolloverPolicy valueOf(String value) { + switch (value) { + case "expire": + return EXPIRE; + case "rollover": + return ROLLOVER; + case "none": + return NONE; + default: + return new CreateBillingCreditRequestBodyDefaultRolloverPolicy(Value.UNKNOWN, value); + } + } + + public enum Value { + NONE, + + ROLLOVER, + + EXPIRE, + + UNKNOWN + } + + public interface Visitor { + T visitNone(); + + T visitRollover(); + + T visitExpire(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditResponse.java new file mode 100644 index 0000000..8f4786f --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingCreditResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateBillingCreditResponse.Builder.class) +public final class CreateBillingCreditResponse { + private final BillingCreditResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private CreateBillingCreditResponse( + BillingCreditResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public BillingCreditResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateBillingCreditResponse && equalTo((CreateBillingCreditResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateBillingCreditResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull BillingCreditResponseData data); + + Builder from(CreateBillingCreditResponse other); + } + + public interface _FinalStage { + CreateBillingCreditResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private BillingCreditResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateBillingCreditResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull BillingCreditResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public CreateBillingCreditResponse build() { + return new CreateBillingCreditResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyExpiryType.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyExpiryType.java new file mode 100644 index 0000000..90b9c6e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyExpiryType.java @@ -0,0 +1,120 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingPlanCreditGrantRequestBodyExpiryType { + public static final CreateBillingPlanCreditGrantRequestBodyExpiryType END_OF_BILLING_PERIOD = + new CreateBillingPlanCreditGrantRequestBodyExpiryType(Value.END_OF_BILLING_PERIOD, "end_of_billing_period"); + + public static final CreateBillingPlanCreditGrantRequestBodyExpiryType DURATION = + new CreateBillingPlanCreditGrantRequestBodyExpiryType(Value.DURATION, "duration"); + + public static final CreateBillingPlanCreditGrantRequestBodyExpiryType END_OF_NEXT_BILLING_PERIOD = + new CreateBillingPlanCreditGrantRequestBodyExpiryType( + Value.END_OF_NEXT_BILLING_PERIOD, "end_of_next_billing_period"); + + public static final CreateBillingPlanCreditGrantRequestBodyExpiryType NO_EXPIRY = + new CreateBillingPlanCreditGrantRequestBodyExpiryType(Value.NO_EXPIRY, "no_expiry"); + + public static final CreateBillingPlanCreditGrantRequestBodyExpiryType END_OF_TRIAL = + new CreateBillingPlanCreditGrantRequestBodyExpiryType(Value.END_OF_TRIAL, "end_of_trial"); + + private final Value value; + + private final String string; + + CreateBillingPlanCreditGrantRequestBodyExpiryType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingPlanCreditGrantRequestBodyExpiryType + && this.string.equals(((CreateBillingPlanCreditGrantRequestBodyExpiryType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case END_OF_BILLING_PERIOD: + return visitor.visitEndOfBillingPeriod(); + case DURATION: + return visitor.visitDuration(); + case END_OF_NEXT_BILLING_PERIOD: + return visitor.visitEndOfNextBillingPeriod(); + case NO_EXPIRY: + return visitor.visitNoExpiry(); + case END_OF_TRIAL: + return visitor.visitEndOfTrial(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingPlanCreditGrantRequestBodyExpiryType valueOf(String value) { + switch (value) { + case "end_of_billing_period": + return END_OF_BILLING_PERIOD; + case "duration": + return DURATION; + case "end_of_next_billing_period": + return END_OF_NEXT_BILLING_PERIOD; + case "no_expiry": + return NO_EXPIRY; + case "end_of_trial": + return END_OF_TRIAL; + default: + return new CreateBillingPlanCreditGrantRequestBodyExpiryType(Value.UNKNOWN, value); + } + } + + public enum Value { + DURATION, + + NO_EXPIRY, + + END_OF_TRIAL, + + END_OF_BILLING_PERIOD, + + END_OF_NEXT_BILLING_PERIOD, + + UNKNOWN + } + + public interface Visitor { + T visitDuration(); + + T visitNoExpiry(); + + T visitEndOfTrial(); + + T visitEndOfBillingPeriod(); + + T visitEndOfNextBillingPeriod(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyExpiryUnit.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyExpiryUnit.java new file mode 100644 index 0000000..ba3341c --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyExpiryUnit.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingPlanCreditGrantRequestBodyExpiryUnit { + public static final CreateBillingPlanCreditGrantRequestBodyExpiryUnit BILLING_PERIODS = + new CreateBillingPlanCreditGrantRequestBodyExpiryUnit(Value.BILLING_PERIODS, "billing_periods"); + + public static final CreateBillingPlanCreditGrantRequestBodyExpiryUnit DAYS = + new CreateBillingPlanCreditGrantRequestBodyExpiryUnit(Value.DAYS, "days"); + + private final Value value; + + private final String string; + + CreateBillingPlanCreditGrantRequestBodyExpiryUnit(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingPlanCreditGrantRequestBodyExpiryUnit + && this.string.equals(((CreateBillingPlanCreditGrantRequestBodyExpiryUnit) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BILLING_PERIODS: + return visitor.visitBillingPeriods(); + case DAYS: + return visitor.visitDays(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingPlanCreditGrantRequestBodyExpiryUnit valueOf(String value) { + switch (value) { + case "billing_periods": + return BILLING_PERIODS; + case "days": + return DAYS; + default: + return new CreateBillingPlanCreditGrantRequestBodyExpiryUnit(Value.UNKNOWN, value); + } + } + + public enum Value { + DAYS, + + BILLING_PERIODS, + + UNKNOWN + } + + public interface Visitor { + T visitDays(); + + T visitBillingPeriods(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetCadence.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetCadence.java new file mode 100644 index 0000000..6f3d3a0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetCadence.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingPlanCreditGrantRequestBodyResetCadence { + public static final CreateBillingPlanCreditGrantRequestBodyResetCadence YEARLY = + new CreateBillingPlanCreditGrantRequestBodyResetCadence(Value.YEARLY, "yearly"); + + public static final CreateBillingPlanCreditGrantRequestBodyResetCadence MONTHLY = + new CreateBillingPlanCreditGrantRequestBodyResetCadence(Value.MONTHLY, "monthly"); + + public static final CreateBillingPlanCreditGrantRequestBodyResetCadence DAILY = + new CreateBillingPlanCreditGrantRequestBodyResetCadence(Value.DAILY, "daily"); + + public static final CreateBillingPlanCreditGrantRequestBodyResetCadence WEEKLY = + new CreateBillingPlanCreditGrantRequestBodyResetCadence(Value.WEEKLY, "weekly"); + + private final Value value; + + private final String string; + + CreateBillingPlanCreditGrantRequestBodyResetCadence(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingPlanCreditGrantRequestBodyResetCadence + && this.string.equals(((CreateBillingPlanCreditGrantRequestBodyResetCadence) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case YEARLY: + return visitor.visitYearly(); + case MONTHLY: + return visitor.visitMonthly(); + case DAILY: + return visitor.visitDaily(); + case WEEKLY: + return visitor.visitWeekly(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingPlanCreditGrantRequestBodyResetCadence valueOf(String value) { + switch (value) { + case "yearly": + return YEARLY; + case "monthly": + return MONTHLY; + case "daily": + return DAILY; + case "weekly": + return WEEKLY; + default: + return new CreateBillingPlanCreditGrantRequestBodyResetCadence(Value.UNKNOWN, value); + } + } + + public enum Value { + MONTHLY, + + YEARLY, + + DAILY, + + WEEKLY, + + UNKNOWN + } + + public interface Visitor { + T visitMonthly(); + + T visitYearly(); + + T visitDaily(); + + T visitWeekly(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetStart.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetStart.java new file mode 100644 index 0000000..bbd345d --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetStart.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingPlanCreditGrantRequestBodyResetStart { + public static final CreateBillingPlanCreditGrantRequestBodyResetStart FIRST_OF_MONTH = + new CreateBillingPlanCreditGrantRequestBodyResetStart(Value.FIRST_OF_MONTH, "first_of_month"); + + public static final CreateBillingPlanCreditGrantRequestBodyResetStart BILLING_PERIOD = + new CreateBillingPlanCreditGrantRequestBodyResetStart(Value.BILLING_PERIOD, "billing_period"); + + private final Value value; + + private final String string; + + CreateBillingPlanCreditGrantRequestBodyResetStart(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingPlanCreditGrantRequestBodyResetStart + && this.string.equals(((CreateBillingPlanCreditGrantRequestBodyResetStart) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FIRST_OF_MONTH: + return visitor.visitFirstOfMonth(); + case BILLING_PERIOD: + return visitor.visitBillingPeriod(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingPlanCreditGrantRequestBodyResetStart valueOf(String value) { + switch (value) { + case "first_of_month": + return FIRST_OF_MONTH; + case "billing_period": + return BILLING_PERIOD; + default: + return new CreateBillingPlanCreditGrantRequestBodyResetStart(Value.UNKNOWN, value); + } + } + + public enum Value { + BILLING_PERIOD, + + FIRST_OF_MONTH, + + UNKNOWN + } + + public interface Visitor { + T visitBillingPeriod(); + + T visitFirstOfMonth(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetType.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetType.java new file mode 100644 index 0000000..a16da60 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantRequestBodyResetType.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateBillingPlanCreditGrantRequestBodyResetType { + public static final CreateBillingPlanCreditGrantRequestBodyResetType NO_RESET = + new CreateBillingPlanCreditGrantRequestBodyResetType(Value.NO_RESET, "no_reset"); + + public static final CreateBillingPlanCreditGrantRequestBodyResetType PLAN_PERIOD = + new CreateBillingPlanCreditGrantRequestBodyResetType(Value.PLAN_PERIOD, "plan_period"); + + private final Value value; + + private final String string; + + CreateBillingPlanCreditGrantRequestBodyResetType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateBillingPlanCreditGrantRequestBodyResetType + && this.string.equals(((CreateBillingPlanCreditGrantRequestBodyResetType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NO_RESET: + return visitor.visitNoReset(); + case PLAN_PERIOD: + return visitor.visitPlanPeriod(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateBillingPlanCreditGrantRequestBodyResetType valueOf(String value) { + switch (value) { + case "no_reset": + return NO_RESET; + case "plan_period": + return PLAN_PERIOD; + default: + return new CreateBillingPlanCreditGrantRequestBodyResetType(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN_PERIOD, + + NO_RESET, + + UNKNOWN + } + + public interface Visitor { + T visitPlanPeriod(); + + T visitNoReset(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantResponse.java new file mode 100644 index 0000000..50b36a4 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateBillingPlanCreditGrantResponse.java @@ -0,0 +1,168 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingPlanCreditGrantResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateBillingPlanCreditGrantResponse.Builder.class) +public final class CreateBillingPlanCreditGrantResponse { + private final BillingPlanCreditGrantResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private CreateBillingPlanCreditGrantResponse( + BillingPlanCreditGrantResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public BillingPlanCreditGrantResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateBillingPlanCreditGrantResponse + && equalTo((CreateBillingPlanCreditGrantResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateBillingPlanCreditGrantResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull BillingPlanCreditGrantResponseData data); + + Builder from(CreateBillingPlanCreditGrantResponse other); + } + + public interface _FinalStage { + CreateBillingPlanCreditGrantResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private BillingPlanCreditGrantResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateBillingPlanCreditGrantResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull BillingPlanCreditGrantResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public CreateBillingPlanCreditGrantResponse build() { + return new CreateBillingPlanCreditGrantResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateCompanyCreditGrantExpiryType.java b/src/main/java/com/schematic/api/resources/credits/types/CreateCompanyCreditGrantExpiryType.java new file mode 100644 index 0000000..95ae51b --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateCompanyCreditGrantExpiryType.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateCompanyCreditGrantExpiryType { + public static final CreateCompanyCreditGrantExpiryType END_OF_BILLING_PERIOD = + new CreateCompanyCreditGrantExpiryType(Value.END_OF_BILLING_PERIOD, "end_of_billing_period"); + + public static final CreateCompanyCreditGrantExpiryType DURATION = + new CreateCompanyCreditGrantExpiryType(Value.DURATION, "duration"); + + public static final CreateCompanyCreditGrantExpiryType END_OF_NEXT_BILLING_PERIOD = + new CreateCompanyCreditGrantExpiryType(Value.END_OF_NEXT_BILLING_PERIOD, "end_of_next_billing_period"); + + public static final CreateCompanyCreditGrantExpiryType NO_EXPIRY = + new CreateCompanyCreditGrantExpiryType(Value.NO_EXPIRY, "no_expiry"); + + public static final CreateCompanyCreditGrantExpiryType END_OF_TRIAL = + new CreateCompanyCreditGrantExpiryType(Value.END_OF_TRIAL, "end_of_trial"); + + private final Value value; + + private final String string; + + CreateCompanyCreditGrantExpiryType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateCompanyCreditGrantExpiryType + && this.string.equals(((CreateCompanyCreditGrantExpiryType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case END_OF_BILLING_PERIOD: + return visitor.visitEndOfBillingPeriod(); + case DURATION: + return visitor.visitDuration(); + case END_OF_NEXT_BILLING_PERIOD: + return visitor.visitEndOfNextBillingPeriod(); + case NO_EXPIRY: + return visitor.visitNoExpiry(); + case END_OF_TRIAL: + return visitor.visitEndOfTrial(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateCompanyCreditGrantExpiryType valueOf(String value) { + switch (value) { + case "end_of_billing_period": + return END_OF_BILLING_PERIOD; + case "duration": + return DURATION; + case "end_of_next_billing_period": + return END_OF_NEXT_BILLING_PERIOD; + case "no_expiry": + return NO_EXPIRY; + case "end_of_trial": + return END_OF_TRIAL; + default: + return new CreateCompanyCreditGrantExpiryType(Value.UNKNOWN, value); + } + } + + public enum Value { + DURATION, + + NO_EXPIRY, + + END_OF_TRIAL, + + END_OF_BILLING_PERIOD, + + END_OF_NEXT_BILLING_PERIOD, + + UNKNOWN + } + + public interface Visitor { + T visitDuration(); + + T visitNoExpiry(); + + T visitEndOfTrial(); + + T visitEndOfBillingPeriod(); + + T visitEndOfNextBillingPeriod(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateCompanyCreditGrantExpiryUnit.java b/src/main/java/com/schematic/api/resources/credits/types/CreateCompanyCreditGrantExpiryUnit.java new file mode 100644 index 0000000..4c8e44e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateCompanyCreditGrantExpiryUnit.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateCompanyCreditGrantExpiryUnit { + public static final CreateCompanyCreditGrantExpiryUnit BILLING_PERIODS = + new CreateCompanyCreditGrantExpiryUnit(Value.BILLING_PERIODS, "billing_periods"); + + public static final CreateCompanyCreditGrantExpiryUnit DAYS = + new CreateCompanyCreditGrantExpiryUnit(Value.DAYS, "days"); + + private final Value value; + + private final String string; + + CreateCompanyCreditGrantExpiryUnit(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateCompanyCreditGrantExpiryUnit + && this.string.equals(((CreateCompanyCreditGrantExpiryUnit) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BILLING_PERIODS: + return visitor.visitBillingPeriods(); + case DAYS: + return visitor.visitDays(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateCompanyCreditGrantExpiryUnit valueOf(String value) { + switch (value) { + case "billing_periods": + return BILLING_PERIODS; + case "days": + return DAYS; + default: + return new CreateCompanyCreditGrantExpiryUnit(Value.UNKNOWN, value); + } + } + + public enum Value { + DAYS, + + BILLING_PERIODS, + + UNKNOWN + } + + public interface Visitor { + T visitDays(); + + T visitBillingPeriods(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyExpiryType.java b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyExpiryType.java new file mode 100644 index 0000000..0afb674 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyExpiryType.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateCreditBundleRequestBodyExpiryType { + public static final CreateCreditBundleRequestBodyExpiryType END_OF_BILLING_PERIOD = + new CreateCreditBundleRequestBodyExpiryType(Value.END_OF_BILLING_PERIOD, "end_of_billing_period"); + + public static final CreateCreditBundleRequestBodyExpiryType DURATION = + new CreateCreditBundleRequestBodyExpiryType(Value.DURATION, "duration"); + + public static final CreateCreditBundleRequestBodyExpiryType END_OF_NEXT_BILLING_PERIOD = + new CreateCreditBundleRequestBodyExpiryType(Value.END_OF_NEXT_BILLING_PERIOD, "end_of_next_billing_period"); + + public static final CreateCreditBundleRequestBodyExpiryType NO_EXPIRY = + new CreateCreditBundleRequestBodyExpiryType(Value.NO_EXPIRY, "no_expiry"); + + public static final CreateCreditBundleRequestBodyExpiryType END_OF_TRIAL = + new CreateCreditBundleRequestBodyExpiryType(Value.END_OF_TRIAL, "end_of_trial"); + + private final Value value; + + private final String string; + + CreateCreditBundleRequestBodyExpiryType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateCreditBundleRequestBodyExpiryType + && this.string.equals(((CreateCreditBundleRequestBodyExpiryType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case END_OF_BILLING_PERIOD: + return visitor.visitEndOfBillingPeriod(); + case DURATION: + return visitor.visitDuration(); + case END_OF_NEXT_BILLING_PERIOD: + return visitor.visitEndOfNextBillingPeriod(); + case NO_EXPIRY: + return visitor.visitNoExpiry(); + case END_OF_TRIAL: + return visitor.visitEndOfTrial(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateCreditBundleRequestBodyExpiryType valueOf(String value) { + switch (value) { + case "end_of_billing_period": + return END_OF_BILLING_PERIOD; + case "duration": + return DURATION; + case "end_of_next_billing_period": + return END_OF_NEXT_BILLING_PERIOD; + case "no_expiry": + return NO_EXPIRY; + case "end_of_trial": + return END_OF_TRIAL; + default: + return new CreateCreditBundleRequestBodyExpiryType(Value.UNKNOWN, value); + } + } + + public enum Value { + DURATION, + + NO_EXPIRY, + + END_OF_TRIAL, + + END_OF_BILLING_PERIOD, + + END_OF_NEXT_BILLING_PERIOD, + + UNKNOWN + } + + public interface Visitor { + T visitDuration(); + + T visitNoExpiry(); + + T visitEndOfTrial(); + + T visitEndOfBillingPeriod(); + + T visitEndOfNextBillingPeriod(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyExpiryUnit.java b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyExpiryUnit.java new file mode 100644 index 0000000..ea7dd22 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyExpiryUnit.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateCreditBundleRequestBodyExpiryUnit { + public static final CreateCreditBundleRequestBodyExpiryUnit BILLING_PERIODS = + new CreateCreditBundleRequestBodyExpiryUnit(Value.BILLING_PERIODS, "billing_periods"); + + public static final CreateCreditBundleRequestBodyExpiryUnit DAYS = + new CreateCreditBundleRequestBodyExpiryUnit(Value.DAYS, "days"); + + private final Value value; + + private final String string; + + CreateCreditBundleRequestBodyExpiryUnit(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateCreditBundleRequestBodyExpiryUnit + && this.string.equals(((CreateCreditBundleRequestBodyExpiryUnit) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BILLING_PERIODS: + return visitor.visitBillingPeriods(); + case DAYS: + return visitor.visitDays(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateCreditBundleRequestBodyExpiryUnit valueOf(String value) { + switch (value) { + case "billing_periods": + return BILLING_PERIODS; + case "days": + return DAYS; + default: + return new CreateCreditBundleRequestBodyExpiryUnit(Value.UNKNOWN, value); + } + } + + public enum Value { + DAYS, + + BILLING_PERIODS, + + UNKNOWN + } + + public interface Visitor { + T visitDays(); + + T visitBillingPeriods(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyStatus.java b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyStatus.java new file mode 100644 index 0000000..0bae58f --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleRequestBodyStatus.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateCreditBundleRequestBodyStatus { + public static final CreateCreditBundleRequestBodyStatus INACTIVE = + new CreateCreditBundleRequestBodyStatus(Value.INACTIVE, "inactive"); + + public static final CreateCreditBundleRequestBodyStatus ACTIVE = + new CreateCreditBundleRequestBodyStatus(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + CreateCreditBundleRequestBodyStatus(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateCreditBundleRequestBodyStatus + && this.string.equals(((CreateCreditBundleRequestBodyStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case INACTIVE: + return visitor.visitInactive(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateCreditBundleRequestBodyStatus valueOf(String value) { + switch (value) { + case "inactive": + return INACTIVE; + case "active": + return ACTIVE; + default: + return new CreateCreditBundleRequestBodyStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + INACTIVE, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitInactive(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleResponse.java b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleResponse.java new file mode 100644 index 0000000..c5bbf4c --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/CreateCreditBundleResponse.java @@ -0,0 +1,167 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditBundleResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateCreditBundleResponse.Builder.class) +public final class CreateCreditBundleResponse { + private final BillingCreditBundleResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private CreateCreditBundleResponse( + BillingCreditBundleResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public BillingCreditBundleResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateCreditBundleResponse && equalTo((CreateCreditBundleResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateCreditBundleResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull BillingCreditBundleResponseData data); + + Builder from(CreateCreditBundleResponse other); + } + + public interface _FinalStage { + CreateCreditBundleResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private BillingCreditBundleResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateCreditBundleResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull BillingCreditBundleResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public CreateCreditBundleResponse build() { + return new CreateCreditBundleResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/DeleteBillingPlanCreditGrantResponse.java b/src/main/java/com/schematic/api/resources/credits/types/DeleteBillingPlanCreditGrantResponse.java new file mode 100644 index 0000000..6f4565f --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/DeleteBillingPlanCreditGrantResponse.java @@ -0,0 +1,166 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.DeleteResponse; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteBillingPlanCreditGrantResponse.Builder.class) +public final class DeleteBillingPlanCreditGrantResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private DeleteBillingPlanCreditGrantResponse( + DeleteResponse data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public DeleteResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteBillingPlanCreditGrantResponse + && equalTo((DeleteBillingPlanCreditGrantResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteBillingPlanCreditGrantResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull DeleteResponse data); + + Builder from(DeleteBillingPlanCreditGrantResponse other); + } + + public interface _FinalStage { + DeleteBillingPlanCreditGrantResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private DeleteResponse data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteBillingPlanCreditGrantResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull DeleteResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public DeleteBillingPlanCreditGrantResponse build() { + return new DeleteBillingPlanCreditGrantResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/DeleteCreditBundleResponse.java b/src/main/java/com/schematic/api/resources/credits/types/DeleteCreditBundleResponse.java new file mode 100644 index 0000000..1d9a2f4 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/DeleteCreditBundleResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.DeleteResponse; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteCreditBundleResponse.Builder.class) +public final class DeleteCreditBundleResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private DeleteCreditBundleResponse( + DeleteResponse data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public DeleteResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCreditBundleResponse && equalTo((DeleteCreditBundleResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCreditBundleResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull DeleteResponse data); + + Builder from(DeleteCreditBundleResponse other); + } + + public interface _FinalStage { + DeleteCreditBundleResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private DeleteResponse data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCreditBundleResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull DeleteResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public DeleteCreditBundleResponse build() { + return new DeleteCreditBundleResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/GetCreditBundleResponse.java b/src/main/java/com/schematic/api/resources/credits/types/GetCreditBundleResponse.java new file mode 100644 index 0000000..94b439e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/GetCreditBundleResponse.java @@ -0,0 +1,167 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditBundleResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetCreditBundleResponse.Builder.class) +public final class GetCreditBundleResponse { + private final BillingCreditBundleResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private GetCreditBundleResponse( + BillingCreditBundleResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public BillingCreditBundleResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetCreditBundleResponse && equalTo((GetCreditBundleResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCreditBundleResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull BillingCreditBundleResponseData data); + + Builder from(GetCreditBundleResponse other); + } + + public interface _FinalStage { + GetCreditBundleResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private BillingCreditBundleResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetCreditBundleResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull BillingCreditBundleResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public GetCreditBundleResponse build() { + return new GetCreditBundleResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerParams.java b/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerParams.java new file mode 100644 index 0000000..ecd6acf --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerParams.java @@ -0,0 +1,294 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetEnrichedCreditLedgerParams.Builder.class) +public final class GetEnrichedCreditLedgerParams { + private final Optional billingCreditId; + + private final Optional companyId; + + private final Optional endTime; + + private final Optional featureId; + + private final Optional limit; + + private final Optional offset; + + private final Optional period; + + private final Optional startTime; + + private final Map additionalProperties; + + private GetEnrichedCreditLedgerParams( + Optional billingCreditId, + Optional companyId, + Optional endTime, + Optional featureId, + Optional limit, + Optional offset, + Optional period, + Optional startTime, + Map additionalProperties) { + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.endTime = endTime; + this.featureId = featureId; + this.limit = limit; + this.offset = offset; + this.period = period; + this.startTime = startTime; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_credit_id") + public Optional getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("end_time") + public Optional getEndTime() { + return endTime; + } + + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("period") + public Optional getPeriod() { + return period; + } + + @JsonProperty("start_time") + public Optional getStartTime() { + return startTime; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetEnrichedCreditLedgerParams && equalTo((GetEnrichedCreditLedgerParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetEnrichedCreditLedgerParams other) { + return billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && endTime.equals(other.endTime) + && featureId.equals(other.featureId) + && limit.equals(other.limit) + && offset.equals(other.offset) + && period.equals(other.period) + && startTime.equals(other.startTime); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingCreditId, + this.companyId, + this.endTime, + this.featureId, + this.limit, + this.offset, + this.period, + this.startTime); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional billingCreditId = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional endTime = Optional.empty(); + + private Optional featureId = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional period = Optional.empty(); + + private Optional startTime = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetEnrichedCreditLedgerParams other) { + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + endTime(other.getEndTime()); + featureId(other.getFeatureId()); + limit(other.getLimit()); + offset(other.getOffset()); + period(other.getPeriod()); + startTime(other.getStartTime()); + return this; + } + + @JsonSetter(value = "billing_credit_id", nulls = Nulls.SKIP) + public Builder billingCreditId(Optional billingCreditId) { + this.billingCreditId = billingCreditId; + return this; + } + + public Builder billingCreditId(String billingCreditId) { + this.billingCreditId = Optional.ofNullable(billingCreditId); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "end_time", nulls = Nulls.SKIP) + public Builder endTime(Optional endTime) { + this.endTime = endTime; + return this; + } + + public Builder endTime(String endTime) { + this.endTime = Optional.ofNullable(endTime); + return this; + } + + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public Builder featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + public Builder featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "period", nulls = Nulls.SKIP) + public Builder period(Optional period) { + this.period = period; + return this; + } + + public Builder period(GetEnrichedCreditLedgerResponseParamsPeriod period) { + this.period = Optional.ofNullable(period); + return this; + } + + @JsonSetter(value = "start_time", nulls = Nulls.SKIP) + public Builder startTime(Optional startTime) { + this.startTime = startTime; + return this; + } + + public Builder startTime(String startTime) { + this.startTime = Optional.ofNullable(startTime); + return this; + } + + public GetEnrichedCreditLedgerParams build() { + return new GetEnrichedCreditLedgerParams( + billingCreditId, + companyId, + endTime, + featureId, + limit, + offset, + period, + startTime, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerRequestPeriod.java b/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerRequestPeriod.java new file mode 100644 index 0000000..b430c98 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerRequestPeriod.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class GetEnrichedCreditLedgerRequestPeriod { + public static final GetEnrichedCreditLedgerRequestPeriod RAW = + new GetEnrichedCreditLedgerRequestPeriod(Value.RAW, "raw"); + + public static final GetEnrichedCreditLedgerRequestPeriod MONTHLY = + new GetEnrichedCreditLedgerRequestPeriod(Value.MONTHLY, "monthly"); + + public static final GetEnrichedCreditLedgerRequestPeriod DAILY = + new GetEnrichedCreditLedgerRequestPeriod(Value.DAILY, "daily"); + + public static final GetEnrichedCreditLedgerRequestPeriod WEEKLY = + new GetEnrichedCreditLedgerRequestPeriod(Value.WEEKLY, "weekly"); + + private final Value value; + + private final String string; + + GetEnrichedCreditLedgerRequestPeriod(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof GetEnrichedCreditLedgerRequestPeriod + && this.string.equals(((GetEnrichedCreditLedgerRequestPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case RAW: + return visitor.visitRaw(); + case MONTHLY: + return visitor.visitMonthly(); + case DAILY: + return visitor.visitDaily(); + case WEEKLY: + return visitor.visitWeekly(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static GetEnrichedCreditLedgerRequestPeriod valueOf(String value) { + switch (value) { + case "raw": + return RAW; + case "monthly": + return MONTHLY; + case "daily": + return DAILY; + case "weekly": + return WEEKLY; + default: + return new GetEnrichedCreditLedgerRequestPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + DAILY, + + WEEKLY, + + MONTHLY, + + RAW, + + UNKNOWN + } + + public interface Visitor { + T visitDaily(); + + T visitWeekly(); + + T visitMonthly(); + + T visitRaw(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerResponse.java b/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerResponse.java new file mode 100644 index 0000000..36c97fa --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CreditLedgerEnrichedEntryResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetEnrichedCreditLedgerResponse.Builder.class) +public final class GetEnrichedCreditLedgerResponse { + private final List data; + + private final GetEnrichedCreditLedgerParams params; + + private final Map additionalProperties; + + private GetEnrichedCreditLedgerResponse( + List data, + GetEnrichedCreditLedgerParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public GetEnrichedCreditLedgerParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetEnrichedCreditLedgerResponse && equalTo((GetEnrichedCreditLedgerResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetEnrichedCreditLedgerResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull GetEnrichedCreditLedgerParams params); + + Builder from(GetEnrichedCreditLedgerResponse other); + } + + public interface _FinalStage { + GetEnrichedCreditLedgerResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(CreditLedgerEnrichedEntryResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private GetEnrichedCreditLedgerParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetEnrichedCreditLedgerResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull GetEnrichedCreditLedgerParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(CreditLedgerEnrichedEntryResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public GetEnrichedCreditLedgerResponse build() { + return new GetEnrichedCreditLedgerResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerResponseParamsPeriod.java b/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerResponseParamsPeriod.java new file mode 100644 index 0000000..3e12b78 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/GetEnrichedCreditLedgerResponseParamsPeriod.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class GetEnrichedCreditLedgerResponseParamsPeriod { + public static final GetEnrichedCreditLedgerResponseParamsPeriod RAW = + new GetEnrichedCreditLedgerResponseParamsPeriod(Value.RAW, "raw"); + + public static final GetEnrichedCreditLedgerResponseParamsPeriod MONTHLY = + new GetEnrichedCreditLedgerResponseParamsPeriod(Value.MONTHLY, "monthly"); + + public static final GetEnrichedCreditLedgerResponseParamsPeriod DAILY = + new GetEnrichedCreditLedgerResponseParamsPeriod(Value.DAILY, "daily"); + + public static final GetEnrichedCreditLedgerResponseParamsPeriod WEEKLY = + new GetEnrichedCreditLedgerResponseParamsPeriod(Value.WEEKLY, "weekly"); + + private final Value value; + + private final String string; + + GetEnrichedCreditLedgerResponseParamsPeriod(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof GetEnrichedCreditLedgerResponseParamsPeriod + && this.string.equals(((GetEnrichedCreditLedgerResponseParamsPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case RAW: + return visitor.visitRaw(); + case MONTHLY: + return visitor.visitMonthly(); + case DAILY: + return visitor.visitDaily(); + case WEEKLY: + return visitor.visitWeekly(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static GetEnrichedCreditLedgerResponseParamsPeriod valueOf(String value) { + switch (value) { + case "raw": + return RAW; + case "monthly": + return MONTHLY; + case "daily": + return DAILY; + case "weekly": + return WEEKLY; + default: + return new GetEnrichedCreditLedgerResponseParamsPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + DAILY, + + WEEKLY, + + MONTHLY, + + RAW, + + UNKNOWN + } + + public interface Visitor { + T visitDaily(); + + T visitWeekly(); + + T visitMonthly(); + + T visitRaw(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/GetSingleBillingCreditResponse.java b/src/main/java/com/schematic/api/resources/credits/types/GetSingleBillingCreditResponse.java new file mode 100644 index 0000000..d3c5985 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/GetSingleBillingCreditResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetSingleBillingCreditResponse.Builder.class) +public final class GetSingleBillingCreditResponse { + private final BillingCreditResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private GetSingleBillingCreditResponse( + BillingCreditResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public BillingCreditResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetSingleBillingCreditResponse && equalTo((GetSingleBillingCreditResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetSingleBillingCreditResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull BillingCreditResponseData data); + + Builder from(GetSingleBillingCreditResponse other); + } + + public interface _FinalStage { + GetSingleBillingCreditResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private BillingCreditResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetSingleBillingCreditResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull BillingCreditResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public GetSingleBillingCreditResponse build() { + return new GetSingleBillingCreditResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/GrantBillingCreditsToCompanyResponse.java b/src/main/java/com/schematic/api/resources/credits/types/GrantBillingCreditsToCompanyResponse.java new file mode 100644 index 0000000..330672f --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/GrantBillingCreditsToCompanyResponse.java @@ -0,0 +1,168 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditGrantResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GrantBillingCreditsToCompanyResponse.Builder.class) +public final class GrantBillingCreditsToCompanyResponse { + private final BillingCreditGrantResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private GrantBillingCreditsToCompanyResponse( + BillingCreditGrantResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public BillingCreditGrantResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GrantBillingCreditsToCompanyResponse + && equalTo((GrantBillingCreditsToCompanyResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GrantBillingCreditsToCompanyResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull BillingCreditGrantResponseData data); + + Builder from(GrantBillingCreditsToCompanyResponse other); + } + + public interface _FinalStage { + GrantBillingCreditsToCompanyResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private BillingCreditGrantResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GrantBillingCreditsToCompanyResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull BillingCreditGrantResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public GrantBillingCreditsToCompanyResponse build() { + return new GrantBillingCreditsToCompanyResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PaginationFilter.java b/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsParams.java similarity index 55% rename from src/main/java/com/schematic/api/types/PaginationFilter.java rename to src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsParams.java index 412f477..bb8fa95 100644 --- a/src/main/java/com/schematic/api/types/PaginationFilter.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsParams.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.schematic.api.types; +package com.schematic.api.resources.credits.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -13,26 +13,42 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = PaginationFilter.Builder.class) -public final class PaginationFilter { +@JsonDeserialize(builder = ListBillingCreditsParams.Builder.class) +public final class ListBillingCreditsParams { + private final Optional> ids; + private final Optional limit; + private final Optional name; + private final Optional offset; private final Map additionalProperties; - private PaginationFilter( - Optional limit, Optional offset, Map additionalProperties) { + private ListBillingCreditsParams( + Optional> ids, + Optional limit, + Optional name, + Optional offset, + Map additionalProperties) { + this.ids = ids; this.limit = limit; + this.name = name; this.offset = offset; this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + /** * @return Page limit (default 100) */ @@ -41,6 +57,11 @@ public Optional getLimit() { return limit; } + @JsonProperty("name") + public Optional getName() { + return name; + } + /** * @return Page offset (default 0) */ @@ -52,7 +73,7 @@ public Optional getOffset() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof PaginationFilter && equalTo((PaginationFilter) other); + return other instanceof ListBillingCreditsParams && equalTo((ListBillingCreditsParams) other); } @JsonAnyGetter @@ -60,13 +81,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(PaginationFilter other) { - return limit.equals(other.limit) && offset.equals(other.offset); + private boolean equalTo(ListBillingCreditsParams other) { + return ids.equals(other.ids) + && limit.equals(other.limit) + && name.equals(other.name) + && offset.equals(other.offset); } @java.lang.Override public int hashCode() { - return Objects.hash(this.limit, this.offset); + return Objects.hash(this.ids, this.limit, this.name, this.offset); } @java.lang.Override @@ -80,8 +104,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> ids = Optional.empty(); + private Optional limit = Optional.empty(); + private Optional name = Optional.empty(); + private Optional offset = Optional.empty(); @JsonAnySetter @@ -89,12 +117,28 @@ public static final class Builder { private Builder() {} - public Builder from(PaginationFilter other) { + public Builder from(ListBillingCreditsParams other) { + ids(other.getIds()); limit(other.getLimit()); + name(other.getName()); offset(other.getOffset()); return this; } + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -106,6 +150,20 @@ public Builder limit(Integer limit) { return this; } + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -117,8 +175,8 @@ public Builder offset(Integer offset) { return this; } - public PaginationFilter build() { - return new PaginationFilter(limit, offset, additionalProperties); + public ListBillingCreditsParams build() { + return new ListBillingCreditsParams(ids, limit, name, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsResponse.java new file mode 100644 index 0000000..bbdb9f6 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListBillingCreditsResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListBillingCreditsResponse.Builder.class) +public final class ListBillingCreditsResponse { + private final List data; + + private final ListBillingCreditsParams params; + + private final Map additionalProperties; + + private ListBillingCreditsResponse( + List data, + ListBillingCreditsParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListBillingCreditsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListBillingCreditsResponse && equalTo((ListBillingCreditsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListBillingCreditsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListBillingCreditsParams params); + + Builder from(ListBillingCreditsResponse other); + } + + public interface _FinalStage { + ListBillingCreditsResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(BillingCreditResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListBillingCreditsParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListBillingCreditsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListBillingCreditsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(BillingCreditResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListBillingCreditsResponse build() { + return new ListBillingCreditsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsParams.java b/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsParams.java new file mode 100644 index 0000000..bee24ad --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsParams.java @@ -0,0 +1,231 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListBillingPlanCreditGrantsParams.Builder.class) +public final class ListBillingPlanCreditGrantsParams { + private final Optional creditId; + + private final Optional> ids; + + private final Optional limit; + + private final Optional offset; + + private final Optional planId; + + private final Optional> planIds; + + private final Map additionalProperties; + + private ListBillingPlanCreditGrantsParams( + Optional creditId, + Optional> ids, + Optional limit, + Optional offset, + Optional planId, + Optional> planIds, + Map additionalProperties) { + this.creditId = creditId; + this.ids = ids; + this.limit = limit; + this.offset = offset; + this.planId = planId; + this.planIds = planIds; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListBillingPlanCreditGrantsParams && equalTo((ListBillingPlanCreditGrantsParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListBillingPlanCreditGrantsParams other) { + return creditId.equals(other.creditId) + && ids.equals(other.ids) + && limit.equals(other.limit) + && offset.equals(other.offset) + && planId.equals(other.planId) + && planIds.equals(other.planIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.creditId, this.ids, this.limit, this.offset, this.planId, this.planIds); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional creditId = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional> planIds = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListBillingPlanCreditGrantsParams other) { + creditId(other.getCreditId()); + ids(other.getIds()); + limit(other.getLimit()); + offset(other.getOffset()); + planId(other.getPlanId()); + planIds(other.getPlanIds()); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; + return this; + } + + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); + return this; + } + + public ListBillingPlanCreditGrantsParams build() { + return new ListBillingPlanCreditGrantsParams( + creditId, ids, limit, offset, planId, planIds, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsResponse.java new file mode 100644 index 0000000..41cc9f3 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListBillingPlanCreditGrantsResponse.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingPlanCreditGrantResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListBillingPlanCreditGrantsResponse.Builder.class) +public final class ListBillingPlanCreditGrantsResponse { + private final List data; + + private final ListBillingPlanCreditGrantsParams params; + + private final Map additionalProperties; + + private ListBillingPlanCreditGrantsResponse( + List data, + ListBillingPlanCreditGrantsParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListBillingPlanCreditGrantsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListBillingPlanCreditGrantsResponse + && equalTo((ListBillingPlanCreditGrantsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListBillingPlanCreditGrantsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListBillingPlanCreditGrantsParams params); + + Builder from(ListBillingPlanCreditGrantsResponse other); + } + + public interface _FinalStage { + ListBillingPlanCreditGrantsResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(BillingPlanCreditGrantResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListBillingPlanCreditGrantsParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListBillingPlanCreditGrantsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListBillingPlanCreditGrantsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(BillingPlanCreditGrantResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListBillingPlanCreditGrantsResponse build() { + return new ListBillingPlanCreditGrantsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsParams.java b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsParams.java new file mode 100644 index 0000000..8cc9357 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsParams.java @@ -0,0 +1,205 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompanyGrantsParams.Builder.class) +public final class ListCompanyGrantsParams { + private final Optional companyId; + + private final Optional dir; + + private final Optional limit; + + private final Optional offset; + + private final Optional order; + + private final Map additionalProperties; + + private ListCompanyGrantsParams( + Optional companyId, + Optional dir, + Optional limit, + Optional offset, + Optional order, + Map additionalProperties) { + this.companyId = companyId; + this.dir = dir; + this.limit = limit; + this.offset = offset; + this.order = order; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("dir") + public Optional getDir() { + return dir; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("order") + public Optional getOrder() { + return order; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompanyGrantsParams && equalTo((ListCompanyGrantsParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompanyGrantsParams other) { + return companyId.equals(other.companyId) + && dir.equals(other.dir) + && limit.equals(other.limit) + && offset.equals(other.offset) + && order.equals(other.order); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.companyId, this.dir, this.limit, this.offset, this.order); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional companyId = Optional.empty(); + + private Optional dir = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional order = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCompanyGrantsParams other) { + companyId(other.getCompanyId()); + dir(other.getDir()); + limit(other.getLimit()); + offset(other.getOffset()); + order(other.getOrder()); + return this; + } + + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @JsonSetter(value = "dir", nulls = Nulls.SKIP) + public Builder dir(Optional dir) { + this.dir = dir; + return this; + } + + public Builder dir(ListCompanyGrantsResponseParamsDir dir) { + this.dir = Optional.ofNullable(dir); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "order", nulls = Nulls.SKIP) + public Builder order(Optional order) { + this.order = order; + return this; + } + + public Builder order(ListCompanyGrantsResponseParamsOrder order) { + this.order = Optional.ofNullable(order); + return this; + } + + public ListCompanyGrantsParams build() { + return new ListCompanyGrantsParams(companyId, dir, limit, offset, order, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsRequestDir.java b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsRequestDir.java new file mode 100644 index 0000000..def0181 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsRequestDir.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListCompanyGrantsRequestDir { + public static final ListCompanyGrantsRequestDir ASC = new ListCompanyGrantsRequestDir(Value.ASC, "asc"); + + public static final ListCompanyGrantsRequestDir DESC = new ListCompanyGrantsRequestDir(Value.DESC, "desc"); + + private final Value value; + + private final String string; + + ListCompanyGrantsRequestDir(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListCompanyGrantsRequestDir + && this.string.equals(((ListCompanyGrantsRequestDir) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASC: + return visitor.visitAsc(); + case DESC: + return visitor.visitDesc(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCompanyGrantsRequestDir valueOf(String value) { + switch (value) { + case "asc": + return ASC; + case "desc": + return DESC; + default: + return new ListCompanyGrantsRequestDir(Value.UNKNOWN, value); + } + } + + public enum Value { + ASC, + + DESC, + + UNKNOWN + } + + public interface Visitor { + T visitAsc(); + + T visitDesc(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsRequestOrder.java b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsRequestOrder.java new file mode 100644 index 0000000..a5f9886 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsRequestOrder.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListCompanyGrantsRequestOrder { + public static final ListCompanyGrantsRequestOrder QUANTITY = + new ListCompanyGrantsRequestOrder(Value.QUANTITY, "quantity"); + + public static final ListCompanyGrantsRequestOrder EXPIRES_AT = + new ListCompanyGrantsRequestOrder(Value.EXPIRES_AT, "expires_at"); + + public static final ListCompanyGrantsRequestOrder CREATED_AT = + new ListCompanyGrantsRequestOrder(Value.CREATED_AT, "created_at"); + + public static final ListCompanyGrantsRequestOrder QUANTITY_REMAINING = + new ListCompanyGrantsRequestOrder(Value.QUANTITY_REMAINING, "quantity_remaining"); + + private final Value value; + + private final String string; + + ListCompanyGrantsRequestOrder(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListCompanyGrantsRequestOrder + && this.string.equals(((ListCompanyGrantsRequestOrder) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case QUANTITY: + return visitor.visitQuantity(); + case EXPIRES_AT: + return visitor.visitExpiresAt(); + case CREATED_AT: + return visitor.visitCreatedAt(); + case QUANTITY_REMAINING: + return visitor.visitQuantityRemaining(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCompanyGrantsRequestOrder valueOf(String value) { + switch (value) { + case "quantity": + return QUANTITY; + case "expires_at": + return EXPIRES_AT; + case "created_at": + return CREATED_AT; + case "quantity_remaining": + return QUANTITY_REMAINING; + default: + return new ListCompanyGrantsRequestOrder(Value.UNKNOWN, value); + } + } + + public enum Value { + CREATED_AT, + + EXPIRES_AT, + + QUANTITY, + + QUANTITY_REMAINING, + + UNKNOWN + } + + public interface Visitor { + T visitCreatedAt(); + + T visitExpiresAt(); + + T visitQuantity(); + + T visitQuantityRemaining(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponse.java new file mode 100644 index 0000000..faf91f9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditGrantResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompanyGrantsResponse.Builder.class) +public final class ListCompanyGrantsResponse { + private final List data; + + private final ListCompanyGrantsParams params; + + private final Map additionalProperties; + + private ListCompanyGrantsResponse( + List data, + ListCompanyGrantsParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListCompanyGrantsParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompanyGrantsResponse && equalTo((ListCompanyGrantsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompanyGrantsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListCompanyGrantsParams params); + + Builder from(ListCompanyGrantsResponse other); + } + + public interface _FinalStage { + ListCompanyGrantsResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(BillingCreditGrantResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListCompanyGrantsParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListCompanyGrantsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListCompanyGrantsParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(BillingCreditGrantResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListCompanyGrantsResponse build() { + return new ListCompanyGrantsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponseParamsDir.java b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponseParamsDir.java new file mode 100644 index 0000000..29b2867 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponseParamsDir.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListCompanyGrantsResponseParamsDir { + public static final ListCompanyGrantsResponseParamsDir ASC = + new ListCompanyGrantsResponseParamsDir(Value.ASC, "asc"); + + public static final ListCompanyGrantsResponseParamsDir DESC = + new ListCompanyGrantsResponseParamsDir(Value.DESC, "desc"); + + private final Value value; + + private final String string; + + ListCompanyGrantsResponseParamsDir(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListCompanyGrantsResponseParamsDir + && this.string.equals(((ListCompanyGrantsResponseParamsDir) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASC: + return visitor.visitAsc(); + case DESC: + return visitor.visitDesc(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCompanyGrantsResponseParamsDir valueOf(String value) { + switch (value) { + case "asc": + return ASC; + case "desc": + return DESC; + default: + return new ListCompanyGrantsResponseParamsDir(Value.UNKNOWN, value); + } + } + + public enum Value { + ASC, + + DESC, + + UNKNOWN + } + + public interface Visitor { + T visitAsc(); + + T visitDesc(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponseParamsOrder.java b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponseParamsOrder.java new file mode 100644 index 0000000..db42abd --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCompanyGrantsResponseParamsOrder.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListCompanyGrantsResponseParamsOrder { + public static final ListCompanyGrantsResponseParamsOrder QUANTITY = + new ListCompanyGrantsResponseParamsOrder(Value.QUANTITY, "quantity"); + + public static final ListCompanyGrantsResponseParamsOrder EXPIRES_AT = + new ListCompanyGrantsResponseParamsOrder(Value.EXPIRES_AT, "expires_at"); + + public static final ListCompanyGrantsResponseParamsOrder CREATED_AT = + new ListCompanyGrantsResponseParamsOrder(Value.CREATED_AT, "created_at"); + + public static final ListCompanyGrantsResponseParamsOrder QUANTITY_REMAINING = + new ListCompanyGrantsResponseParamsOrder(Value.QUANTITY_REMAINING, "quantity_remaining"); + + private final Value value; + + private final String string; + + ListCompanyGrantsResponseParamsOrder(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListCompanyGrantsResponseParamsOrder + && this.string.equals(((ListCompanyGrantsResponseParamsOrder) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case QUANTITY: + return visitor.visitQuantity(); + case EXPIRES_AT: + return visitor.visitExpiresAt(); + case CREATED_AT: + return visitor.visitCreatedAt(); + case QUANTITY_REMAINING: + return visitor.visitQuantityRemaining(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCompanyGrantsResponseParamsOrder valueOf(String value) { + switch (value) { + case "quantity": + return QUANTITY; + case "expires_at": + return EXPIRES_AT; + case "created_at": + return CREATED_AT; + case "quantity_remaining": + return QUANTITY_REMAINING; + default: + return new ListCompanyGrantsResponseParamsOrder(Value.UNKNOWN, value); + } + } + + public enum Value { + CREATED_AT, + + EXPIRES_AT, + + QUANTITY, + + QUANTITY_REMAINING, + + UNKNOWN + } + + public interface Visitor { + T visitCreatedAt(); + + T visitExpiresAt(); + + T visitQuantity(); + + T visitQuantityRemaining(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesParams.java b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesParams.java new file mode 100644 index 0000000..5cab593 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesParams.java @@ -0,0 +1,230 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCreditBundlesParams.Builder.class) +public final class ListCreditBundlesParams { + private final Optional bundleType; + + private final Optional creditId; + + private final Optional> ids; + + private final Optional limit; + + private final Optional offset; + + private final Optional status; + + private final Map additionalProperties; + + private ListCreditBundlesParams( + Optional bundleType, + Optional creditId, + Optional> ids, + Optional limit, + Optional offset, + Optional status, + Map additionalProperties) { + this.bundleType = bundleType; + this.creditId = creditId; + this.ids = ids; + this.limit = limit; + this.offset = offset; + this.status = status; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("bundle_type") + public Optional getBundleType() { + return bundleType; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCreditBundlesParams && equalTo((ListCreditBundlesParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCreditBundlesParams other) { + return bundleType.equals(other.bundleType) + && creditId.equals(other.creditId) + && ids.equals(other.ids) + && limit.equals(other.limit) + && offset.equals(other.offset) + && status.equals(other.status); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.bundleType, this.creditId, this.ids, this.limit, this.offset, this.status); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional bundleType = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + private Optional status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCreditBundlesParams other) { + bundleType(other.getBundleType()); + creditId(other.getCreditId()); + ids(other.getIds()); + limit(other.getLimit()); + offset(other.getOffset()); + status(other.getStatus()); + return this; + } + + @JsonSetter(value = "bundle_type", nulls = Nulls.SKIP) + public Builder bundleType(Optional bundleType) { + this.bundleType = bundleType; + return this; + } + + public Builder bundleType(String bundleType) { + this.bundleType = Optional.ofNullable(bundleType); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(ListCreditBundlesResponseParamsStatus status) { + this.status = Optional.ofNullable(status); + return this; + } + + public ListCreditBundlesParams build() { + return new ListCreditBundlesParams(bundleType, creditId, ids, limit, offset, status, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesRequestStatus.java b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesRequestStatus.java new file mode 100644 index 0000000..b1afd89 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesRequestStatus.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListCreditBundlesRequestStatus { + public static final ListCreditBundlesRequestStatus INACTIVE = + new ListCreditBundlesRequestStatus(Value.INACTIVE, "inactive"); + + public static final ListCreditBundlesRequestStatus ACTIVE = + new ListCreditBundlesRequestStatus(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + ListCreditBundlesRequestStatus(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListCreditBundlesRequestStatus + && this.string.equals(((ListCreditBundlesRequestStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case INACTIVE: + return visitor.visitInactive(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCreditBundlesRequestStatus valueOf(String value) { + switch (value) { + case "inactive": + return INACTIVE; + case "active": + return ACTIVE; + default: + return new ListCreditBundlesRequestStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + INACTIVE, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitInactive(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponse.java new file mode 100644 index 0000000..b3c9799 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditBundleResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCreditBundlesResponse.Builder.class) +public final class ListCreditBundlesResponse { + private final List data; + + private final ListCreditBundlesParams params; + + private final Map additionalProperties; + + private ListCreditBundlesResponse( + List data, + ListCreditBundlesParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListCreditBundlesParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCreditBundlesResponse && equalTo((ListCreditBundlesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCreditBundlesResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListCreditBundlesParams params); + + Builder from(ListCreditBundlesResponse other); + } + + public interface _FinalStage { + ListCreditBundlesResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(BillingCreditBundleResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListCreditBundlesParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListCreditBundlesResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListCreditBundlesParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(BillingCreditBundleResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListCreditBundlesResponse build() { + return new ListCreditBundlesResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponseParamsStatus.java b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponseParamsStatus.java new file mode 100644 index 0000000..71590fc --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListCreditBundlesResponseParamsStatus.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListCreditBundlesResponseParamsStatus { + public static final ListCreditBundlesResponseParamsStatus INACTIVE = + new ListCreditBundlesResponseParamsStatus(Value.INACTIVE, "inactive"); + + public static final ListCreditBundlesResponseParamsStatus ACTIVE = + new ListCreditBundlesResponseParamsStatus(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + ListCreditBundlesResponseParamsStatus(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListCreditBundlesResponseParamsStatus + && this.string.equals(((ListCreditBundlesResponseParamsStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case INACTIVE: + return visitor.visitInactive(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListCreditBundlesResponseParamsStatus valueOf(String value) { + switch (value) { + case "inactive": + return INACTIVE; + case "active": + return ACTIVE; + default: + return new ListCreditBundlesResponseParamsStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + INACTIVE, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitInactive(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditParams.java b/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditParams.java new file mode 100644 index 0000000..69a753d --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditParams.java @@ -0,0 +1,182 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListGrantsForCreditParams.Builder.class) +public final class ListGrantsForCreditParams { + private final Optional creditId; + + private final Optional> ids; + + private final Optional limit; + + private final Optional offset; + + private final Map additionalProperties; + + private ListGrantsForCreditParams( + Optional creditId, + Optional> ids, + Optional limit, + Optional offset, + Map additionalProperties) { + this.creditId = creditId; + this.ids = ids; + this.limit = limit; + this.offset = offset; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + + /** + * @return Page limit (default 100) + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return Page offset (default 0) + */ + @JsonProperty("offset") + public Optional getOffset() { + return offset; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListGrantsForCreditParams && equalTo((ListGrantsForCreditParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListGrantsForCreditParams other) { + return creditId.equals(other.creditId) + && ids.equals(other.ids) + && limit.equals(other.limit) + && offset.equals(other.offset); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.creditId, this.ids, this.limit, this.offset); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional creditId = Optional.empty(); + + private Optional> ids = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional offset = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListGrantsForCreditParams other) { + creditId(other.getCreditId()); + ids(other.getIds()); + limit(other.getLimit()); + offset(other.getOffset()); + return this; + } + + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public Builder creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + public Builder creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + /** + *

Page limit (default 100)

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

Page offset (default 0)

+ */ + @JsonSetter(value = "offset", nulls = Nulls.SKIP) + public Builder offset(Optional offset) { + this.offset = offset; + return this; + } + + public Builder offset(Integer offset) { + this.offset = Optional.ofNullable(offset); + return this; + } + + public ListGrantsForCreditParams build() { + return new ListGrantsForCreditParams(creditId, ids, limit, offset, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditResponse.java new file mode 100644 index 0000000..e9ebfb7 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ListGrantsForCreditResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditGrantResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListGrantsForCreditResponse.Builder.class) +public final class ListGrantsForCreditResponse { + private final List data; + + private final ListGrantsForCreditParams params; + + private final Map additionalProperties; + + private ListGrantsForCreditResponse( + List data, + ListGrantsForCreditParams params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListGrantsForCreditParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListGrantsForCreditResponse && equalTo((ListGrantsForCreditResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListGrantsForCreditResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListGrantsForCreditParams params); + + Builder from(ListGrantsForCreditResponse other); + } + + public interface _FinalStage { + ListGrantsForCreditResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(BillingCreditGrantResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListGrantsForCreditParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListGrantsForCreditResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListGrantsForCreditParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(BillingCreditGrantResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListGrantsForCreditResponse build() { + return new ListGrantsForCreditResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/SoftDeleteBillingCreditResponse.java b/src/main/java/com/schematic/api/resources/credits/types/SoftDeleteBillingCreditResponse.java new file mode 100644 index 0000000..80e8e8a --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/SoftDeleteBillingCreditResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.DeleteResponse; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SoftDeleteBillingCreditResponse.Builder.class) +public final class SoftDeleteBillingCreditResponse { + private final DeleteResponse data; + + private final Map params; + + private final Map additionalProperties; + + private SoftDeleteBillingCreditResponse( + DeleteResponse data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public DeleteResponse getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SoftDeleteBillingCreditResponse && equalTo((SoftDeleteBillingCreditResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SoftDeleteBillingCreditResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull DeleteResponse data); + + Builder from(SoftDeleteBillingCreditResponse other); + } + + public interface _FinalStage { + SoftDeleteBillingCreditResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private DeleteResponse data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SoftDeleteBillingCreditResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull DeleteResponse data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public SoftDeleteBillingCreditResponse build() { + return new SoftDeleteBillingCreditResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditRequestBodyBurnStrategy.java b/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditRequestBodyBurnStrategy.java new file mode 100644 index 0000000..9a482b3 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditRequestBodyBurnStrategy.java @@ -0,0 +1,110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UpdateBillingCreditRequestBodyBurnStrategy { + public static final UpdateBillingCreditRequestBodyBurnStrategy PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT = + new UpdateBillingCreditRequestBodyBurnStrategy( + Value.PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT, + "plan_first_then_credit_bundles_first_in_first_out"); + + public static final UpdateBillingCreditRequestBodyBurnStrategy FIRST_IN_FIRST_OUT = + new UpdateBillingCreditRequestBodyBurnStrategy(Value.FIRST_IN_FIRST_OUT, "first_in_first_out"); + + public static final UpdateBillingCreditRequestBodyBurnStrategy LAST_IN_FIRST_OUT = + new UpdateBillingCreditRequestBodyBurnStrategy(Value.LAST_IN_FIRST_OUT, "last_in_first_out"); + + public static final UpdateBillingCreditRequestBodyBurnStrategy EXPIRATION_PRIORITY = + new UpdateBillingCreditRequestBodyBurnStrategy(Value.EXPIRATION_PRIORITY, "expiration_priority"); + + private final Value value; + + private final String string; + + UpdateBillingCreditRequestBodyBurnStrategy(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateBillingCreditRequestBodyBurnStrategy + && this.string.equals(((UpdateBillingCreditRequestBodyBurnStrategy) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT: + return visitor.visitPlanFirstThenCreditBundlesFirstInFirstOut(); + case FIRST_IN_FIRST_OUT: + return visitor.visitFirstInFirstOut(); + case LAST_IN_FIRST_OUT: + return visitor.visitLastInFirstOut(); + case EXPIRATION_PRIORITY: + return visitor.visitExpirationPriority(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateBillingCreditRequestBodyBurnStrategy valueOf(String value) { + switch (value) { + case "plan_first_then_credit_bundles_first_in_first_out": + return PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT; + case "first_in_first_out": + return FIRST_IN_FIRST_OUT; + case "last_in_first_out": + return LAST_IN_FIRST_OUT; + case "expiration_priority": + return EXPIRATION_PRIORITY; + default: + return new UpdateBillingCreditRequestBodyBurnStrategy(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN_FIRST_THEN_CREDIT_BUNDLES_FIRST_IN_FIRST_OUT, + + FIRST_IN_FIRST_OUT, + + LAST_IN_FIRST_OUT, + + EXPIRATION_PRIORITY, + + UNKNOWN + } + + public interface Visitor { + T visitPlanFirstThenCreditBundlesFirstInFirstOut(); + + T visitFirstInFirstOut(); + + T visitLastInFirstOut(); + + T visitExpirationPriority(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditRequestBodyDefaultRolloverPolicy.java b/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditRequestBodyDefaultRolloverPolicy.java new file mode 100644 index 0000000..dab2b2e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditRequestBodyDefaultRolloverPolicy.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UpdateBillingCreditRequestBodyDefaultRolloverPolicy { + public static final UpdateBillingCreditRequestBodyDefaultRolloverPolicy EXPIRE = + new UpdateBillingCreditRequestBodyDefaultRolloverPolicy(Value.EXPIRE, "expire"); + + public static final UpdateBillingCreditRequestBodyDefaultRolloverPolicy ROLLOVER = + new UpdateBillingCreditRequestBodyDefaultRolloverPolicy(Value.ROLLOVER, "rollover"); + + public static final UpdateBillingCreditRequestBodyDefaultRolloverPolicy NONE = + new UpdateBillingCreditRequestBodyDefaultRolloverPolicy(Value.NONE, "none"); + + private final Value value; + + private final String string; + + UpdateBillingCreditRequestBodyDefaultRolloverPolicy(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateBillingCreditRequestBodyDefaultRolloverPolicy + && this.string.equals(((UpdateBillingCreditRequestBodyDefaultRolloverPolicy) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case EXPIRE: + return visitor.visitExpire(); + case ROLLOVER: + return visitor.visitRollover(); + case NONE: + return visitor.visitNone(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateBillingCreditRequestBodyDefaultRolloverPolicy valueOf(String value) { + switch (value) { + case "expire": + return EXPIRE; + case "rollover": + return ROLLOVER; + case "none": + return NONE; + default: + return new UpdateBillingCreditRequestBodyDefaultRolloverPolicy(Value.UNKNOWN, value); + } + } + + public enum Value { + NONE, + + ROLLOVER, + + EXPIRE, + + UNKNOWN + } + + public interface Visitor { + T visitNone(); + + T visitRollover(); + + T visitExpire(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditResponse.java b/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditResponse.java new file mode 100644 index 0000000..103f6ab --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/UpdateBillingCreditResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateBillingCreditResponse.Builder.class) +public final class UpdateBillingCreditResponse { + private final BillingCreditResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private UpdateBillingCreditResponse( + BillingCreditResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public BillingCreditResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateBillingCreditResponse && equalTo((UpdateBillingCreditResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateBillingCreditResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull BillingCreditResponseData data); + + Builder from(UpdateBillingCreditResponse other); + } + + public interface _FinalStage { + UpdateBillingCreditResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private BillingCreditResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateBillingCreditResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull BillingCreditResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public UpdateBillingCreditResponse build() { + return new UpdateBillingCreditResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyExpiryType.java b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyExpiryType.java new file mode 100644 index 0000000..91ca2fe --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyExpiryType.java @@ -0,0 +1,120 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UpdateCreditBundleDetailsRequestBodyExpiryType { + public static final UpdateCreditBundleDetailsRequestBodyExpiryType END_OF_BILLING_PERIOD = + new UpdateCreditBundleDetailsRequestBodyExpiryType(Value.END_OF_BILLING_PERIOD, "end_of_billing_period"); + + public static final UpdateCreditBundleDetailsRequestBodyExpiryType DURATION = + new UpdateCreditBundleDetailsRequestBodyExpiryType(Value.DURATION, "duration"); + + public static final UpdateCreditBundleDetailsRequestBodyExpiryType END_OF_NEXT_BILLING_PERIOD = + new UpdateCreditBundleDetailsRequestBodyExpiryType( + Value.END_OF_NEXT_BILLING_PERIOD, "end_of_next_billing_period"); + + public static final UpdateCreditBundleDetailsRequestBodyExpiryType NO_EXPIRY = + new UpdateCreditBundleDetailsRequestBodyExpiryType(Value.NO_EXPIRY, "no_expiry"); + + public static final UpdateCreditBundleDetailsRequestBodyExpiryType END_OF_TRIAL = + new UpdateCreditBundleDetailsRequestBodyExpiryType(Value.END_OF_TRIAL, "end_of_trial"); + + private final Value value; + + private final String string; + + UpdateCreditBundleDetailsRequestBodyExpiryType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateCreditBundleDetailsRequestBodyExpiryType + && this.string.equals(((UpdateCreditBundleDetailsRequestBodyExpiryType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case END_OF_BILLING_PERIOD: + return visitor.visitEndOfBillingPeriod(); + case DURATION: + return visitor.visitDuration(); + case END_OF_NEXT_BILLING_PERIOD: + return visitor.visitEndOfNextBillingPeriod(); + case NO_EXPIRY: + return visitor.visitNoExpiry(); + case END_OF_TRIAL: + return visitor.visitEndOfTrial(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateCreditBundleDetailsRequestBodyExpiryType valueOf(String value) { + switch (value) { + case "end_of_billing_period": + return END_OF_BILLING_PERIOD; + case "duration": + return DURATION; + case "end_of_next_billing_period": + return END_OF_NEXT_BILLING_PERIOD; + case "no_expiry": + return NO_EXPIRY; + case "end_of_trial": + return END_OF_TRIAL; + default: + return new UpdateCreditBundleDetailsRequestBodyExpiryType(Value.UNKNOWN, value); + } + } + + public enum Value { + DURATION, + + NO_EXPIRY, + + END_OF_TRIAL, + + END_OF_BILLING_PERIOD, + + END_OF_NEXT_BILLING_PERIOD, + + UNKNOWN + } + + public interface Visitor { + T visitDuration(); + + T visitNoExpiry(); + + T visitEndOfTrial(); + + T visitEndOfBillingPeriod(); + + T visitEndOfNextBillingPeriod(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyExpiryUnit.java b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyExpiryUnit.java new file mode 100644 index 0000000..cd1e392 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyExpiryUnit.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UpdateCreditBundleDetailsRequestBodyExpiryUnit { + public static final UpdateCreditBundleDetailsRequestBodyExpiryUnit BILLING_PERIODS = + new UpdateCreditBundleDetailsRequestBodyExpiryUnit(Value.BILLING_PERIODS, "billing_periods"); + + public static final UpdateCreditBundleDetailsRequestBodyExpiryUnit DAYS = + new UpdateCreditBundleDetailsRequestBodyExpiryUnit(Value.DAYS, "days"); + + private final Value value; + + private final String string; + + UpdateCreditBundleDetailsRequestBodyExpiryUnit(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateCreditBundleDetailsRequestBodyExpiryUnit + && this.string.equals(((UpdateCreditBundleDetailsRequestBodyExpiryUnit) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BILLING_PERIODS: + return visitor.visitBillingPeriods(); + case DAYS: + return visitor.visitDays(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateCreditBundleDetailsRequestBodyExpiryUnit valueOf(String value) { + switch (value) { + case "billing_periods": + return BILLING_PERIODS; + case "days": + return DAYS; + default: + return new UpdateCreditBundleDetailsRequestBodyExpiryUnit(Value.UNKNOWN, value); + } + } + + public enum Value { + DAYS, + + BILLING_PERIODS, + + UNKNOWN + } + + public interface Visitor { + T visitDays(); + + T visitBillingPeriods(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyStatus.java b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyStatus.java new file mode 100644 index 0000000..df685dc --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsRequestBodyStatus.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UpdateCreditBundleDetailsRequestBodyStatus { + public static final UpdateCreditBundleDetailsRequestBodyStatus INACTIVE = + new UpdateCreditBundleDetailsRequestBodyStatus(Value.INACTIVE, "inactive"); + + public static final UpdateCreditBundleDetailsRequestBodyStatus ACTIVE = + new UpdateCreditBundleDetailsRequestBodyStatus(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + UpdateCreditBundleDetailsRequestBodyStatus(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateCreditBundleDetailsRequestBodyStatus + && this.string.equals(((UpdateCreditBundleDetailsRequestBodyStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case INACTIVE: + return visitor.visitInactive(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateCreditBundleDetailsRequestBodyStatus valueOf(String value) { + switch (value) { + case "inactive": + return INACTIVE; + case "active": + return ACTIVE; + default: + return new UpdateCreditBundleDetailsRequestBodyStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + INACTIVE, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitInactive(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsResponse.java b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsResponse.java new file mode 100644 index 0000000..c696093 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/UpdateCreditBundleDetailsResponse.java @@ -0,0 +1,167 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.BillingCreditBundleResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateCreditBundleDetailsResponse.Builder.class) +public final class UpdateCreditBundleDetailsResponse { + private final BillingCreditBundleResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private UpdateCreditBundleDetailsResponse( + BillingCreditBundleResponseData data, + Map params, + Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public BillingCreditBundleResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCreditBundleDetailsResponse && equalTo((UpdateCreditBundleDetailsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCreditBundleDetailsResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull BillingCreditBundleResponseData data); + + Builder from(UpdateCreditBundleDetailsResponse other); + } + + public interface _FinalStage { + UpdateCreditBundleDetailsResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private BillingCreditBundleResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCreditBundleDetailsResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull BillingCreditBundleResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public UpdateCreditBundleDetailsResponse build() { + return new UpdateCreditBundleDetailsResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/credits/types/ZeroOutGrantRequestBodyReason.java b/src/main/java/com/schematic/api/resources/credits/types/ZeroOutGrantRequestBodyReason.java new file mode 100644 index 0000000..74a047a --- /dev/null +++ b/src/main/java/com/schematic/api/resources/credits/types/ZeroOutGrantRequestBodyReason.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.credits.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ZeroOutGrantRequestBodyReason { + public static final ZeroOutGrantRequestBodyReason PLAN_CHANGE = + new ZeroOutGrantRequestBodyReason(Value.PLAN_CHANGE, "plan_change"); + + public static final ZeroOutGrantRequestBodyReason PLAN_PERIOD_RESET = + new ZeroOutGrantRequestBodyReason(Value.PLAN_PERIOD_RESET, "plan_period_reset"); + + public static final ZeroOutGrantRequestBodyReason EXPIRED = + new ZeroOutGrantRequestBodyReason(Value.EXPIRED, "expired"); + + public static final ZeroOutGrantRequestBodyReason MANUAL = + new ZeroOutGrantRequestBodyReason(Value.MANUAL, "manual"); + + private final Value value; + + private final String string; + + ZeroOutGrantRequestBodyReason(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ZeroOutGrantRequestBodyReason + && this.string.equals(((ZeroOutGrantRequestBodyReason) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAN_CHANGE: + return visitor.visitPlanChange(); + case PLAN_PERIOD_RESET: + return visitor.visitPlanPeriodReset(); + case EXPIRED: + return visitor.visitExpired(); + case MANUAL: + return visitor.visitManual(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ZeroOutGrantRequestBodyReason valueOf(String value) { + switch (value) { + case "plan_change": + return PLAN_CHANGE; + case "plan_period_reset": + return PLAN_PERIOD_RESET; + case "expired": + return EXPIRED; + case "manual": + return MANUAL; + default: + return new ZeroOutGrantRequestBodyReason(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN_CHANGE, + + MANUAL, + + PLAN_PERIOD_RESET, + + EXPIRED, + + UNKNOWN + } + + public interface Visitor { + T visitPlanChange(); + + T visitManual(); + + T visitPlanPeriodReset(); + + T visitExpired(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/plans/types/GetAudienceResponse.java b/src/main/java/com/schematic/api/resources/credits/types/ZeroOutGrantResponse.java similarity index 73% rename from src/main/java/com/schematic/api/resources/plans/types/GetAudienceResponse.java rename to src/main/java/com/schematic/api/resources/credits/types/ZeroOutGrantResponse.java index 3703532..7ee3e07 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/GetAudienceResponse.java +++ b/src/main/java/com/schematic/api/resources/credits/types/ZeroOutGrantResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.schematic.api.resources.plans.types; +package com.schematic.api.resources.credits.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import com.schematic.api.types.PlanAudienceDetailResponseData; +import com.schematic.api.types.BillingCreditGrantResponseData; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -21,16 +21,16 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = GetAudienceResponse.Builder.class) -public final class GetAudienceResponse { - private final PlanAudienceDetailResponseData data; +@JsonDeserialize(builder = ZeroOutGrantResponse.Builder.class) +public final class ZeroOutGrantResponse { + private final BillingCreditGrantResponseData data; private final Map params; private final Map additionalProperties; - private GetAudienceResponse( - PlanAudienceDetailResponseData data, + private ZeroOutGrantResponse( + BillingCreditGrantResponseData data, Map params, Map additionalProperties) { this.data = data; @@ -39,7 +39,7 @@ private GetAudienceResponse( } @JsonProperty("data") - public PlanAudienceDetailResponseData getData() { + public BillingCreditGrantResponseData getData() { return data; } @@ -54,7 +54,7 @@ public Map getParams() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof GetAudienceResponse && equalTo((GetAudienceResponse) other); + return other instanceof ZeroOutGrantResponse && equalTo((ZeroOutGrantResponse) other); } @JsonAnyGetter @@ -62,7 +62,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(GetAudienceResponse other) { + private boolean equalTo(ZeroOutGrantResponse other) { return data.equals(other.data) && params.equals(other.params); } @@ -81,14 +81,17 @@ public static DataStage builder() { } public interface DataStage { - _FinalStage data(@NotNull PlanAudienceDetailResponseData data); + _FinalStage data(@NotNull BillingCreditGrantResponseData data); - Builder from(GetAudienceResponse other); + Builder from(ZeroOutGrantResponse other); } public interface _FinalStage { - GetAudienceResponse build(); + ZeroOutGrantResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -98,7 +101,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements DataStage, _FinalStage { - private PlanAudienceDetailResponseData data; + private BillingCreditGrantResponseData data; private Map params = new LinkedHashMap<>(); @@ -108,7 +111,7 @@ public static final class Builder implements DataStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(GetAudienceResponse other) { + public Builder from(ZeroOutGrantResponse other) { data(other.getData()); params(other.getParams()); return this; @@ -116,7 +119,7 @@ public Builder from(GetAudienceResponse other) { @java.lang.Override @JsonSetter("data") - public _FinalStage data(@NotNull PlanAudienceDetailResponseData data) { + public _FinalStage data(@NotNull BillingCreditGrantResponseData data) { this.data = Objects.requireNonNull(data, "data must not be null"); return this; } @@ -137,21 +140,28 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } @java.lang.Override - public GetAudienceResponse build() { - return new GetAudienceResponse(data, params, additionalProperties); + public ZeroOutGrantResponse build() { + return new ZeroOutGrantResponse(data, params, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/crm/AsyncCrmClient.java b/src/main/java/com/schematic/api/resources/crm/AsyncCrmClient.java new file mode 100644 index 0000000..f8c6ff9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/crm/AsyncCrmClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.crm; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.crm.requests.CreateCrmDealLineItemAssociationRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmDealRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmLineItemRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmProductRequestBody; +import com.schematic.api.resources.crm.requests.ListCrmProductsRequest; +import com.schematic.api.resources.crm.types.ListCrmProductsResponse; +import com.schematic.api.resources.crm.types.UpsertCrmDealResponse; +import com.schematic.api.resources.crm.types.UpsertCrmProductResponse; +import com.schematic.api.resources.crm.types.UpsertDealLineItemAssociationResponse; +import com.schematic.api.resources.crm.types.UpsertLineItemResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncCrmClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCrmClient rawClient; + + public AsyncCrmClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCrmClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCrmClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture upsertDealLineItemAssociation( + CreateCrmDealLineItemAssociationRequestBody request) { + return this.rawClient.upsertDealLineItemAssociation(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertDealLineItemAssociation( + CreateCrmDealLineItemAssociationRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .upsertDealLineItemAssociation(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture upsertLineItem(CreateCrmLineItemRequestBody request) { + return this.rawClient.upsertLineItem(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertLineItem( + CreateCrmLineItemRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertLineItem(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertCrmDeal(CreateCrmDealRequestBody request) { + return this.rawClient.upsertCrmDeal(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertCrmDeal( + CreateCrmDealRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertCrmDeal(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listCrmProducts() { + return this.rawClient.listCrmProducts().thenApply(response -> response.body()); + } + + public CompletableFuture listCrmProducts(ListCrmProductsRequest request) { + return this.rawClient.listCrmProducts(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCrmProducts( + ListCrmProductsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCrmProducts(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertCrmProduct(CreateCrmProductRequestBody request) { + return this.rawClient.upsertCrmProduct(request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertCrmProduct( + CreateCrmProductRequestBody request, RequestOptions requestOptions) { + return this.rawClient.upsertCrmProduct(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/crm/AsyncRawCrmClient.java b/src/main/java/com/schematic/api/resources/crm/AsyncRawCrmClient.java new file mode 100644 index 0000000..e8ba567 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/crm/AsyncRawCrmClient.java @@ -0,0 +1,521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.crm; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.crm.requests.CreateCrmDealLineItemAssociationRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmDealRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmLineItemRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmProductRequestBody; +import com.schematic.api.resources.crm.requests.ListCrmProductsRequest; +import com.schematic.api.resources.crm.types.ListCrmProductsResponse; +import com.schematic.api.resources.crm.types.UpsertCrmDealResponse; +import com.schematic.api.resources.crm.types.UpsertCrmProductResponse; +import com.schematic.api.resources.crm.types.UpsertDealLineItemAssociationResponse; +import com.schematic.api.resources.crm.types.UpsertLineItemResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCrmClient { + protected final ClientOptions clientOptions; + + public AsyncRawCrmClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> + upsertDealLineItemAssociation(CreateCrmDealLineItemAssociationRequestBody request) { + return upsertDealLineItemAssociation(request, null); + } + + public CompletableFuture> + upsertDealLineItemAssociation( + CreateCrmDealLineItemAssociationRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/associations/deal-line-item") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertDealLineItemAssociationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertLineItem( + CreateCrmLineItemRequestBody request) { + return upsertLineItem(request, null); + } + + public CompletableFuture> upsertLineItem( + CreateCrmLineItemRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/deal-line-item/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertLineItemResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertCrmDeal( + CreateCrmDealRequestBody request) { + return upsertCrmDeal(request, null); + } + + public CompletableFuture> upsertCrmDeal( + CreateCrmDealRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/deals/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertCrmDealResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listCrmProducts() { + return listCrmProducts(ListCrmProductsRequest.builder().build()); + } + + public CompletableFuture> listCrmProducts( + ListCrmProductsRequest request) { + return listCrmProducts(request, null); + } + + public CompletableFuture> listCrmProducts( + ListCrmProductsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/products"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCrmProductsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertCrmProduct( + CreateCrmProductRequestBody request) { + return upsertCrmProduct(request, null); + } + + public CompletableFuture> upsertCrmProduct( + CreateCrmProductRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/products/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertCrmProductResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/crm/CrmClient.java b/src/main/java/com/schematic/api/resources/crm/CrmClient.java index 337cdfe..f6a87b3 100644 --- a/src/main/java/com/schematic/api/resources/crm/CrmClient.java +++ b/src/main/java/com/schematic/api/resources/crm/CrmClient.java @@ -3,17 +3,8 @@ */ package com.schematic.api.resources.crm; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.crm.requests.CreateCrmDealLineItemAssociationRequestBody; import com.schematic.api.resources.crm.requests.CreateCrmDealRequestBody; import com.schematic.api.resources.crm.requests.CreateCrmLineItemRequestBody; @@ -24,332 +15,70 @@ import com.schematic.api.resources.crm.types.UpsertCrmProductResponse; import com.schematic.api.resources.crm.types.UpsertDealLineItemAssociationResponse; import com.schematic.api.resources.crm.types.UpsertLineItemResponse; -import com.schematic.api.types.ApiError; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CrmClient { protected final ClientOptions clientOptions; + private final RawCrmClient rawClient; + public CrmClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCrmClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCrmClient withRawResponse() { + return this.rawClient; } public UpsertDealLineItemAssociationResponse upsertDealLineItemAssociation( CreateCrmDealLineItemAssociationRequestBody request) { - return upsertDealLineItemAssociation(request, null); + return this.rawClient.upsertDealLineItemAssociation(request).body(); } public UpsertDealLineItemAssociationResponse upsertDealLineItemAssociation( CreateCrmDealLineItemAssociationRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/associations/deal-line-item") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), UpsertDealLineItemAssociationResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient + .upsertDealLineItemAssociation(request, requestOptions) + .body(); } public UpsertLineItemResponse upsertLineItem(CreateCrmLineItemRequestBody request) { - return upsertLineItem(request, null); + return this.rawClient.upsertLineItem(request).body(); } public UpsertLineItemResponse upsertLineItem(CreateCrmLineItemRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/deal-line-item/upsert") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertLineItemResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertLineItem(request, requestOptions).body(); } public UpsertCrmDealResponse upsertCrmDeal(CreateCrmDealRequestBody request) { - return upsertCrmDeal(request, null); + return this.rawClient.upsertCrmDeal(request).body(); } public UpsertCrmDealResponse upsertCrmDeal(CreateCrmDealRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/deals/upsert") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertCrmDealResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertCrmDeal(request, requestOptions).body(); } public ListCrmProductsResponse listCrmProducts() { - return listCrmProducts(ListCrmProductsRequest.builder().build()); + return this.rawClient.listCrmProducts().body(); } public ListCrmProductsResponse listCrmProducts(ListCrmProductsRequest request) { - return listCrmProducts(request, null); + return this.rawClient.listCrmProducts(request).body(); } public ListCrmProductsResponse listCrmProducts(ListCrmProductsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/products"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCrmProductsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listCrmProducts(request, requestOptions).body(); } public UpsertCrmProductResponse upsertCrmProduct(CreateCrmProductRequestBody request) { - return upsertCrmProduct(request, null); + return this.rawClient.upsertCrmProduct(request).body(); } public UpsertCrmProductResponse upsertCrmProduct( CreateCrmProductRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/products/upsert") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertCrmProductResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.upsertCrmProduct(request, requestOptions).body(); } } diff --git a/src/main/java/com/schematic/api/resources/crm/RawCrmClient.java b/src/main/java/com/schematic/api/resources/crm/RawCrmClient.java new file mode 100644 index 0000000..dea3d02 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/crm/RawCrmClient.java @@ -0,0 +1,393 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.crm; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.crm.requests.CreateCrmDealLineItemAssociationRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmDealRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmLineItemRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmProductRequestBody; +import com.schematic.api.resources.crm.requests.ListCrmProductsRequest; +import com.schematic.api.resources.crm.types.ListCrmProductsResponse; +import com.schematic.api.resources.crm.types.UpsertCrmDealResponse; +import com.schematic.api.resources.crm.types.UpsertCrmProductResponse; +import com.schematic.api.resources.crm.types.UpsertDealLineItemAssociationResponse; +import com.schematic.api.resources.crm.types.UpsertLineItemResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCrmClient { + protected final ClientOptions clientOptions; + + public RawCrmClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse upsertDealLineItemAssociation( + CreateCrmDealLineItemAssociationRequestBody request) { + return upsertDealLineItemAssociation(request, null); + } + + public BaseSchematicHttpResponse upsertDealLineItemAssociation( + CreateCrmDealLineItemAssociationRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/associations/deal-line-item") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertDealLineItemAssociationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertLineItem(CreateCrmLineItemRequestBody request) { + return upsertLineItem(request, null); + } + + public BaseSchematicHttpResponse upsertLineItem( + CreateCrmLineItemRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/deal-line-item/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertLineItemResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertCrmDeal(CreateCrmDealRequestBody request) { + return upsertCrmDeal(request, null); + } + + public BaseSchematicHttpResponse upsertCrmDeal( + CreateCrmDealRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/deals/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertCrmDealResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listCrmProducts() { + return listCrmProducts(ListCrmProductsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCrmProducts(ListCrmProductsRequest request) { + return listCrmProducts(request, null); + } + + public BaseSchematicHttpResponse listCrmProducts( + ListCrmProductsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/products"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCrmProductsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertCrmProduct(CreateCrmProductRequestBody request) { + return upsertCrmProduct(request, null); + } + + public BaseSchematicHttpResponse upsertCrmProduct( + CreateCrmProductRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/products/upsert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpsertCrmProductResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/crm/requests/ListCrmProductsRequest.java b/src/main/java/com/schematic/api/resources/crm/requests/ListCrmProductsRequest.java index 12370b8..10bdd70 100644 --- a/src/main/java/com/schematic/api/resources/crm/requests/ListCrmProductsRequest.java +++ b/src/main/java/com/schematic/api/resources/crm/requests/ListCrmProductsRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,7 +22,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListCrmProductsRequest.Builder.class) public final class ListCrmProductsRequest { - private final Optional ids; + private final Optional> ids; private final Optional name; @@ -31,7 +33,7 @@ public final class ListCrmProductsRequest { private final Map additionalProperties; private ListCrmProductsRequest( - Optional ids, + Optional> ids, Optional name, Optional limit, Optional offset, @@ -44,7 +46,7 @@ private ListCrmProductsRequest( } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -103,7 +105,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional name = Optional.empty(); @@ -125,16 +127,21 @@ public Builder from(ListCrmProductsRequest other) { } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -146,6 +153,9 @@ public Builder name(String name) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -157,6 +167,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/crm/types/ListCrmProductsParams.java b/src/main/java/com/schematic/api/resources/crm/types/ListCrmProductsParams.java index 004e2ed..dbaca93 100644 --- a/src/main/java/com/schematic/api/resources/crm/types/ListCrmProductsParams.java +++ b/src/main/java/com/schematic/api/resources/crm/types/ListCrmProductsParams.java @@ -136,6 +136,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -158,6 +161,9 @@ public Builder name(String name) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/crm/types/ListCrmProductsResponse.java b/src/main/java/com/schematic/api/resources/crm/types/ListCrmProductsResponse.java index 3bb0b96..1733a46 100644 --- a/src/main/java/com/schematic/api/resources/crm/types/ListCrmProductsResponse.java +++ b/src/main/java/com/schematic/api/resources/crm/types/ListCrmProductsResponse.java @@ -36,9 +36,6 @@ private ListCrmProductsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListCrmProductsParams params); Builder from(ListCrmProductsResponse other); @@ -116,6 +116,7 @@ public Builder from(ListCrmProductsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListCrmProductsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(CrmProductResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(CrmProductResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/crm/types/UpsertCrmDealResponse.java b/src/main/java/com/schematic/api/resources/crm/types/UpsertCrmDealResponse.java index d2a6a45..17987f3 100644 --- a/src/main/java/com/schematic/api/resources/crm/types/UpsertCrmDealResponse.java +++ b/src/main/java/com/schematic/api/resources/crm/types/UpsertCrmDealResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertCrmDealResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/crm/types/UpsertCrmProductResponse.java b/src/main/java/com/schematic/api/resources/crm/types/UpsertCrmProductResponse.java index 01cd0f4..56a2ac7 100644 --- a/src/main/java/com/schematic/api/resources/crm/types/UpsertCrmProductResponse.java +++ b/src/main/java/com/schematic/api/resources/crm/types/UpsertCrmProductResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertCrmProductResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/crm/types/UpsertDealLineItemAssociationResponse.java b/src/main/java/com/schematic/api/resources/crm/types/UpsertDealLineItemAssociationResponse.java index d6e9b23..a8ace2a 100644 --- a/src/main/java/com/schematic/api/resources/crm/types/UpsertDealLineItemAssociationResponse.java +++ b/src/main/java/com/schematic/api/resources/crm/types/UpsertDealLineItemAssociationResponse.java @@ -88,6 +88,9 @@ public interface DataStage { public interface _FinalStage { UpsertDealLineItemAssociationResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -136,15 +139,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/crm/types/UpsertLineItemResponse.java b/src/main/java/com/schematic/api/resources/crm/types/UpsertLineItemResponse.java index eea3bc9..cc47d4e 100644 --- a/src/main/java/com/schematic/api/resources/crm/types/UpsertLineItemResponse.java +++ b/src/main/java/com/schematic/api/resources/crm/types/UpsertLineItemResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpsertLineItemResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/dataexports/AsyncDataexportsClient.java b/src/main/java/com/schematic/api/resources/dataexports/AsyncDataexportsClient.java new file mode 100644 index 0000000..98d913b --- /dev/null +++ b/src/main/java/com/schematic/api/resources/dataexports/AsyncDataexportsClient.java @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.dataexports; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.dataexports.requests.CreateDataExportRequestBody; +import com.schematic.api.resources.dataexports.types.CreateDataExportResponse; +import java.io.InputStream; +import java.util.concurrent.CompletableFuture; + +public class AsyncDataexportsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDataexportsClient rawClient; + + public AsyncDataexportsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDataexportsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDataexportsClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture createDataExport(CreateDataExportRequestBody request) { + return this.rawClient.createDataExport(request).thenApply(response -> response.body()); + } + + public CompletableFuture createDataExport( + CreateDataExportRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createDataExport(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getDataExportArtifact(String dataExportId) { + return this.rawClient.getDataExportArtifact(dataExportId).thenApply(response -> response.body()); + } + + public CompletableFuture getDataExportArtifact(String dataExportId, RequestOptions requestOptions) { + return this.rawClient + .getDataExportArtifact(dataExportId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/dataexports/AsyncRawDataexportsClient.java b/src/main/java/com/schematic/api/resources/dataexports/AsyncRawDataexportsClient.java new file mode 100644 index 0000000..3ab183b --- /dev/null +++ b/src/main/java/com/schematic/api/resources/dataexports/AsyncRawDataexportsClient.java @@ -0,0 +1,214 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.dataexports; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.ResponseBodyInputStream; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.dataexports.requests.CreateDataExportRequestBody; +import com.schematic.api.resources.dataexports.types.CreateDataExportResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDataexportsClient { + protected final ClientOptions clientOptions; + + public AsyncRawDataexportsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> createDataExport( + CreateDataExportRequestBody request) { + return createDataExport(request, null); + } + + public CompletableFuture> createDataExport( + CreateDataExportRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data-exports") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateDataExportResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getDataExportArtifact(String dataExportId) { + return getDataExportArtifact(dataExportId, null); + } + + public CompletableFuture> getDataExportArtifact( + String dataExportId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data-exports") + .addPathSegment(dataExportId) + .addPathSegments("artifact") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + future.complete( + new BaseSchematicHttpResponse<>(new ResponseBodyInputStream(response), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/dataexports/DataexportsClient.java b/src/main/java/com/schematic/api/resources/dataexports/DataexportsClient.java new file mode 100644 index 0000000..4b95499 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/dataexports/DataexportsClient.java @@ -0,0 +1,47 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.dataexports; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.dataexports.requests.CreateDataExportRequestBody; +import com.schematic.api.resources.dataexports.types.CreateDataExportResponse; +import java.io.InputStream; + +public class DataexportsClient { + protected final ClientOptions clientOptions; + + private final RawDataexportsClient rawClient; + + public DataexportsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawDataexportsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDataexportsClient withRawResponse() { + return this.rawClient; + } + + public CreateDataExportResponse createDataExport(CreateDataExportRequestBody request) { + return this.rawClient.createDataExport(request).body(); + } + + public CreateDataExportResponse createDataExport( + CreateDataExportRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createDataExport(request, requestOptions).body(); + } + + public InputStream getDataExportArtifact(String dataExportId) { + return this.rawClient.getDataExportArtifact(dataExportId).body(); + } + + public InputStream getDataExportArtifact(String dataExportId, RequestOptions requestOptions) { + return this.rawClient + .getDataExportArtifact(dataExportId, requestOptions) + .body(); + } +} diff --git a/src/main/java/com/schematic/api/resources/dataexports/RawDataexportsClient.java b/src/main/java/com/schematic/api/resources/dataexports/RawDataexportsClient.java new file mode 100644 index 0000000..0db7273 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/dataexports/RawDataexportsClient.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.dataexports; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.core.ResponseBodyInputStream; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.dataexports.requests.CreateDataExportRequestBody; +import com.schematic.api.resources.dataexports.types.CreateDataExportResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.io.InputStream; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDataexportsClient { + protected final ClientOptions clientOptions; + + public RawDataexportsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse createDataExport(CreateDataExportRequestBody request) { + return createDataExport(request, null); + } + + public BaseSchematicHttpResponse createDataExport( + CreateDataExportRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data-exports") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateDataExportResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getDataExportArtifact(String dataExportId) { + return getDataExportArtifact(dataExportId, null); + } + + public BaseSchematicHttpResponse getDataExportArtifact( + String dataExportId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data-exports") + .addPathSegment(dataExportId) + .addPathSegments("artifact") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try { + Response response = client.newCall(okhttpRequest).execute(); + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>(new ResponseBodyInputStream(response), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/dataexports/requests/CreateDataExportRequestBody.java b/src/main/java/com/schematic/api/resources/dataexports/requests/CreateDataExportRequestBody.java new file mode 100644 index 0000000..42bb3ab --- /dev/null +++ b/src/main/java/com/schematic/api/resources/dataexports/requests/CreateDataExportRequestBody.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.dataexports.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateDataExportRequestBody.Builder.class) +public final class CreateDataExportRequestBody { + private final String metadata; + + private final Map additionalProperties; + + private CreateDataExportRequestBody(String metadata, Map additionalProperties) { + this.metadata = metadata; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("export_type") + public String getExportType() { + return "company-feature-usage"; + } + + @JsonProperty("metadata") + public String getMetadata() { + return metadata; + } + + @JsonProperty("output_file_type") + public String getOutputFileType() { + return "csv"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateDataExportRequestBody && equalTo((CreateDataExportRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateDataExportRequestBody other) { + return metadata.equals(other.metadata); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.metadata); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static MetadataStage builder() { + return new Builder(); + } + + public interface MetadataStage { + _FinalStage metadata(@NotNull String metadata); + + Builder from(CreateDataExportRequestBody other); + } + + public interface _FinalStage { + CreateDataExportRequestBody build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements MetadataStage, _FinalStage { + private String metadata; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateDataExportRequestBody other) { + metadata(other.getMetadata()); + return this; + } + + @java.lang.Override + @JsonSetter("metadata") + public _FinalStage metadata(@NotNull String metadata) { + this.metadata = Objects.requireNonNull(metadata, "metadata must not be null"); + return this; + } + + @java.lang.Override + public CreateDataExportRequestBody build() { + return new CreateDataExportRequestBody(metadata, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/dataexports/types/CreateDataExportResponse.java b/src/main/java/com/schematic/api/resources/dataexports/types/CreateDataExportResponse.java new file mode 100644 index 0000000..08e6bf5 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/dataexports/types/CreateDataExportResponse.java @@ -0,0 +1,165 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.dataexports.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.DataExportResponseData; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateDataExportResponse.Builder.class) +public final class CreateDataExportResponse { + private final DataExportResponseData data; + + private final Map params; + + private final Map additionalProperties; + + private CreateDataExportResponse( + DataExportResponseData data, Map params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public DataExportResponseData getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public Map getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateDataExportResponse && equalTo((CreateDataExportResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateDataExportResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DataStage builder() { + return new Builder(); + } + + public interface DataStage { + _FinalStage data(@NotNull DataExportResponseData data); + + Builder from(CreateDataExportResponse other); + } + + public interface _FinalStage { + CreateDataExportResponse build(); + + /** + *

Input parameters

+ */ + _FinalStage params(Map params); + + _FinalStage putAllParams(Map params); + + _FinalStage params(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DataStage, _FinalStage { + private DataExportResponseData data; + + private Map params = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateDataExportResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + @java.lang.Override + @JsonSetter("data") + public _FinalStage data(@NotNull DataExportResponseData data) { + this.data = Objects.requireNonNull(data, "data must not be null"); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage params(String key, JsonNode value) { + this.params.put(key, value); + return this; + } + + /** + *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage putAllParams(Map params) { + if (params != null) { + this.params.putAll(params); + } + return this; + } + + /** + *

Input parameters

+ */ + @java.lang.Override + @JsonSetter(value = "params", nulls = Nulls.SKIP) + public _FinalStage params(Map params) { + this.params.clear(); + if (params != null) { + this.params.putAll(params); + } + return this; + } + + @java.lang.Override + public CreateDataExportResponse build() { + return new CreateDataExportResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/entitlements/AsyncEntitlementsClient.java b/src/main/java/com/schematic/api/resources/entitlements/AsyncEntitlementsClient.java new file mode 100644 index 0000000..cbc8adf --- /dev/null +++ b/src/main/java/com/schematic/api/resources/entitlements/AsyncEntitlementsClient.java @@ -0,0 +1,275 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.entitlements; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.entitlements.requests.CountCompanyOverridesRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureCompaniesRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureUsageRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureUsersRequest; +import com.schematic.api.resources.entitlements.requests.CountPlanEntitlementsRequest; +import com.schematic.api.resources.entitlements.requests.CreateCompanyOverrideRequestBody; +import com.schematic.api.resources.entitlements.requests.CreatePlanEntitlementRequestBody; +import com.schematic.api.resources.entitlements.requests.GetFeatureUsageByCompanyRequest; +import com.schematic.api.resources.entitlements.requests.ListCompanyOverridesRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureCompaniesRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureUsageRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureUsersRequest; +import com.schematic.api.resources.entitlements.requests.ListPlanEntitlementsRequest; +import com.schematic.api.resources.entitlements.requests.UpdateCompanyOverrideRequestBody; +import com.schematic.api.resources.entitlements.requests.UpdatePlanEntitlementRequestBody; +import com.schematic.api.resources.entitlements.types.CountCompanyOverridesResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureCompaniesResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureUsageResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureUsersResponse; +import com.schematic.api.resources.entitlements.types.CountPlanEntitlementsResponse; +import com.schematic.api.resources.entitlements.types.CreateCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.DeleteCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.DeletePlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.GetCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.GetFeatureUsageByCompanyResponse; +import com.schematic.api.resources.entitlements.types.GetPlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.ListCompanyOverridesResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureCompaniesResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureUsageResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureUsersResponse; +import com.schematic.api.resources.entitlements.types.ListPlanEntitlementsResponse; +import com.schematic.api.resources.entitlements.types.UpdateCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncEntitlementsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEntitlementsClient rawClient; + + public AsyncEntitlementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEntitlementsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEntitlementsClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture listCompanyOverrides() { + return this.rawClient.listCompanyOverrides().thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyOverrides(ListCompanyOverridesRequest request) { + return this.rawClient.listCompanyOverrides(request).thenApply(response -> response.body()); + } + + public CompletableFuture listCompanyOverrides( + ListCompanyOverridesRequest request, RequestOptions requestOptions) { + return this.rawClient.listCompanyOverrides(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createCompanyOverride( + CreateCompanyOverrideRequestBody request) { + return this.rawClient.createCompanyOverride(request).thenApply(response -> response.body()); + } + + public CompletableFuture createCompanyOverride( + CreateCompanyOverrideRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createCompanyOverride(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getCompanyOverride(String companyOverrideId) { + return this.rawClient.getCompanyOverride(companyOverrideId).thenApply(response -> response.body()); + } + + public CompletableFuture getCompanyOverride( + String companyOverrideId, RequestOptions requestOptions) { + return this.rawClient + .getCompanyOverride(companyOverrideId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture updateCompanyOverride( + String companyOverrideId, UpdateCompanyOverrideRequestBody request) { + return this.rawClient.updateCompanyOverride(companyOverrideId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateCompanyOverride( + String companyOverrideId, UpdateCompanyOverrideRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCompanyOverride(companyOverrideId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deleteCompanyOverride(String companyOverrideId) { + return this.rawClient.deleteCompanyOverride(companyOverrideId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteCompanyOverride( + String companyOverrideId, RequestOptions requestOptions) { + return this.rawClient + .deleteCompanyOverride(companyOverrideId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture countCompanyOverrides() { + return this.rawClient.countCompanyOverrides().thenApply(response -> response.body()); + } + + public CompletableFuture countCompanyOverrides( + CountCompanyOverridesRequest request) { + return this.rawClient.countCompanyOverrides(request).thenApply(response -> response.body()); + } + + public CompletableFuture countCompanyOverrides( + CountCompanyOverridesRequest request, RequestOptions requestOptions) { + return this.rawClient.countCompanyOverrides(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listFeatureCompanies(ListFeatureCompaniesRequest request) { + return this.rawClient.listFeatureCompanies(request).thenApply(response -> response.body()); + } + + public CompletableFuture listFeatureCompanies( + ListFeatureCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient.listFeatureCompanies(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countFeatureCompanies( + CountFeatureCompaniesRequest request) { + return this.rawClient.countFeatureCompanies(request).thenApply(response -> response.body()); + } + + public CompletableFuture countFeatureCompanies( + CountFeatureCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient.countFeatureCompanies(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listFeatureUsage() { + return this.rawClient.listFeatureUsage().thenApply(response -> response.body()); + } + + public CompletableFuture listFeatureUsage(ListFeatureUsageRequest request) { + return this.rawClient.listFeatureUsage(request).thenApply(response -> response.body()); + } + + public CompletableFuture listFeatureUsage( + ListFeatureUsageRequest request, RequestOptions requestOptions) { + return this.rawClient.listFeatureUsage(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countFeatureUsage() { + return this.rawClient.countFeatureUsage().thenApply(response -> response.body()); + } + + public CompletableFuture countFeatureUsage(CountFeatureUsageRequest request) { + return this.rawClient.countFeatureUsage(request).thenApply(response -> response.body()); + } + + public CompletableFuture countFeatureUsage( + CountFeatureUsageRequest request, RequestOptions requestOptions) { + return this.rawClient.countFeatureUsage(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listFeatureUsers(ListFeatureUsersRequest request) { + return this.rawClient.listFeatureUsers(request).thenApply(response -> response.body()); + } + + public CompletableFuture listFeatureUsers( + ListFeatureUsersRequest request, RequestOptions requestOptions) { + return this.rawClient.listFeatureUsers(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countFeatureUsers(CountFeatureUsersRequest request) { + return this.rawClient.countFeatureUsers(request).thenApply(response -> response.body()); + } + + public CompletableFuture countFeatureUsers( + CountFeatureUsersRequest request, RequestOptions requestOptions) { + return this.rawClient.countFeatureUsers(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listPlanEntitlements() { + return this.rawClient.listPlanEntitlements().thenApply(response -> response.body()); + } + + public CompletableFuture listPlanEntitlements(ListPlanEntitlementsRequest request) { + return this.rawClient.listPlanEntitlements(request).thenApply(response -> response.body()); + } + + public CompletableFuture listPlanEntitlements( + ListPlanEntitlementsRequest request, RequestOptions requestOptions) { + return this.rawClient.listPlanEntitlements(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createPlanEntitlement( + CreatePlanEntitlementRequestBody request) { + return this.rawClient.createPlanEntitlement(request).thenApply(response -> response.body()); + } + + public CompletableFuture createPlanEntitlement( + CreatePlanEntitlementRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createPlanEntitlement(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getPlanEntitlement(String planEntitlementId) { + return this.rawClient.getPlanEntitlement(planEntitlementId).thenApply(response -> response.body()); + } + + public CompletableFuture getPlanEntitlement( + String planEntitlementId, RequestOptions requestOptions) { + return this.rawClient + .getPlanEntitlement(planEntitlementId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture updatePlanEntitlement( + String planEntitlementId, UpdatePlanEntitlementRequestBody request) { + return this.rawClient.updatePlanEntitlement(planEntitlementId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlanEntitlement( + String planEntitlementId, UpdatePlanEntitlementRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updatePlanEntitlement(planEntitlementId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture deletePlanEntitlement(String planEntitlementId) { + return this.rawClient.deletePlanEntitlement(planEntitlementId).thenApply(response -> response.body()); + } + + public CompletableFuture deletePlanEntitlement( + String planEntitlementId, RequestOptions requestOptions) { + return this.rawClient + .deletePlanEntitlement(planEntitlementId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture countPlanEntitlements() { + return this.rawClient.countPlanEntitlements().thenApply(response -> response.body()); + } + + public CompletableFuture countPlanEntitlements( + CountPlanEntitlementsRequest request) { + return this.rawClient.countPlanEntitlements(request).thenApply(response -> response.body()); + } + + public CompletableFuture countPlanEntitlements( + CountPlanEntitlementsRequest request, RequestOptions requestOptions) { + return this.rawClient.countPlanEntitlements(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getFeatureUsageByCompany( + GetFeatureUsageByCompanyRequest request) { + return this.rawClient.getFeatureUsageByCompany(request).thenApply(response -> response.body()); + } + + public CompletableFuture getFeatureUsageByCompany( + GetFeatureUsageByCompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.getFeatureUsageByCompany(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/entitlements/AsyncRawEntitlementsClient.java b/src/main/java/com/schematic/api/resources/entitlements/AsyncRawEntitlementsClient.java new file mode 100644 index 0000000..f35526a --- /dev/null +++ b/src/main/java/com/schematic/api/resources/entitlements/AsyncRawEntitlementsClient.java @@ -0,0 +1,1958 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.entitlements; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.entitlements.requests.CountCompanyOverridesRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureCompaniesRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureUsageRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureUsersRequest; +import com.schematic.api.resources.entitlements.requests.CountPlanEntitlementsRequest; +import com.schematic.api.resources.entitlements.requests.CreateCompanyOverrideRequestBody; +import com.schematic.api.resources.entitlements.requests.CreatePlanEntitlementRequestBody; +import com.schematic.api.resources.entitlements.requests.GetFeatureUsageByCompanyRequest; +import com.schematic.api.resources.entitlements.requests.ListCompanyOverridesRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureCompaniesRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureUsageRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureUsersRequest; +import com.schematic.api.resources.entitlements.requests.ListPlanEntitlementsRequest; +import com.schematic.api.resources.entitlements.requests.UpdateCompanyOverrideRequestBody; +import com.schematic.api.resources.entitlements.requests.UpdatePlanEntitlementRequestBody; +import com.schematic.api.resources.entitlements.types.CountCompanyOverridesResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureCompaniesResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureUsageResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureUsersResponse; +import com.schematic.api.resources.entitlements.types.CountPlanEntitlementsResponse; +import com.schematic.api.resources.entitlements.types.CreateCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.DeleteCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.DeletePlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.GetCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.GetFeatureUsageByCompanyResponse; +import com.schematic.api.resources.entitlements.types.GetPlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.ListCompanyOverridesResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureCompaniesResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureUsageResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureUsersResponse; +import com.schematic.api.resources.entitlements.types.ListPlanEntitlementsResponse; +import com.schematic.api.resources.entitlements.types.UpdateCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEntitlementsClient { + protected final ClientOptions clientOptions; + + public AsyncRawEntitlementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> listCompanyOverrides() { + return listCompanyOverrides(ListCompanyOverridesRequest.builder().build()); + } + + public CompletableFuture> listCompanyOverrides( + ListCompanyOverridesRequest request) { + return listCompanyOverrides(request, null); + } + + public CompletableFuture> listCompanyOverrides( + ListCompanyOverridesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getWithoutExpired().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_expired", request.getWithoutExpired().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListCompanyOverridesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createCompanyOverride( + CreateCompanyOverrideRequestBody request) { + return createCompanyOverride(request, null); + } + + public CompletableFuture> createCompanyOverride( + CreateCompanyOverrideRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateCompanyOverrideResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getCompanyOverride( + String companyOverrideId) { + return getCompanyOverride(companyOverrideId, null); + } + + public CompletableFuture> getCompanyOverride( + String companyOverrideId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides") + .addPathSegment(companyOverrideId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetCompanyOverrideResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateCompanyOverride( + String companyOverrideId, UpdateCompanyOverrideRequestBody request) { + return updateCompanyOverride(companyOverrideId, request, null); + } + + public CompletableFuture> updateCompanyOverride( + String companyOverrideId, UpdateCompanyOverrideRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides") + .addPathSegment(companyOverrideId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateCompanyOverrideResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteCompanyOverride( + String companyOverrideId) { + return deleteCompanyOverride(companyOverrideId, null); + } + + public CompletableFuture> deleteCompanyOverride( + String companyOverrideId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides") + .addPathSegment(companyOverrideId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeleteCompanyOverrideResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countCompanyOverrides() { + return countCompanyOverrides(CountCompanyOverridesRequest.builder().build()); + } + + public CompletableFuture> countCompanyOverrides( + CountCompanyOverridesRequest request) { + return countCompanyOverrides(request, null); + } + + public CompletableFuture> countCompanyOverrides( + CountCompanyOverridesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides/count"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getWithoutExpired().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_expired", request.getWithoutExpired().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountCompanyOverridesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listFeatureCompanies( + ListFeatureCompaniesRequest request) { + return listFeatureCompanies(request, null); + } + + public CompletableFuture> listFeatureCompanies( + ListFeatureCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-companies"); + QueryStringMapper.addQueryParameter(httpUrl, "feature_id", request.getFeatureId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListFeatureCompaniesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countFeatureCompanies( + CountFeatureCompaniesRequest request) { + return countFeatureCompanies(request, null); + } + + public CompletableFuture> countFeatureCompanies( + CountFeatureCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-companies/count"); + QueryStringMapper.addQueryParameter(httpUrl, "feature_id", request.getFeatureId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountFeatureCompaniesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listFeatureUsage() { + return listFeatureUsage(ListFeatureUsageRequest.builder().build()); + } + + public CompletableFuture> listFeatureUsage( + ListFeatureUsageRequest request) { + return listFeatureUsage(request, null); + } + + public CompletableFuture> listFeatureUsage( + ListFeatureUsageRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-usage"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCompanyKeys().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_keys", request.getCompanyKeys().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutNegativeEntitlements().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_negative_entitlements", + request.getWithoutNegativeEntitlements().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListFeatureUsageResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countFeatureUsage() { + return countFeatureUsage(CountFeatureUsageRequest.builder().build()); + } + + public CompletableFuture> countFeatureUsage( + CountFeatureUsageRequest request) { + return countFeatureUsage(request, null); + } + + public CompletableFuture> countFeatureUsage( + CountFeatureUsageRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-usage/count"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCompanyKeys().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_keys", request.getCompanyKeys().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutNegativeEntitlements().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_negative_entitlements", + request.getWithoutNegativeEntitlements().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountFeatureUsageResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listFeatureUsers( + ListFeatureUsersRequest request) { + return listFeatureUsers(request, null); + } + + public CompletableFuture> listFeatureUsers( + ListFeatureUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-users"); + QueryStringMapper.addQueryParameter(httpUrl, "feature_id", request.getFeatureId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListFeatureUsersResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countFeatureUsers( + CountFeatureUsersRequest request) { + return countFeatureUsers(request, null); + } + + public CompletableFuture> countFeatureUsers( + CountFeatureUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-users/count"); + QueryStringMapper.addQueryParameter(httpUrl, "feature_id", request.getFeatureId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountFeatureUsersResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listPlanEntitlements() { + return listPlanEntitlements(ListPlanEntitlementsRequest.builder().build()); + } + + public CompletableFuture> listPlanEntitlements( + ListPlanEntitlementsRequest request) { + return listPlanEntitlements(request, null); + } + + public CompletableFuture> listPlanEntitlements( + ListPlanEntitlementsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements"); + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithMeteredProducts().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_metered_products", + request.getWithMeteredProducts().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListPlanEntitlementsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createPlanEntitlement( + CreatePlanEntitlementRequestBody request) { + return createPlanEntitlement(request, null); + } + + public CompletableFuture> createPlanEntitlement( + CreatePlanEntitlementRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreatePlanEntitlementResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getPlanEntitlement( + String planEntitlementId) { + return getPlanEntitlement(planEntitlementId, null); + } + + public CompletableFuture> getPlanEntitlement( + String planEntitlementId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements") + .addPathSegment(planEntitlementId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetPlanEntitlementResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updatePlanEntitlement( + String planEntitlementId, UpdatePlanEntitlementRequestBody request) { + return updatePlanEntitlement(planEntitlementId, request, null); + } + + public CompletableFuture> updatePlanEntitlement( + String planEntitlementId, UpdatePlanEntitlementRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements") + .addPathSegment(planEntitlementId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdatePlanEntitlementResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deletePlanEntitlement( + String planEntitlementId) { + return deletePlanEntitlement(planEntitlementId, null); + } + + public CompletableFuture> deletePlanEntitlement( + String planEntitlementId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements") + .addPathSegment(planEntitlementId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), DeletePlanEntitlementResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countPlanEntitlements() { + return countPlanEntitlements(CountPlanEntitlementsRequest.builder().build()); + } + + public CompletableFuture> countPlanEntitlements( + CountPlanEntitlementsRequest request) { + return countPlanEntitlements(request, null); + } + + public CompletableFuture> countPlanEntitlements( + CountPlanEntitlementsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements/count"); + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithMeteredProducts().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_metered_products", + request.getWithMeteredProducts().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountPlanEntitlementsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getFeatureUsageByCompany( + GetFeatureUsageByCompanyRequest request) { + return getFeatureUsageByCompany(request, null); + } + + public CompletableFuture> getFeatureUsageByCompany( + GetFeatureUsageByCompanyRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("usage-by-company"); + QueryStringMapper.addQueryParameter(httpUrl, "keys", request.getKeys(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetFeatureUsageByCompanyResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/entitlements/RawEntitlementsClient.java b/src/main/java/com/schematic/api/resources/entitlements/RawEntitlementsClient.java new file mode 100644 index 0000000..30d0a2e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/entitlements/RawEntitlementsClient.java @@ -0,0 +1,1496 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.entitlements; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.entitlements.requests.CountCompanyOverridesRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureCompaniesRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureUsageRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureUsersRequest; +import com.schematic.api.resources.entitlements.requests.CountPlanEntitlementsRequest; +import com.schematic.api.resources.entitlements.requests.CreateCompanyOverrideRequestBody; +import com.schematic.api.resources.entitlements.requests.CreatePlanEntitlementRequestBody; +import com.schematic.api.resources.entitlements.requests.GetFeatureUsageByCompanyRequest; +import com.schematic.api.resources.entitlements.requests.ListCompanyOverridesRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureCompaniesRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureUsageRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureUsersRequest; +import com.schematic.api.resources.entitlements.requests.ListPlanEntitlementsRequest; +import com.schematic.api.resources.entitlements.requests.UpdateCompanyOverrideRequestBody; +import com.schematic.api.resources.entitlements.requests.UpdatePlanEntitlementRequestBody; +import com.schematic.api.resources.entitlements.types.CountCompanyOverridesResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureCompaniesResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureUsageResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureUsersResponse; +import com.schematic.api.resources.entitlements.types.CountPlanEntitlementsResponse; +import com.schematic.api.resources.entitlements.types.CreateCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.DeleteCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.DeletePlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.GetCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.GetFeatureUsageByCompanyResponse; +import com.schematic.api.resources.entitlements.types.GetPlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.ListCompanyOverridesResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureCompaniesResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureUsageResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureUsersResponse; +import com.schematic.api.resources.entitlements.types.ListPlanEntitlementsResponse; +import com.schematic.api.resources.entitlements.types.UpdateCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEntitlementsClient { + protected final ClientOptions clientOptions; + + public RawEntitlementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse listCompanyOverrides() { + return listCompanyOverrides(ListCompanyOverridesRequest.builder().build()); + } + + public BaseSchematicHttpResponse listCompanyOverrides( + ListCompanyOverridesRequest request) { + return listCompanyOverrides(request, null); + } + + public BaseSchematicHttpResponse listCompanyOverrides( + ListCompanyOverridesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getWithoutExpired().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_expired", request.getWithoutExpired().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListCompanyOverridesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createCompanyOverride( + CreateCompanyOverrideRequestBody request) { + return createCompanyOverride(request, null); + } + + public BaseSchematicHttpResponse createCompanyOverride( + CreateCompanyOverrideRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateCompanyOverrideResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getCompanyOverride(String companyOverrideId) { + return getCompanyOverride(companyOverrideId, null); + } + + public BaseSchematicHttpResponse getCompanyOverride( + String companyOverrideId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides") + .addPathSegment(companyOverrideId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetCompanyOverrideResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateCompanyOverride( + String companyOverrideId, UpdateCompanyOverrideRequestBody request) { + return updateCompanyOverride(companyOverrideId, request, null); + } + + public BaseSchematicHttpResponse updateCompanyOverride( + String companyOverrideId, UpdateCompanyOverrideRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides") + .addPathSegment(companyOverrideId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateCompanyOverrideResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteCompanyOverride(String companyOverrideId) { + return deleteCompanyOverride(companyOverrideId, null); + } + + public BaseSchematicHttpResponse deleteCompanyOverride( + String companyOverrideId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides") + .addPathSegment(companyOverrideId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteCompanyOverrideResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countCompanyOverrides() { + return countCompanyOverrides(CountCompanyOverridesRequest.builder().build()); + } + + public BaseSchematicHttpResponse countCompanyOverrides( + CountCompanyOverridesRequest request) { + return countCompanyOverrides(request, null); + } + + public BaseSchematicHttpResponse countCompanyOverrides( + CountCompanyOverridesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-overrides/count"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getWithoutExpired().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_expired", request.getWithoutExpired().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getCompanyIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_ids", request.getCompanyIds().get(), true); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountCompanyOverridesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listFeatureCompanies( + ListFeatureCompaniesRequest request) { + return listFeatureCompanies(request, null); + } + + public BaseSchematicHttpResponse listFeatureCompanies( + ListFeatureCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-companies"); + QueryStringMapper.addQueryParameter(httpUrl, "feature_id", request.getFeatureId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFeatureCompaniesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countFeatureCompanies( + CountFeatureCompaniesRequest request) { + return countFeatureCompanies(request, null); + } + + public BaseSchematicHttpResponse countFeatureCompanies( + CountFeatureCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-companies/count"); + QueryStringMapper.addQueryParameter(httpUrl, "feature_id", request.getFeatureId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFeatureCompaniesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listFeatureUsage() { + return listFeatureUsage(ListFeatureUsageRequest.builder().build()); + } + + public BaseSchematicHttpResponse listFeatureUsage(ListFeatureUsageRequest request) { + return listFeatureUsage(request, null); + } + + public BaseSchematicHttpResponse listFeatureUsage( + ListFeatureUsageRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-usage"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCompanyKeys().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_keys", request.getCompanyKeys().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutNegativeEntitlements().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_negative_entitlements", + request.getWithoutNegativeEntitlements().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFeatureUsageResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countFeatureUsage() { + return countFeatureUsage(CountFeatureUsageRequest.builder().build()); + } + + public BaseSchematicHttpResponse countFeatureUsage(CountFeatureUsageRequest request) { + return countFeatureUsage(request, null); + } + + public BaseSchematicHttpResponse countFeatureUsage( + CountFeatureUsageRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-usage/count"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCompanyKeys().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_keys", request.getCompanyKeys().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutNegativeEntitlements().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_negative_entitlements", + request.getWithoutNegativeEntitlements().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFeatureUsageResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listFeatureUsers(ListFeatureUsersRequest request) { + return listFeatureUsers(request, null); + } + + public BaseSchematicHttpResponse listFeatureUsers( + ListFeatureUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-users"); + QueryStringMapper.addQueryParameter(httpUrl, "feature_id", request.getFeatureId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFeatureUsersResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countFeatureUsers(CountFeatureUsersRequest request) { + return countFeatureUsers(request, null); + } + + public BaseSchematicHttpResponse countFeatureUsers( + CountFeatureUsersRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("feature-users/count"); + QueryStringMapper.addQueryParameter(httpUrl, "feature_id", request.getFeatureId(), false); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFeatureUsersResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listPlanEntitlements() { + return listPlanEntitlements(ListPlanEntitlementsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listPlanEntitlements( + ListPlanEntitlementsRequest request) { + return listPlanEntitlements(request, null); + } + + public BaseSchematicHttpResponse listPlanEntitlements( + ListPlanEntitlementsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements"); + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithMeteredProducts().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_metered_products", + request.getWithMeteredProducts().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPlanEntitlementsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createPlanEntitlement( + CreatePlanEntitlementRequestBody request) { + return createPlanEntitlement(request, null); + } + + public BaseSchematicHttpResponse createPlanEntitlement( + CreatePlanEntitlementRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreatePlanEntitlementResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getPlanEntitlement(String planEntitlementId) { + return getPlanEntitlement(planEntitlementId, null); + } + + public BaseSchematicHttpResponse getPlanEntitlement( + String planEntitlementId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements") + .addPathSegment(planEntitlementId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanEntitlementResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updatePlanEntitlement( + String planEntitlementId, UpdatePlanEntitlementRequestBody request) { + return updatePlanEntitlement(planEntitlementId, request, null); + } + + public BaseSchematicHttpResponse updatePlanEntitlement( + String planEntitlementId, UpdatePlanEntitlementRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements") + .addPathSegment(planEntitlementId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdatePlanEntitlementResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deletePlanEntitlement(String planEntitlementId) { + return deletePlanEntitlement(planEntitlementId, null); + } + + public BaseSchematicHttpResponse deletePlanEntitlement( + String planEntitlementId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements") + .addPathSegment(planEntitlementId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletePlanEntitlementResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countPlanEntitlements() { + return countPlanEntitlements(CountPlanEntitlementsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countPlanEntitlements( + CountPlanEntitlementsRequest request) { + return countPlanEntitlements(request, null); + } + + public BaseSchematicHttpResponse countPlanEntitlements( + CountPlanEntitlementsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-entitlements/count"); + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getPlanId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_id", request.getPlanId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithMeteredProducts().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "with_metered_products", + request.getWithMeteredProducts().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getFeatureIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_ids", request.getFeatureIds().get(), true); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getPlanIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_ids", request.getPlanIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountPlanEntitlementsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getFeatureUsageByCompany( + GetFeatureUsageByCompanyRequest request) { + return getFeatureUsageByCompany(request, null); + } + + public BaseSchematicHttpResponse getFeatureUsageByCompany( + GetFeatureUsageByCompanyRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("usage-by-company"); + QueryStringMapper.addQueryParameter(httpUrl, "keys", request.getKeys(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetFeatureUsageByCompanyResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CountCompanyOverridesRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CountCompanyOverridesRequest.java index 2801134..b9569f2 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CountCompanyOverridesRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CountCompanyOverridesRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,15 +22,15 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountCompanyOverridesRequest.Builder.class) public final class CountCompanyOverridesRequest { - private final Optional companyId; + private final Optional> companyIds; - private final Optional companyIds; + private final Optional> featureIds; - private final Optional featureId; + private final Optional> ids; - private final Optional featureIds; + private final Optional companyId; - private final Optional ids; + private final Optional featureId; private final Optional withoutExpired; @@ -41,21 +43,21 @@ public final class CountCompanyOverridesRequest { private final Map additionalProperties; private CountCompanyOverridesRequest( + Optional> companyIds, + Optional> featureIds, + Optional> ids, Optional companyId, - Optional companyIds, Optional featureId, - Optional featureIds, - Optional ids, Optional withoutExpired, Optional q, Optional limit, Optional offset, Map additionalProperties) { - this.companyId = companyId; this.companyIds = companyIds; - this.featureId = featureId; this.featureIds = featureIds; this.ids = ids; + this.companyId = companyId; + this.featureId = featureId; this.withoutExpired = withoutExpired; this.q = q; this.limit = limit; @@ -63,35 +65,19 @@ private CountCompanyOverridesRequest( this.additionalProperties = additionalProperties; } - /** - * @return Filter company overrides by a single company ID (starting with comp_) - */ - @JsonProperty("company_id") - public Optional getCompanyId() { - return companyId; - } - /** * @return Filter company overrides by multiple company IDs (starting with comp_) */ @JsonProperty("company_ids") - public Optional getCompanyIds() { + public Optional> getCompanyIds() { return companyIds; } - /** - * @return Filter company overrides by a single feature ID (starting with feat_) - */ - @JsonProperty("feature_id") - public Optional getFeatureId() { - return featureId; - } - /** * @return Filter company overrides by multiple feature IDs (starting with feat_) */ @JsonProperty("feature_ids") - public Optional getFeatureIds() { + public Optional> getFeatureIds() { return featureIds; } @@ -99,10 +85,26 @@ public Optional getFeatureIds() { * @return Filter company overrides by multiple company override IDs (starting with cmov_) */ @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } + /** + * @return Filter company overrides by a single company ID (starting with comp_) + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return Filter company overrides by a single feature ID (starting with feat_) + */ + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + /** * @return Filter company overrides by whether they have not expired */ @@ -147,11 +149,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountCompanyOverridesRequest other) { - return companyId.equals(other.companyId) - && companyIds.equals(other.companyIds) - && featureId.equals(other.featureId) + return companyIds.equals(other.companyIds) && featureIds.equals(other.featureIds) && ids.equals(other.ids) + && companyId.equals(other.companyId) + && featureId.equals(other.featureId) && withoutExpired.equals(other.withoutExpired) && q.equals(other.q) && limit.equals(other.limit) @@ -161,11 +163,11 @@ private boolean equalTo(CountCompanyOverridesRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.companyId, this.companyIds, - this.featureId, this.featureIds, this.ids, + this.companyId, + this.featureId, this.withoutExpired, this.q, this.limit, @@ -183,15 +185,15 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional companyId = Optional.empty(); + private Optional> companyIds = Optional.empty(); - private Optional companyIds = Optional.empty(); + private Optional> featureIds = Optional.empty(); - private Optional featureId = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional featureIds = Optional.empty(); + private Optional companyId = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional featureId = Optional.empty(); private Optional withoutExpired = Optional.empty(); @@ -207,11 +209,11 @@ public static final class Builder { private Builder() {} public Builder from(CountCompanyOverridesRequest other) { - companyId(other.getCompanyId()); companyIds(other.getCompanyIds()); - featureId(other.getFeatureId()); featureIds(other.getFeatureIds()); ids(other.getIds()); + companyId(other.getCompanyId()); + featureId(other.getFeatureId()); withoutExpired(other.getWithoutExpired()); q(other.getQ()); limit(other.getLimit()); @@ -219,61 +221,94 @@ public Builder from(CountCompanyOverridesRequest other) { return this; } - @JsonSetter(value = "company_id", nulls = Nulls.SKIP) - public Builder companyId(Optional companyId) { - this.companyId = companyId; - return this; - } - - public Builder companyId(String companyId) { - this.companyId = Optional.ofNullable(companyId); - return this; - } - + /** + *

Filter company overrides by multiple company IDs (starting with comp_)

+ */ @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) - public Builder companyIds(Optional companyIds) { + public Builder companyIds(Optional> companyIds) { this.companyIds = companyIds; return this; } - public Builder companyIds(String companyIds) { + public Builder companyIds(List companyIds) { this.companyIds = Optional.ofNullable(companyIds); return this; } - @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) - public Builder featureId(Optional featureId) { - this.featureId = featureId; + public Builder companyIds(String companyIds) { + this.companyIds = Optional.of(Collections.singletonList(companyIds)); return this; } - public Builder featureId(String featureId) { - this.featureId = Optional.ofNullable(featureId); + /** + *

Filter company overrides by multiple feature IDs (starting with feat_)

+ */ + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; return this; } - @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) - public Builder featureIds(Optional featureIds) { - this.featureIds = featureIds; + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); return this; } public Builder featureIds(String featureIds) { - this.featureIds = Optional.ofNullable(featureIds); + this.featureIds = Optional.of(Collections.singletonList(featureIds)); return this; } + /** + *

Filter company overrides by multiple company override IDs (starting with cmov_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Filter company overrides by a single company ID (starting with comp_)

+ */ + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

Filter company overrides by a single feature ID (starting with feat_)

+ */ + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public Builder featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + public Builder featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + /** + *

Filter company overrides by whether they have not expired

+ */ @JsonSetter(value = "without_expired", nulls = Nulls.SKIP) public Builder withoutExpired(Optional withoutExpired) { this.withoutExpired = withoutExpired; @@ -285,6 +320,9 @@ public Builder withoutExpired(Boolean withoutExpired) { return this; } + /** + *

Search for company overrides by feature or company name

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -296,6 +334,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -307,6 +348,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -320,11 +364,11 @@ public Builder offset(Integer offset) { public CountCompanyOverridesRequest build() { return new CountCompanyOverridesRequest( - companyId, companyIds, - featureId, featureIds, ids, + companyId, + featureId, withoutExpired, q, limit, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureCompaniesRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureCompaniesRequest.java index b69a4e7..c5d9704 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureCompaniesRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureCompaniesRequest.java @@ -115,10 +115,16 @@ public interface _FinalStage { _FinalStage q(String q); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -165,6 +171,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -182,6 +191,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureUsageRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureUsageRequest.java index 8b996ae..f834392 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureUsageRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureUsageRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,12 +22,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountFeatureUsageRequest.Builder.class) public final class CountFeatureUsageRequest { + private final Optional> featureIds; + private final Optional companyId; private final Optional> companyKeys; - private final Optional featureIds; - private final Optional q; private final Optional withoutNegativeEntitlements; @@ -37,17 +39,17 @@ public final class CountFeatureUsageRequest { private final Map additionalProperties; private CountFeatureUsageRequest( + Optional> featureIds, Optional companyId, Optional> companyKeys, - Optional featureIds, Optional q, Optional withoutNegativeEntitlements, Optional limit, Optional offset, Map additionalProperties) { + this.featureIds = featureIds; this.companyId = companyId; this.companyKeys = companyKeys; - this.featureIds = featureIds; this.q = q; this.withoutNegativeEntitlements = withoutNegativeEntitlements; this.limit = limit; @@ -55,6 +57,11 @@ private CountFeatureUsageRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("feature_ids") + public Optional> getFeatureIds() { + return featureIds; + } + @JsonProperty("company_id") public Optional getCompanyId() { return companyId; @@ -65,11 +72,6 @@ public Optional> getCompanyKeys() { return companyKeys; } - @JsonProperty("feature_ids") - public Optional getFeatureIds() { - return featureIds; - } - @JsonProperty("q") public Optional getQ() { return q; @@ -108,9 +110,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountFeatureUsageRequest other) { - return companyId.equals(other.companyId) + return featureIds.equals(other.featureIds) + && companyId.equals(other.companyId) && companyKeys.equals(other.companyKeys) - && featureIds.equals(other.featureIds) && q.equals(other.q) && withoutNegativeEntitlements.equals(other.withoutNegativeEntitlements) && limit.equals(other.limit) @@ -120,9 +122,9 @@ private boolean equalTo(CountFeatureUsageRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.featureIds, this.companyId, this.companyKeys, - this.featureIds, this.q, this.withoutNegativeEntitlements, this.limit, @@ -140,12 +142,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> featureIds = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional> companyKeys = Optional.empty(); - private Optional featureIds = Optional.empty(); - private Optional q = Optional.empty(); private Optional withoutNegativeEntitlements = Optional.empty(); @@ -160,9 +162,9 @@ public static final class Builder { private Builder() {} public Builder from(CountFeatureUsageRequest other) { + featureIds(other.getFeatureIds()); companyId(other.getCompanyId()); companyKeys(other.getCompanyKeys()); - featureIds(other.getFeatureIds()); q(other.getQ()); withoutNegativeEntitlements(other.getWithoutNegativeEntitlements()); limit(other.getLimit()); @@ -170,6 +172,22 @@ public Builder from(CountFeatureUsageRequest other) { return this; } + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; + return this; + } + + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); + return this; + } + + public Builder featureIds(String featureIds) { + this.featureIds = Optional.of(Collections.singletonList(featureIds)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -192,17 +210,6 @@ public Builder companyKeys(Map companyKeys) { return this; } - @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) - public Builder featureIds(Optional featureIds) { - this.featureIds = featureIds; - return this; - } - - public Builder featureIds(String featureIds) { - this.featureIds = Optional.ofNullable(featureIds); - return this; - } - @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -225,6 +232,9 @@ public Builder withoutNegativeEntitlements(Boolean withoutNegativeEntitlements) return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -236,6 +246,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -249,9 +262,9 @@ public Builder offset(Integer offset) { public CountFeatureUsageRequest build() { return new CountFeatureUsageRequest( + featureIds, companyId, companyKeys, - featureIds, q, withoutNegativeEntitlements, limit, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureUsersRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureUsersRequest.java index d389587..a67f80b 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureUsersRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CountFeatureUsersRequest.java @@ -115,10 +115,16 @@ public interface _FinalStage { _FinalStage q(String q); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -165,6 +171,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -182,6 +191,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CountPlanEntitlementsRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CountPlanEntitlementsRequest.java index ef3f1d2..abbf0a0 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CountPlanEntitlementsRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CountPlanEntitlementsRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,15 +22,15 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountPlanEntitlementsRequest.Builder.class) public final class CountPlanEntitlementsRequest { - private final Optional featureId; + private final Optional> featureIds; - private final Optional featureIds; + private final Optional> ids; - private final Optional ids; + private final Optional> planIds; - private final Optional planId; + private final Optional featureId; - private final Optional planIds; + private final Optional planId; private final Optional q; @@ -41,21 +43,21 @@ public final class CountPlanEntitlementsRequest { private final Map additionalProperties; private CountPlanEntitlementsRequest( + Optional> featureIds, + Optional> ids, + Optional> planIds, Optional featureId, - Optional featureIds, - Optional ids, Optional planId, - Optional planIds, Optional q, Optional withMeteredProducts, Optional limit, Optional offset, Map additionalProperties) { - this.featureId = featureId; this.featureIds = featureIds; this.ids = ids; - this.planId = planId; this.planIds = planIds; + this.featureId = featureId; + this.planId = planId; this.q = q; this.withMeteredProducts = withMeteredProducts; this.limit = limit; @@ -63,19 +65,11 @@ private CountPlanEntitlementsRequest( this.additionalProperties = additionalProperties; } - /** - * @return Filter plan entitlements by a single feature ID (starting with feat_) - */ - @JsonProperty("feature_id") - public Optional getFeatureId() { - return featureId; - } - /** * @return Filter plan entitlements by multiple feature IDs (starting with feat_) */ @JsonProperty("feature_ids") - public Optional getFeatureIds() { + public Optional> getFeatureIds() { return featureIds; } @@ -83,24 +77,32 @@ public Optional getFeatureIds() { * @return Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) */ @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } /** - * @return Filter plan entitlements by a single plan ID (starting with plan_) + * @return Filter plan entitlements by multiple plan IDs (starting with plan_) */ - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; } /** - * @return Filter plan entitlements by multiple plan IDs (starting with plan_) + * @return Filter plan entitlements by a single feature ID (starting with feat_) */ - @JsonProperty("plan_ids") - public Optional getPlanIds() { - return planIds; + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + + /** + * @return Filter plan entitlements by a single plan ID (starting with plan_) + */ + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; } /** @@ -147,11 +149,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountPlanEntitlementsRequest other) { - return featureId.equals(other.featureId) - && featureIds.equals(other.featureIds) + return featureIds.equals(other.featureIds) && ids.equals(other.ids) - && planId.equals(other.planId) && planIds.equals(other.planIds) + && featureId.equals(other.featureId) + && planId.equals(other.planId) && q.equals(other.q) && withMeteredProducts.equals(other.withMeteredProducts) && limit.equals(other.limit) @@ -161,11 +163,11 @@ private boolean equalTo(CountPlanEntitlementsRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.featureId, this.featureIds, this.ids, - this.planId, this.planIds, + this.featureId, + this.planId, this.q, this.withMeteredProducts, this.limit, @@ -183,15 +185,15 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional featureId = Optional.empty(); + private Optional> featureIds = Optional.empty(); - private Optional featureIds = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional> planIds = Optional.empty(); - private Optional planId = Optional.empty(); + private Optional featureId = Optional.empty(); - private Optional planIds = Optional.empty(); + private Optional planId = Optional.empty(); private Optional q = Optional.empty(); @@ -207,11 +209,11 @@ public static final class Builder { private Builder() {} public Builder from(CountPlanEntitlementsRequest other) { - featureId(other.getFeatureId()); featureIds(other.getFeatureIds()); ids(other.getIds()); - planId(other.getPlanId()); planIds(other.getPlanIds()); + featureId(other.getFeatureId()); + planId(other.getPlanId()); q(other.getQ()); withMeteredProducts(other.getWithMeteredProducts()); limit(other.getLimit()); @@ -219,61 +221,94 @@ public Builder from(CountPlanEntitlementsRequest other) { return this; } - @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) - public Builder featureId(Optional featureId) { - this.featureId = featureId; - return this; - } - - public Builder featureId(String featureId) { - this.featureId = Optional.ofNullable(featureId); + /** + *

Filter plan entitlements by multiple feature IDs (starting with feat_)

+ */ + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; return this; } - @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) - public Builder featureIds(Optional featureIds) { - this.featureIds = featureIds; + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); return this; } public Builder featureIds(String featureIds) { - this.featureIds = Optional.ofNullable(featureIds); + this.featureIds = Optional.of(Collections.singletonList(featureIds)); return this; } + /** + *

Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public Builder planId(Optional planId) { - this.planId = planId; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder planId(String planId) { - this.planId = Optional.ofNullable(planId); + /** + *

Filter plan entitlements by multiple plan IDs (starting with plan_)

+ */ + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; return this; } - @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) - public Builder planIds(Optional planIds) { - this.planIds = planIds; + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); return this; } public Builder planIds(String planIds) { - this.planIds = Optional.ofNullable(planIds); + this.planIds = Optional.of(Collections.singletonList(planIds)); return this; } + /** + *

Filter plan entitlements by a single feature ID (starting with feat_)

+ */ + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public Builder featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + public Builder featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + /** + *

Filter plan entitlements by a single plan ID (starting with plan_)

+ */ + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + /** + *

Search for plan entitlements by feature or company name

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -285,6 +320,9 @@ public Builder q(String q) { return this; } + /** + *

Filter plan entitlements only with metered products

+ */ @JsonSetter(value = "with_metered_products", nulls = Nulls.SKIP) public Builder withMeteredProducts(Optional withMeteredProducts) { this.withMeteredProducts = withMeteredProducts; @@ -296,6 +334,9 @@ public Builder withMeteredProducts(Boolean withMeteredProducts) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -307,6 +348,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -320,11 +364,11 @@ public Builder offset(Integer offset) { public CountPlanEntitlementsRequest build() { return new CountPlanEntitlementsRequest( - featureId, featureIds, ids, - planId, planIds, + featureId, + planId, q, withMeteredProducts, limit, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CreateCompanyOverrideRequestBody.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CreateCompanyOverrideRequestBody.java index 377195f..a469c39 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CreateCompanyOverrideRequestBody.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CreateCompanyOverrideRequestBody.java @@ -27,6 +27,8 @@ public final class CreateCompanyOverrideRequestBody { private final String companyId; + private final Optional creditConsumptionRate; + private final Optional expirationDate; private final String featureId; @@ -35,8 +37,12 @@ public final class CreateCompanyOverrideRequestBody { private final Optional metricPeriodMonthReset; + private final Optional note; + private final Optional valueBool; + private final Optional valueCreditId; + private final Optional valueNumeric; private final Optional valueTraitId; @@ -47,21 +53,27 @@ public final class CreateCompanyOverrideRequestBody { private CreateCompanyOverrideRequestBody( String companyId, + Optional creditConsumptionRate, Optional expirationDate, String featureId, Optional metricPeriod, Optional metricPeriodMonthReset, + Optional note, Optional valueBool, + Optional valueCreditId, Optional valueNumeric, Optional valueTraitId, CreateCompanyOverrideRequestBodyValueType valueType, Map additionalProperties) { this.companyId = companyId; + this.creditConsumptionRate = creditConsumptionRate; this.expirationDate = expirationDate; this.featureId = featureId; this.metricPeriod = metricPeriod; this.metricPeriodMonthReset = metricPeriodMonthReset; + this.note = note; this.valueBool = valueBool; + this.valueCreditId = valueCreditId; this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; @@ -73,6 +85,11 @@ public String getCompanyId() { return companyId; } + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + @JsonProperty("expiration_date") public Optional getExpirationDate() { return expirationDate; @@ -93,11 +110,21 @@ public Optional getMetri return metricPeriodMonthReset; } + @JsonProperty("note") + public Optional getNote() { + return note; + } + @JsonProperty("value_bool") public Optional getValueBool() { return valueBool; } + @JsonProperty("value_credit_id") + public Optional getValueCreditId() { + return valueCreditId; + } + @JsonProperty("value_numeric") public Optional getValueNumeric() { return valueNumeric; @@ -126,11 +153,14 @@ public Map getAdditionalProperties() { private boolean equalTo(CreateCompanyOverrideRequestBody other) { return companyId.equals(other.companyId) + && creditConsumptionRate.equals(other.creditConsumptionRate) && expirationDate.equals(other.expirationDate) && featureId.equals(other.featureId) && metricPeriod.equals(other.metricPeriod) && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) + && note.equals(other.note) && valueBool.equals(other.valueBool) + && valueCreditId.equals(other.valueCreditId) && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType); @@ -140,11 +170,14 @@ private boolean equalTo(CreateCompanyOverrideRequestBody other) { public int hashCode() { return Objects.hash( this.companyId, + this.creditConsumptionRate, this.expirationDate, this.featureId, this.metricPeriod, this.metricPeriodMonthReset, + this.note, this.valueBool, + this.valueCreditId, this.valueNumeric, this.valueTraitId, this.valueType); @@ -176,6 +209,10 @@ public interface ValueTypeStage { public interface _FinalStage { CreateCompanyOverrideRequestBody build(); + _FinalStage creditConsumptionRate(Optional creditConsumptionRate); + + _FinalStage creditConsumptionRate(Double creditConsumptionRate); + _FinalStage expirationDate(Optional expirationDate); _FinalStage expirationDate(OffsetDateTime expirationDate); @@ -190,10 +227,18 @@ _FinalStage metricPeriodMonthReset( _FinalStage metricPeriodMonthReset( CreateCompanyOverrideRequestBodyMetricPeriodMonthReset metricPeriodMonthReset); + _FinalStage note(Optional note); + + _FinalStage note(String note); + _FinalStage valueBool(Optional valueBool); _FinalStage valueBool(Boolean valueBool); + _FinalStage valueCreditId(Optional valueCreditId); + + _FinalStage valueCreditId(String valueCreditId); + _FinalStage valueNumeric(Optional valueNumeric); _FinalStage valueNumeric(Integer valueNumeric); @@ -215,8 +260,12 @@ public static final class Builder implements CompanyIdStage, FeatureIdStage, Val private Optional valueNumeric = Optional.empty(); + private Optional valueCreditId = Optional.empty(); + private Optional valueBool = Optional.empty(); + private Optional note = Optional.empty(); + private Optional metricPeriodMonthReset = Optional.empty(); @@ -224,6 +273,8 @@ public static final class Builder implements CompanyIdStage, FeatureIdStage, Val private Optional expirationDate = Optional.empty(); + private Optional creditConsumptionRate = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -232,11 +283,14 @@ private Builder() {} @java.lang.Override public Builder from(CreateCompanyOverrideRequestBody other) { companyId(other.getCompanyId()); + creditConsumptionRate(other.getCreditConsumptionRate()); expirationDate(other.getExpirationDate()); featureId(other.getFeatureId()); metricPeriod(other.getMetricPeriod()); metricPeriodMonthReset(other.getMetricPeriodMonthReset()); + note(other.getNote()); valueBool(other.getValueBool()); + valueCreditId(other.getValueCreditId()); valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); @@ -290,6 +344,19 @@ public _FinalStage valueNumeric(Optional valueNumeric) { return this; } + @java.lang.Override + public _FinalStage valueCreditId(String valueCreditId) { + this.valueCreditId = Optional.ofNullable(valueCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit_id", nulls = Nulls.SKIP) + public _FinalStage valueCreditId(Optional valueCreditId) { + this.valueCreditId = valueCreditId; + return this; + } + @java.lang.Override public _FinalStage valueBool(Boolean valueBool) { this.valueBool = Optional.ofNullable(valueBool); @@ -303,6 +370,19 @@ public _FinalStage valueBool(Optional valueBool) { return this; } + @java.lang.Override + public _FinalStage note(String note) { + this.note = Optional.ofNullable(note); + return this; + } + + @java.lang.Override + @JsonSetter(value = "note", nulls = Nulls.SKIP) + public _FinalStage note(Optional note) { + this.note = note; + return this; + } + @java.lang.Override public _FinalStage metricPeriodMonthReset( CreateCompanyOverrideRequestBodyMetricPeriodMonthReset metricPeriodMonthReset) { @@ -344,15 +424,31 @@ public _FinalStage expirationDate(Optional expirationDate) { return this; } + @java.lang.Override + public _FinalStage creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public _FinalStage creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + @java.lang.Override public CreateCompanyOverrideRequestBody build() { return new CreateCompanyOverrideRequestBody( companyId, + creditConsumptionRate, expirationDate, featureId, metricPeriod, metricPeriodMonthReset, + note, valueBool, + valueCreditId, valueNumeric, valueTraitId, valueType, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/CreatePlanEntitlementRequestBody.java b/src/main/java/com/schematic/api/resources/entitlements/requests/CreatePlanEntitlementRequestBody.java index fccb20d..ce627d9 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/CreatePlanEntitlementRequestBody.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/CreatePlanEntitlementRequestBody.java @@ -14,8 +14,11 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementRequestBodyMetricPeriod; import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementRequestBodyMetricPeriodMonthReset; +import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementRequestBodyPriceBehavior; import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementRequestBodyValueType; +import com.schematic.api.types.CreatePriceTierRequestBody; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -24,6 +27,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreatePlanEntitlementRequestBody.Builder.class) public final class CreatePlanEntitlementRequestBody { + private final Optional billingProductId; + + private final Optional billingThreshold; + + private final Optional creditConsumptionRate; + + private final Optional currency; + private final String featureId; private final Optional metricPeriod; @@ -32,14 +43,28 @@ public final class CreatePlanEntitlementRequestBody { private final Optional monthlyMeteredPriceId; + private final Optional> monthlyPriceTiers; + + private final Optional monthlyUnitPrice; + + private final Optional monthlyUnitPriceDecimal; + + private final Optional overageBillingProductId; + private final String planId; - private final Optional priceBehavior; + private final Optional priceBehavior; + + private final Optional> priceTiers; private final Optional softLimit; + private final Optional tierMode; + private final Optional valueBool; + private final Optional valueCreditId; + private final Optional valueNumeric; private final Optional valueTraitId; @@ -48,37 +73,91 @@ public final class CreatePlanEntitlementRequestBody { private final Optional yearlyMeteredPriceId; + private final Optional> yearlyPriceTiers; + + private final Optional yearlyUnitPrice; + + private final Optional yearlyUnitPriceDecimal; + private final Map additionalProperties; private CreatePlanEntitlementRequestBody( + Optional billingProductId, + Optional billingThreshold, + Optional creditConsumptionRate, + Optional currency, String featureId, Optional metricPeriod, Optional metricPeriodMonthReset, Optional monthlyMeteredPriceId, + Optional> monthlyPriceTiers, + Optional monthlyUnitPrice, + Optional monthlyUnitPriceDecimal, + Optional overageBillingProductId, String planId, - Optional priceBehavior, + Optional priceBehavior, + Optional> priceTiers, Optional softLimit, + Optional tierMode, Optional valueBool, + Optional valueCreditId, Optional valueNumeric, Optional valueTraitId, CreatePlanEntitlementRequestBodyValueType valueType, Optional yearlyMeteredPriceId, + Optional> yearlyPriceTiers, + Optional yearlyUnitPrice, + Optional yearlyUnitPriceDecimal, Map additionalProperties) { + this.billingProductId = billingProductId; + this.billingThreshold = billingThreshold; + this.creditConsumptionRate = creditConsumptionRate; + this.currency = currency; this.featureId = featureId; this.metricPeriod = metricPeriod; this.metricPeriodMonthReset = metricPeriodMonthReset; this.monthlyMeteredPriceId = monthlyMeteredPriceId; + this.monthlyPriceTiers = monthlyPriceTiers; + this.monthlyUnitPrice = monthlyUnitPrice; + this.monthlyUnitPriceDecimal = monthlyUnitPriceDecimal; + this.overageBillingProductId = overageBillingProductId; this.planId = planId; this.priceBehavior = priceBehavior; + this.priceTiers = priceTiers; this.softLimit = softLimit; + this.tierMode = tierMode; this.valueBool = valueBool; + this.valueCreditId = valueCreditId; this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; this.yearlyMeteredPriceId = yearlyMeteredPriceId; + this.yearlyPriceTiers = yearlyPriceTiers; + this.yearlyUnitPrice = yearlyUnitPrice; + this.yearlyUnitPriceDecimal = yearlyUnitPriceDecimal; this.additionalProperties = additionalProperties; } + @JsonProperty("billing_product_id") + public Optional getBillingProductId() { + return billingProductId; + } + + @JsonProperty("billing_threshold") + public Optional getBillingThreshold() { + return billingThreshold; + } + + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + @JsonProperty("feature_id") public String getFeatureId() { return featureId; @@ -99,26 +178,64 @@ public Optional getMonthlyMeteredPriceId() { return monthlyMeteredPriceId; } + @JsonProperty("monthly_price_tiers") + public Optional> getMonthlyPriceTiers() { + return monthlyPriceTiers; + } + + @JsonProperty("monthly_unit_price") + public Optional getMonthlyUnitPrice() { + return monthlyUnitPrice; + } + + @JsonProperty("monthly_unit_price_decimal") + public Optional getMonthlyUnitPriceDecimal() { + return monthlyUnitPriceDecimal; + } + + @JsonProperty("overage_billing_product_id") + public Optional getOverageBillingProductId() { + return overageBillingProductId; + } + @JsonProperty("plan_id") public String getPlanId() { return planId; } @JsonProperty("price_behavior") - public Optional getPriceBehavior() { + public Optional getPriceBehavior() { return priceBehavior; } + /** + * @return Use MonthlyPriceTiers or YearlyPriceTiers instead + */ + @JsonProperty("price_tiers") + public Optional> getPriceTiers() { + return priceTiers; + } + @JsonProperty("soft_limit") public Optional getSoftLimit() { return softLimit; } + @JsonProperty("tier_mode") + public Optional getTierMode() { + return tierMode; + } + @JsonProperty("value_bool") public Optional getValueBool() { return valueBool; } + @JsonProperty("value_credit_id") + public Optional getValueCreditId() { + return valueCreditId; + } + @JsonProperty("value_numeric") public Optional getValueNumeric() { return valueNumeric; @@ -139,6 +256,21 @@ public Optional getYearlyMeteredPriceId() { return yearlyMeteredPriceId; } + @JsonProperty("yearly_price_tiers") + public Optional> getYearlyPriceTiers() { + return yearlyPriceTiers; + } + + @JsonProperty("yearly_unit_price") + public Optional getYearlyUnitPrice() { + return yearlyUnitPrice; + } + + @JsonProperty("yearly_unit_price_decimal") + public Optional getYearlyUnitPriceDecimal() { + return yearlyUnitPriceDecimal; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -151,35 +283,63 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreatePlanEntitlementRequestBody other) { - return featureId.equals(other.featureId) + return billingProductId.equals(other.billingProductId) + && billingThreshold.equals(other.billingThreshold) + && creditConsumptionRate.equals(other.creditConsumptionRate) + && currency.equals(other.currency) + && featureId.equals(other.featureId) && metricPeriod.equals(other.metricPeriod) && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) && monthlyMeteredPriceId.equals(other.monthlyMeteredPriceId) + && monthlyPriceTiers.equals(other.monthlyPriceTiers) + && monthlyUnitPrice.equals(other.monthlyUnitPrice) + && monthlyUnitPriceDecimal.equals(other.monthlyUnitPriceDecimal) + && overageBillingProductId.equals(other.overageBillingProductId) && planId.equals(other.planId) && priceBehavior.equals(other.priceBehavior) + && priceTiers.equals(other.priceTiers) && softLimit.equals(other.softLimit) + && tierMode.equals(other.tierMode) && valueBool.equals(other.valueBool) + && valueCreditId.equals(other.valueCreditId) && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType) - && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId); + && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId) + && yearlyPriceTiers.equals(other.yearlyPriceTiers) + && yearlyUnitPrice.equals(other.yearlyUnitPrice) + && yearlyUnitPriceDecimal.equals(other.yearlyUnitPriceDecimal); } @java.lang.Override public int hashCode() { return Objects.hash( + this.billingProductId, + this.billingThreshold, + this.creditConsumptionRate, + this.currency, this.featureId, this.metricPeriod, this.metricPeriodMonthReset, this.monthlyMeteredPriceId, + this.monthlyPriceTiers, + this.monthlyUnitPrice, + this.monthlyUnitPriceDecimal, + this.overageBillingProductId, this.planId, this.priceBehavior, + this.priceTiers, this.softLimit, + this.tierMode, this.valueBool, + this.valueCreditId, this.valueNumeric, this.valueTraitId, this.valueType, - this.yearlyMeteredPriceId); + this.yearlyMeteredPriceId, + this.yearlyPriceTiers, + this.yearlyUnitPrice, + this.yearlyUnitPriceDecimal); } @java.lang.Override @@ -208,6 +368,22 @@ public interface ValueTypeStage { public interface _FinalStage { CreatePlanEntitlementRequestBody build(); + _FinalStage billingProductId(Optional billingProductId); + + _FinalStage billingProductId(String billingProductId); + + _FinalStage billingThreshold(Optional billingThreshold); + + _FinalStage billingThreshold(Integer billingThreshold); + + _FinalStage creditConsumptionRate(Optional creditConsumptionRate); + + _FinalStage creditConsumptionRate(Double creditConsumptionRate); + + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + _FinalStage metricPeriod(Optional metricPeriod); _FinalStage metricPeriod(CreatePlanEntitlementRequestBodyMetricPeriod metricPeriod); @@ -222,18 +398,49 @@ _FinalStage metricPeriodMonthReset( _FinalStage monthlyMeteredPriceId(String monthlyMeteredPriceId); - _FinalStage priceBehavior(Optional priceBehavior); + _FinalStage monthlyPriceTiers(Optional> monthlyPriceTiers); + + _FinalStage monthlyPriceTiers(List monthlyPriceTiers); + + _FinalStage monthlyUnitPrice(Optional monthlyUnitPrice); + + _FinalStage monthlyUnitPrice(Integer monthlyUnitPrice); + + _FinalStage monthlyUnitPriceDecimal(Optional monthlyUnitPriceDecimal); + + _FinalStage monthlyUnitPriceDecimal(String monthlyUnitPriceDecimal); + + _FinalStage overageBillingProductId(Optional overageBillingProductId); - _FinalStage priceBehavior(String priceBehavior); + _FinalStage overageBillingProductId(String overageBillingProductId); + + _FinalStage priceBehavior(Optional priceBehavior); + + _FinalStage priceBehavior(CreatePlanEntitlementRequestBodyPriceBehavior priceBehavior); + + /** + *

Use MonthlyPriceTiers or YearlyPriceTiers instead

+ */ + _FinalStage priceTiers(Optional> priceTiers); + + _FinalStage priceTiers(List priceTiers); _FinalStage softLimit(Optional softLimit); _FinalStage softLimit(Integer softLimit); + _FinalStage tierMode(Optional tierMode); + + _FinalStage tierMode(String tierMode); + _FinalStage valueBool(Optional valueBool); _FinalStage valueBool(Boolean valueBool); + _FinalStage valueCreditId(Optional valueCreditId); + + _FinalStage valueCreditId(String valueCreditId); + _FinalStage valueNumeric(Optional valueNumeric); _FinalStage valueNumeric(Integer valueNumeric); @@ -245,6 +452,18 @@ _FinalStage metricPeriodMonthReset( _FinalStage yearlyMeteredPriceId(Optional yearlyMeteredPriceId); _FinalStage yearlyMeteredPriceId(String yearlyMeteredPriceId); + + _FinalStage yearlyPriceTiers(Optional> yearlyPriceTiers); + + _FinalStage yearlyPriceTiers(List yearlyPriceTiers); + + _FinalStage yearlyUnitPrice(Optional yearlyUnitPrice); + + _FinalStage yearlyUnitPrice(Integer yearlyUnitPrice); + + _FinalStage yearlyUnitPriceDecimal(Optional yearlyUnitPriceDecimal); + + _FinalStage yearlyUnitPriceDecimal(String yearlyUnitPriceDecimal); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -255,17 +474,37 @@ public static final class Builder implements FeatureIdStage, PlanIdStage, ValueT private CreatePlanEntitlementRequestBodyValueType valueType; + private Optional yearlyUnitPriceDecimal = Optional.empty(); + + private Optional yearlyUnitPrice = Optional.empty(); + + private Optional> yearlyPriceTiers = Optional.empty(); + private Optional yearlyMeteredPriceId = Optional.empty(); private Optional valueTraitId = Optional.empty(); private Optional valueNumeric = Optional.empty(); + private Optional valueCreditId = Optional.empty(); + private Optional valueBool = Optional.empty(); + private Optional tierMode = Optional.empty(); + private Optional softLimit = Optional.empty(); - private Optional priceBehavior = Optional.empty(); + private Optional> priceTiers = Optional.empty(); + + private Optional priceBehavior = Optional.empty(); + + private Optional overageBillingProductId = Optional.empty(); + + private Optional monthlyUnitPriceDecimal = Optional.empty(); + + private Optional monthlyUnitPrice = Optional.empty(); + + private Optional> monthlyPriceTiers = Optional.empty(); private Optional monthlyMeteredPriceId = Optional.empty(); @@ -274,6 +513,14 @@ public static final class Builder implements FeatureIdStage, PlanIdStage, ValueT private Optional metricPeriod = Optional.empty(); + private Optional currency = Optional.empty(); + + private Optional creditConsumptionRate = Optional.empty(); + + private Optional billingThreshold = Optional.empty(); + + private Optional billingProductId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -281,18 +528,32 @@ private Builder() {} @java.lang.Override public Builder from(CreatePlanEntitlementRequestBody other) { + billingProductId(other.getBillingProductId()); + billingThreshold(other.getBillingThreshold()); + creditConsumptionRate(other.getCreditConsumptionRate()); + currency(other.getCurrency()); featureId(other.getFeatureId()); metricPeriod(other.getMetricPeriod()); metricPeriodMonthReset(other.getMetricPeriodMonthReset()); monthlyMeteredPriceId(other.getMonthlyMeteredPriceId()); + monthlyPriceTiers(other.getMonthlyPriceTiers()); + monthlyUnitPrice(other.getMonthlyUnitPrice()); + monthlyUnitPriceDecimal(other.getMonthlyUnitPriceDecimal()); + overageBillingProductId(other.getOverageBillingProductId()); planId(other.getPlanId()); priceBehavior(other.getPriceBehavior()); + priceTiers(other.getPriceTiers()); softLimit(other.getSoftLimit()); + tierMode(other.getTierMode()); valueBool(other.getValueBool()); + valueCreditId(other.getValueCreditId()); valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); yearlyMeteredPriceId(other.getYearlyMeteredPriceId()); + yearlyPriceTiers(other.getYearlyPriceTiers()); + yearlyUnitPrice(other.getYearlyUnitPrice()); + yearlyUnitPriceDecimal(other.getYearlyUnitPriceDecimal()); return this; } @@ -317,6 +578,45 @@ public _FinalStage valueType(@NotNull CreatePlanEntitlementRequestBodyValueType return this; } + @java.lang.Override + public _FinalStage yearlyUnitPriceDecimal(String yearlyUnitPriceDecimal) { + this.yearlyUnitPriceDecimal = Optional.ofNullable(yearlyUnitPriceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_unit_price_decimal", nulls = Nulls.SKIP) + public _FinalStage yearlyUnitPriceDecimal(Optional yearlyUnitPriceDecimal) { + this.yearlyUnitPriceDecimal = yearlyUnitPriceDecimal; + return this; + } + + @java.lang.Override + public _FinalStage yearlyUnitPrice(Integer yearlyUnitPrice) { + this.yearlyUnitPrice = Optional.ofNullable(yearlyUnitPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_unit_price", nulls = Nulls.SKIP) + public _FinalStage yearlyUnitPrice(Optional yearlyUnitPrice) { + this.yearlyUnitPrice = yearlyUnitPrice; + return this; + } + + @java.lang.Override + public _FinalStage yearlyPriceTiers(List yearlyPriceTiers) { + this.yearlyPriceTiers = Optional.ofNullable(yearlyPriceTiers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_price_tiers", nulls = Nulls.SKIP) + public _FinalStage yearlyPriceTiers(Optional> yearlyPriceTiers) { + this.yearlyPriceTiers = yearlyPriceTiers; + return this; + } + @java.lang.Override public _FinalStage yearlyMeteredPriceId(String yearlyMeteredPriceId) { this.yearlyMeteredPriceId = Optional.ofNullable(yearlyMeteredPriceId); @@ -356,6 +656,19 @@ public _FinalStage valueNumeric(Optional valueNumeric) { return this; } + @java.lang.Override + public _FinalStage valueCreditId(String valueCreditId) { + this.valueCreditId = Optional.ofNullable(valueCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit_id", nulls = Nulls.SKIP) + public _FinalStage valueCreditId(Optional valueCreditId) { + this.valueCreditId = valueCreditId; + return this; + } + @java.lang.Override public _FinalStage valueBool(Boolean valueBool) { this.valueBool = Optional.ofNullable(valueBool); @@ -369,6 +682,19 @@ public _FinalStage valueBool(Optional valueBool) { return this; } + @java.lang.Override + public _FinalStage tierMode(String tierMode) { + this.tierMode = Optional.ofNullable(tierMode); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tier_mode", nulls = Nulls.SKIP) + public _FinalStage tierMode(Optional tierMode) { + this.tierMode = tierMode; + return this; + } + @java.lang.Override public _FinalStage softLimit(Integer softLimit) { this.softLimit = Optional.ofNullable(softLimit); @@ -382,19 +708,91 @@ public _FinalStage softLimit(Optional softLimit) { return this; } + /** + *

Use MonthlyPriceTiers or YearlyPriceTiers instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage priceTiers(List priceTiers) { + this.priceTiers = Optional.ofNullable(priceTiers); + return this; + } + + /** + *

Use MonthlyPriceTiers or YearlyPriceTiers instead

+ */ + @java.lang.Override + @JsonSetter(value = "price_tiers", nulls = Nulls.SKIP) + public _FinalStage priceTiers(Optional> priceTiers) { + this.priceTiers = priceTiers; + return this; + } + @java.lang.Override - public _FinalStage priceBehavior(String priceBehavior) { + public _FinalStage priceBehavior(CreatePlanEntitlementRequestBodyPriceBehavior priceBehavior) { this.priceBehavior = Optional.ofNullable(priceBehavior); return this; } @java.lang.Override @JsonSetter(value = "price_behavior", nulls = Nulls.SKIP) - public _FinalStage priceBehavior(Optional priceBehavior) { + public _FinalStage priceBehavior(Optional priceBehavior) { this.priceBehavior = priceBehavior; return this; } + @java.lang.Override + public _FinalStage overageBillingProductId(String overageBillingProductId) { + this.overageBillingProductId = Optional.ofNullable(overageBillingProductId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "overage_billing_product_id", nulls = Nulls.SKIP) + public _FinalStage overageBillingProductId(Optional overageBillingProductId) { + this.overageBillingProductId = overageBillingProductId; + return this; + } + + @java.lang.Override + public _FinalStage monthlyUnitPriceDecimal(String monthlyUnitPriceDecimal) { + this.monthlyUnitPriceDecimal = Optional.ofNullable(monthlyUnitPriceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_unit_price_decimal", nulls = Nulls.SKIP) + public _FinalStage monthlyUnitPriceDecimal(Optional monthlyUnitPriceDecimal) { + this.monthlyUnitPriceDecimal = monthlyUnitPriceDecimal; + return this; + } + + @java.lang.Override + public _FinalStage monthlyUnitPrice(Integer monthlyUnitPrice) { + this.monthlyUnitPrice = Optional.ofNullable(monthlyUnitPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_unit_price", nulls = Nulls.SKIP) + public _FinalStage monthlyUnitPrice(Optional monthlyUnitPrice) { + this.monthlyUnitPrice = monthlyUnitPrice; + return this; + } + + @java.lang.Override + public _FinalStage monthlyPriceTiers(List monthlyPriceTiers) { + this.monthlyPriceTiers = Optional.ofNullable(monthlyPriceTiers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_price_tiers", nulls = Nulls.SKIP) + public _FinalStage monthlyPriceTiers(Optional> monthlyPriceTiers) { + this.monthlyPriceTiers = monthlyPriceTiers; + return this; + } + @java.lang.Override public _FinalStage monthlyMeteredPriceId(String monthlyMeteredPriceId) { this.monthlyMeteredPriceId = Optional.ofNullable(monthlyMeteredPriceId); @@ -436,21 +834,87 @@ public _FinalStage metricPeriod(Optional currency) { + this.currency = currency; + return this; + } + + @java.lang.Override + public _FinalStage creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public _FinalStage creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + + @java.lang.Override + public _FinalStage billingThreshold(Integer billingThreshold) { + this.billingThreshold = Optional.ofNullable(billingThreshold); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_threshold", nulls = Nulls.SKIP) + public _FinalStage billingThreshold(Optional billingThreshold) { + this.billingThreshold = billingThreshold; + return this; + } + + @java.lang.Override + public _FinalStage billingProductId(String billingProductId) { + this.billingProductId = Optional.ofNullable(billingProductId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_product_id", nulls = Nulls.SKIP) + public _FinalStage billingProductId(Optional billingProductId) { + this.billingProductId = billingProductId; + return this; + } + @java.lang.Override public CreatePlanEntitlementRequestBody build() { return new CreatePlanEntitlementRequestBody( + billingProductId, + billingThreshold, + creditConsumptionRate, + currency, featureId, metricPeriod, metricPeriodMonthReset, monthlyMeteredPriceId, + monthlyPriceTiers, + monthlyUnitPrice, + monthlyUnitPriceDecimal, + overageBillingProductId, planId, priceBehavior, + priceTiers, softLimit, + tierMode, valueBool, + valueCreditId, valueNumeric, valueTraitId, valueType, yearlyMeteredPriceId, + yearlyPriceTiers, + yearlyUnitPrice, + yearlyUnitPriceDecimal, additionalProperties); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/GetFeatureUsageByCompanyRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/GetFeatureUsageByCompanyRequest.java index 89182d0..42fb859 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/GetFeatureUsageByCompanyRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/GetFeatureUsageByCompanyRequest.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; @@ -21,11 +20,11 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GetFeatureUsageByCompanyRequest.Builder.class) public final class GetFeatureUsageByCompanyRequest { - private final Map keys; + private final Map keys; private final Map additionalProperties; - private GetFeatureUsageByCompanyRequest(Map keys, Map additionalProperties) { + private GetFeatureUsageByCompanyRequest(Map keys, Map additionalProperties) { this.keys = keys; this.additionalProperties = additionalProperties; } @@ -34,7 +33,7 @@ private GetFeatureUsageByCompanyRequest(Map keys, Map getKeys() { + public Map getKeys() { return keys; } @@ -69,7 +68,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Map keys = new LinkedHashMap<>(); + private Map keys = new LinkedHashMap<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -81,19 +80,26 @@ public Builder from(GetFeatureUsageByCompanyRequest other) { return this; } + /** + *

Key/value pairs

+ */ @JsonSetter(value = "keys", nulls = Nulls.SKIP) - public Builder keys(Map keys) { + public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } - public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + public Builder putAllKeys(Map keys) { + if (keys != null) { + this.keys.putAll(keys); + } return this; } - public Builder keys(String key, JsonNode value) { + public Builder keys(String key, String value) { this.keys.put(key, value); return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/ListCompanyOverridesRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/ListCompanyOverridesRequest.java index c5eb20d..c56f4bf 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/ListCompanyOverridesRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/ListCompanyOverridesRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,15 +22,15 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListCompanyOverridesRequest.Builder.class) public final class ListCompanyOverridesRequest { - private final Optional companyId; + private final Optional> companyIds; - private final Optional companyIds; + private final Optional> featureIds; - private final Optional featureId; + private final Optional> ids; - private final Optional featureIds; + private final Optional companyId; - private final Optional ids; + private final Optional featureId; private final Optional withoutExpired; @@ -41,21 +43,21 @@ public final class ListCompanyOverridesRequest { private final Map additionalProperties; private ListCompanyOverridesRequest( + Optional> companyIds, + Optional> featureIds, + Optional> ids, Optional companyId, - Optional companyIds, Optional featureId, - Optional featureIds, - Optional ids, Optional withoutExpired, Optional q, Optional limit, Optional offset, Map additionalProperties) { - this.companyId = companyId; this.companyIds = companyIds; - this.featureId = featureId; this.featureIds = featureIds; this.ids = ids; + this.companyId = companyId; + this.featureId = featureId; this.withoutExpired = withoutExpired; this.q = q; this.limit = limit; @@ -63,35 +65,19 @@ private ListCompanyOverridesRequest( this.additionalProperties = additionalProperties; } - /** - * @return Filter company overrides by a single company ID (starting with comp_) - */ - @JsonProperty("company_id") - public Optional getCompanyId() { - return companyId; - } - /** * @return Filter company overrides by multiple company IDs (starting with comp_) */ @JsonProperty("company_ids") - public Optional getCompanyIds() { + public Optional> getCompanyIds() { return companyIds; } - /** - * @return Filter company overrides by a single feature ID (starting with feat_) - */ - @JsonProperty("feature_id") - public Optional getFeatureId() { - return featureId; - } - /** * @return Filter company overrides by multiple feature IDs (starting with feat_) */ @JsonProperty("feature_ids") - public Optional getFeatureIds() { + public Optional> getFeatureIds() { return featureIds; } @@ -99,10 +85,26 @@ public Optional getFeatureIds() { * @return Filter company overrides by multiple company override IDs (starting with cmov_) */ @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } + /** + * @return Filter company overrides by a single company ID (starting with comp_) + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return Filter company overrides by a single feature ID (starting with feat_) + */ + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + /** * @return Filter company overrides by whether they have not expired */ @@ -147,11 +149,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListCompanyOverridesRequest other) { - return companyId.equals(other.companyId) - && companyIds.equals(other.companyIds) - && featureId.equals(other.featureId) + return companyIds.equals(other.companyIds) && featureIds.equals(other.featureIds) && ids.equals(other.ids) + && companyId.equals(other.companyId) + && featureId.equals(other.featureId) && withoutExpired.equals(other.withoutExpired) && q.equals(other.q) && limit.equals(other.limit) @@ -161,11 +163,11 @@ private boolean equalTo(ListCompanyOverridesRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.companyId, this.companyIds, - this.featureId, this.featureIds, this.ids, + this.companyId, + this.featureId, this.withoutExpired, this.q, this.limit, @@ -183,15 +185,15 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional companyId = Optional.empty(); + private Optional> companyIds = Optional.empty(); - private Optional companyIds = Optional.empty(); + private Optional> featureIds = Optional.empty(); - private Optional featureId = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional featureIds = Optional.empty(); + private Optional companyId = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional featureId = Optional.empty(); private Optional withoutExpired = Optional.empty(); @@ -207,11 +209,11 @@ public static final class Builder { private Builder() {} public Builder from(ListCompanyOverridesRequest other) { - companyId(other.getCompanyId()); companyIds(other.getCompanyIds()); - featureId(other.getFeatureId()); featureIds(other.getFeatureIds()); ids(other.getIds()); + companyId(other.getCompanyId()); + featureId(other.getFeatureId()); withoutExpired(other.getWithoutExpired()); q(other.getQ()); limit(other.getLimit()); @@ -219,61 +221,94 @@ public Builder from(ListCompanyOverridesRequest other) { return this; } - @JsonSetter(value = "company_id", nulls = Nulls.SKIP) - public Builder companyId(Optional companyId) { - this.companyId = companyId; - return this; - } - - public Builder companyId(String companyId) { - this.companyId = Optional.ofNullable(companyId); - return this; - } - + /** + *

Filter company overrides by multiple company IDs (starting with comp_)

+ */ @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) - public Builder companyIds(Optional companyIds) { + public Builder companyIds(Optional> companyIds) { this.companyIds = companyIds; return this; } - public Builder companyIds(String companyIds) { + public Builder companyIds(List companyIds) { this.companyIds = Optional.ofNullable(companyIds); return this; } - @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) - public Builder featureId(Optional featureId) { - this.featureId = featureId; + public Builder companyIds(String companyIds) { + this.companyIds = Optional.of(Collections.singletonList(companyIds)); return this; } - public Builder featureId(String featureId) { - this.featureId = Optional.ofNullable(featureId); + /** + *

Filter company overrides by multiple feature IDs (starting with feat_)

+ */ + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; return this; } - @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) - public Builder featureIds(Optional featureIds) { - this.featureIds = featureIds; + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); return this; } public Builder featureIds(String featureIds) { - this.featureIds = Optional.ofNullable(featureIds); + this.featureIds = Optional.of(Collections.singletonList(featureIds)); return this; } + /** + *

Filter company overrides by multiple company override IDs (starting with cmov_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Filter company overrides by a single company ID (starting with comp_)

+ */ + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

Filter company overrides by a single feature ID (starting with feat_)

+ */ + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public Builder featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + public Builder featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + /** + *

Filter company overrides by whether they have not expired

+ */ @JsonSetter(value = "without_expired", nulls = Nulls.SKIP) public Builder withoutExpired(Optional withoutExpired) { this.withoutExpired = withoutExpired; @@ -285,6 +320,9 @@ public Builder withoutExpired(Boolean withoutExpired) { return this; } + /** + *

Search for company overrides by feature or company name

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -296,6 +334,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -307,6 +348,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -320,11 +364,11 @@ public Builder offset(Integer offset) { public ListCompanyOverridesRequest build() { return new ListCompanyOverridesRequest( - companyId, companyIds, - featureId, featureIds, ids, + companyId, + featureId, withoutExpired, q, limit, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureCompaniesRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureCompaniesRequest.java index f320c1a..3ead52b 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureCompaniesRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureCompaniesRequest.java @@ -115,10 +115,16 @@ public interface _FinalStage { _FinalStage q(String q); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -165,6 +171,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -182,6 +191,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureUsageRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureUsageRequest.java index 91ed5f4..ff297b9 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureUsageRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureUsageRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,12 +22,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListFeatureUsageRequest.Builder.class) public final class ListFeatureUsageRequest { + private final Optional> featureIds; + private final Optional companyId; private final Optional> companyKeys; - private final Optional featureIds; - private final Optional q; private final Optional withoutNegativeEntitlements; @@ -37,17 +39,17 @@ public final class ListFeatureUsageRequest { private final Map additionalProperties; private ListFeatureUsageRequest( + Optional> featureIds, Optional companyId, Optional> companyKeys, - Optional featureIds, Optional q, Optional withoutNegativeEntitlements, Optional limit, Optional offset, Map additionalProperties) { + this.featureIds = featureIds; this.companyId = companyId; this.companyKeys = companyKeys; - this.featureIds = featureIds; this.q = q; this.withoutNegativeEntitlements = withoutNegativeEntitlements; this.limit = limit; @@ -55,6 +57,11 @@ private ListFeatureUsageRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("feature_ids") + public Optional> getFeatureIds() { + return featureIds; + } + @JsonProperty("company_id") public Optional getCompanyId() { return companyId; @@ -65,11 +72,6 @@ public Optional> getCompanyKeys() { return companyKeys; } - @JsonProperty("feature_ids") - public Optional getFeatureIds() { - return featureIds; - } - @JsonProperty("q") public Optional getQ() { return q; @@ -108,9 +110,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListFeatureUsageRequest other) { - return companyId.equals(other.companyId) + return featureIds.equals(other.featureIds) + && companyId.equals(other.companyId) && companyKeys.equals(other.companyKeys) - && featureIds.equals(other.featureIds) && q.equals(other.q) && withoutNegativeEntitlements.equals(other.withoutNegativeEntitlements) && limit.equals(other.limit) @@ -120,9 +122,9 @@ private boolean equalTo(ListFeatureUsageRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.featureIds, this.companyId, this.companyKeys, - this.featureIds, this.q, this.withoutNegativeEntitlements, this.limit, @@ -140,12 +142,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> featureIds = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional> companyKeys = Optional.empty(); - private Optional featureIds = Optional.empty(); - private Optional q = Optional.empty(); private Optional withoutNegativeEntitlements = Optional.empty(); @@ -160,9 +162,9 @@ public static final class Builder { private Builder() {} public Builder from(ListFeatureUsageRequest other) { + featureIds(other.getFeatureIds()); companyId(other.getCompanyId()); companyKeys(other.getCompanyKeys()); - featureIds(other.getFeatureIds()); q(other.getQ()); withoutNegativeEntitlements(other.getWithoutNegativeEntitlements()); limit(other.getLimit()); @@ -170,6 +172,22 @@ public Builder from(ListFeatureUsageRequest other) { return this; } + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; + return this; + } + + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); + return this; + } + + public Builder featureIds(String featureIds) { + this.featureIds = Optional.of(Collections.singletonList(featureIds)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -192,17 +210,6 @@ public Builder companyKeys(Map companyKeys) { return this; } - @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) - public Builder featureIds(Optional featureIds) { - this.featureIds = featureIds; - return this; - } - - public Builder featureIds(String featureIds) { - this.featureIds = Optional.ofNullable(featureIds); - return this; - } - @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -225,6 +232,9 @@ public Builder withoutNegativeEntitlements(Boolean withoutNegativeEntitlements) return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -236,6 +246,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -249,9 +262,9 @@ public Builder offset(Integer offset) { public ListFeatureUsageRequest build() { return new ListFeatureUsageRequest( + featureIds, companyId, companyKeys, - featureIds, q, withoutNegativeEntitlements, limit, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureUsersRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureUsersRequest.java index 6e876bc..5b2f308 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureUsersRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/ListFeatureUsersRequest.java @@ -115,10 +115,16 @@ public interface _FinalStage { _FinalStage q(String q); + /** + *

Page limit (default 100)

+ */ _FinalStage limit(Optional limit); _FinalStage limit(Integer limit); + /** + *

Page offset (default 0)

+ */ _FinalStage offset(Optional offset); _FinalStage offset(Integer offset); @@ -165,6 +171,9 @@ public _FinalStage offset(Integer offset) { return this; } + /** + *

Page offset (default 0)

+ */ @java.lang.Override @JsonSetter(value = "offset", nulls = Nulls.SKIP) public _FinalStage offset(Optional offset) { @@ -182,6 +191,9 @@ public _FinalStage limit(Integer limit) { return this; } + /** + *

Page limit (default 100)

+ */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) public _FinalStage limit(Optional limit) { diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/ListPlanEntitlementsRequest.java b/src/main/java/com/schematic/api/resources/entitlements/requests/ListPlanEntitlementsRequest.java index 903ac58..c7588c8 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/ListPlanEntitlementsRequest.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/ListPlanEntitlementsRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,15 +22,15 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListPlanEntitlementsRequest.Builder.class) public final class ListPlanEntitlementsRequest { - private final Optional featureId; + private final Optional> featureIds; - private final Optional featureIds; + private final Optional> ids; - private final Optional ids; + private final Optional> planIds; - private final Optional planId; + private final Optional featureId; - private final Optional planIds; + private final Optional planId; private final Optional q; @@ -41,21 +43,21 @@ public final class ListPlanEntitlementsRequest { private final Map additionalProperties; private ListPlanEntitlementsRequest( + Optional> featureIds, + Optional> ids, + Optional> planIds, Optional featureId, - Optional featureIds, - Optional ids, Optional planId, - Optional planIds, Optional q, Optional withMeteredProducts, Optional limit, Optional offset, Map additionalProperties) { - this.featureId = featureId; this.featureIds = featureIds; this.ids = ids; - this.planId = planId; this.planIds = planIds; + this.featureId = featureId; + this.planId = planId; this.q = q; this.withMeteredProducts = withMeteredProducts; this.limit = limit; @@ -63,19 +65,11 @@ private ListPlanEntitlementsRequest( this.additionalProperties = additionalProperties; } - /** - * @return Filter plan entitlements by a single feature ID (starting with feat_) - */ - @JsonProperty("feature_id") - public Optional getFeatureId() { - return featureId; - } - /** * @return Filter plan entitlements by multiple feature IDs (starting with feat_) */ @JsonProperty("feature_ids") - public Optional getFeatureIds() { + public Optional> getFeatureIds() { return featureIds; } @@ -83,24 +77,32 @@ public Optional getFeatureIds() { * @return Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) */ @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } /** - * @return Filter plan entitlements by a single plan ID (starting with plan_) + * @return Filter plan entitlements by multiple plan IDs (starting with plan_) */ - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; + @JsonProperty("plan_ids") + public Optional> getPlanIds() { + return planIds; } /** - * @return Filter plan entitlements by multiple plan IDs (starting with plan_) + * @return Filter plan entitlements by a single feature ID (starting with feat_) */ - @JsonProperty("plan_ids") - public Optional getPlanIds() { - return planIds; + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + + /** + * @return Filter plan entitlements by a single plan ID (starting with plan_) + */ + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; } /** @@ -147,11 +149,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListPlanEntitlementsRequest other) { - return featureId.equals(other.featureId) - && featureIds.equals(other.featureIds) + return featureIds.equals(other.featureIds) && ids.equals(other.ids) - && planId.equals(other.planId) && planIds.equals(other.planIds) + && featureId.equals(other.featureId) + && planId.equals(other.planId) && q.equals(other.q) && withMeteredProducts.equals(other.withMeteredProducts) && limit.equals(other.limit) @@ -161,11 +163,11 @@ private boolean equalTo(ListPlanEntitlementsRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.featureId, this.featureIds, this.ids, - this.planId, this.planIds, + this.featureId, + this.planId, this.q, this.withMeteredProducts, this.limit, @@ -183,15 +185,15 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional featureId = Optional.empty(); + private Optional> featureIds = Optional.empty(); - private Optional featureIds = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional> planIds = Optional.empty(); - private Optional planId = Optional.empty(); + private Optional featureId = Optional.empty(); - private Optional planIds = Optional.empty(); + private Optional planId = Optional.empty(); private Optional q = Optional.empty(); @@ -207,11 +209,11 @@ public static final class Builder { private Builder() {} public Builder from(ListPlanEntitlementsRequest other) { - featureId(other.getFeatureId()); featureIds(other.getFeatureIds()); ids(other.getIds()); - planId(other.getPlanId()); planIds(other.getPlanIds()); + featureId(other.getFeatureId()); + planId(other.getPlanId()); q(other.getQ()); withMeteredProducts(other.getWithMeteredProducts()); limit(other.getLimit()); @@ -219,61 +221,94 @@ public Builder from(ListPlanEntitlementsRequest other) { return this; } - @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) - public Builder featureId(Optional featureId) { - this.featureId = featureId; - return this; - } - - public Builder featureId(String featureId) { - this.featureId = Optional.ofNullable(featureId); + /** + *

Filter plan entitlements by multiple feature IDs (starting with feat_)

+ */ + @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) + public Builder featureIds(Optional> featureIds) { + this.featureIds = featureIds; return this; } - @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) - public Builder featureIds(Optional featureIds) { - this.featureIds = featureIds; + public Builder featureIds(List featureIds) { + this.featureIds = Optional.ofNullable(featureIds); return this; } public Builder featureIds(String featureIds) { - this.featureIds = Optional.ofNullable(featureIds); + this.featureIds = Optional.of(Collections.singletonList(featureIds)); return this; } + /** + *

Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public Builder planId(Optional planId) { - this.planId = planId; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder planId(String planId) { - this.planId = Optional.ofNullable(planId); + /** + *

Filter plan entitlements by multiple plan IDs (starting with plan_)

+ */ + @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) + public Builder planIds(Optional> planIds) { + this.planIds = planIds; return this; } - @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) - public Builder planIds(Optional planIds) { - this.planIds = planIds; + public Builder planIds(List planIds) { + this.planIds = Optional.ofNullable(planIds); return this; } public Builder planIds(String planIds) { - this.planIds = Optional.ofNullable(planIds); + this.planIds = Optional.of(Collections.singletonList(planIds)); return this; } + /** + *

Filter plan entitlements by a single feature ID (starting with feat_)

+ */ + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public Builder featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + public Builder featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + /** + *

Filter plan entitlements by a single plan ID (starting with plan_)

+ */ + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + /** + *

Search for plan entitlements by feature or company name

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -285,6 +320,9 @@ public Builder q(String q) { return this; } + /** + *

Filter plan entitlements only with metered products

+ */ @JsonSetter(value = "with_metered_products", nulls = Nulls.SKIP) public Builder withMeteredProducts(Optional withMeteredProducts) { this.withMeteredProducts = withMeteredProducts; @@ -296,6 +334,9 @@ public Builder withMeteredProducts(Boolean withMeteredProducts) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -307,6 +348,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -320,11 +364,11 @@ public Builder offset(Integer offset) { public ListPlanEntitlementsRequest build() { return new ListPlanEntitlementsRequest( - featureId, featureIds, ids, - planId, planIds, + featureId, + planId, q, withMeteredProducts, limit, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/UpdateCompanyOverrideRequestBody.java b/src/main/java/com/schematic/api/resources/entitlements/requests/UpdateCompanyOverrideRequestBody.java index a919159..7379c93 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/UpdateCompanyOverrideRequestBody.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/UpdateCompanyOverrideRequestBody.java @@ -25,14 +25,20 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateCompanyOverrideRequestBody.Builder.class) public final class UpdateCompanyOverrideRequestBody { + private final Optional creditConsumptionRate; + private final Optional expirationDate; private final Optional metricPeriod; private final Optional metricPeriodMonthReset; + private final Optional note; + private final Optional valueBool; + private final Optional valueCreditId; + private final Optional valueNumeric; private final Optional valueTraitId; @@ -42,24 +48,35 @@ public final class UpdateCompanyOverrideRequestBody { private final Map additionalProperties; private UpdateCompanyOverrideRequestBody( + Optional creditConsumptionRate, Optional expirationDate, Optional metricPeriod, Optional metricPeriodMonthReset, + Optional note, Optional valueBool, + Optional valueCreditId, Optional valueNumeric, Optional valueTraitId, UpdateCompanyOverrideRequestBodyValueType valueType, Map additionalProperties) { + this.creditConsumptionRate = creditConsumptionRate; this.expirationDate = expirationDate; this.metricPeriod = metricPeriod; this.metricPeriodMonthReset = metricPeriodMonthReset; + this.note = note; this.valueBool = valueBool; + this.valueCreditId = valueCreditId; this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; this.additionalProperties = additionalProperties; } + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + @JsonProperty("expiration_date") public Optional getExpirationDate() { return expirationDate; @@ -75,11 +92,21 @@ public Optional getMetri return metricPeriodMonthReset; } + @JsonProperty("note") + public Optional getNote() { + return note; + } + @JsonProperty("value_bool") public Optional getValueBool() { return valueBool; } + @JsonProperty("value_credit_id") + public Optional getValueCreditId() { + return valueCreditId; + } + @JsonProperty("value_numeric") public Optional getValueNumeric() { return valueNumeric; @@ -107,10 +134,13 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateCompanyOverrideRequestBody other) { - return expirationDate.equals(other.expirationDate) + return creditConsumptionRate.equals(other.creditConsumptionRate) + && expirationDate.equals(other.expirationDate) && metricPeriod.equals(other.metricPeriod) && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) + && note.equals(other.note) && valueBool.equals(other.valueBool) + && valueCreditId.equals(other.valueCreditId) && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType); @@ -119,10 +149,13 @@ private boolean equalTo(UpdateCompanyOverrideRequestBody other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.creditConsumptionRate, this.expirationDate, this.metricPeriod, this.metricPeriodMonthReset, + this.note, this.valueBool, + this.valueCreditId, this.valueNumeric, this.valueTraitId, this.valueType); @@ -146,6 +179,10 @@ public interface ValueTypeStage { public interface _FinalStage { UpdateCompanyOverrideRequestBody build(); + _FinalStage creditConsumptionRate(Optional creditConsumptionRate); + + _FinalStage creditConsumptionRate(Double creditConsumptionRate); + _FinalStage expirationDate(Optional expirationDate); _FinalStage expirationDate(OffsetDateTime expirationDate); @@ -160,10 +197,18 @@ _FinalStage metricPeriodMonthReset( _FinalStage metricPeriodMonthReset( UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset metricPeriodMonthReset); + _FinalStage note(Optional note); + + _FinalStage note(String note); + _FinalStage valueBool(Optional valueBool); _FinalStage valueBool(Boolean valueBool); + _FinalStage valueCreditId(Optional valueCreditId); + + _FinalStage valueCreditId(String valueCreditId); + _FinalStage valueNumeric(Optional valueNumeric); _FinalStage valueNumeric(Integer valueNumeric); @@ -181,8 +226,12 @@ public static final class Builder implements ValueTypeStage, _FinalStage { private Optional valueNumeric = Optional.empty(); + private Optional valueCreditId = Optional.empty(); + private Optional valueBool = Optional.empty(); + private Optional note = Optional.empty(); + private Optional metricPeriodMonthReset = Optional.empty(); @@ -190,6 +239,8 @@ public static final class Builder implements ValueTypeStage, _FinalStage { private Optional expirationDate = Optional.empty(); + private Optional creditConsumptionRate = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -197,10 +248,13 @@ private Builder() {} @java.lang.Override public Builder from(UpdateCompanyOverrideRequestBody other) { + creditConsumptionRate(other.getCreditConsumptionRate()); expirationDate(other.getExpirationDate()); metricPeriod(other.getMetricPeriod()); metricPeriodMonthReset(other.getMetricPeriodMonthReset()); + note(other.getNote()); valueBool(other.getValueBool()); + valueCreditId(other.getValueCreditId()); valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); @@ -240,6 +294,19 @@ public _FinalStage valueNumeric(Optional valueNumeric) { return this; } + @java.lang.Override + public _FinalStage valueCreditId(String valueCreditId) { + this.valueCreditId = Optional.ofNullable(valueCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit_id", nulls = Nulls.SKIP) + public _FinalStage valueCreditId(Optional valueCreditId) { + this.valueCreditId = valueCreditId; + return this; + } + @java.lang.Override public _FinalStage valueBool(Boolean valueBool) { this.valueBool = Optional.ofNullable(valueBool); @@ -253,6 +320,19 @@ public _FinalStage valueBool(Optional valueBool) { return this; } + @java.lang.Override + public _FinalStage note(String note) { + this.note = Optional.ofNullable(note); + return this; + } + + @java.lang.Override + @JsonSetter(value = "note", nulls = Nulls.SKIP) + public _FinalStage note(Optional note) { + this.note = note; + return this; + } + @java.lang.Override public _FinalStage metricPeriodMonthReset( UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset metricPeriodMonthReset) { @@ -294,13 +374,29 @@ public _FinalStage expirationDate(Optional expirationDate) { return this; } + @java.lang.Override + public _FinalStage creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public _FinalStage creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + @java.lang.Override public UpdateCompanyOverrideRequestBody build() { return new UpdateCompanyOverrideRequestBody( + creditConsumptionRate, expirationDate, metricPeriod, metricPeriodMonthReset, + note, valueBool, + valueCreditId, valueNumeric, valueTraitId, valueType, diff --git a/src/main/java/com/schematic/api/resources/entitlements/requests/UpdatePlanEntitlementRequestBody.java b/src/main/java/com/schematic/api/resources/entitlements/requests/UpdatePlanEntitlementRequestBody.java index f7cdb97..ac2fa6a 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/requests/UpdatePlanEntitlementRequestBody.java +++ b/src/main/java/com/schematic/api/resources/entitlements/requests/UpdatePlanEntitlementRequestBody.java @@ -14,8 +14,11 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementRequestBodyMetricPeriod; import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset; +import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementRequestBodyPriceBehavior; import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementRequestBodyValueType; +import com.schematic.api.types.CreatePriceTierRequestBody; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -24,18 +27,40 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdatePlanEntitlementRequestBody.Builder.class) public final class UpdatePlanEntitlementRequestBody { + private final Optional billingProductId; + + private final Optional billingThreshold; + + private final Optional creditConsumptionRate; + + private final Optional currency; + private final Optional metricPeriod; private final Optional metricPeriodMonthReset; private final Optional monthlyMeteredPriceId; - private final Optional priceBehavior; + private final Optional> monthlyPriceTiers; + + private final Optional monthlyUnitPrice; + + private final Optional monthlyUnitPriceDecimal; + + private final Optional overageBillingProductId; + + private final Optional priceBehavior; + + private final Optional> priceTiers; private final Optional softLimit; + private final Optional tierMode; + private final Optional valueBool; + private final Optional valueCreditId; + private final Optional valueNumeric; private final Optional valueTraitId; @@ -44,33 +69,87 @@ public final class UpdatePlanEntitlementRequestBody { private final Optional yearlyMeteredPriceId; + private final Optional> yearlyPriceTiers; + + private final Optional yearlyUnitPrice; + + private final Optional yearlyUnitPriceDecimal; + private final Map additionalProperties; private UpdatePlanEntitlementRequestBody( + Optional billingProductId, + Optional billingThreshold, + Optional creditConsumptionRate, + Optional currency, Optional metricPeriod, Optional metricPeriodMonthReset, Optional monthlyMeteredPriceId, - Optional priceBehavior, + Optional> monthlyPriceTiers, + Optional monthlyUnitPrice, + Optional monthlyUnitPriceDecimal, + Optional overageBillingProductId, + Optional priceBehavior, + Optional> priceTiers, Optional softLimit, + Optional tierMode, Optional valueBool, + Optional valueCreditId, Optional valueNumeric, Optional valueTraitId, UpdatePlanEntitlementRequestBodyValueType valueType, Optional yearlyMeteredPriceId, + Optional> yearlyPriceTiers, + Optional yearlyUnitPrice, + Optional yearlyUnitPriceDecimal, Map additionalProperties) { + this.billingProductId = billingProductId; + this.billingThreshold = billingThreshold; + this.creditConsumptionRate = creditConsumptionRate; + this.currency = currency; this.metricPeriod = metricPeriod; this.metricPeriodMonthReset = metricPeriodMonthReset; this.monthlyMeteredPriceId = monthlyMeteredPriceId; + this.monthlyPriceTiers = monthlyPriceTiers; + this.monthlyUnitPrice = monthlyUnitPrice; + this.monthlyUnitPriceDecimal = monthlyUnitPriceDecimal; + this.overageBillingProductId = overageBillingProductId; this.priceBehavior = priceBehavior; + this.priceTiers = priceTiers; this.softLimit = softLimit; + this.tierMode = tierMode; this.valueBool = valueBool; + this.valueCreditId = valueCreditId; this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; this.yearlyMeteredPriceId = yearlyMeteredPriceId; + this.yearlyPriceTiers = yearlyPriceTiers; + this.yearlyUnitPrice = yearlyUnitPrice; + this.yearlyUnitPriceDecimal = yearlyUnitPriceDecimal; this.additionalProperties = additionalProperties; } + @JsonProperty("billing_product_id") + public Optional getBillingProductId() { + return billingProductId; + } + + @JsonProperty("billing_threshold") + public Optional getBillingThreshold() { + return billingThreshold; + } + + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + @JsonProperty("metric_period") public Optional getMetricPeriod() { return metricPeriod; @@ -86,21 +165,59 @@ public Optional getMonthlyMeteredPriceId() { return monthlyMeteredPriceId; } + @JsonProperty("monthly_price_tiers") + public Optional> getMonthlyPriceTiers() { + return monthlyPriceTiers; + } + + @JsonProperty("monthly_unit_price") + public Optional getMonthlyUnitPrice() { + return monthlyUnitPrice; + } + + @JsonProperty("monthly_unit_price_decimal") + public Optional getMonthlyUnitPriceDecimal() { + return monthlyUnitPriceDecimal; + } + + @JsonProperty("overage_billing_product_id") + public Optional getOverageBillingProductId() { + return overageBillingProductId; + } + @JsonProperty("price_behavior") - public Optional getPriceBehavior() { + public Optional getPriceBehavior() { return priceBehavior; } + /** + * @return Use MonthlyPriceTiers or YearlyPriceTiers instead + */ + @JsonProperty("price_tiers") + public Optional> getPriceTiers() { + return priceTiers; + } + @JsonProperty("soft_limit") public Optional getSoftLimit() { return softLimit; } + @JsonProperty("tier_mode") + public Optional getTierMode() { + return tierMode; + } + @JsonProperty("value_bool") public Optional getValueBool() { return valueBool; } + @JsonProperty("value_credit_id") + public Optional getValueCreditId() { + return valueCreditId; + } + @JsonProperty("value_numeric") public Optional getValueNumeric() { return valueNumeric; @@ -121,6 +238,21 @@ public Optional getYearlyMeteredPriceId() { return yearlyMeteredPriceId; } + @JsonProperty("yearly_price_tiers") + public Optional> getYearlyPriceTiers() { + return yearlyPriceTiers; + } + + @JsonProperty("yearly_unit_price") + public Optional getYearlyUnitPrice() { + return yearlyUnitPrice; + } + + @JsonProperty("yearly_unit_price_decimal") + public Optional getYearlyUnitPriceDecimal() { + return yearlyUnitPriceDecimal; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -133,31 +265,59 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdatePlanEntitlementRequestBody other) { - return metricPeriod.equals(other.metricPeriod) + return billingProductId.equals(other.billingProductId) + && billingThreshold.equals(other.billingThreshold) + && creditConsumptionRate.equals(other.creditConsumptionRate) + && currency.equals(other.currency) + && metricPeriod.equals(other.metricPeriod) && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) && monthlyMeteredPriceId.equals(other.monthlyMeteredPriceId) + && monthlyPriceTiers.equals(other.monthlyPriceTiers) + && monthlyUnitPrice.equals(other.monthlyUnitPrice) + && monthlyUnitPriceDecimal.equals(other.monthlyUnitPriceDecimal) + && overageBillingProductId.equals(other.overageBillingProductId) && priceBehavior.equals(other.priceBehavior) + && priceTiers.equals(other.priceTiers) && softLimit.equals(other.softLimit) + && tierMode.equals(other.tierMode) && valueBool.equals(other.valueBool) + && valueCreditId.equals(other.valueCreditId) && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType) - && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId); + && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId) + && yearlyPriceTiers.equals(other.yearlyPriceTiers) + && yearlyUnitPrice.equals(other.yearlyUnitPrice) + && yearlyUnitPriceDecimal.equals(other.yearlyUnitPriceDecimal); } @java.lang.Override public int hashCode() { return Objects.hash( + this.billingProductId, + this.billingThreshold, + this.creditConsumptionRate, + this.currency, this.metricPeriod, this.metricPeriodMonthReset, this.monthlyMeteredPriceId, + this.monthlyPriceTiers, + this.monthlyUnitPrice, + this.monthlyUnitPriceDecimal, + this.overageBillingProductId, this.priceBehavior, + this.priceTiers, this.softLimit, + this.tierMode, this.valueBool, + this.valueCreditId, this.valueNumeric, this.valueTraitId, this.valueType, - this.yearlyMeteredPriceId); + this.yearlyMeteredPriceId, + this.yearlyPriceTiers, + this.yearlyUnitPrice, + this.yearlyUnitPriceDecimal); } @java.lang.Override @@ -178,6 +338,22 @@ public interface ValueTypeStage { public interface _FinalStage { UpdatePlanEntitlementRequestBody build(); + _FinalStage billingProductId(Optional billingProductId); + + _FinalStage billingProductId(String billingProductId); + + _FinalStage billingThreshold(Optional billingThreshold); + + _FinalStage billingThreshold(Integer billingThreshold); + + _FinalStage creditConsumptionRate(Optional creditConsumptionRate); + + _FinalStage creditConsumptionRate(Double creditConsumptionRate); + + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + _FinalStage metricPeriod(Optional metricPeriod); _FinalStage metricPeriod(UpdatePlanEntitlementRequestBodyMetricPeriod metricPeriod); @@ -192,18 +368,49 @@ _FinalStage metricPeriodMonthReset( _FinalStage monthlyMeteredPriceId(String monthlyMeteredPriceId); - _FinalStage priceBehavior(Optional priceBehavior); + _FinalStage monthlyPriceTiers(Optional> monthlyPriceTiers); + + _FinalStage monthlyPriceTiers(List monthlyPriceTiers); + + _FinalStage monthlyUnitPrice(Optional monthlyUnitPrice); + + _FinalStage monthlyUnitPrice(Integer monthlyUnitPrice); + + _FinalStage monthlyUnitPriceDecimal(Optional monthlyUnitPriceDecimal); + + _FinalStage monthlyUnitPriceDecimal(String monthlyUnitPriceDecimal); + + _FinalStage overageBillingProductId(Optional overageBillingProductId); - _FinalStage priceBehavior(String priceBehavior); + _FinalStage overageBillingProductId(String overageBillingProductId); + + _FinalStage priceBehavior(Optional priceBehavior); + + _FinalStage priceBehavior(UpdatePlanEntitlementRequestBodyPriceBehavior priceBehavior); + + /** + *

Use MonthlyPriceTiers or YearlyPriceTiers instead

+ */ + _FinalStage priceTiers(Optional> priceTiers); + + _FinalStage priceTiers(List priceTiers); _FinalStage softLimit(Optional softLimit); _FinalStage softLimit(Integer softLimit); + _FinalStage tierMode(Optional tierMode); + + _FinalStage tierMode(String tierMode); + _FinalStage valueBool(Optional valueBool); _FinalStage valueBool(Boolean valueBool); + _FinalStage valueCreditId(Optional valueCreditId); + + _FinalStage valueCreditId(String valueCreditId); + _FinalStage valueNumeric(Optional valueNumeric); _FinalStage valueNumeric(Integer valueNumeric); @@ -215,23 +422,55 @@ _FinalStage metricPeriodMonthReset( _FinalStage yearlyMeteredPriceId(Optional yearlyMeteredPriceId); _FinalStage yearlyMeteredPriceId(String yearlyMeteredPriceId); + + _FinalStage yearlyPriceTiers(Optional> yearlyPriceTiers); + + _FinalStage yearlyPriceTiers(List yearlyPriceTiers); + + _FinalStage yearlyUnitPrice(Optional yearlyUnitPrice); + + _FinalStage yearlyUnitPrice(Integer yearlyUnitPrice); + + _FinalStage yearlyUnitPriceDecimal(Optional yearlyUnitPriceDecimal); + + _FinalStage yearlyUnitPriceDecimal(String yearlyUnitPriceDecimal); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ValueTypeStage, _FinalStage { private UpdatePlanEntitlementRequestBodyValueType valueType; + private Optional yearlyUnitPriceDecimal = Optional.empty(); + + private Optional yearlyUnitPrice = Optional.empty(); + + private Optional> yearlyPriceTiers = Optional.empty(); + private Optional yearlyMeteredPriceId = Optional.empty(); private Optional valueTraitId = Optional.empty(); private Optional valueNumeric = Optional.empty(); + private Optional valueCreditId = Optional.empty(); + private Optional valueBool = Optional.empty(); + private Optional tierMode = Optional.empty(); + private Optional softLimit = Optional.empty(); - private Optional priceBehavior = Optional.empty(); + private Optional> priceTiers = Optional.empty(); + + private Optional priceBehavior = Optional.empty(); + + private Optional overageBillingProductId = Optional.empty(); + + private Optional monthlyUnitPriceDecimal = Optional.empty(); + + private Optional monthlyUnitPrice = Optional.empty(); + + private Optional> monthlyPriceTiers = Optional.empty(); private Optional monthlyMeteredPriceId = Optional.empty(); @@ -240,6 +479,14 @@ public static final class Builder implements ValueTypeStage, _FinalStage { private Optional metricPeriod = Optional.empty(); + private Optional currency = Optional.empty(); + + private Optional creditConsumptionRate = Optional.empty(); + + private Optional billingThreshold = Optional.empty(); + + private Optional billingProductId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -247,16 +494,30 @@ private Builder() {} @java.lang.Override public Builder from(UpdatePlanEntitlementRequestBody other) { + billingProductId(other.getBillingProductId()); + billingThreshold(other.getBillingThreshold()); + creditConsumptionRate(other.getCreditConsumptionRate()); + currency(other.getCurrency()); metricPeriod(other.getMetricPeriod()); metricPeriodMonthReset(other.getMetricPeriodMonthReset()); monthlyMeteredPriceId(other.getMonthlyMeteredPriceId()); + monthlyPriceTiers(other.getMonthlyPriceTiers()); + monthlyUnitPrice(other.getMonthlyUnitPrice()); + monthlyUnitPriceDecimal(other.getMonthlyUnitPriceDecimal()); + overageBillingProductId(other.getOverageBillingProductId()); priceBehavior(other.getPriceBehavior()); + priceTiers(other.getPriceTiers()); softLimit(other.getSoftLimit()); + tierMode(other.getTierMode()); valueBool(other.getValueBool()); + valueCreditId(other.getValueCreditId()); valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); yearlyMeteredPriceId(other.getYearlyMeteredPriceId()); + yearlyPriceTiers(other.getYearlyPriceTiers()); + yearlyUnitPrice(other.getYearlyUnitPrice()); + yearlyUnitPriceDecimal(other.getYearlyUnitPriceDecimal()); return this; } @@ -267,6 +528,45 @@ public _FinalStage valueType(@NotNull UpdatePlanEntitlementRequestBodyValueType return this; } + @java.lang.Override + public _FinalStage yearlyUnitPriceDecimal(String yearlyUnitPriceDecimal) { + this.yearlyUnitPriceDecimal = Optional.ofNullable(yearlyUnitPriceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_unit_price_decimal", nulls = Nulls.SKIP) + public _FinalStage yearlyUnitPriceDecimal(Optional yearlyUnitPriceDecimal) { + this.yearlyUnitPriceDecimal = yearlyUnitPriceDecimal; + return this; + } + + @java.lang.Override + public _FinalStage yearlyUnitPrice(Integer yearlyUnitPrice) { + this.yearlyUnitPrice = Optional.ofNullable(yearlyUnitPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_unit_price", nulls = Nulls.SKIP) + public _FinalStage yearlyUnitPrice(Optional yearlyUnitPrice) { + this.yearlyUnitPrice = yearlyUnitPrice; + return this; + } + + @java.lang.Override + public _FinalStage yearlyPriceTiers(List yearlyPriceTiers) { + this.yearlyPriceTiers = Optional.ofNullable(yearlyPriceTiers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_price_tiers", nulls = Nulls.SKIP) + public _FinalStage yearlyPriceTiers(Optional> yearlyPriceTiers) { + this.yearlyPriceTiers = yearlyPriceTiers; + return this; + } + @java.lang.Override public _FinalStage yearlyMeteredPriceId(String yearlyMeteredPriceId) { this.yearlyMeteredPriceId = Optional.ofNullable(yearlyMeteredPriceId); @@ -306,6 +606,19 @@ public _FinalStage valueNumeric(Optional valueNumeric) { return this; } + @java.lang.Override + public _FinalStage valueCreditId(String valueCreditId) { + this.valueCreditId = Optional.ofNullable(valueCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit_id", nulls = Nulls.SKIP) + public _FinalStage valueCreditId(Optional valueCreditId) { + this.valueCreditId = valueCreditId; + return this; + } + @java.lang.Override public _FinalStage valueBool(Boolean valueBool) { this.valueBool = Optional.ofNullable(valueBool); @@ -319,6 +632,19 @@ public _FinalStage valueBool(Optional valueBool) { return this; } + @java.lang.Override + public _FinalStage tierMode(String tierMode) { + this.tierMode = Optional.ofNullable(tierMode); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tier_mode", nulls = Nulls.SKIP) + public _FinalStage tierMode(Optional tierMode) { + this.tierMode = tierMode; + return this; + } + @java.lang.Override public _FinalStage softLimit(Integer softLimit) { this.softLimit = Optional.ofNullable(softLimit); @@ -332,19 +658,91 @@ public _FinalStage softLimit(Optional softLimit) { return this; } + /** + *

Use MonthlyPriceTiers or YearlyPriceTiers instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage priceTiers(List priceTiers) { + this.priceTiers = Optional.ofNullable(priceTiers); + return this; + } + + /** + *

Use MonthlyPriceTiers or YearlyPriceTiers instead

+ */ + @java.lang.Override + @JsonSetter(value = "price_tiers", nulls = Nulls.SKIP) + public _FinalStage priceTiers(Optional> priceTiers) { + this.priceTiers = priceTiers; + return this; + } + @java.lang.Override - public _FinalStage priceBehavior(String priceBehavior) { + public _FinalStage priceBehavior(UpdatePlanEntitlementRequestBodyPriceBehavior priceBehavior) { this.priceBehavior = Optional.ofNullable(priceBehavior); return this; } @java.lang.Override @JsonSetter(value = "price_behavior", nulls = Nulls.SKIP) - public _FinalStage priceBehavior(Optional priceBehavior) { + public _FinalStage priceBehavior(Optional priceBehavior) { this.priceBehavior = priceBehavior; return this; } + @java.lang.Override + public _FinalStage overageBillingProductId(String overageBillingProductId) { + this.overageBillingProductId = Optional.ofNullable(overageBillingProductId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "overage_billing_product_id", nulls = Nulls.SKIP) + public _FinalStage overageBillingProductId(Optional overageBillingProductId) { + this.overageBillingProductId = overageBillingProductId; + return this; + } + + @java.lang.Override + public _FinalStage monthlyUnitPriceDecimal(String monthlyUnitPriceDecimal) { + this.monthlyUnitPriceDecimal = Optional.ofNullable(monthlyUnitPriceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_unit_price_decimal", nulls = Nulls.SKIP) + public _FinalStage monthlyUnitPriceDecimal(Optional monthlyUnitPriceDecimal) { + this.monthlyUnitPriceDecimal = monthlyUnitPriceDecimal; + return this; + } + + @java.lang.Override + public _FinalStage monthlyUnitPrice(Integer monthlyUnitPrice) { + this.monthlyUnitPrice = Optional.ofNullable(monthlyUnitPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_unit_price", nulls = Nulls.SKIP) + public _FinalStage monthlyUnitPrice(Optional monthlyUnitPrice) { + this.monthlyUnitPrice = monthlyUnitPrice; + return this; + } + + @java.lang.Override + public _FinalStage monthlyPriceTiers(List monthlyPriceTiers) { + this.monthlyPriceTiers = Optional.ofNullable(monthlyPriceTiers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_price_tiers", nulls = Nulls.SKIP) + public _FinalStage monthlyPriceTiers(Optional> monthlyPriceTiers) { + this.monthlyPriceTiers = monthlyPriceTiers; + return this; + } + @java.lang.Override public _FinalStage monthlyMeteredPriceId(String monthlyMeteredPriceId) { this.monthlyMeteredPriceId = Optional.ofNullable(monthlyMeteredPriceId); @@ -386,19 +784,85 @@ public _FinalStage metricPeriod(Optional currency) { + this.currency = currency; + return this; + } + + @java.lang.Override + public _FinalStage creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public _FinalStage creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + + @java.lang.Override + public _FinalStage billingThreshold(Integer billingThreshold) { + this.billingThreshold = Optional.ofNullable(billingThreshold); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_threshold", nulls = Nulls.SKIP) + public _FinalStage billingThreshold(Optional billingThreshold) { + this.billingThreshold = billingThreshold; + return this; + } + + @java.lang.Override + public _FinalStage billingProductId(String billingProductId) { + this.billingProductId = Optional.ofNullable(billingProductId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_product_id", nulls = Nulls.SKIP) + public _FinalStage billingProductId(Optional billingProductId) { + this.billingProductId = billingProductId; + return this; + } + @java.lang.Override public UpdatePlanEntitlementRequestBody build() { return new UpdatePlanEntitlementRequestBody( + billingProductId, + billingThreshold, + creditConsumptionRate, + currency, metricPeriod, metricPeriodMonthReset, monthlyMeteredPriceId, + monthlyPriceTiers, + monthlyUnitPrice, + monthlyUnitPriceDecimal, + overageBillingProductId, priceBehavior, + priceTiers, softLimit, + tierMode, valueBool, + valueCreditId, valueNumeric, valueTraitId, valueType, yearlyMeteredPriceId, + yearlyPriceTiers, + yearlyUnitPrice, + yearlyUnitPriceDecimal, additionalProperties); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesParams.java index adfc2c3..9be6d52 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesParams.java @@ -220,6 +220,9 @@ public Builder from(CountCompanyOverridesParams other) { return this; } + /** + *

Filter company overrides by a single company ID (starting with comp_)

+ */ @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -231,6 +234,9 @@ public Builder companyId(String companyId) { return this; } + /** + *

Filter company overrides by multiple company IDs (starting with comp_)

+ */ @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) public Builder companyIds(Optional> companyIds) { this.companyIds = companyIds; @@ -242,6 +248,9 @@ public Builder companyIds(List companyIds) { return this; } + /** + *

Filter company overrides by a single feature ID (starting with feat_)

+ */ @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) public Builder featureId(Optional featureId) { this.featureId = featureId; @@ -253,6 +262,9 @@ public Builder featureId(String featureId) { return this; } + /** + *

Filter company overrides by multiple feature IDs (starting with feat_)

+ */ @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) public Builder featureIds(Optional> featureIds) { this.featureIds = featureIds; @@ -264,6 +276,9 @@ public Builder featureIds(List featureIds) { return this; } + /** + *

Filter company overrides by multiple company override IDs (starting with cmov_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -275,6 +290,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -286,6 +304,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -297,6 +318,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Search for company overrides by feature or company name

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -308,6 +332,9 @@ public Builder q(String q) { return this; } + /** + *

Filter company overrides by whether they have not expired

+ */ @JsonSetter(value = "without_expired", nulls = Nulls.SKIP) public Builder withoutExpired(Optional withoutExpired) { this.withoutExpired = withoutExpired; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesResponse.java index a9a0c70..e25efb2 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountCompanyOverridesResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountCompanyOverridesParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesParams.java index 20cde87..67222b4 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesParams.java @@ -135,6 +135,9 @@ public Builder featureId(String featureId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesResponse.java index 221ba0e..b821b1a 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureCompaniesResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountFeatureCompaniesParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageParams.java index 6e97708..5826be6 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageParams.java @@ -204,6 +204,9 @@ public Builder featureIds(List featureIds) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -215,6 +218,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageResponse.java index 73b04eb..1879e8a 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsageResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountFeatureUsageParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersParams.java index e9d1faa..90b303f 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersParams.java @@ -135,6 +135,9 @@ public Builder featureId(String featureId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersResponse.java index ea237f2..d135c87 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountFeatureUsersResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountFeatureUsersParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsParams.java index 57f41fb..784ce4a 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsParams.java @@ -220,6 +220,9 @@ public Builder from(CountPlanEntitlementsParams other) { return this; } + /** + *

Filter plan entitlements by a single feature ID (starting with feat_)

+ */ @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) public Builder featureId(Optional featureId) { this.featureId = featureId; @@ -231,6 +234,9 @@ public Builder featureId(String featureId) { return this; } + /** + *

Filter plan entitlements by multiple feature IDs (starting with feat_)

+ */ @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) public Builder featureIds(Optional> featureIds) { this.featureIds = featureIds; @@ -242,6 +248,9 @@ public Builder featureIds(List featureIds) { return this; } + /** + *

Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -253,6 +262,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -264,6 +276,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -275,6 +290,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Filter plan entitlements by a single plan ID (starting with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -286,6 +304,9 @@ public Builder planId(String planId) { return this; } + /** + *

Filter plan entitlements by multiple plan IDs (starting with plan_)

+ */ @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) public Builder planIds(Optional> planIds) { this.planIds = planIds; @@ -297,6 +318,9 @@ public Builder planIds(List planIds) { return this; } + /** + *

Search for plan entitlements by feature or company name

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -308,6 +332,9 @@ public Builder q(String q) { return this; } + /** + *

Filter plan entitlements only with metered products

+ */ @JsonSetter(value = "with_metered_products", nulls = Nulls.SKIP) public Builder withMeteredProducts(Optional withMeteredProducts) { this.withMeteredProducts = withMeteredProducts; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsResponse.java index 0312885..05ce432 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CountPlanEntitlementsResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountPlanEntitlementsParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyMetricPeriod.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyMetricPeriod.java index bdc9c3f..73e73df 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyMetricPeriod.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyMetricPeriod.java @@ -3,26 +3,106 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateCompanyOverrideRequestBodyMetricPeriod { - ALL_TIME("all_time"), +public final class CreateCompanyOverrideRequestBodyMetricPeriod { + public static final CreateCompanyOverrideRequestBodyMetricPeriod CURRENT_DAY = + new CreateCompanyOverrideRequestBodyMetricPeriod(Value.CURRENT_DAY, "current_day"); - CURRENT_MONTH("current_month"), + public static final CreateCompanyOverrideRequestBodyMetricPeriod ALL_TIME = + new CreateCompanyOverrideRequestBodyMetricPeriod(Value.ALL_TIME, "all_time"); - CURRENT_WEEK("current_week"), + public static final CreateCompanyOverrideRequestBodyMetricPeriod CURRENT_WEEK = + new CreateCompanyOverrideRequestBodyMetricPeriod(Value.CURRENT_WEEK, "current_week"); - CURRENT_DAY("current_day"); + public static final CreateCompanyOverrideRequestBodyMetricPeriod CURRENT_MONTH = + new CreateCompanyOverrideRequestBodyMetricPeriod(Value.CURRENT_MONTH, "current_month"); - private final String value; + private final Value value; - CreateCompanyOverrideRequestBodyMetricPeriod(String value) { + private final String string; + + CreateCompanyOverrideRequestBodyMetricPeriod(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateCompanyOverrideRequestBodyMetricPeriod + && this.string.equals(((CreateCompanyOverrideRequestBodyMetricPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CURRENT_DAY: + return visitor.visitCurrentDay(); + case ALL_TIME: + return visitor.visitAllTime(); + case CURRENT_WEEK: + return visitor.visitCurrentWeek(); + case CURRENT_MONTH: + return visitor.visitCurrentMonth(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateCompanyOverrideRequestBodyMetricPeriod valueOf(String value) { + switch (value) { + case "current_day": + return CURRENT_DAY; + case "all_time": + return ALL_TIME; + case "current_week": + return CURRENT_WEEK; + case "current_month": + return CURRENT_MONTH; + default: + return new CreateCompanyOverrideRequestBodyMetricPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + ALL_TIME, + + CURRENT_MONTH, + + CURRENT_WEEK, + + CURRENT_DAY, + + UNKNOWN + } + + public interface Visitor { + T visitAllTime(); + + T visitCurrentMonth(); + + T visitCurrentWeek(); + + T visitCurrentDay(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyMetricPeriodMonthReset.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyMetricPeriodMonthReset.java index 4dc5257..8253175 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyMetricPeriodMonthReset.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyMetricPeriodMonthReset.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateCompanyOverrideRequestBodyMetricPeriodMonthReset { - FIRST_OF_MONTH("first_of_month"), +public final class CreateCompanyOverrideRequestBodyMetricPeriodMonthReset { + public static final CreateCompanyOverrideRequestBodyMetricPeriodMonthReset FIRST_OF_MONTH = + new CreateCompanyOverrideRequestBodyMetricPeriodMonthReset(Value.FIRST_OF_MONTH, "first_of_month"); - BILLING_CYCLE("billing_cycle"); + public static final CreateCompanyOverrideRequestBodyMetricPeriodMonthReset BILLING_CYCLE = + new CreateCompanyOverrideRequestBodyMetricPeriodMonthReset(Value.BILLING_CYCLE, "billing_cycle"); - private final String value; + private final Value value; - CreateCompanyOverrideRequestBodyMetricPeriodMonthReset(String value) { + private final String string; + + CreateCompanyOverrideRequestBodyMetricPeriodMonthReset(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateCompanyOverrideRequestBodyMetricPeriodMonthReset + && this.string.equals(((CreateCompanyOverrideRequestBodyMetricPeriodMonthReset) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FIRST_OF_MONTH: + return visitor.visitFirstOfMonth(); + case BILLING_CYCLE: + return visitor.visitBillingCycle(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateCompanyOverrideRequestBodyMetricPeriodMonthReset valueOf(String value) { + switch (value) { + case "first_of_month": + return FIRST_OF_MONTH; + case "billing_cycle": + return BILLING_CYCLE; + default: + return new CreateCompanyOverrideRequestBodyMetricPeriodMonthReset(Value.UNKNOWN, value); + } + } + + public enum Value { + FIRST_OF_MONTH, + + BILLING_CYCLE, + + UNKNOWN + } + + public interface Visitor { + T visitFirstOfMonth(); + + T visitBillingCycle(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyValueType.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyValueType.java index 2e4502d..74374e5 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyValueType.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideRequestBodyValueType.java @@ -3,26 +3,117 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateCompanyOverrideRequestBodyValueType { - BOOLEAN("boolean"), +public final class CreateCompanyOverrideRequestBodyValueType { + public static final CreateCompanyOverrideRequestBodyValueType NUMERIC = + new CreateCompanyOverrideRequestBodyValueType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final CreateCompanyOverrideRequestBodyValueType TRAIT = + new CreateCompanyOverrideRequestBodyValueType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final CreateCompanyOverrideRequestBodyValueType BOOLEAN = + new CreateCompanyOverrideRequestBodyValueType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final CreateCompanyOverrideRequestBodyValueType CREDIT = + new CreateCompanyOverrideRequestBodyValueType(Value.CREDIT, "credit"); - private final String value; + public static final CreateCompanyOverrideRequestBodyValueType UNLIMITED = + new CreateCompanyOverrideRequestBodyValueType(Value.UNLIMITED, "unlimited"); - CreateCompanyOverrideRequestBodyValueType(String value) { + private final Value value; + + private final String string; + + CreateCompanyOverrideRequestBodyValueType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateCompanyOverrideRequestBodyValueType + && this.string.equals(((CreateCompanyOverrideRequestBodyValueType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case CREDIT: + return visitor.visitCredit(); + case UNLIMITED: + return visitor.visitUnlimited(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateCompanyOverrideRequestBodyValueType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "credit": + return CREDIT; + case "unlimited": + return UNLIMITED; + default: + return new CreateCompanyOverrideRequestBodyValueType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CREDIT, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCredit(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideResponse.java index dabd967..666fa98 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreateCompanyOverrideResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateCompanyOverrideResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyMetricPeriod.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyMetricPeriod.java index 398d3bb..ed9c4e9 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyMetricPeriod.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyMetricPeriod.java @@ -3,26 +3,106 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreatePlanEntitlementRequestBodyMetricPeriod { - ALL_TIME("all_time"), +public final class CreatePlanEntitlementRequestBodyMetricPeriod { + public static final CreatePlanEntitlementRequestBodyMetricPeriod CURRENT_DAY = + new CreatePlanEntitlementRequestBodyMetricPeriod(Value.CURRENT_DAY, "current_day"); - CURRENT_MONTH("current_month"), + public static final CreatePlanEntitlementRequestBodyMetricPeriod ALL_TIME = + new CreatePlanEntitlementRequestBodyMetricPeriod(Value.ALL_TIME, "all_time"); - CURRENT_WEEK("current_week"), + public static final CreatePlanEntitlementRequestBodyMetricPeriod CURRENT_WEEK = + new CreatePlanEntitlementRequestBodyMetricPeriod(Value.CURRENT_WEEK, "current_week"); - CURRENT_DAY("current_day"); + public static final CreatePlanEntitlementRequestBodyMetricPeriod CURRENT_MONTH = + new CreatePlanEntitlementRequestBodyMetricPeriod(Value.CURRENT_MONTH, "current_month"); - private final String value; + private final Value value; - CreatePlanEntitlementRequestBodyMetricPeriod(String value) { + private final String string; + + CreatePlanEntitlementRequestBodyMetricPeriod(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreatePlanEntitlementRequestBodyMetricPeriod + && this.string.equals(((CreatePlanEntitlementRequestBodyMetricPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CURRENT_DAY: + return visitor.visitCurrentDay(); + case ALL_TIME: + return visitor.visitAllTime(); + case CURRENT_WEEK: + return visitor.visitCurrentWeek(); + case CURRENT_MONTH: + return visitor.visitCurrentMonth(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreatePlanEntitlementRequestBodyMetricPeriod valueOf(String value) { + switch (value) { + case "current_day": + return CURRENT_DAY; + case "all_time": + return ALL_TIME; + case "current_week": + return CURRENT_WEEK; + case "current_month": + return CURRENT_MONTH; + default: + return new CreatePlanEntitlementRequestBodyMetricPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + ALL_TIME, + + CURRENT_MONTH, + + CURRENT_WEEK, + + CURRENT_DAY, + + UNKNOWN + } + + public interface Visitor { + T visitAllTime(); + + T visitCurrentMonth(); + + T visitCurrentWeek(); + + T visitCurrentDay(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyMetricPeriodMonthReset.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyMetricPeriodMonthReset.java index a200806..8efca18 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyMetricPeriodMonthReset.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyMetricPeriodMonthReset.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreatePlanEntitlementRequestBodyMetricPeriodMonthReset { - FIRST_OF_MONTH("first_of_month"), +public final class CreatePlanEntitlementRequestBodyMetricPeriodMonthReset { + public static final CreatePlanEntitlementRequestBodyMetricPeriodMonthReset FIRST_OF_MONTH = + new CreatePlanEntitlementRequestBodyMetricPeriodMonthReset(Value.FIRST_OF_MONTH, "first_of_month"); - BILLING_CYCLE("billing_cycle"); + public static final CreatePlanEntitlementRequestBodyMetricPeriodMonthReset BILLING_CYCLE = + new CreatePlanEntitlementRequestBodyMetricPeriodMonthReset(Value.BILLING_CYCLE, "billing_cycle"); - private final String value; + private final Value value; - CreatePlanEntitlementRequestBodyMetricPeriodMonthReset(String value) { + private final String string; + + CreatePlanEntitlementRequestBodyMetricPeriodMonthReset(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreatePlanEntitlementRequestBodyMetricPeriodMonthReset + && this.string.equals(((CreatePlanEntitlementRequestBodyMetricPeriodMonthReset) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FIRST_OF_MONTH: + return visitor.visitFirstOfMonth(); + case BILLING_CYCLE: + return visitor.visitBillingCycle(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreatePlanEntitlementRequestBodyMetricPeriodMonthReset valueOf(String value) { + switch (value) { + case "first_of_month": + return FIRST_OF_MONTH; + case "billing_cycle": + return BILLING_CYCLE; + default: + return new CreatePlanEntitlementRequestBodyMetricPeriodMonthReset(Value.UNKNOWN, value); + } + } + + public enum Value { + FIRST_OF_MONTH, + + BILLING_CYCLE, + + UNKNOWN + } + + public interface Visitor { + T visitFirstOfMonth(); + + T visitBillingCycle(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyPriceBehavior.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyPriceBehavior.java new file mode 100644 index 0000000..b83218c0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyPriceBehavior.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.entitlements.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreatePlanEntitlementRequestBodyPriceBehavior { + public static final CreatePlanEntitlementRequestBodyPriceBehavior TIER = + new CreatePlanEntitlementRequestBodyPriceBehavior(Value.TIER, "tier"); + + public static final CreatePlanEntitlementRequestBodyPriceBehavior CREDIT_BURNDOWN = + new CreatePlanEntitlementRequestBodyPriceBehavior(Value.CREDIT_BURNDOWN, "credit_burndown"); + + public static final CreatePlanEntitlementRequestBodyPriceBehavior OVERAGE = + new CreatePlanEntitlementRequestBodyPriceBehavior(Value.OVERAGE, "overage"); + + public static final CreatePlanEntitlementRequestBodyPriceBehavior PAY_AS_YOU_GO = + new CreatePlanEntitlementRequestBodyPriceBehavior(Value.PAY_AS_YOU_GO, "pay_as_you_go"); + + public static final CreatePlanEntitlementRequestBodyPriceBehavior PAY_IN_ADVANCE = + new CreatePlanEntitlementRequestBodyPriceBehavior(Value.PAY_IN_ADVANCE, "pay_in_advance"); + + private final Value value; + + private final String string; + + CreatePlanEntitlementRequestBodyPriceBehavior(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreatePlanEntitlementRequestBodyPriceBehavior + && this.string.equals(((CreatePlanEntitlementRequestBodyPriceBehavior) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case TIER: + return visitor.visitTier(); + case CREDIT_BURNDOWN: + return visitor.visitCreditBurndown(); + case OVERAGE: + return visitor.visitOverage(); + case PAY_AS_YOU_GO: + return visitor.visitPayAsYouGo(); + case PAY_IN_ADVANCE: + return visitor.visitPayInAdvance(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreatePlanEntitlementRequestBodyPriceBehavior valueOf(String value) { + switch (value) { + case "tier": + return TIER; + case "credit_burndown": + return CREDIT_BURNDOWN; + case "overage": + return OVERAGE; + case "pay_as_you_go": + return PAY_AS_YOU_GO; + case "pay_in_advance": + return PAY_IN_ADVANCE; + default: + return new CreatePlanEntitlementRequestBodyPriceBehavior(Value.UNKNOWN, value); + } + } + + public enum Value { + PAY_AS_YOU_GO, + + PAY_IN_ADVANCE, + + OVERAGE, + + CREDIT_BURNDOWN, + + TIER, + + UNKNOWN + } + + public interface Visitor { + T visitPayAsYouGo(); + + T visitPayInAdvance(); + + T visitOverage(); + + T visitCreditBurndown(); + + T visitTier(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyValueType.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyValueType.java index aa3aa5e..2eef31b 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyValueType.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementRequestBodyValueType.java @@ -3,26 +3,117 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreatePlanEntitlementRequestBodyValueType { - BOOLEAN("boolean"), +public final class CreatePlanEntitlementRequestBodyValueType { + public static final CreatePlanEntitlementRequestBodyValueType NUMERIC = + new CreatePlanEntitlementRequestBodyValueType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final CreatePlanEntitlementRequestBodyValueType TRAIT = + new CreatePlanEntitlementRequestBodyValueType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final CreatePlanEntitlementRequestBodyValueType BOOLEAN = + new CreatePlanEntitlementRequestBodyValueType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final CreatePlanEntitlementRequestBodyValueType CREDIT = + new CreatePlanEntitlementRequestBodyValueType(Value.CREDIT, "credit"); - private final String value; + public static final CreatePlanEntitlementRequestBodyValueType UNLIMITED = + new CreatePlanEntitlementRequestBodyValueType(Value.UNLIMITED, "unlimited"); - CreatePlanEntitlementRequestBodyValueType(String value) { + private final Value value; + + private final String string; + + CreatePlanEntitlementRequestBodyValueType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreatePlanEntitlementRequestBodyValueType + && this.string.equals(((CreatePlanEntitlementRequestBodyValueType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case CREDIT: + return visitor.visitCredit(); + case UNLIMITED: + return visitor.visitUnlimited(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreatePlanEntitlementRequestBodyValueType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "credit": + return CREDIT; + case "unlimited": + return UNLIMITED; + default: + return new CreatePlanEntitlementRequestBodyValueType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CREDIT, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCredit(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementResponse.java index 75f1e7f..e1da40e 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/CreatePlanEntitlementResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreatePlanEntitlementResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/DeleteCompanyOverrideResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/DeleteCompanyOverrideResponse.java index 874ecf9..55bbc0d 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/DeleteCompanyOverrideResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/DeleteCompanyOverrideResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteCompanyOverrideResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/DeletePlanEntitlementResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/DeletePlanEntitlementResponse.java index 1f4a155..7a645e2 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/DeletePlanEntitlementResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/DeletePlanEntitlementResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeletePlanEntitlementResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/GetCompanyOverrideResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/GetCompanyOverrideResponse.java index ee67c5b..ea03a2a 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/GetCompanyOverrideResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/GetCompanyOverrideResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetCompanyOverrideResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyParams.java index e8ffc11..3df0210 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyParams.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; @@ -21,18 +20,18 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GetFeatureUsageByCompanyParams.Builder.class) public final class GetFeatureUsageByCompanyParams { - private final Optional> keys; + private final Optional> keys; private final Map additionalProperties; private GetFeatureUsageByCompanyParams( - Optional> keys, Map additionalProperties) { + Optional> keys, Map additionalProperties) { this.keys = keys; this.additionalProperties = additionalProperties; } @JsonProperty("keys") - public Optional> getKeys() { + public Optional> getKeys() { return keys; } @@ -67,7 +66,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional> keys = Optional.empty(); + private Optional> keys = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -80,12 +79,12 @@ public Builder from(GetFeatureUsageByCompanyParams other) { } @JsonSetter(value = "keys", nulls = Nulls.SKIP) - public Builder keys(Optional> keys) { + public Builder keys(Optional> keys) { this.keys = keys; return this; } - public Builder keys(Map keys) { + public Builder keys(Map keys) { this.keys = Optional.ofNullable(keys); return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyResponse.java index 74f4ac0..2920eb3 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/GetFeatureUsageByCompanyResponse.java @@ -84,6 +84,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull GetFeatureUsageByCompanyParams params); } @@ -117,6 +120,7 @@ public ParamsStage data(@NotNull FeatureUsageDetailResponseData data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/GetPlanEntitlementResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/GetPlanEntitlementResponse.java index e0a6600..b10675d 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/GetPlanEntitlementResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/GetPlanEntitlementResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetPlanEntitlementResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesParams.java index 86ca1c5..03465b1 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesParams.java @@ -220,6 +220,9 @@ public Builder from(ListCompanyOverridesParams other) { return this; } + /** + *

Filter company overrides by a single company ID (starting with comp_)

+ */ @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -231,6 +234,9 @@ public Builder companyId(String companyId) { return this; } + /** + *

Filter company overrides by multiple company IDs (starting with comp_)

+ */ @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) public Builder companyIds(Optional> companyIds) { this.companyIds = companyIds; @@ -242,6 +248,9 @@ public Builder companyIds(List companyIds) { return this; } + /** + *

Filter company overrides by a single feature ID (starting with feat_)

+ */ @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) public Builder featureId(Optional featureId) { this.featureId = featureId; @@ -253,6 +262,9 @@ public Builder featureId(String featureId) { return this; } + /** + *

Filter company overrides by multiple feature IDs (starting with feat_)

+ */ @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) public Builder featureIds(Optional> featureIds) { this.featureIds = featureIds; @@ -264,6 +276,9 @@ public Builder featureIds(List featureIds) { return this; } + /** + *

Filter company overrides by multiple company override IDs (starting with cmov_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -275,6 +290,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -286,6 +304,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -297,6 +318,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Search for company overrides by feature or company name

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -308,6 +332,9 @@ public Builder q(String q) { return this; } + /** + *

Filter company overrides by whether they have not expired

+ */ @JsonSetter(value = "without_expired", nulls = Nulls.SKIP) public Builder withoutExpired(Optional withoutExpired) { this.withoutExpired = withoutExpired; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesResponse.java index 94ead84..c41fd0f 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListCompanyOverridesResponse.java @@ -38,9 +38,6 @@ private ListCompanyOverridesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListCompanyOverridesParams params); Builder from(ListCompanyOverridesResponse other); @@ -118,6 +118,7 @@ public Builder from(ListCompanyOverridesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListCompanyOverridesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(CompanyOverrideResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(CompanyOverrideResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesParams.java index e3d6ba3..ace3cfb 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesParams.java @@ -135,6 +135,9 @@ public Builder featureId(String featureId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesResponse.java index 37b8210..c9c14a9 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureCompaniesResponse.java @@ -38,9 +38,6 @@ private ListFeatureCompaniesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListFeatureCompaniesParams params); Builder from(ListFeatureCompaniesResponse other); @@ -118,6 +118,7 @@ public Builder from(ListFeatureCompaniesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListFeatureCompaniesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(FeatureCompanyResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(FeatureCompanyResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageParams.java index db0a613..b995609 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageParams.java @@ -204,6 +204,9 @@ public Builder featureIds(List featureIds) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -215,6 +218,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageResponse.java index dbae5a5..e08c608 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsageResponse.java @@ -38,9 +38,6 @@ private ListFeatureUsageResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListFeatureUsageParams params); Builder from(ListFeatureUsageResponse other); @@ -118,6 +118,7 @@ public Builder from(ListFeatureUsageResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListFeatureUsageParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(FeatureUsageResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(FeatureUsageResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersParams.java index 34927d9..6a981bd 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersParams.java @@ -135,6 +135,9 @@ public Builder featureId(String featureId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -146,6 +149,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersResponse.java index f9aa252..aa9306f 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListFeatureUsersResponse.java @@ -38,9 +38,6 @@ private ListFeatureUsersResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListFeatureUsersParams params); Builder from(ListFeatureUsersResponse other); @@ -118,6 +118,7 @@ public Builder from(ListFeatureUsersResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListFeatureUsersParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(FeatureCompanyUserResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(FeatureCompanyUserResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsParams.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsParams.java index 5305509..37f35c1 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsParams.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsParams.java @@ -220,6 +220,9 @@ public Builder from(ListPlanEntitlementsParams other) { return this; } + /** + *

Filter plan entitlements by a single feature ID (starting with feat_)

+ */ @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) public Builder featureId(Optional featureId) { this.featureId = featureId; @@ -231,6 +234,9 @@ public Builder featureId(String featureId) { return this; } + /** + *

Filter plan entitlements by multiple feature IDs (starting with feat_)

+ */ @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) public Builder featureIds(Optional> featureIds) { this.featureIds = featureIds; @@ -242,6 +248,9 @@ public Builder featureIds(List featureIds) { return this; } + /** + *

Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_)

+ */ @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -253,6 +262,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -264,6 +276,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -275,6 +290,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Filter plan entitlements by a single plan ID (starting with plan_)

+ */ @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) public Builder planId(Optional planId) { this.planId = planId; @@ -286,6 +304,9 @@ public Builder planId(String planId) { return this; } + /** + *

Filter plan entitlements by multiple plan IDs (starting with plan_)

+ */ @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) public Builder planIds(Optional> planIds) { this.planIds = planIds; @@ -297,6 +318,9 @@ public Builder planIds(List planIds) { return this; } + /** + *

Search for plan entitlements by feature or company name

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -308,6 +332,9 @@ public Builder q(String q) { return this; } + /** + *

Filter plan entitlements only with metered products

+ */ @JsonSetter(value = "with_metered_products", nulls = Nulls.SKIP) public Builder withMeteredProducts(Optional withMeteredProducts) { this.withMeteredProducts = withMeteredProducts; diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsResponse.java index b498def..3a5853b 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/ListPlanEntitlementsResponse.java @@ -38,9 +38,6 @@ private ListPlanEntitlementsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListPlanEntitlementsParams params); Builder from(ListPlanEntitlementsResponse other); @@ -118,6 +118,7 @@ public Builder from(ListPlanEntitlementsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListPlanEntitlementsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(PlanEntitlementResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(PlanEntitlementResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyMetricPeriod.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyMetricPeriod.java index 923aaaf..bd9e11e 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyMetricPeriod.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyMetricPeriod.java @@ -3,26 +3,106 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateCompanyOverrideRequestBodyMetricPeriod { - ALL_TIME("all_time"), +public final class UpdateCompanyOverrideRequestBodyMetricPeriod { + public static final UpdateCompanyOverrideRequestBodyMetricPeriod CURRENT_DAY = + new UpdateCompanyOverrideRequestBodyMetricPeriod(Value.CURRENT_DAY, "current_day"); - CURRENT_MONTH("current_month"), + public static final UpdateCompanyOverrideRequestBodyMetricPeriod ALL_TIME = + new UpdateCompanyOverrideRequestBodyMetricPeriod(Value.ALL_TIME, "all_time"); - CURRENT_WEEK("current_week"), + public static final UpdateCompanyOverrideRequestBodyMetricPeriod CURRENT_WEEK = + new UpdateCompanyOverrideRequestBodyMetricPeriod(Value.CURRENT_WEEK, "current_week"); - CURRENT_DAY("current_day"); + public static final UpdateCompanyOverrideRequestBodyMetricPeriod CURRENT_MONTH = + new UpdateCompanyOverrideRequestBodyMetricPeriod(Value.CURRENT_MONTH, "current_month"); - private final String value; + private final Value value; - UpdateCompanyOverrideRequestBodyMetricPeriod(String value) { + private final String string; + + UpdateCompanyOverrideRequestBodyMetricPeriod(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateCompanyOverrideRequestBodyMetricPeriod + && this.string.equals(((UpdateCompanyOverrideRequestBodyMetricPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CURRENT_DAY: + return visitor.visitCurrentDay(); + case ALL_TIME: + return visitor.visitAllTime(); + case CURRENT_WEEK: + return visitor.visitCurrentWeek(); + case CURRENT_MONTH: + return visitor.visitCurrentMonth(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateCompanyOverrideRequestBodyMetricPeriod valueOf(String value) { + switch (value) { + case "current_day": + return CURRENT_DAY; + case "all_time": + return ALL_TIME; + case "current_week": + return CURRENT_WEEK; + case "current_month": + return CURRENT_MONTH; + default: + return new UpdateCompanyOverrideRequestBodyMetricPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + ALL_TIME, + + CURRENT_MONTH, + + CURRENT_WEEK, + + CURRENT_DAY, + + UNKNOWN + } + + public interface Visitor { + T visitAllTime(); + + T visitCurrentMonth(); + + T visitCurrentWeek(); + + T visitCurrentDay(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset.java index 1d13e08..248693d 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset { - FIRST_OF_MONTH("first_of_month"), +public final class UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset { + public static final UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset FIRST_OF_MONTH = + new UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset(Value.FIRST_OF_MONTH, "first_of_month"); - BILLING_CYCLE("billing_cycle"); + public static final UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset BILLING_CYCLE = + new UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset(Value.BILLING_CYCLE, "billing_cycle"); - private final String value; + private final Value value; - UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset(String value) { + private final String string; + + UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset + && this.string.equals(((UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FIRST_OF_MONTH: + return visitor.visitFirstOfMonth(); + case BILLING_CYCLE: + return visitor.visitBillingCycle(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset valueOf(String value) { + switch (value) { + case "first_of_month": + return FIRST_OF_MONTH; + case "billing_cycle": + return BILLING_CYCLE; + default: + return new UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset(Value.UNKNOWN, value); + } + } + + public enum Value { + FIRST_OF_MONTH, + + BILLING_CYCLE, + + UNKNOWN + } + + public interface Visitor { + T visitFirstOfMonth(); + + T visitBillingCycle(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyValueType.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyValueType.java index 410aa79..20d5945 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyValueType.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideRequestBodyValueType.java @@ -3,26 +3,117 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateCompanyOverrideRequestBodyValueType { - BOOLEAN("boolean"), +public final class UpdateCompanyOverrideRequestBodyValueType { + public static final UpdateCompanyOverrideRequestBodyValueType NUMERIC = + new UpdateCompanyOverrideRequestBodyValueType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final UpdateCompanyOverrideRequestBodyValueType TRAIT = + new UpdateCompanyOverrideRequestBodyValueType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final UpdateCompanyOverrideRequestBodyValueType BOOLEAN = + new UpdateCompanyOverrideRequestBodyValueType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final UpdateCompanyOverrideRequestBodyValueType CREDIT = + new UpdateCompanyOverrideRequestBodyValueType(Value.CREDIT, "credit"); - private final String value; + public static final UpdateCompanyOverrideRequestBodyValueType UNLIMITED = + new UpdateCompanyOverrideRequestBodyValueType(Value.UNLIMITED, "unlimited"); - UpdateCompanyOverrideRequestBodyValueType(String value) { + private final Value value; + + private final String string; + + UpdateCompanyOverrideRequestBodyValueType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateCompanyOverrideRequestBodyValueType + && this.string.equals(((UpdateCompanyOverrideRequestBodyValueType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case CREDIT: + return visitor.visitCredit(); + case UNLIMITED: + return visitor.visitUnlimited(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateCompanyOverrideRequestBodyValueType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "credit": + return CREDIT; + case "unlimited": + return UNLIMITED; + default: + return new UpdateCompanyOverrideRequestBodyValueType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CREDIT, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCredit(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideResponse.java index 151c967..76901a4 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdateCompanyOverrideResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateCompanyOverrideResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyMetricPeriod.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyMetricPeriod.java index 22453cd..890af67 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyMetricPeriod.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyMetricPeriod.java @@ -3,26 +3,106 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdatePlanEntitlementRequestBodyMetricPeriod { - ALL_TIME("all_time"), +public final class UpdatePlanEntitlementRequestBodyMetricPeriod { + public static final UpdatePlanEntitlementRequestBodyMetricPeriod CURRENT_DAY = + new UpdatePlanEntitlementRequestBodyMetricPeriod(Value.CURRENT_DAY, "current_day"); - CURRENT_MONTH("current_month"), + public static final UpdatePlanEntitlementRequestBodyMetricPeriod ALL_TIME = + new UpdatePlanEntitlementRequestBodyMetricPeriod(Value.ALL_TIME, "all_time"); - CURRENT_WEEK("current_week"), + public static final UpdatePlanEntitlementRequestBodyMetricPeriod CURRENT_WEEK = + new UpdatePlanEntitlementRequestBodyMetricPeriod(Value.CURRENT_WEEK, "current_week"); - CURRENT_DAY("current_day"); + public static final UpdatePlanEntitlementRequestBodyMetricPeriod CURRENT_MONTH = + new UpdatePlanEntitlementRequestBodyMetricPeriod(Value.CURRENT_MONTH, "current_month"); - private final String value; + private final Value value; - UpdatePlanEntitlementRequestBodyMetricPeriod(String value) { + private final String string; + + UpdatePlanEntitlementRequestBodyMetricPeriod(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdatePlanEntitlementRequestBodyMetricPeriod + && this.string.equals(((UpdatePlanEntitlementRequestBodyMetricPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CURRENT_DAY: + return visitor.visitCurrentDay(); + case ALL_TIME: + return visitor.visitAllTime(); + case CURRENT_WEEK: + return visitor.visitCurrentWeek(); + case CURRENT_MONTH: + return visitor.visitCurrentMonth(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdatePlanEntitlementRequestBodyMetricPeriod valueOf(String value) { + switch (value) { + case "current_day": + return CURRENT_DAY; + case "all_time": + return ALL_TIME; + case "current_week": + return CURRENT_WEEK; + case "current_month": + return CURRENT_MONTH; + default: + return new UpdatePlanEntitlementRequestBodyMetricPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + ALL_TIME, + + CURRENT_MONTH, + + CURRENT_WEEK, + + CURRENT_DAY, + + UNKNOWN + } + + public interface Visitor { + T visitAllTime(); + + T visitCurrentMonth(); + + T visitCurrentWeek(); + + T visitCurrentDay(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset.java index 17c7a51..3b15761 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset { - FIRST_OF_MONTH("first_of_month"), +public final class UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset { + public static final UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset FIRST_OF_MONTH = + new UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset(Value.FIRST_OF_MONTH, "first_of_month"); - BILLING_CYCLE("billing_cycle"); + public static final UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset BILLING_CYCLE = + new UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset(Value.BILLING_CYCLE, "billing_cycle"); - private final String value; + private final Value value; - UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset(String value) { + private final String string; + + UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset + && this.string.equals(((UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FIRST_OF_MONTH: + return visitor.visitFirstOfMonth(); + case BILLING_CYCLE: + return visitor.visitBillingCycle(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset valueOf(String value) { + switch (value) { + case "first_of_month": + return FIRST_OF_MONTH; + case "billing_cycle": + return BILLING_CYCLE; + default: + return new UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset(Value.UNKNOWN, value); + } + } + + public enum Value { + FIRST_OF_MONTH, + + BILLING_CYCLE, + + UNKNOWN + } + + public interface Visitor { + T visitFirstOfMonth(); + + T visitBillingCycle(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyPriceBehavior.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyPriceBehavior.java new file mode 100644 index 0000000..d1fa89b --- /dev/null +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyPriceBehavior.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.entitlements.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UpdatePlanEntitlementRequestBodyPriceBehavior { + public static final UpdatePlanEntitlementRequestBodyPriceBehavior TIER = + new UpdatePlanEntitlementRequestBodyPriceBehavior(Value.TIER, "tier"); + + public static final UpdatePlanEntitlementRequestBodyPriceBehavior CREDIT_BURNDOWN = + new UpdatePlanEntitlementRequestBodyPriceBehavior(Value.CREDIT_BURNDOWN, "credit_burndown"); + + public static final UpdatePlanEntitlementRequestBodyPriceBehavior OVERAGE = + new UpdatePlanEntitlementRequestBodyPriceBehavior(Value.OVERAGE, "overage"); + + public static final UpdatePlanEntitlementRequestBodyPriceBehavior PAY_AS_YOU_GO = + new UpdatePlanEntitlementRequestBodyPriceBehavior(Value.PAY_AS_YOU_GO, "pay_as_you_go"); + + public static final UpdatePlanEntitlementRequestBodyPriceBehavior PAY_IN_ADVANCE = + new UpdatePlanEntitlementRequestBodyPriceBehavior(Value.PAY_IN_ADVANCE, "pay_in_advance"); + + private final Value value; + + private final String string; + + UpdatePlanEntitlementRequestBodyPriceBehavior(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdatePlanEntitlementRequestBodyPriceBehavior + && this.string.equals(((UpdatePlanEntitlementRequestBodyPriceBehavior) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case TIER: + return visitor.visitTier(); + case CREDIT_BURNDOWN: + return visitor.visitCreditBurndown(); + case OVERAGE: + return visitor.visitOverage(); + case PAY_AS_YOU_GO: + return visitor.visitPayAsYouGo(); + case PAY_IN_ADVANCE: + return visitor.visitPayInAdvance(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdatePlanEntitlementRequestBodyPriceBehavior valueOf(String value) { + switch (value) { + case "tier": + return TIER; + case "credit_burndown": + return CREDIT_BURNDOWN; + case "overage": + return OVERAGE; + case "pay_as_you_go": + return PAY_AS_YOU_GO; + case "pay_in_advance": + return PAY_IN_ADVANCE; + default: + return new UpdatePlanEntitlementRequestBodyPriceBehavior(Value.UNKNOWN, value); + } + } + + public enum Value { + PAY_AS_YOU_GO, + + PAY_IN_ADVANCE, + + OVERAGE, + + CREDIT_BURNDOWN, + + TIER, + + UNKNOWN + } + + public interface Visitor { + T visitPayAsYouGo(); + + T visitPayInAdvance(); + + T visitOverage(); + + T visitCreditBurndown(); + + T visitTier(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyValueType.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyValueType.java index dc5ce7f..a50be7c 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyValueType.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementRequestBodyValueType.java @@ -3,26 +3,117 @@ */ package com.schematic.api.resources.entitlements.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdatePlanEntitlementRequestBodyValueType { - BOOLEAN("boolean"), +public final class UpdatePlanEntitlementRequestBodyValueType { + public static final UpdatePlanEntitlementRequestBodyValueType NUMERIC = + new UpdatePlanEntitlementRequestBodyValueType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final UpdatePlanEntitlementRequestBodyValueType TRAIT = + new UpdatePlanEntitlementRequestBodyValueType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final UpdatePlanEntitlementRequestBodyValueType BOOLEAN = + new UpdatePlanEntitlementRequestBodyValueType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final UpdatePlanEntitlementRequestBodyValueType CREDIT = + new UpdatePlanEntitlementRequestBodyValueType(Value.CREDIT, "credit"); - private final String value; + public static final UpdatePlanEntitlementRequestBodyValueType UNLIMITED = + new UpdatePlanEntitlementRequestBodyValueType(Value.UNLIMITED, "unlimited"); - UpdatePlanEntitlementRequestBodyValueType(String value) { + private final Value value; + + private final String string; + + UpdatePlanEntitlementRequestBodyValueType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdatePlanEntitlementRequestBodyValueType + && this.string.equals(((UpdatePlanEntitlementRequestBodyValueType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case CREDIT: + return visitor.visitCredit(); + case UNLIMITED: + return visitor.visitUnlimited(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdatePlanEntitlementRequestBodyValueType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "credit": + return CREDIT; + case "unlimited": + return UNLIMITED; + default: + return new UpdatePlanEntitlementRequestBodyValueType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CREDIT, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCredit(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementResponse.java b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementResponse.java index a188552..99a80ee 100644 --- a/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementResponse.java +++ b/src/main/java/com/schematic/api/resources/entitlements/types/UpdatePlanEntitlementResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdatePlanEntitlementResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/events/AsyncEventsClient.java b/src/main/java/com/schematic/api/resources/events/AsyncEventsClient.java new file mode 100644 index 0000000..2ead712 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/AsyncEventsClient.java @@ -0,0 +1,96 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; +import com.schematic.api.resources.events.requests.GetEventSummariesRequest; +import com.schematic.api.resources.events.requests.ListEventsRequest; +import com.schematic.api.resources.events.types.CreateEventBatchResponse; +import com.schematic.api.resources.events.types.CreateEventResponse; +import com.schematic.api.resources.events.types.GetEventResponse; +import com.schematic.api.resources.events.types.GetEventSummariesResponse; +import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; +import com.schematic.api.resources.events.types.ListEventsResponse; +import com.schematic.api.types.CreateEventRequestBody; +import java.util.concurrent.CompletableFuture; + +public class AsyncEventsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEventsClient rawClient; + + public AsyncEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEventsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEventsClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture createEventBatch(CreateEventBatchRequestBody request) { + return this.rawClient.createEventBatch(request).thenApply(response -> response.body()); + } + + public CompletableFuture createEventBatch( + CreateEventBatchRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createEventBatch(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getEventSummaries() { + return this.rawClient.getEventSummaries().thenApply(response -> response.body()); + } + + public CompletableFuture getEventSummaries(GetEventSummariesRequest request) { + return this.rawClient.getEventSummaries(request).thenApply(response -> response.body()); + } + + public CompletableFuture getEventSummaries( + GetEventSummariesRequest request, RequestOptions requestOptions) { + return this.rawClient.getEventSummaries(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listEvents() { + return this.rawClient.listEvents().thenApply(response -> response.body()); + } + + public CompletableFuture listEvents(ListEventsRequest request) { + return this.rawClient.listEvents(request).thenApply(response -> response.body()); + } + + public CompletableFuture listEvents(ListEventsRequest request, RequestOptions requestOptions) { + return this.rawClient.listEvents(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createEvent(CreateEventRequestBody request) { + return this.rawClient.createEvent(request).thenApply(response -> response.body()); + } + + public CompletableFuture createEvent( + CreateEventRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createEvent(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getEvent(String eventId) { + return this.rawClient.getEvent(eventId).thenApply(response -> response.body()); + } + + public CompletableFuture getEvent(String eventId, RequestOptions requestOptions) { + return this.rawClient.getEvent(eventId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getSegmentIntegrationStatus() { + return this.rawClient.getSegmentIntegrationStatus().thenApply(response -> response.body()); + } + + public CompletableFuture getSegmentIntegrationStatus( + RequestOptions requestOptions) { + return this.rawClient.getSegmentIntegrationStatus(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java b/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java new file mode 100644 index 0000000..1e22ad9 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/AsyncRawEventsClient.java @@ -0,0 +1,606 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; +import com.schematic.api.resources.events.requests.GetEventSummariesRequest; +import com.schematic.api.resources.events.requests.ListEventsRequest; +import com.schematic.api.resources.events.types.CreateEventBatchResponse; +import com.schematic.api.resources.events.types.CreateEventResponse; +import com.schematic.api.resources.events.types.GetEventResponse; +import com.schematic.api.resources.events.types.GetEventSummariesResponse; +import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; +import com.schematic.api.resources.events.types.ListEventsResponse; +import com.schematic.api.types.ApiError; +import com.schematic.api.types.CreateEventRequestBody; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEventsClient { + protected final ClientOptions clientOptions; + + public AsyncRawEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> createEventBatch( + CreateEventBatchRequestBody request) { + return createEventBatch(request, null); + } + + public CompletableFuture> createEventBatch( + CreateEventBatchRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("event-batch") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreateEventBatchResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getEventSummaries() { + return getEventSummaries(GetEventSummariesRequest.builder().build()); + } + + public CompletableFuture> getEventSummaries( + GetEventSummariesRequest request) { + return getEventSummaries(request, null); + } + + public CompletableFuture> getEventSummaries( + GetEventSummariesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("event-types"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getEventSubtypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_subtypes", request.getEventSubtypes().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetEventSummariesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listEvents() { + return listEvents(ListEventsRequest.builder().build()); + } + + public CompletableFuture> listEvents(ListEventsRequest request) { + return listEvents(request, null); + } + + public CompletableFuture> listEvents( + ListEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getEventSubtype().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_subtype", request.getEventSubtype().get(), false); + } + if (request.getFlagId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "flag_id", request.getFlagId().get(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getEventTypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_types", request.getEventTypes().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListEventsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createEvent( + CreateEventRequestBody request) { + return createEvent(request, null); + } + + public CompletableFuture> createEvent( + CreateEventRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateEventResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getEvent(String eventId) { + return getEvent(eventId, null); + } + + public CompletableFuture> getEvent( + String eventId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events") + .addPathSegment(eventId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetEventResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + getSegmentIntegrationStatus() { + return getSegmentIntegrationStatus(null); + } + + public CompletableFuture> + getSegmentIntegrationStatus(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segment-integration") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetSegmentIntegrationStatusResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/events/EventsClient.java b/src/main/java/com/schematic/api/resources/events/EventsClient.java index e253a96..164fa71 100644 --- a/src/main/java/com/schematic/api/resources/events/EventsClient.java +++ b/src/main/java/com/schematic/api/resources/events/EventsClient.java @@ -3,18 +3,8 @@ */ package com.schematic.api.resources.events; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.NotFoundError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; import com.schematic.api.resources.events.requests.GetEventSummariesRequest; import com.schematic.api.resources.events.requests.ListEventsRequest; @@ -24,397 +14,80 @@ import com.schematic.api.resources.events.types.GetEventSummariesResponse; import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; import com.schematic.api.resources.events.types.ListEventsResponse; -import com.schematic.api.types.ApiError; import com.schematic.api.types.CreateEventRequestBody; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EventsClient { protected final ClientOptions clientOptions; + private final RawEventsClient rawClient; + public EventsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEventsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEventsClient withRawResponse() { + return this.rawClient; } public CreateEventBatchResponse createEventBatch(CreateEventBatchRequestBody request) { - return createEventBatch(request, null); + return this.rawClient.createEventBatch(request).body(); } public CreateEventBatchResponse createEventBatch( CreateEventBatchRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("event-batch") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateEventBatchResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.createEventBatch(request, requestOptions).body(); } public GetEventSummariesResponse getEventSummaries() { - return getEventSummaries(GetEventSummariesRequest.builder().build()); + return this.rawClient.getEventSummaries().body(); } public GetEventSummariesResponse getEventSummaries(GetEventSummariesRequest request) { - return getEventSummaries(request, null); + return this.rawClient.getEventSummaries(request).body(); } public GetEventSummariesResponse getEventSummaries( GetEventSummariesRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("event-types"); - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getEventSubtypes().isPresent()) { - httpUrl.addQueryParameter( - "event_subtypes", request.getEventSubtypes().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetEventSummariesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getEventSummaries(request, requestOptions).body(); } public ListEventsResponse listEvents() { - return listEvents(ListEventsRequest.builder().build()); + return this.rawClient.listEvents().body(); } public ListEventsResponse listEvents(ListEventsRequest request) { - return listEvents(request, null); + return this.rawClient.listEvents(request).body(); } public ListEventsResponse listEvents(ListEventsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("events"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getEventSubtype().isPresent()) { - httpUrl.addQueryParameter("event_subtype", request.getEventSubtype().get()); - } - if (request.getEventTypes().isPresent()) { - httpUrl.addQueryParameter("event_types", request.getEventTypes().get()); - } - if (request.getFlagId().isPresent()) { - httpUrl.addQueryParameter("flag_id", request.getFlagId().get()); - } - if (request.getUserId().isPresent()) { - httpUrl.addQueryParameter("user_id", request.getUserId().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListEventsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listEvents(request, requestOptions).body(); } public CreateEventResponse createEvent(CreateEventRequestBody request) { - return createEvent(request, null); + return this.rawClient.createEvent(request).body(); } public CreateEventResponse createEvent(CreateEventRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("events") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateEventResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.createEvent(request, requestOptions).body(); } public GetEventResponse getEvent(String eventId) { - return getEvent(eventId, null); + return this.rawClient.getEvent(eventId).body(); } public GetEventResponse getEvent(String eventId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("events") - .addPathSegment(eventId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetEventResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getEvent(eventId, requestOptions).body(); } public GetSegmentIntegrationStatusResponse getSegmentIntegrationStatus() { - return getSegmentIntegrationStatus(null); + return this.rawClient.getSegmentIntegrationStatus().body(); } public GetSegmentIntegrationStatusResponse getSegmentIntegrationStatus(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("segment-integration") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), GetSegmentIntegrationStatusResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getSegmentIntegrationStatus(requestOptions).body(); } } diff --git a/src/main/java/com/schematic/api/resources/events/RawEventsClient.java b/src/main/java/com/schematic/api/resources/events/RawEventsClient.java new file mode 100644 index 0000000..7f6534c --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/RawEventsClient.java @@ -0,0 +1,458 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; +import com.schematic.api.resources.events.requests.GetEventSummariesRequest; +import com.schematic.api.resources.events.requests.ListEventsRequest; +import com.schematic.api.resources.events.types.CreateEventBatchResponse; +import com.schematic.api.resources.events.types.CreateEventResponse; +import com.schematic.api.resources.events.types.GetEventResponse; +import com.schematic.api.resources.events.types.GetEventSummariesResponse; +import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; +import com.schematic.api.resources.events.types.ListEventsResponse; +import com.schematic.api.types.ApiError; +import com.schematic.api.types.CreateEventRequestBody; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEventsClient { + protected final ClientOptions clientOptions; + + public RawEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse createEventBatch(CreateEventBatchRequestBody request) { + return createEventBatch(request, null); + } + + public BaseSchematicHttpResponse createEventBatch( + CreateEventBatchRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("event-batch") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateEventBatchResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getEventSummaries() { + return getEventSummaries(GetEventSummariesRequest.builder().build()); + } + + public BaseSchematicHttpResponse getEventSummaries(GetEventSummariesRequest request) { + return getEventSummaries(request, null); + } + + public BaseSchematicHttpResponse getEventSummaries( + GetEventSummariesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("event-types"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getEventSubtypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_subtypes", request.getEventSubtypes().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetEventSummariesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listEvents() { + return listEvents(ListEventsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listEvents(ListEventsRequest request) { + return listEvents(request, null); + } + + public BaseSchematicHttpResponse listEvents( + ListEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getEventSubtype().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_subtype", request.getEventSubtype().get(), false); + } + if (request.getFlagId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "flag_id", request.getFlagId().get(), false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getEventTypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_types", request.getEventTypes().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListEventsResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createEvent(CreateEventRequestBody request) { + return createEvent(request, null); + } + + public BaseSchematicHttpResponse createEvent( + CreateEventRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateEventResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getEvent(String eventId) { + return getEvent(eventId, null); + } + + public BaseSchematicHttpResponse getEvent(String eventId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events") + .addPathSegment(eventId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetEventResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getSegmentIntegrationStatus() { + return getSegmentIntegrationStatus(null); + } + + public BaseSchematicHttpResponse getSegmentIntegrationStatus( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segment-integration") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetSegmentIntegrationStatusResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/events/requests/CreateEventBatchRequestBody.java b/src/main/java/com/schematic/api/resources/events/requests/CreateEventBatchRequestBody.java index 5eb5a3b..bf2de32 100644 --- a/src/main/java/com/schematic/api/resources/events/requests/CreateEventBatchRequestBody.java +++ b/src/main/java/com/schematic/api/resources/events/requests/CreateEventBatchRequestBody.java @@ -82,7 +82,9 @@ public Builder from(CreateEventBatchRequestBody other) { @JsonSetter(value = "events", nulls = Nulls.SKIP) public Builder events(List events) { this.events.clear(); - this.events.addAll(events); + if (events != null) { + this.events.addAll(events); + } return this; } @@ -92,7 +94,9 @@ public Builder addEvents(CreateEventRequestBody events) { } public Builder addAllEvents(List events) { - this.events.addAll(events); + if (events != null) { + this.events.addAll(events); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/events/requests/GetEventSummariesRequest.java b/src/main/java/com/schematic/api/resources/events/requests/GetEventSummariesRequest.java index 8d273b7..56b2ed5 100644 --- a/src/main/java/com/schematic/api/resources/events/requests/GetEventSummariesRequest.java +++ b/src/main/java/com/schematic/api/resources/events/requests/GetEventSummariesRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,9 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GetEventSummariesRequest.Builder.class) public final class GetEventSummariesRequest { - private final Optional q; + private final Optional> eventSubtypes; - private final Optional eventSubtypes; + private final Optional q; private final Optional limit; @@ -31,28 +33,28 @@ public final class GetEventSummariesRequest { private final Map additionalProperties; private GetEventSummariesRequest( + Optional> eventSubtypes, Optional q, - Optional eventSubtypes, Optional limit, Optional offset, Map additionalProperties) { - this.q = q; this.eventSubtypes = eventSubtypes; + this.q = q; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } + @JsonProperty("event_subtypes") + public Optional> getEventSubtypes() { + return eventSubtypes; + } + @JsonProperty("q") public Optional getQ() { return q; } - @JsonProperty("event_subtypes") - public Optional getEventSubtypes() { - return eventSubtypes; - } - /** * @return Page limit (default 100) */ @@ -81,15 +83,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(GetEventSummariesRequest other) { - return q.equals(other.q) - && eventSubtypes.equals(other.eventSubtypes) + return eventSubtypes.equals(other.eventSubtypes) + && q.equals(other.q) && limit.equals(other.limit) && offset.equals(other.offset); } @java.lang.Override public int hashCode() { - return Objects.hash(this.q, this.eventSubtypes, this.limit, this.offset); + return Objects.hash(this.eventSubtypes, this.q, this.limit, this.offset); } @java.lang.Override @@ -103,9 +105,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional q = Optional.empty(); + private Optional> eventSubtypes = Optional.empty(); - private Optional eventSubtypes = Optional.empty(); + private Optional q = Optional.empty(); private Optional limit = Optional.empty(); @@ -117,35 +119,43 @@ public static final class Builder { private Builder() {} public Builder from(GetEventSummariesRequest other) { - q(other.getQ()); eventSubtypes(other.getEventSubtypes()); + q(other.getQ()); limit(other.getLimit()); offset(other.getOffset()); return this; } - @JsonSetter(value = "q", nulls = Nulls.SKIP) - public Builder q(Optional q) { - this.q = q; + @JsonSetter(value = "event_subtypes", nulls = Nulls.SKIP) + public Builder eventSubtypes(Optional> eventSubtypes) { + this.eventSubtypes = eventSubtypes; return this; } - public Builder q(String q) { - this.q = Optional.ofNullable(q); + public Builder eventSubtypes(List eventSubtypes) { + this.eventSubtypes = Optional.ofNullable(eventSubtypes); return this; } - @JsonSetter(value = "event_subtypes", nulls = Nulls.SKIP) - public Builder eventSubtypes(Optional eventSubtypes) { - this.eventSubtypes = eventSubtypes; + public Builder eventSubtypes(String eventSubtypes) { + this.eventSubtypes = Optional.of(Collections.singletonList(eventSubtypes)); return this; } - public Builder eventSubtypes(String eventSubtypes) { - this.eventSubtypes = Optional.ofNullable(eventSubtypes); + @JsonSetter(value = "q", nulls = Nulls.SKIP) + public Builder q(Optional q) { + this.q = q; + return this; + } + + public Builder q(String q) { + this.q = Optional.ofNullable(q); return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -157,6 +167,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -169,7 +182,7 @@ public Builder offset(Integer offset) { } public GetEventSummariesRequest build() { - return new GetEventSummariesRequest(q, eventSubtypes, limit, offset, additionalProperties); + return new GetEventSummariesRequest(eventSubtypes, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/events/requests/ListEventsRequest.java b/src/main/java/com/schematic/api/resources/events/requests/ListEventsRequest.java index f89d537..e666f03 100644 --- a/src/main/java/com/schematic/api/resources/events/requests/ListEventsRequest.java +++ b/src/main/java/com/schematic/api/resources/events/requests/ListEventsRequest.java @@ -12,7 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.events.types.ListEventsRequestEventTypesItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,12 +23,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListEventsRequest.Builder.class) public final class ListEventsRequest { + private final Optional> eventTypes; + private final Optional companyId; private final Optional eventSubtype; - private final Optional eventTypes; - private final Optional flagId; private final Optional userId; @@ -37,17 +40,17 @@ public final class ListEventsRequest { private final Map additionalProperties; private ListEventsRequest( + Optional> eventTypes, Optional companyId, Optional eventSubtype, - Optional eventTypes, Optional flagId, Optional userId, Optional limit, Optional offset, Map additionalProperties) { + this.eventTypes = eventTypes; this.companyId = companyId; this.eventSubtype = eventSubtype; - this.eventTypes = eventTypes; this.flagId = flagId; this.userId = userId; this.limit = limit; @@ -55,6 +58,11 @@ private ListEventsRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("event_types") + public Optional> getEventTypes() { + return eventTypes; + } + @JsonProperty("company_id") public Optional getCompanyId() { return companyId; @@ -65,11 +73,6 @@ public Optional getEventSubtype() { return eventSubtype; } - @JsonProperty("event_types") - public Optional getEventTypes() { - return eventTypes; - } - @JsonProperty("flag_id") public Optional getFlagId() { return flagId; @@ -108,9 +111,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListEventsRequest other) { - return companyId.equals(other.companyId) + return eventTypes.equals(other.eventTypes) + && companyId.equals(other.companyId) && eventSubtype.equals(other.eventSubtype) - && eventTypes.equals(other.eventTypes) && flagId.equals(other.flagId) && userId.equals(other.userId) && limit.equals(other.limit) @@ -120,7 +123,7 @@ private boolean equalTo(ListEventsRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.companyId, this.eventSubtype, this.eventTypes, this.flagId, this.userId, this.limit, this.offset); + this.eventTypes, this.companyId, this.eventSubtype, this.flagId, this.userId, this.limit, this.offset); } @java.lang.Override @@ -134,12 +137,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> eventTypes = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional eventSubtype = Optional.empty(); - private Optional eventTypes = Optional.empty(); - private Optional flagId = Optional.empty(); private Optional userId = Optional.empty(); @@ -154,9 +157,9 @@ public static final class Builder { private Builder() {} public Builder from(ListEventsRequest other) { + eventTypes(other.getEventTypes()); companyId(other.getCompanyId()); eventSubtype(other.getEventSubtype()); - eventTypes(other.getEventTypes()); flagId(other.getFlagId()); userId(other.getUserId()); limit(other.getLimit()); @@ -164,6 +167,22 @@ public Builder from(ListEventsRequest other) { return this; } + @JsonSetter(value = "event_types", nulls = Nulls.SKIP) + public Builder eventTypes(Optional> eventTypes) { + this.eventTypes = eventTypes; + return this; + } + + public Builder eventTypes(List eventTypes) { + this.eventTypes = Optional.ofNullable(eventTypes); + return this; + } + + public Builder eventTypes(ListEventsRequestEventTypesItem eventTypes) { + this.eventTypes = Optional.of(Collections.singletonList(eventTypes)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -186,17 +205,6 @@ public Builder eventSubtype(String eventSubtype) { return this; } - @JsonSetter(value = "event_types", nulls = Nulls.SKIP) - public Builder eventTypes(Optional eventTypes) { - this.eventTypes = eventTypes; - return this; - } - - public Builder eventTypes(String eventTypes) { - this.eventTypes = Optional.ofNullable(eventTypes); - return this; - } - @JsonSetter(value = "flag_id", nulls = Nulls.SKIP) public Builder flagId(Optional flagId) { this.flagId = flagId; @@ -219,6 +227,9 @@ public Builder userId(String userId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -230,6 +241,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -243,7 +257,7 @@ public Builder offset(Integer offset) { public ListEventsRequest build() { return new ListEventsRequest( - companyId, eventSubtype, eventTypes, flagId, userId, limit, offset, additionalProperties); + eventTypes, companyId, eventSubtype, flagId, userId, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/events/types/CreateEventBatchResponse.java b/src/main/java/com/schematic/api/resources/events/types/CreateEventBatchResponse.java index 076c40b..0c666cf 100644 --- a/src/main/java/com/schematic/api/resources/events/types/CreateEventBatchResponse.java +++ b/src/main/java/com/schematic/api/resources/events/types/CreateEventBatchResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateEventBatchResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/events/types/CreateEventResponse.java b/src/main/java/com/schematic/api/resources/events/types/CreateEventResponse.java index 6460478..3ce6a4d 100644 --- a/src/main/java/com/schematic/api/resources/events/types/CreateEventResponse.java +++ b/src/main/java/com/schematic/api/resources/events/types/CreateEventResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateEventResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/events/types/GetEventResponse.java b/src/main/java/com/schematic/api/resources/events/types/GetEventResponse.java index 8306c7c..94cc93b 100644 --- a/src/main/java/com/schematic/api/resources/events/types/GetEventResponse.java +++ b/src/main/java/com/schematic/api/resources/events/types/GetEventResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetEventResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesParams.java b/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesParams.java index 79e368d..8d0b076 100644 --- a/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesParams.java +++ b/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesParams.java @@ -136,6 +136,9 @@ public Builder eventSubtypes(List eventSubtypes) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -147,6 +150,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesResponse.java b/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesResponse.java index 10ac650..189912a 100644 --- a/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesResponse.java +++ b/src/main/java/com/schematic/api/resources/events/types/GetEventSummariesResponse.java @@ -38,9 +38,6 @@ private GetEventSummariesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull GetEventSummariesParams params); Builder from(GetEventSummariesResponse other); @@ -118,6 +118,7 @@ public Builder from(GetEventSummariesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull GetEventSummariesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(EventSummaryResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(EventSummaryResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/events/types/GetSegmentIntegrationStatusResponse.java b/src/main/java/com/schematic/api/resources/events/types/GetSegmentIntegrationStatusResponse.java index 9d6cc35..acb9033 100644 --- a/src/main/java/com/schematic/api/resources/events/types/GetSegmentIntegrationStatusResponse.java +++ b/src/main/java/com/schematic/api/resources/events/types/GetSegmentIntegrationStatusResponse.java @@ -88,6 +88,9 @@ public interface DataStage { public interface _FinalStage { GetSegmentIntegrationStatusResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -136,15 +139,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/events/types/ListEventsParams.java b/src/main/java/com/schematic/api/resources/events/types/ListEventsParams.java index 06c04d5..be694cd 100644 --- a/src/main/java/com/schematic/api/resources/events/types/ListEventsParams.java +++ b/src/main/java/com/schematic/api/resources/events/types/ListEventsParams.java @@ -25,7 +25,7 @@ public final class ListEventsParams { private final Optional eventSubtype; - private final Optional> eventTypes; + private final Optional> eventTypes; private final Optional flagId; @@ -40,7 +40,7 @@ public final class ListEventsParams { private ListEventsParams( Optional companyId, Optional eventSubtype, - Optional> eventTypes, + Optional> eventTypes, Optional flagId, Optional limit, Optional offset, @@ -67,7 +67,7 @@ public Optional getEventSubtype() { } @JsonProperty("event_types") - public Optional> getEventTypes() { + public Optional> getEventTypes() { return eventTypes; } @@ -139,7 +139,7 @@ public static final class Builder { private Optional eventSubtype = Optional.empty(); - private Optional> eventTypes = Optional.empty(); + private Optional> eventTypes = Optional.empty(); private Optional flagId = Optional.empty(); @@ -188,12 +188,12 @@ public Builder eventSubtype(String eventSubtype) { } @JsonSetter(value = "event_types", nulls = Nulls.SKIP) - public Builder eventTypes(Optional> eventTypes) { + public Builder eventTypes(Optional> eventTypes) { this.eventTypes = eventTypes; return this; } - public Builder eventTypes(List eventTypes) { + public Builder eventTypes(List eventTypes) { this.eventTypes = Optional.ofNullable(eventTypes); return this; } @@ -209,6 +209,9 @@ public Builder flagId(String flagId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -220,6 +223,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/events/types/ListEventsRequestEventTypesItem.java b/src/main/java/com/schematic/api/resources/events/types/ListEventsRequestEventTypesItem.java new file mode 100644 index 0000000..f4a67b0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/types/ListEventsRequestEventTypesItem.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListEventsRequestEventTypesItem { + public static final ListEventsRequestEventTypesItem FLAG_CHECK = + new ListEventsRequestEventTypesItem(Value.FLAG_CHECK, "flag_check"); + + public static final ListEventsRequestEventTypesItem TRACK = + new ListEventsRequestEventTypesItem(Value.TRACK, "track"); + + public static final ListEventsRequestEventTypesItem IDENTIFY = + new ListEventsRequestEventTypesItem(Value.IDENTIFY, "identify"); + + private final Value value; + + private final String string; + + ListEventsRequestEventTypesItem(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListEventsRequestEventTypesItem + && this.string.equals(((ListEventsRequestEventTypesItem) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FLAG_CHECK: + return visitor.visitFlagCheck(); + case TRACK: + return visitor.visitTrack(); + case IDENTIFY: + return visitor.visitIdentify(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListEventsRequestEventTypesItem valueOf(String value) { + switch (value) { + case "flag_check": + return FLAG_CHECK; + case "track": + return TRACK; + case "identify": + return IDENTIFY; + default: + return new ListEventsRequestEventTypesItem(Value.UNKNOWN, value); + } + } + + public enum Value { + IDENTIFY, + + TRACK, + + FLAG_CHECK, + + UNKNOWN + } + + public interface Visitor { + T visitIdentify(); + + T visitTrack(); + + T visitFlagCheck(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/events/types/ListEventsResponse.java b/src/main/java/com/schematic/api/resources/events/types/ListEventsResponse.java index 9bc689d..b3df23f 100644 --- a/src/main/java/com/schematic/api/resources/events/types/ListEventsResponse.java +++ b/src/main/java/com/schematic/api/resources/events/types/ListEventsResponse.java @@ -36,9 +36,6 @@ private ListEventsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListEventsParams params); Builder from(ListEventsResponse other); @@ -116,6 +116,7 @@ public Builder from(ListEventsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListEventsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(EventDetailResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(EventDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/events/types/ListEventsResponseParamsEventTypesItem.java b/src/main/java/com/schematic/api/resources/events/types/ListEventsResponseParamsEventTypesItem.java new file mode 100644 index 0000000..d9602f1 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/events/types/ListEventsResponseParamsEventTypesItem.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.events.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListEventsResponseParamsEventTypesItem { + public static final ListEventsResponseParamsEventTypesItem FLAG_CHECK = + new ListEventsResponseParamsEventTypesItem(Value.FLAG_CHECK, "flag_check"); + + public static final ListEventsResponseParamsEventTypesItem TRACK = + new ListEventsResponseParamsEventTypesItem(Value.TRACK, "track"); + + public static final ListEventsResponseParamsEventTypesItem IDENTIFY = + new ListEventsResponseParamsEventTypesItem(Value.IDENTIFY, "identify"); + + private final Value value; + + private final String string; + + ListEventsResponseParamsEventTypesItem(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListEventsResponseParamsEventTypesItem + && this.string.equals(((ListEventsResponseParamsEventTypesItem) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FLAG_CHECK: + return visitor.visitFlagCheck(); + case TRACK: + return visitor.visitTrack(); + case IDENTIFY: + return visitor.visitIdentify(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListEventsResponseParamsEventTypesItem valueOf(String value) { + switch (value) { + case "flag_check": + return FLAG_CHECK; + case "track": + return TRACK; + case "identify": + return IDENTIFY; + default: + return new ListEventsResponseParamsEventTypesItem(Value.UNKNOWN, value); + } + } + + public enum Value { + IDENTIFY, + + TRACK, + + FLAG_CHECK, + + UNKNOWN + } + + public interface Visitor { + T visitIdentify(); + + T visitTrack(); + + T visitFlagCheck(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/features/AsyncFeaturesClient.java b/src/main/java/com/schematic/api/resources/features/AsyncFeaturesClient.java new file mode 100644 index 0000000..3eb9b96 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/features/AsyncFeaturesClient.java @@ -0,0 +1,208 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.features; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.features.requests.CountFeaturesRequest; +import com.schematic.api.resources.features.requests.CountFlagsRequest; +import com.schematic.api.resources.features.requests.CreateFeatureRequestBody; +import com.schematic.api.resources.features.requests.ListFeaturesRequest; +import com.schematic.api.resources.features.requests.ListFlagsRequest; +import com.schematic.api.resources.features.requests.UpdateFeatureRequestBody; +import com.schematic.api.resources.features.requests.UpdateFlagRulesRequestBody; +import com.schematic.api.resources.features.types.CheckFlagResponse; +import com.schematic.api.resources.features.types.CheckFlagsResponse; +import com.schematic.api.resources.features.types.CountFeaturesResponse; +import com.schematic.api.resources.features.types.CountFlagsResponse; +import com.schematic.api.resources.features.types.CreateFeatureResponse; +import com.schematic.api.resources.features.types.CreateFlagResponse; +import com.schematic.api.resources.features.types.DeleteFeatureResponse; +import com.schematic.api.resources.features.types.DeleteFlagResponse; +import com.schematic.api.resources.features.types.GetFeatureResponse; +import com.schematic.api.resources.features.types.GetFlagResponse; +import com.schematic.api.resources.features.types.ListFeaturesResponse; +import com.schematic.api.resources.features.types.ListFlagsResponse; +import com.schematic.api.resources.features.types.UpdateFeatureResponse; +import com.schematic.api.resources.features.types.UpdateFlagResponse; +import com.schematic.api.resources.features.types.UpdateFlagRulesResponse; +import com.schematic.api.types.CheckFlagRequestBody; +import com.schematic.api.types.CreateFlagRequestBody; +import java.util.concurrent.CompletableFuture; + +public class AsyncFeaturesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFeaturesClient rawClient; + + public AsyncFeaturesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFeaturesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFeaturesClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture listFeatures() { + return this.rawClient.listFeatures().thenApply(response -> response.body()); + } + + public CompletableFuture listFeatures(ListFeaturesRequest request) { + return this.rawClient.listFeatures(request).thenApply(response -> response.body()); + } + + public CompletableFuture listFeatures( + ListFeaturesRequest request, RequestOptions requestOptions) { + return this.rawClient.listFeatures(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createFeature(CreateFeatureRequestBody request) { + return this.rawClient.createFeature(request).thenApply(response -> response.body()); + } + + public CompletableFuture createFeature( + CreateFeatureRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createFeature(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getFeature(String featureId) { + return this.rawClient.getFeature(featureId).thenApply(response -> response.body()); + } + + public CompletableFuture getFeature(String featureId, RequestOptions requestOptions) { + return this.rawClient.getFeature(featureId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateFeature(String featureId) { + return this.rawClient.updateFeature(featureId).thenApply(response -> response.body()); + } + + public CompletableFuture updateFeature(String featureId, UpdateFeatureRequestBody request) { + return this.rawClient.updateFeature(featureId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateFeature( + String featureId, UpdateFeatureRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateFeature(featureId, request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteFeature(String featureId) { + return this.rawClient.deleteFeature(featureId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteFeature(String featureId, RequestOptions requestOptions) { + return this.rawClient.deleteFeature(featureId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countFeatures() { + return this.rawClient.countFeatures().thenApply(response -> response.body()); + } + + public CompletableFuture countFeatures(CountFeaturesRequest request) { + return this.rawClient.countFeatures(request).thenApply(response -> response.body()); + } + + public CompletableFuture countFeatures( + CountFeaturesRequest request, RequestOptions requestOptions) { + return this.rawClient.countFeatures(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listFlags() { + return this.rawClient.listFlags().thenApply(response -> response.body()); + } + + public CompletableFuture listFlags(ListFlagsRequest request) { + return this.rawClient.listFlags(request).thenApply(response -> response.body()); + } + + public CompletableFuture listFlags(ListFlagsRequest request, RequestOptions requestOptions) { + return this.rawClient.listFlags(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createFlag(CreateFlagRequestBody request) { + return this.rawClient.createFlag(request).thenApply(response -> response.body()); + } + + public CompletableFuture createFlag( + CreateFlagRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createFlag(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getFlag(String flagId) { + return this.rawClient.getFlag(flagId).thenApply(response -> response.body()); + } + + public CompletableFuture getFlag(String flagId, RequestOptions requestOptions) { + return this.rawClient.getFlag(flagId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateFlag(String flagId, CreateFlagRequestBody request) { + return this.rawClient.updateFlag(flagId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateFlag( + String flagId, CreateFlagRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateFlag(flagId, request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteFlag(String flagId) { + return this.rawClient.deleteFlag(flagId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteFlag(String flagId, RequestOptions requestOptions) { + return this.rawClient.deleteFlag(flagId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateFlagRules( + String flagId, UpdateFlagRulesRequestBody request) { + return this.rawClient.updateFlagRules(flagId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateFlagRules( + String flagId, UpdateFlagRulesRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateFlagRules(flagId, request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture checkFlag(String key) { + return this.rawClient.checkFlag(key).thenApply(response -> response.body()); + } + + public CompletableFuture checkFlag(String key, CheckFlagRequestBody request) { + return this.rawClient.checkFlag(key, request).thenApply(response -> response.body()); + } + + public CompletableFuture checkFlag( + String key, CheckFlagRequestBody request, RequestOptions requestOptions) { + return this.rawClient.checkFlag(key, request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture checkFlags() { + return this.rawClient.checkFlags().thenApply(response -> response.body()); + } + + public CompletableFuture checkFlags(CheckFlagRequestBody request) { + return this.rawClient.checkFlags(request).thenApply(response -> response.body()); + } + + public CompletableFuture checkFlags( + CheckFlagRequestBody request, RequestOptions requestOptions) { + return this.rawClient.checkFlags(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countFlags() { + return this.rawClient.countFlags().thenApply(response -> response.body()); + } + + public CompletableFuture countFlags(CountFlagsRequest request) { + return this.rawClient.countFlags(request).thenApply(response -> response.body()); + } + + public CompletableFuture countFlags(CountFlagsRequest request, RequestOptions requestOptions) { + return this.rawClient.countFlags(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/features/AsyncRawFeaturesClient.java b/src/main/java/com/schematic/api/resources/features/AsyncRawFeaturesClient.java new file mode 100644 index 0000000..61b7092 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/features/AsyncRawFeaturesClient.java @@ -0,0 +1,1496 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.features; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.features.requests.CountFeaturesRequest; +import com.schematic.api.resources.features.requests.CountFlagsRequest; +import com.schematic.api.resources.features.requests.CreateFeatureRequestBody; +import com.schematic.api.resources.features.requests.ListFeaturesRequest; +import com.schematic.api.resources.features.requests.ListFlagsRequest; +import com.schematic.api.resources.features.requests.UpdateFeatureRequestBody; +import com.schematic.api.resources.features.requests.UpdateFlagRulesRequestBody; +import com.schematic.api.resources.features.types.CheckFlagResponse; +import com.schematic.api.resources.features.types.CheckFlagsResponse; +import com.schematic.api.resources.features.types.CountFeaturesResponse; +import com.schematic.api.resources.features.types.CountFlagsResponse; +import com.schematic.api.resources.features.types.CreateFeatureResponse; +import com.schematic.api.resources.features.types.CreateFlagResponse; +import com.schematic.api.resources.features.types.DeleteFeatureResponse; +import com.schematic.api.resources.features.types.DeleteFlagResponse; +import com.schematic.api.resources.features.types.GetFeatureResponse; +import com.schematic.api.resources.features.types.GetFlagResponse; +import com.schematic.api.resources.features.types.ListFeaturesResponse; +import com.schematic.api.resources.features.types.ListFlagsResponse; +import com.schematic.api.resources.features.types.UpdateFeatureResponse; +import com.schematic.api.resources.features.types.UpdateFlagResponse; +import com.schematic.api.resources.features.types.UpdateFlagRulesResponse; +import com.schematic.api.types.ApiError; +import com.schematic.api.types.CheckFlagRequestBody; +import com.schematic.api.types.CreateFlagRequestBody; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFeaturesClient { + protected final ClientOptions clientOptions; + + public AsyncRawFeaturesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> listFeatures() { + return listFeatures(ListFeaturesRequest.builder().build()); + } + + public CompletableFuture> listFeatures( + ListFeaturesRequest request) { + return listFeatures(request, null); + } + + public CompletableFuture> listFeatures( + ListFeaturesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutCompanyOverrideFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_company_override_for", + request.getWithoutCompanyOverrideFor().get(), + false); + } + if (request.getWithoutPlanEntitlementFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_plan_entitlement_for", + request.getWithoutPlanEntitlementFor().get(), + false); + } + if (request.getBooleanRequireEvent().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "boolean_require_event", + request.getBooleanRequireEvent().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getFeatureType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_type", request.getFeatureType().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFeaturesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createFeature( + CreateFeatureRequestBody request) { + return createFeature(request, null); + } + + public CompletableFuture> createFeature( + CreateFeatureRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateFeatureResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getFeature(String featureId) { + return getFeature(featureId, null); + } + + public CompletableFuture> getFeature( + String featureId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features") + .addPathSegment(featureId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetFeatureResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateFeature(String featureId) { + return updateFeature(featureId, UpdateFeatureRequestBody.builder().build()); + } + + public CompletableFuture> updateFeature( + String featureId, UpdateFeatureRequestBody request) { + return updateFeature(featureId, request, null); + } + + public CompletableFuture> updateFeature( + String featureId, UpdateFeatureRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features") + .addPathSegment(featureId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateFeatureResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteFeature(String featureId) { + return deleteFeature(featureId, null); + } + + public CompletableFuture> deleteFeature( + String featureId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features") + .addPathSegment(featureId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteFeatureResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countFeatures() { + return countFeatures(CountFeaturesRequest.builder().build()); + } + + public CompletableFuture> countFeatures( + CountFeaturesRequest request) { + return countFeatures(request, null); + } + + public CompletableFuture> countFeatures( + CountFeaturesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutCompanyOverrideFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_company_override_for", + request.getWithoutCompanyOverrideFor().get(), + false); + } + if (request.getWithoutPlanEntitlementFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_plan_entitlement_for", + request.getWithoutPlanEntitlementFor().get(), + false); + } + if (request.getBooleanRequireEvent().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "boolean_require_event", + request.getBooleanRequireEvent().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getFeatureType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_type", request.getFeatureType().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFeaturesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listFlags() { + return listFlags(ListFlagsRequest.builder().build()); + } + + public CompletableFuture> listFlags(ListFlagsRequest request) { + return listFlags(request, null); + } + + public CompletableFuture> listFlags( + ListFlagsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags"); + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFlagsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createFlag(CreateFlagRequestBody request) { + return createFlag(request, null); + } + + public CompletableFuture> createFlag( + CreateFlagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateFlagResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getFlag(String flagId) { + return getFlag(flagId, null); + } + + public CompletableFuture> getFlag( + String flagId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(flagId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetFlagResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateFlag( + String flagId, CreateFlagRequestBody request) { + return updateFlag(flagId, request, null); + } + + public CompletableFuture> updateFlag( + String flagId, CreateFlagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(flagId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateFlagResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteFlag(String flagId) { + return deleteFlag(flagId, null); + } + + public CompletableFuture> deleteFlag( + String flagId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(flagId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteFlagResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateFlagRules( + String flagId, UpdateFlagRulesRequestBody request) { + return updateFlagRules(flagId, request, null); + } + + public CompletableFuture> updateFlagRules( + String flagId, UpdateFlagRulesRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(flagId) + .addPathSegments("rules") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateFlagRulesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> checkFlag(String key) { + return checkFlag(key, CheckFlagRequestBody.builder().build()); + } + + public CompletableFuture> checkFlag( + String key, CheckFlagRequestBody request) { + return checkFlag(key, request, null); + } + + public CompletableFuture> checkFlag( + String key, CheckFlagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(key) + .addPathSegments("check") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckFlagResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> checkFlags() { + return checkFlags(CheckFlagRequestBody.builder().build()); + } + + public CompletableFuture> checkFlags(CheckFlagRequestBody request) { + return checkFlags(request, null); + } + + public CompletableFuture> checkFlags( + CheckFlagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags/check") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckFlagsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countFlags() { + return countFlags(CountFlagsRequest.builder().build()); + } + + public CompletableFuture> countFlags(CountFlagsRequest request) { + return countFlags(request, null); + } + + public CompletableFuture> countFlags( + CountFlagsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags/count"); + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFlagsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/features/FeaturesClient.java b/src/main/java/com/schematic/api/resources/features/FeaturesClient.java index 53d8882..f9352c9 100644 --- a/src/main/java/com/schematic/api/resources/features/FeaturesClient.java +++ b/src/main/java/com/schematic/api/resources/features/FeaturesClient.java @@ -3,18 +3,8 @@ */ package com.schematic.api.resources.features; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.NotFoundError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.features.requests.CountFeaturesRequest; import com.schematic.api.resources.features.requests.CountFlagsRequest; import com.schematic.api.resources.features.requests.CreateFeatureRequestBody; @@ -24,8 +14,6 @@ import com.schematic.api.resources.features.requests.UpdateFlagRulesRequestBody; import com.schematic.api.resources.features.types.CheckFlagResponse; import com.schematic.api.resources.features.types.CheckFlagsResponse; -import com.schematic.api.resources.features.types.CountAudienceCompaniesResponse; -import com.schematic.api.resources.features.types.CountAudienceUsersResponse; import com.schematic.api.resources.features.types.CountFeaturesResponse; import com.schematic.api.resources.features.types.CountFlagsResponse; import com.schematic.api.resources.features.types.CreateFeatureResponse; @@ -34,1235 +22,178 @@ import com.schematic.api.resources.features.types.DeleteFlagResponse; import com.schematic.api.resources.features.types.GetFeatureResponse; import com.schematic.api.resources.features.types.GetFlagResponse; -import com.schematic.api.resources.features.types.ListAudienceCompaniesResponse; -import com.schematic.api.resources.features.types.ListAudienceUsersResponse; import com.schematic.api.resources.features.types.ListFeaturesResponse; import com.schematic.api.resources.features.types.ListFlagsResponse; import com.schematic.api.resources.features.types.UpdateFeatureResponse; import com.schematic.api.resources.features.types.UpdateFlagResponse; import com.schematic.api.resources.features.types.UpdateFlagRulesResponse; -import com.schematic.api.types.ApiError; -import com.schematic.api.types.AudienceRequestBody; import com.schematic.api.types.CheckFlagRequestBody; import com.schematic.api.types.CreateFlagRequestBody; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FeaturesClient { protected final ClientOptions clientOptions; + private final RawFeaturesClient rawClient; + public FeaturesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFeaturesClient(clientOptions); } - public CountAudienceCompaniesResponse countAudienceCompanies(AudienceRequestBody request) { - return countAudienceCompanies(request, null); - } - - public CountAudienceCompaniesResponse countAudienceCompanies( - AudienceRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audience/count-companies") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountAudienceCompaniesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } - } - - public CountAudienceUsersResponse countAudienceUsers(AudienceRequestBody request) { - return countAudienceUsers(request, null); - } - - public CountAudienceUsersResponse countAudienceUsers(AudienceRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audience/count-users") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountAudienceUsersResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } - } - - public ListAudienceCompaniesResponse listAudienceCompanies(AudienceRequestBody request) { - return listAudienceCompanies(request, null); - } - - public ListAudienceCompaniesResponse listAudienceCompanies( - AudienceRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audience/get-companies") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAudienceCompaniesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } - } - - public ListAudienceUsersResponse listAudienceUsers(AudienceRequestBody request) { - return listAudienceUsers(request, null); - } - - public ListAudienceUsersResponse listAudienceUsers(AudienceRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audience/get-users") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAudienceUsersResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + /** + * Get responses with HTTP metadata like headers + */ + public RawFeaturesClient withRawResponse() { + return this.rawClient; } public ListFeaturesResponse listFeatures() { - return listFeatures(ListFeaturesRequest.builder().build()); + return this.rawClient.listFeatures().body(); } public ListFeaturesResponse listFeatures(ListFeaturesRequest request) { - return listFeatures(request, null); + return this.rawClient.listFeatures(request).body(); } public ListFeaturesResponse listFeatures(ListFeaturesRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("features"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getWithoutCompanyOverrideFor().isPresent()) { - httpUrl.addQueryParameter( - "without_company_override_for", - request.getWithoutCompanyOverrideFor().get()); - } - if (request.getWithoutPlanEntitlementFor().isPresent()) { - httpUrl.addQueryParameter( - "without_plan_entitlement_for", - request.getWithoutPlanEntitlementFor().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFeaturesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listFeatures(request, requestOptions).body(); } public CreateFeatureResponse createFeature(CreateFeatureRequestBody request) { - return createFeature(request, null); + return this.rawClient.createFeature(request).body(); } public CreateFeatureResponse createFeature(CreateFeatureRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("features") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateFeatureResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.createFeature(request, requestOptions).body(); } public GetFeatureResponse getFeature(String featureId) { - return getFeature(featureId, null); + return this.rawClient.getFeature(featureId).body(); } public GetFeatureResponse getFeature(String featureId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("features") - .addPathSegment(featureId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetFeatureResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getFeature(featureId, requestOptions).body(); } public UpdateFeatureResponse updateFeature(String featureId) { - return updateFeature(featureId, UpdateFeatureRequestBody.builder().build()); + return this.rawClient.updateFeature(featureId).body(); } public UpdateFeatureResponse updateFeature(String featureId, UpdateFeatureRequestBody request) { - return updateFeature(featureId, request, null); + return this.rawClient.updateFeature(featureId, request).body(); } public UpdateFeatureResponse updateFeature( String featureId, UpdateFeatureRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("features") - .addPathSegment(featureId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateFeatureResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.updateFeature(featureId, request, requestOptions).body(); } public DeleteFeatureResponse deleteFeature(String featureId) { - return deleteFeature(featureId, null); + return this.rawClient.deleteFeature(featureId).body(); } public DeleteFeatureResponse deleteFeature(String featureId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("features") - .addPathSegment(featureId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteFeatureResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.deleteFeature(featureId, requestOptions).body(); } public CountFeaturesResponse countFeatures() { - return countFeatures(CountFeaturesRequest.builder().build()); + return this.rawClient.countFeatures().body(); } public CountFeaturesResponse countFeatures(CountFeaturesRequest request) { - return countFeatures(request, null); + return this.rawClient.countFeatures(request).body(); } public CountFeaturesResponse countFeatures(CountFeaturesRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("features/count"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getWithoutCompanyOverrideFor().isPresent()) { - httpUrl.addQueryParameter( - "without_company_override_for", - request.getWithoutCompanyOverrideFor().get()); - } - if (request.getWithoutPlanEntitlementFor().isPresent()) { - httpUrl.addQueryParameter( - "without_plan_entitlement_for", - request.getWithoutPlanEntitlementFor().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFeaturesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.countFeatures(request, requestOptions).body(); } public ListFlagsResponse listFlags() { - return listFlags(ListFlagsRequest.builder().build()); + return this.rawClient.listFlags().body(); } public ListFlagsResponse listFlags(ListFlagsRequest request) { - return listFlags(request, null); + return this.rawClient.listFlags(request).body(); } public ListFlagsResponse listFlags(ListFlagsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags"); - if (request.getFeatureId().isPresent()) { - httpUrl.addQueryParameter("feature_id", request.getFeatureId().get()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFlagsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listFlags(request, requestOptions).body(); } public CreateFlagResponse createFlag(CreateFlagRequestBody request) { - return createFlag(request, null); + return this.rawClient.createFlag(request).body(); } public CreateFlagResponse createFlag(CreateFlagRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateFlagResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.createFlag(request, requestOptions).body(); } public GetFlagResponse getFlag(String flagId) { - return getFlag(flagId, null); + return this.rawClient.getFlag(flagId).body(); } public GetFlagResponse getFlag(String flagId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags") - .addPathSegment(flagId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetFlagResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getFlag(flagId, requestOptions).body(); } public UpdateFlagResponse updateFlag(String flagId, CreateFlagRequestBody request) { - return updateFlag(flagId, request, null); + return this.rawClient.updateFlag(flagId, request).body(); } public UpdateFlagResponse updateFlag(String flagId, CreateFlagRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags") - .addPathSegment(flagId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateFlagResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.updateFlag(flagId, request, requestOptions).body(); } public DeleteFlagResponse deleteFlag(String flagId) { - return deleteFlag(flagId, null); + return this.rawClient.deleteFlag(flagId).body(); } public DeleteFlagResponse deleteFlag(String flagId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags") - .addPathSegment(flagId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteFlagResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.deleteFlag(flagId, requestOptions).body(); } public UpdateFlagRulesResponse updateFlagRules(String flagId, UpdateFlagRulesRequestBody request) { - return updateFlagRules(flagId, request, null); + return this.rawClient.updateFlagRules(flagId, request).body(); } public UpdateFlagRulesResponse updateFlagRules( String flagId, UpdateFlagRulesRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags") - .addPathSegment(flagId) - .addPathSegments("rules") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateFlagRulesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.updateFlagRules(flagId, request, requestOptions).body(); } public CheckFlagResponse checkFlag(String key) { - return checkFlag(key, CheckFlagRequestBody.builder().build()); + return this.rawClient.checkFlag(key).body(); } public CheckFlagResponse checkFlag(String key, CheckFlagRequestBody request) { - return checkFlag(key, request, null); + return this.rawClient.checkFlag(key, request).body(); } public CheckFlagResponse checkFlag(String key, CheckFlagRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags") - .addPathSegment(key) - .addPathSegments("check") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckFlagResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.checkFlag(key, request, requestOptions).body(); } public CheckFlagsResponse checkFlags() { - return checkFlags(CheckFlagRequestBody.builder().build()); + return this.rawClient.checkFlags().body(); } public CheckFlagsResponse checkFlags(CheckFlagRequestBody request) { - return checkFlags(request, null); + return this.rawClient.checkFlags(request).body(); } public CheckFlagsResponse checkFlags(CheckFlagRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags/check") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckFlagsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.checkFlags(request, requestOptions).body(); } public CountFlagsResponse countFlags() { - return countFlags(CountFlagsRequest.builder().build()); + return this.rawClient.countFlags().body(); } public CountFlagsResponse countFlags(CountFlagsRequest request) { - return countFlags(request, null); + return this.rawClient.countFlags(request).body(); } public CountFlagsResponse countFlags(CountFlagsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("flags/count"); - if (request.getFeatureId().isPresent()) { - httpUrl.addQueryParameter("feature_id", request.getFeatureId().get()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFlagsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.countFlags(request, requestOptions).body(); } } diff --git a/src/main/java/com/schematic/api/resources/features/RawFeaturesClient.java b/src/main/java/com/schematic/api/resources/features/RawFeaturesClient.java new file mode 100644 index 0000000..2c34e5e --- /dev/null +++ b/src/main/java/com/schematic/api/resources/features/RawFeaturesClient.java @@ -0,0 +1,1133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.features; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.features.requests.CountFeaturesRequest; +import com.schematic.api.resources.features.requests.CountFlagsRequest; +import com.schematic.api.resources.features.requests.CreateFeatureRequestBody; +import com.schematic.api.resources.features.requests.ListFeaturesRequest; +import com.schematic.api.resources.features.requests.ListFlagsRequest; +import com.schematic.api.resources.features.requests.UpdateFeatureRequestBody; +import com.schematic.api.resources.features.requests.UpdateFlagRulesRequestBody; +import com.schematic.api.resources.features.types.CheckFlagResponse; +import com.schematic.api.resources.features.types.CheckFlagsResponse; +import com.schematic.api.resources.features.types.CountFeaturesResponse; +import com.schematic.api.resources.features.types.CountFlagsResponse; +import com.schematic.api.resources.features.types.CreateFeatureResponse; +import com.schematic.api.resources.features.types.CreateFlagResponse; +import com.schematic.api.resources.features.types.DeleteFeatureResponse; +import com.schematic.api.resources.features.types.DeleteFlagResponse; +import com.schematic.api.resources.features.types.GetFeatureResponse; +import com.schematic.api.resources.features.types.GetFlagResponse; +import com.schematic.api.resources.features.types.ListFeaturesResponse; +import com.schematic.api.resources.features.types.ListFlagsResponse; +import com.schematic.api.resources.features.types.UpdateFeatureResponse; +import com.schematic.api.resources.features.types.UpdateFlagResponse; +import com.schematic.api.resources.features.types.UpdateFlagRulesResponse; +import com.schematic.api.types.ApiError; +import com.schematic.api.types.CheckFlagRequestBody; +import com.schematic.api.types.CreateFlagRequestBody; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFeaturesClient { + protected final ClientOptions clientOptions; + + public RawFeaturesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse listFeatures() { + return listFeatures(ListFeaturesRequest.builder().build()); + } + + public BaseSchematicHttpResponse listFeatures(ListFeaturesRequest request) { + return listFeatures(request, null); + } + + public BaseSchematicHttpResponse listFeatures( + ListFeaturesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutCompanyOverrideFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_company_override_for", + request.getWithoutCompanyOverrideFor().get(), + false); + } + if (request.getWithoutPlanEntitlementFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_plan_entitlement_for", + request.getWithoutPlanEntitlementFor().get(), + false); + } + if (request.getBooleanRequireEvent().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "boolean_require_event", + request.getBooleanRequireEvent().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getFeatureType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_type", request.getFeatureType().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFeaturesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createFeature(CreateFeatureRequestBody request) { + return createFeature(request, null); + } + + public BaseSchematicHttpResponse createFeature( + CreateFeatureRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateFeatureResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getFeature(String featureId) { + return getFeature(featureId, null); + } + + public BaseSchematicHttpResponse getFeature(String featureId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features") + .addPathSegment(featureId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetFeatureResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateFeature(String featureId) { + return updateFeature(featureId, UpdateFeatureRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse updateFeature( + String featureId, UpdateFeatureRequestBody request) { + return updateFeature(featureId, request, null); + } + + public BaseSchematicHttpResponse updateFeature( + String featureId, UpdateFeatureRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features") + .addPathSegment(featureId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateFeatureResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteFeature(String featureId) { + return deleteFeature(featureId, null); + } + + public BaseSchematicHttpResponse deleteFeature( + String featureId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features") + .addPathSegment(featureId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteFeatureResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countFeatures() { + return countFeatures(CountFeaturesRequest.builder().build()); + } + + public BaseSchematicHttpResponse countFeatures(CountFeaturesRequest request) { + return countFeatures(request, null); + } + + public BaseSchematicHttpResponse countFeatures( + CountFeaturesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("features/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWithoutCompanyOverrideFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_company_override_for", + request.getWithoutCompanyOverrideFor().get(), + false); + } + if (request.getWithoutPlanEntitlementFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_plan_entitlement_for", + request.getWithoutPlanEntitlementFor().get(), + false); + } + if (request.getBooleanRequireEvent().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "boolean_require_event", + request.getBooleanRequireEvent().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + if (request.getFeatureType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_type", request.getFeatureType().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFeaturesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listFlags() { + return listFlags(ListFlagsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listFlags(ListFlagsRequest request) { + return listFlags(request, null); + } + + public BaseSchematicHttpResponse listFlags( + ListFlagsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags"); + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListFlagsResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createFlag(CreateFlagRequestBody request) { + return createFlag(request, null); + } + + public BaseSchematicHttpResponse createFlag( + CreateFlagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateFlagResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getFlag(String flagId) { + return getFlag(flagId, null); + } + + public BaseSchematicHttpResponse getFlag(String flagId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(flagId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetFlagResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateFlag(String flagId, CreateFlagRequestBody request) { + return updateFlag(flagId, request, null); + } + + public BaseSchematicHttpResponse updateFlag( + String flagId, CreateFlagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(flagId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateFlagResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteFlag(String flagId) { + return deleteFlag(flagId, null); + } + + public BaseSchematicHttpResponse deleteFlag(String flagId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(flagId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteFlagResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateFlagRules( + String flagId, UpdateFlagRulesRequestBody request) { + return updateFlagRules(flagId, request, null); + } + + public BaseSchematicHttpResponse updateFlagRules( + String flagId, UpdateFlagRulesRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(flagId) + .addPathSegments("rules") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateFlagRulesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse checkFlag(String key) { + return checkFlag(key, CheckFlagRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse checkFlag(String key, CheckFlagRequestBody request) { + return checkFlag(key, request, null); + } + + public BaseSchematicHttpResponse checkFlag( + String key, CheckFlagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags") + .addPathSegment(key) + .addPathSegments("check") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckFlagResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse checkFlags() { + return checkFlags(CheckFlagRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse checkFlags(CheckFlagRequestBody request) { + return checkFlags(request, null); + } + + public BaseSchematicHttpResponse checkFlags( + CheckFlagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags/check") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CheckFlagsResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countFlags() { + return countFlags(CountFlagsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countFlags(CountFlagsRequest request) { + return countFlags(request, null); + } + + public BaseSchematicHttpResponse countFlags( + CountFlagsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("flags/count"); + if (request.getFeatureId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "feature_id", request.getFeatureId().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountFlagsResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/features/requests/CountFeaturesRequest.java b/src/main/java/com/schematic/api/resources/features/requests/CountFeaturesRequest.java index 4235889..2e5e165 100644 --- a/src/main/java/com/schematic/api/resources/features/requests/CountFeaturesRequest.java +++ b/src/main/java/com/schematic/api/resources/features/requests/CountFeaturesRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,7 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountFeaturesRequest.Builder.class) public final class CountFeaturesRequest { - private final Optional ids; + private final Optional> ids; + + private final Optional> featureType; private final Optional q; @@ -28,6 +32,8 @@ public final class CountFeaturesRequest { private final Optional withoutPlanEntitlementFor; + private final Optional booleanRequireEvent; + private final Optional limit; private final Optional offset; @@ -35,27 +41,42 @@ public final class CountFeaturesRequest { private final Map additionalProperties; private CountFeaturesRequest( - Optional ids, + Optional> ids, + Optional> featureType, Optional q, Optional withoutCompanyOverrideFor, Optional withoutPlanEntitlementFor, + Optional booleanRequireEvent, Optional limit, Optional offset, Map additionalProperties) { this.ids = ids; + this.featureType = featureType; this.q = q; this.withoutCompanyOverrideFor = withoutCompanyOverrideFor; this.withoutPlanEntitlementFor = withoutPlanEntitlementFor; + this.booleanRequireEvent = booleanRequireEvent; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } + /** + * @return Filter by one or more feature types (boolean, event, trait) + */ + @JsonProperty("feature_type") + public Optional> getFeatureType() { + return featureType; + } + + /** + * @return Search by feature name or ID + */ @JsonProperty("q") public Optional getQ() { return q; @@ -77,6 +98,14 @@ public Optional getWithoutPlanEntitlementFor() { return withoutPlanEntitlementFor; } + /** + * @return Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter. + */ + @JsonProperty("boolean_require_event") + public Optional getBooleanRequireEvent() { + return booleanRequireEvent; + } + /** * @return Page limit (default 100) */ @@ -106,9 +135,11 @@ public Map getAdditionalProperties() { private boolean equalTo(CountFeaturesRequest other) { return ids.equals(other.ids) + && featureType.equals(other.featureType) && q.equals(other.q) && withoutCompanyOverrideFor.equals(other.withoutCompanyOverrideFor) && withoutPlanEntitlementFor.equals(other.withoutPlanEntitlementFor) + && booleanRequireEvent.equals(other.booleanRequireEvent) && limit.equals(other.limit) && offset.equals(other.offset); } @@ -117,9 +148,11 @@ private boolean equalTo(CountFeaturesRequest other) { public int hashCode() { return Objects.hash( this.ids, + this.featureType, this.q, this.withoutCompanyOverrideFor, this.withoutPlanEntitlementFor, + this.booleanRequireEvent, this.limit, this.offset); } @@ -135,7 +168,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); + + private Optional> featureType = Optional.empty(); private Optional q = Optional.empty(); @@ -143,6 +178,8 @@ public static final class Builder { private Optional withoutPlanEntitlementFor = Optional.empty(); + private Optional booleanRequireEvent = Optional.empty(); + private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); @@ -154,25 +191,54 @@ private Builder() {} public Builder from(CountFeaturesRequest other) { ids(other.getIds()); + featureType(other.getFeatureType()); q(other.getQ()); withoutCompanyOverrideFor(other.getWithoutCompanyOverrideFor()); withoutPlanEntitlementFor(other.getWithoutPlanEntitlementFor()); + booleanRequireEvent(other.getBooleanRequireEvent()); limit(other.getLimit()); offset(other.getOffset()); return this; } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Filter by one or more feature types (boolean, event, trait)

+ */ + @JsonSetter(value = "feature_type", nulls = Nulls.SKIP) + public Builder featureType(Optional> featureType) { + this.featureType = featureType; + return this; + } + + public Builder featureType(List featureType) { + this.featureType = Optional.ofNullable(featureType); + return this; + } + + public Builder featureType(String featureType) { + this.featureType = Optional.of(Collections.singletonList(featureType)); + return this; + } + + /** + *

Search by feature name or ID

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -184,6 +250,9 @@ public Builder q(String q) { return this; } + /** + *

Filter out features that already have a company override for the specified company ID

+ */ @JsonSetter(value = "without_company_override_for", nulls = Nulls.SKIP) public Builder withoutCompanyOverrideFor(Optional withoutCompanyOverrideFor) { this.withoutCompanyOverrideFor = withoutCompanyOverrideFor; @@ -195,6 +264,9 @@ public Builder withoutCompanyOverrideFor(String withoutCompanyOverrideFor) { return this; } + /** + *

Filter out features that already have a plan entitlement for the specified plan ID

+ */ @JsonSetter(value = "without_plan_entitlement_for", nulls = Nulls.SKIP) public Builder withoutPlanEntitlementFor(Optional withoutPlanEntitlementFor) { this.withoutPlanEntitlementFor = withoutPlanEntitlementFor; @@ -206,6 +278,23 @@ public Builder withoutPlanEntitlementFor(String withoutPlanEntitlementFor) { return this; } + /** + *

Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter.

+ */ + @JsonSetter(value = "boolean_require_event", nulls = Nulls.SKIP) + public Builder booleanRequireEvent(Optional booleanRequireEvent) { + this.booleanRequireEvent = booleanRequireEvent; + return this; + } + + public Builder booleanRequireEvent(Boolean booleanRequireEvent) { + this.booleanRequireEvent = Optional.ofNullable(booleanRequireEvent); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -217,6 +306,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -230,7 +322,15 @@ public Builder offset(Integer offset) { public CountFeaturesRequest build() { return new CountFeaturesRequest( - ids, q, withoutCompanyOverrideFor, withoutPlanEntitlementFor, limit, offset, additionalProperties); + ids, + featureType, + q, + withoutCompanyOverrideFor, + withoutPlanEntitlementFor, + booleanRequireEvent, + limit, + offset, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/features/requests/CountFlagsRequest.java b/src/main/java/com/schematic/api/resources/features/requests/CountFlagsRequest.java index c2b534a..2a34436 100644 --- a/src/main/java/com/schematic/api/resources/features/requests/CountFlagsRequest.java +++ b/src/main/java/com/schematic/api/resources/features/requests/CountFlagsRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,9 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountFlagsRequest.Builder.class) public final class CountFlagsRequest { - private final Optional featureId; + private final Optional> ids; - private final Optional ids; + private final Optional featureId; private final Optional q; @@ -33,30 +35,33 @@ public final class CountFlagsRequest { private final Map additionalProperties; private CountFlagsRequest( + Optional> ids, Optional featureId, - Optional ids, Optional q, Optional limit, Optional offset, Map additionalProperties) { - this.featureId = featureId; this.ids = ids; + this.featureId = featureId; this.q = q; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + @JsonProperty("feature_id") public Optional getFeatureId() { return featureId; } - @JsonProperty("ids") - public Optional getIds() { - return ids; - } - + /** + * @return Search by flag name, key, or ID + */ @JsonProperty("q") public Optional getQ() { return q; @@ -90,8 +95,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountFlagsRequest other) { - return featureId.equals(other.featureId) - && ids.equals(other.ids) + return ids.equals(other.ids) + && featureId.equals(other.featureId) && q.equals(other.q) && limit.equals(other.limit) && offset.equals(other.offset); @@ -99,7 +104,7 @@ private boolean equalTo(CountFlagsRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.featureId, this.ids, this.q, this.limit, this.offset); + return Objects.hash(this.ids, this.featureId, this.q, this.limit, this.offset); } @java.lang.Override @@ -113,9 +118,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional featureId = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional featureId = Optional.empty(); private Optional q = Optional.empty(); @@ -129,36 +134,44 @@ public static final class Builder { private Builder() {} public Builder from(CountFlagsRequest other) { - featureId(other.getFeatureId()); ids(other.getIds()); + featureId(other.getFeatureId()); q(other.getQ()); limit(other.getLimit()); offset(other.getOffset()); return this; } - @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) - public Builder featureId(Optional featureId) { - this.featureId = featureId; + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder featureId(String featureId) { - this.featureId = Optional.ofNullable(featureId); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public Builder featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + public Builder featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); return this; } + /** + *

Search by flag name, key, or ID

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -170,6 +183,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -181,6 +197,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -193,7 +212,7 @@ public Builder offset(Integer offset) { } public CountFlagsRequest build() { - return new CountFlagsRequest(featureId, ids, q, limit, offset, additionalProperties); + return new CountFlagsRequest(ids, featureId, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/features/requests/CreateFeatureRequestBody.java b/src/main/java/com/schematic/api/resources/features/requests/CreateFeatureRequestBody.java index eae3310..e857de2 100644 --- a/src/main/java/com/schematic/api/resources/features/requests/CreateFeatureRequestBody.java +++ b/src/main/java/com/schematic/api/resources/features/requests/CreateFeatureRequestBody.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.features.types.CreateFeatureRequestBodyFeatureType; +import com.schematic.api.resources.features.types.CreateFeatureRequestBodyLifecyclePhase; import com.schematic.api.types.CreateOrUpdateFlagRequestBody; import java.util.HashMap; import java.util.Map; @@ -33,7 +34,7 @@ public final class CreateFeatureRequestBody { private final Optional icon; - private final Optional lifecyclePhase; + private final Optional lifecyclePhase; private final Optional maintainerId; @@ -53,7 +54,7 @@ private CreateFeatureRequestBody( CreateFeatureRequestBodyFeatureType featureType, Optional flag, Optional icon, - Optional lifecyclePhase, + Optional lifecyclePhase, Optional maintainerId, String name, Optional pluralName, @@ -100,7 +101,7 @@ public Optional getIcon() { } @JsonProperty("lifecycle_phase") - public Optional getLifecyclePhase() { + public Optional getLifecyclePhase() { return lifecyclePhase; } @@ -208,9 +209,9 @@ public interface _FinalStage { _FinalStage icon(String icon); - _FinalStage lifecyclePhase(Optional lifecyclePhase); + _FinalStage lifecyclePhase(Optional lifecyclePhase); - _FinalStage lifecyclePhase(String lifecyclePhase); + _FinalStage lifecyclePhase(CreateFeatureRequestBodyLifecyclePhase lifecyclePhase); _FinalStage maintainerId(Optional maintainerId); @@ -245,7 +246,7 @@ public static final class Builder implements DescriptionStage, FeatureTypeStage, private Optional maintainerId = Optional.empty(); - private Optional lifecyclePhase = Optional.empty(); + private Optional lifecyclePhase = Optional.empty(); private Optional icon = Optional.empty(); @@ -348,14 +349,14 @@ public _FinalStage maintainerId(Optional maintainerId) { } @java.lang.Override - public _FinalStage lifecyclePhase(String lifecyclePhase) { + public _FinalStage lifecyclePhase(CreateFeatureRequestBodyLifecyclePhase lifecyclePhase) { this.lifecyclePhase = Optional.ofNullable(lifecyclePhase); return this; } @java.lang.Override @JsonSetter(value = "lifecycle_phase", nulls = Nulls.SKIP) - public _FinalStage lifecyclePhase(Optional lifecyclePhase) { + public _FinalStage lifecyclePhase(Optional lifecyclePhase) { this.lifecyclePhase = lifecyclePhase; return this; } diff --git a/src/main/java/com/schematic/api/resources/features/requests/ListFeaturesRequest.java b/src/main/java/com/schematic/api/resources/features/requests/ListFeaturesRequest.java index 94c826b..ba98452 100644 --- a/src/main/java/com/schematic/api/resources/features/requests/ListFeaturesRequest.java +++ b/src/main/java/com/schematic/api/resources/features/requests/ListFeaturesRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,7 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListFeaturesRequest.Builder.class) public final class ListFeaturesRequest { - private final Optional ids; + private final Optional> ids; + + private final Optional> featureType; private final Optional q; @@ -28,6 +32,8 @@ public final class ListFeaturesRequest { private final Optional withoutPlanEntitlementFor; + private final Optional booleanRequireEvent; + private final Optional limit; private final Optional offset; @@ -35,27 +41,42 @@ public final class ListFeaturesRequest { private final Map additionalProperties; private ListFeaturesRequest( - Optional ids, + Optional> ids, + Optional> featureType, Optional q, Optional withoutCompanyOverrideFor, Optional withoutPlanEntitlementFor, + Optional booleanRequireEvent, Optional limit, Optional offset, Map additionalProperties) { this.ids = ids; + this.featureType = featureType; this.q = q; this.withoutCompanyOverrideFor = withoutCompanyOverrideFor; this.withoutPlanEntitlementFor = withoutPlanEntitlementFor; + this.booleanRequireEvent = booleanRequireEvent; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } + /** + * @return Filter by one or more feature types (boolean, event, trait) + */ + @JsonProperty("feature_type") + public Optional> getFeatureType() { + return featureType; + } + + /** + * @return Search by feature name or ID + */ @JsonProperty("q") public Optional getQ() { return q; @@ -77,6 +98,14 @@ public Optional getWithoutPlanEntitlementFor() { return withoutPlanEntitlementFor; } + /** + * @return Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter. + */ + @JsonProperty("boolean_require_event") + public Optional getBooleanRequireEvent() { + return booleanRequireEvent; + } + /** * @return Page limit (default 100) */ @@ -106,9 +135,11 @@ public Map getAdditionalProperties() { private boolean equalTo(ListFeaturesRequest other) { return ids.equals(other.ids) + && featureType.equals(other.featureType) && q.equals(other.q) && withoutCompanyOverrideFor.equals(other.withoutCompanyOverrideFor) && withoutPlanEntitlementFor.equals(other.withoutPlanEntitlementFor) + && booleanRequireEvent.equals(other.booleanRequireEvent) && limit.equals(other.limit) && offset.equals(other.offset); } @@ -117,9 +148,11 @@ private boolean equalTo(ListFeaturesRequest other) { public int hashCode() { return Objects.hash( this.ids, + this.featureType, this.q, this.withoutCompanyOverrideFor, this.withoutPlanEntitlementFor, + this.booleanRequireEvent, this.limit, this.offset); } @@ -135,7 +168,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); + + private Optional> featureType = Optional.empty(); private Optional q = Optional.empty(); @@ -143,6 +178,8 @@ public static final class Builder { private Optional withoutPlanEntitlementFor = Optional.empty(); + private Optional booleanRequireEvent = Optional.empty(); + private Optional limit = Optional.empty(); private Optional offset = Optional.empty(); @@ -154,25 +191,54 @@ private Builder() {} public Builder from(ListFeaturesRequest other) { ids(other.getIds()); + featureType(other.getFeatureType()); q(other.getQ()); withoutCompanyOverrideFor(other.getWithoutCompanyOverrideFor()); withoutPlanEntitlementFor(other.getWithoutPlanEntitlementFor()); + booleanRequireEvent(other.getBooleanRequireEvent()); limit(other.getLimit()); offset(other.getOffset()); return this; } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + + /** + *

Filter by one or more feature types (boolean, event, trait)

+ */ + @JsonSetter(value = "feature_type", nulls = Nulls.SKIP) + public Builder featureType(Optional> featureType) { + this.featureType = featureType; + return this; + } + + public Builder featureType(List featureType) { + this.featureType = Optional.ofNullable(featureType); + return this; + } + + public Builder featureType(String featureType) { + this.featureType = Optional.of(Collections.singletonList(featureType)); + return this; + } + + /** + *

Search by feature name or ID

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -184,6 +250,9 @@ public Builder q(String q) { return this; } + /** + *

Filter out features that already have a company override for the specified company ID

+ */ @JsonSetter(value = "without_company_override_for", nulls = Nulls.SKIP) public Builder withoutCompanyOverrideFor(Optional withoutCompanyOverrideFor) { this.withoutCompanyOverrideFor = withoutCompanyOverrideFor; @@ -195,6 +264,9 @@ public Builder withoutCompanyOverrideFor(String withoutCompanyOverrideFor) { return this; } + /** + *

Filter out features that already have a plan entitlement for the specified plan ID

+ */ @JsonSetter(value = "without_plan_entitlement_for", nulls = Nulls.SKIP) public Builder withoutPlanEntitlementFor(Optional withoutPlanEntitlementFor) { this.withoutPlanEntitlementFor = withoutPlanEntitlementFor; @@ -206,6 +278,23 @@ public Builder withoutPlanEntitlementFor(String withoutPlanEntitlementFor) { return this; } + /** + *

Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter.

+ */ + @JsonSetter(value = "boolean_require_event", nulls = Nulls.SKIP) + public Builder booleanRequireEvent(Optional booleanRequireEvent) { + this.booleanRequireEvent = booleanRequireEvent; + return this; + } + + public Builder booleanRequireEvent(Boolean booleanRequireEvent) { + this.booleanRequireEvent = Optional.ofNullable(booleanRequireEvent); + return this; + } + + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -217,6 +306,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -230,7 +322,15 @@ public Builder offset(Integer offset) { public ListFeaturesRequest build() { return new ListFeaturesRequest( - ids, q, withoutCompanyOverrideFor, withoutPlanEntitlementFor, limit, offset, additionalProperties); + ids, + featureType, + q, + withoutCompanyOverrideFor, + withoutPlanEntitlementFor, + booleanRequireEvent, + limit, + offset, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/features/requests/ListFlagsRequest.java b/src/main/java/com/schematic/api/resources/features/requests/ListFlagsRequest.java index 6c428c5..11f5021 100644 --- a/src/main/java/com/schematic/api/resources/features/requests/ListFlagsRequest.java +++ b/src/main/java/com/schematic/api/resources/features/requests/ListFlagsRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,9 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListFlagsRequest.Builder.class) public final class ListFlagsRequest { - private final Optional featureId; + private final Optional> ids; - private final Optional ids; + private final Optional featureId; private final Optional q; @@ -33,30 +35,33 @@ public final class ListFlagsRequest { private final Map additionalProperties; private ListFlagsRequest( + Optional> ids, Optional featureId, - Optional ids, Optional q, Optional limit, Optional offset, Map additionalProperties) { - this.featureId = featureId; this.ids = ids; + this.featureId = featureId; this.q = q; this.limit = limit; this.offset = offset; this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + @JsonProperty("feature_id") public Optional getFeatureId() { return featureId; } - @JsonProperty("ids") - public Optional getIds() { - return ids; - } - + /** + * @return Search by flag name, key, or ID + */ @JsonProperty("q") public Optional getQ() { return q; @@ -90,8 +95,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListFlagsRequest other) { - return featureId.equals(other.featureId) - && ids.equals(other.ids) + return ids.equals(other.ids) + && featureId.equals(other.featureId) && q.equals(other.q) && limit.equals(other.limit) && offset.equals(other.offset); @@ -99,7 +104,7 @@ private boolean equalTo(ListFlagsRequest other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.featureId, this.ids, this.q, this.limit, this.offset); + return Objects.hash(this.ids, this.featureId, this.q, this.limit, this.offset); } @java.lang.Override @@ -113,9 +118,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional featureId = Optional.empty(); + private Optional> ids = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional featureId = Optional.empty(); private Optional q = Optional.empty(); @@ -129,36 +134,44 @@ public static final class Builder { private Builder() {} public Builder from(ListFlagsRequest other) { - featureId(other.getFeatureId()); ids(other.getIds()); + featureId(other.getFeatureId()); q(other.getQ()); limit(other.getLimit()); offset(other.getOffset()); return this; } - @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) - public Builder featureId(Optional featureId) { - this.featureId = featureId; + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; return this; } - public Builder featureId(String featureId) { - this.featureId = Optional.ofNullable(featureId); + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public Builder featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + public Builder featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); return this; } + /** + *

Search by flag name, key, or ID

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -170,6 +183,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -181,6 +197,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -193,7 +212,7 @@ public Builder offset(Integer offset) { } public ListFlagsRequest build() { - return new ListFlagsRequest(featureId, ids, q, limit, offset, additionalProperties); + return new ListFlagsRequest(ids, featureId, q, limit, offset, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/features/requests/UpdateFeatureRequestBody.java b/src/main/java/com/schematic/api/resources/features/requests/UpdateFeatureRequestBody.java index 9ff3a04..34e65b0 100644 --- a/src/main/java/com/schematic/api/resources/features/requests/UpdateFeatureRequestBody.java +++ b/src/main/java/com/schematic/api/resources/features/requests/UpdateFeatureRequestBody.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.features.types.UpdateFeatureRequestBodyFeatureType; +import com.schematic.api.resources.features.types.UpdateFeatureRequestBodyLifecyclePhase; import com.schematic.api.types.CreateOrUpdateFlagRequestBody; import java.util.HashMap; import java.util.Map; @@ -32,7 +33,7 @@ public final class UpdateFeatureRequestBody { private final Optional icon; - private final Optional lifecyclePhase; + private final Optional lifecyclePhase; private final Optional maintainerId; @@ -52,7 +53,7 @@ private UpdateFeatureRequestBody( Optional featureType, Optional flag, Optional icon, - Optional lifecyclePhase, + Optional lifecyclePhase, Optional maintainerId, Optional name, Optional pluralName, @@ -99,7 +100,7 @@ public Optional getIcon() { } @JsonProperty("lifecycle_phase") - public Optional getLifecyclePhase() { + public Optional getLifecyclePhase() { return lifecyclePhase; } @@ -190,7 +191,7 @@ public static final class Builder { private Optional icon = Optional.empty(); - private Optional lifecyclePhase = Optional.empty(); + private Optional lifecyclePhase = Optional.empty(); private Optional maintainerId = Optional.empty(); @@ -278,12 +279,12 @@ public Builder icon(String icon) { } @JsonSetter(value = "lifecycle_phase", nulls = Nulls.SKIP) - public Builder lifecyclePhase(Optional lifecyclePhase) { + public Builder lifecyclePhase(Optional lifecyclePhase) { this.lifecyclePhase = lifecyclePhase; return this; } - public Builder lifecyclePhase(String lifecyclePhase) { + public Builder lifecyclePhase(UpdateFeatureRequestBodyLifecyclePhase lifecyclePhase) { this.lifecyclePhase = Optional.ofNullable(lifecyclePhase); return this; } diff --git a/src/main/java/com/schematic/api/resources/features/requests/UpdateFlagRulesRequestBody.java b/src/main/java/com/schematic/api/resources/features/requests/UpdateFlagRulesRequestBody.java index d58fd88..009d56c 100644 --- a/src/main/java/com/schematic/api/resources/features/requests/UpdateFlagRulesRequestBody.java +++ b/src/main/java/com/schematic/api/resources/features/requests/UpdateFlagRulesRequestBody.java @@ -83,7 +83,9 @@ public Builder from(UpdateFlagRulesRequestBody other) { @JsonSetter(value = "rules", nulls = Nulls.SKIP) public Builder rules(List rules) { this.rules.clear(); - this.rules.addAll(rules); + if (rules != null) { + this.rules.addAll(rules); + } return this; } @@ -93,7 +95,9 @@ public Builder addRules(CreateOrUpdateRuleRequestBody rules) { } public Builder addAllRules(List rules) { - this.rules.addAll(rules); + if (rules != null) { + this.rules.addAll(rules); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/CheckFlagResponse.java b/src/main/java/com/schematic/api/resources/features/types/CheckFlagResponse.java index ec66c6b..cd2410d 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CheckFlagResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/CheckFlagResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CheckFlagResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/CheckFlagsResponse.java b/src/main/java/com/schematic/api/resources/features/types/CheckFlagsResponse.java index d36e92d..0ab405f 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CheckFlagsResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/CheckFlagsResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CheckFlagsResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/CountFeaturesParams.java b/src/main/java/com/schematic/api/resources/features/types/CountFeaturesParams.java index c5ef0ad..9923b76 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CountFeaturesParams.java +++ b/src/main/java/com/schematic/api/resources/features/types/CountFeaturesParams.java @@ -21,6 +21,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountFeaturesParams.Builder.class) public final class CountFeaturesParams { + private final Optional booleanRequireEvent; + + private final Optional> featureType; + private final Optional> ids; private final Optional limit; @@ -36,6 +40,8 @@ public final class CountFeaturesParams { private final Map additionalProperties; private CountFeaturesParams( + Optional booleanRequireEvent, + Optional> featureType, Optional> ids, Optional limit, Optional offset, @@ -43,6 +49,8 @@ private CountFeaturesParams( Optional withoutCompanyOverrideFor, Optional withoutPlanEntitlementFor, Map additionalProperties) { + this.booleanRequireEvent = booleanRequireEvent; + this.featureType = featureType; this.ids = ids; this.limit = limit; this.offset = offset; @@ -52,6 +60,22 @@ private CountFeaturesParams( this.additionalProperties = additionalProperties; } + /** + * @return Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter. + */ + @JsonProperty("boolean_require_event") + public Optional getBooleanRequireEvent() { + return booleanRequireEvent; + } + + /** + * @return Filter by one or more feature types (boolean, event, trait) + */ + @JsonProperty("feature_type") + public Optional> getFeatureType() { + return featureType; + } + @JsonProperty("ids") public Optional> getIds() { return ids; @@ -73,6 +97,9 @@ public Optional getOffset() { return offset; } + /** + * @return Search by feature name or ID + */ @JsonProperty("q") public Optional getQ() { return q; @@ -106,7 +133,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountFeaturesParams other) { - return ids.equals(other.ids) + return booleanRequireEvent.equals(other.booleanRequireEvent) + && featureType.equals(other.featureType) + && ids.equals(other.ids) && limit.equals(other.limit) && offset.equals(other.offset) && q.equals(other.q) @@ -117,6 +146,8 @@ private boolean equalTo(CountFeaturesParams other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.booleanRequireEvent, + this.featureType, this.ids, this.limit, this.offset, @@ -136,6 +167,10 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional booleanRequireEvent = Optional.empty(); + + private Optional> featureType = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional limit = Optional.empty(); @@ -154,6 +189,8 @@ public static final class Builder { private Builder() {} public Builder from(CountFeaturesParams other) { + booleanRequireEvent(other.getBooleanRequireEvent()); + featureType(other.getFeatureType()); ids(other.getIds()); limit(other.getLimit()); offset(other.getOffset()); @@ -163,6 +200,34 @@ public Builder from(CountFeaturesParams other) { return this; } + /** + *

Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter.

+ */ + @JsonSetter(value = "boolean_require_event", nulls = Nulls.SKIP) + public Builder booleanRequireEvent(Optional booleanRequireEvent) { + this.booleanRequireEvent = booleanRequireEvent; + return this; + } + + public Builder booleanRequireEvent(Boolean booleanRequireEvent) { + this.booleanRequireEvent = Optional.ofNullable(booleanRequireEvent); + return this; + } + + /** + *

Filter by one or more feature types (boolean, event, trait)

+ */ + @JsonSetter(value = "feature_type", nulls = Nulls.SKIP) + public Builder featureType(Optional> featureType) { + this.featureType = featureType; + return this; + } + + public Builder featureType(List featureType) { + this.featureType = Optional.ofNullable(featureType); + return this; + } + @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -174,6 +239,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -185,6 +253,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -196,6 +267,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Search by feature name or ID

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -207,6 +281,9 @@ public Builder q(String q) { return this; } + /** + *

Filter out features that already have a company override for the specified company ID

+ */ @JsonSetter(value = "without_company_override_for", nulls = Nulls.SKIP) public Builder withoutCompanyOverrideFor(Optional withoutCompanyOverrideFor) { this.withoutCompanyOverrideFor = withoutCompanyOverrideFor; @@ -218,6 +295,9 @@ public Builder withoutCompanyOverrideFor(String withoutCompanyOverrideFor) { return this; } + /** + *

Filter out features that already have a plan entitlement for the specified plan ID

+ */ @JsonSetter(value = "without_plan_entitlement_for", nulls = Nulls.SKIP) public Builder withoutPlanEntitlementFor(Optional withoutPlanEntitlementFor) { this.withoutPlanEntitlementFor = withoutPlanEntitlementFor; @@ -231,7 +311,15 @@ public Builder withoutPlanEntitlementFor(String withoutPlanEntitlementFor) { public CountFeaturesParams build() { return new CountFeaturesParams( - ids, limit, offset, q, withoutCompanyOverrideFor, withoutPlanEntitlementFor, additionalProperties); + booleanRequireEvent, + featureType, + ids, + limit, + offset, + q, + withoutCompanyOverrideFor, + withoutPlanEntitlementFor, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/features/types/CountFeaturesResponse.java b/src/main/java/com/schematic/api/resources/features/types/CountFeaturesResponse.java index 1fa7294..e5544ad 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CountFeaturesResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/CountFeaturesResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountFeaturesParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/features/types/CountFlagsParams.java b/src/main/java/com/schematic/api/resources/features/types/CountFlagsParams.java index d4905f1..f339eed 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CountFlagsParams.java +++ b/src/main/java/com/schematic/api/resources/features/types/CountFlagsParams.java @@ -74,6 +74,9 @@ public Optional getOffset() { return offset; } + /** + * @return Search by flag name, key, or ID + */ @JsonProperty("q") public Optional getQ() { return q; @@ -160,6 +163,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -171,6 +177,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -182,6 +191,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Search by flag name, key, or ID

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; diff --git a/src/main/java/com/schematic/api/resources/features/types/CountFlagsResponse.java b/src/main/java/com/schematic/api/resources/features/types/CountFlagsResponse.java index 8dccb47..5e0a143 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CountFlagsResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/CountFlagsResponse.java @@ -81,6 +81,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountFlagsParams params); } @@ -114,6 +117,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/features/types/CreateFeatureRequestBodyFeatureType.java b/src/main/java/com/schematic/api/resources/features/types/CreateFeatureRequestBodyFeatureType.java index be8ad20..c63763d 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CreateFeatureRequestBodyFeatureType.java +++ b/src/main/java/com/schematic/api/resources/features/types/CreateFeatureRequestBodyFeatureType.java @@ -3,24 +3,95 @@ */ package com.schematic.api.resources.features.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateFeatureRequestBodyFeatureType { - BOOLEAN("boolean"), +public final class CreateFeatureRequestBodyFeatureType { + public static final CreateFeatureRequestBodyFeatureType TRAIT = + new CreateFeatureRequestBodyFeatureType(Value.TRAIT, "trait"); - EVENT("event"), + public static final CreateFeatureRequestBodyFeatureType BOOLEAN = + new CreateFeatureRequestBodyFeatureType(Value.BOOLEAN, "boolean"); - TRAIT("trait"); + public static final CreateFeatureRequestBodyFeatureType EVENT = + new CreateFeatureRequestBodyFeatureType(Value.EVENT, "event"); - private final String value; + private final Value value; - CreateFeatureRequestBodyFeatureType(String value) { + private final String string; + + CreateFeatureRequestBodyFeatureType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateFeatureRequestBodyFeatureType + && this.string.equals(((CreateFeatureRequestBodyFeatureType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case EVENT: + return visitor.visitEvent(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateFeatureRequestBodyFeatureType valueOf(String value) { + switch (value) { + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "event": + return EVENT; + default: + return new CreateFeatureRequestBodyFeatureType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + EVENT, + + TRAIT, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitEvent(); + + T visitTrait(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/features/types/CreateFeatureRequestBodyLifecyclePhase.java b/src/main/java/com/schematic/api/resources/features/types/CreateFeatureRequestBodyLifecyclePhase.java new file mode 100644 index 0000000..4810c38 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/features/types/CreateFeatureRequestBodyLifecyclePhase.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.features.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreateFeatureRequestBodyLifecyclePhase { + public static final CreateFeatureRequestBodyLifecyclePhase GA = + new CreateFeatureRequestBodyLifecyclePhase(Value.GA, "ga"); + + public static final CreateFeatureRequestBodyLifecyclePhase ALPHA = + new CreateFeatureRequestBodyLifecyclePhase(Value.ALPHA, "alpha"); + + public static final CreateFeatureRequestBodyLifecyclePhase BETA = + new CreateFeatureRequestBodyLifecyclePhase(Value.BETA, "beta"); + + public static final CreateFeatureRequestBodyLifecyclePhase INACTIVE = + new CreateFeatureRequestBodyLifecyclePhase(Value.INACTIVE, "inactive"); + + public static final CreateFeatureRequestBodyLifecyclePhase ADD_ON = + new CreateFeatureRequestBodyLifecyclePhase(Value.ADD_ON, "add_on"); + + public static final CreateFeatureRequestBodyLifecyclePhase DEPRECATED = + new CreateFeatureRequestBodyLifecyclePhase(Value.DEPRECATED, "deprecated"); + + public static final CreateFeatureRequestBodyLifecyclePhase LEGACY = + new CreateFeatureRequestBodyLifecyclePhase(Value.LEGACY, "legacy"); + + public static final CreateFeatureRequestBodyLifecyclePhase INTERNAL_TESTING = + new CreateFeatureRequestBodyLifecyclePhase(Value.INTERNAL_TESTING, "internal_testing"); + + public static final CreateFeatureRequestBodyLifecyclePhase IN_PLAN = + new CreateFeatureRequestBodyLifecyclePhase(Value.IN_PLAN, "in_plan"); + + private final Value value; + + private final String string; + + CreateFeatureRequestBodyLifecyclePhase(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateFeatureRequestBodyLifecyclePhase + && this.string.equals(((CreateFeatureRequestBodyLifecyclePhase) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case GA: + return visitor.visitGa(); + case ALPHA: + return visitor.visitAlpha(); + case BETA: + return visitor.visitBeta(); + case INACTIVE: + return visitor.visitInactive(); + case ADD_ON: + return visitor.visitAddOn(); + case DEPRECATED: + return visitor.visitDeprecated(); + case LEGACY: + return visitor.visitLegacy(); + case INTERNAL_TESTING: + return visitor.visitInternalTesting(); + case IN_PLAN: + return visitor.visitInPlan(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateFeatureRequestBodyLifecyclePhase valueOf(String value) { + switch (value) { + case "ga": + return GA; + case "alpha": + return ALPHA; + case "beta": + return BETA; + case "inactive": + return INACTIVE; + case "add_on": + return ADD_ON; + case "deprecated": + return DEPRECATED; + case "legacy": + return LEGACY; + case "internal_testing": + return INTERNAL_TESTING; + case "in_plan": + return IN_PLAN; + default: + return new CreateFeatureRequestBodyLifecyclePhase(Value.UNKNOWN, value); + } + } + + public enum Value { + ADD_ON, + + ALPHA, + + BETA, + + DEPRECATED, + + GA, + + IN_PLAN, + + INACTIVE, + + INTERNAL_TESTING, + + LEGACY, + + UNKNOWN + } + + public interface Visitor { + T visitAddOn(); + + T visitAlpha(); + + T visitBeta(); + + T visitDeprecated(); + + T visitGa(); + + T visitInPlan(); + + T visitInactive(); + + T visitInternalTesting(); + + T visitLegacy(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/features/types/CreateFeatureResponse.java b/src/main/java/com/schematic/api/resources/features/types/CreateFeatureResponse.java index df91437..85c73e7 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CreateFeatureResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/CreateFeatureResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateFeatureResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/CreateFlagResponse.java b/src/main/java/com/schematic/api/resources/features/types/CreateFlagResponse.java index 02da44c..1c4b489 100644 --- a/src/main/java/com/schematic/api/resources/features/types/CreateFlagResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/CreateFlagResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateFlagResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/DeleteFeatureResponse.java b/src/main/java/com/schematic/api/resources/features/types/DeleteFeatureResponse.java index a024da0..2df9dae 100644 --- a/src/main/java/com/schematic/api/resources/features/types/DeleteFeatureResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/DeleteFeatureResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteFeatureResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/DeleteFlagResponse.java b/src/main/java/com/schematic/api/resources/features/types/DeleteFlagResponse.java index 7ac1cf6..d420ade 100644 --- a/src/main/java/com/schematic/api/resources/features/types/DeleteFlagResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/DeleteFlagResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteFlagResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/GetFeatureResponse.java b/src/main/java/com/schematic/api/resources/features/types/GetFeatureResponse.java index 57d468c..f253547 100644 --- a/src/main/java/com/schematic/api/resources/features/types/GetFeatureResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/GetFeatureResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetFeatureResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/GetFlagResponse.java b/src/main/java/com/schematic/api/resources/features/types/GetFlagResponse.java index 7f43e7f..22f3ee8 100644 --- a/src/main/java/com/schematic/api/resources/features/types/GetFlagResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/GetFlagResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetFlagResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/ListAudienceUsersResponse.java b/src/main/java/com/schematic/api/resources/features/types/ListAudienceUsersResponse.java deleted file mode 100644 index f95e4a7..0000000 --- a/src/main/java/com/schematic/api/resources/features/types/ListAudienceUsersResponse.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.schematic.api.resources.features.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.schematic.api.core.ObjectMappers; -import com.schematic.api.types.UserDetailResponseData; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListAudienceUsersResponse.Builder.class) -public final class ListAudienceUsersResponse { - private final List data; - - private final Map params; - - private final Map additionalProperties; - - private ListAudienceUsersResponse( - List data, Map params, Map additionalProperties) { - this.data = data; - this.params = params; - this.additionalProperties = additionalProperties; - } - - /** - * @return The returned resources - */ - @JsonProperty("data") - public List getData() { - return data; - } - - /** - * @return Input parameters - */ - @JsonProperty("params") - public Map getParams() { - return params; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListAudienceUsersResponse && equalTo((ListAudienceUsersResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListAudienceUsersResponse other) { - return data.equals(other.data) && params.equals(other.params); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.data, this.params); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List data = new ArrayList<>(); - - private Map params = new LinkedHashMap<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListAudienceUsersResponse other) { - data(other.getData()); - params(other.getParams()); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(List data) { - this.data.clear(); - this.data.addAll(data); - return this; - } - - public Builder addData(UserDetailResponseData data) { - this.data.add(data); - return this; - } - - public Builder addAllData(List data) { - this.data.addAll(data); - return this; - } - - @JsonSetter(value = "params", nulls = Nulls.SKIP) - public Builder params(Map params) { - this.params.clear(); - this.params.putAll(params); - return this; - } - - public Builder putAllParams(Map params) { - this.params.putAll(params); - return this; - } - - public Builder params(String key, JsonNode value) { - this.params.put(key, value); - return this; - } - - public ListAudienceUsersResponse build() { - return new ListAudienceUsersResponse(data, params, additionalProperties); - } - } -} diff --git a/src/main/java/com/schematic/api/resources/features/types/ListFeaturesParams.java b/src/main/java/com/schematic/api/resources/features/types/ListFeaturesParams.java index 5cc2229..9dcbd3a 100644 --- a/src/main/java/com/schematic/api/resources/features/types/ListFeaturesParams.java +++ b/src/main/java/com/schematic/api/resources/features/types/ListFeaturesParams.java @@ -21,6 +21,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListFeaturesParams.Builder.class) public final class ListFeaturesParams { + private final Optional booleanRequireEvent; + + private final Optional> featureType; + private final Optional> ids; private final Optional limit; @@ -36,6 +40,8 @@ public final class ListFeaturesParams { private final Map additionalProperties; private ListFeaturesParams( + Optional booleanRequireEvent, + Optional> featureType, Optional> ids, Optional limit, Optional offset, @@ -43,6 +49,8 @@ private ListFeaturesParams( Optional withoutCompanyOverrideFor, Optional withoutPlanEntitlementFor, Map additionalProperties) { + this.booleanRequireEvent = booleanRequireEvent; + this.featureType = featureType; this.ids = ids; this.limit = limit; this.offset = offset; @@ -52,6 +60,22 @@ private ListFeaturesParams( this.additionalProperties = additionalProperties; } + /** + * @return Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter. + */ + @JsonProperty("boolean_require_event") + public Optional getBooleanRequireEvent() { + return booleanRequireEvent; + } + + /** + * @return Filter by one or more feature types (boolean, event, trait) + */ + @JsonProperty("feature_type") + public Optional> getFeatureType() { + return featureType; + } + @JsonProperty("ids") public Optional> getIds() { return ids; @@ -73,6 +97,9 @@ public Optional getOffset() { return offset; } + /** + * @return Search by feature name or ID + */ @JsonProperty("q") public Optional getQ() { return q; @@ -106,7 +133,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListFeaturesParams other) { - return ids.equals(other.ids) + return booleanRequireEvent.equals(other.booleanRequireEvent) + && featureType.equals(other.featureType) + && ids.equals(other.ids) && limit.equals(other.limit) && offset.equals(other.offset) && q.equals(other.q) @@ -117,6 +146,8 @@ private boolean equalTo(ListFeaturesParams other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.booleanRequireEvent, + this.featureType, this.ids, this.limit, this.offset, @@ -136,6 +167,10 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional booleanRequireEvent = Optional.empty(); + + private Optional> featureType = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional limit = Optional.empty(); @@ -154,6 +189,8 @@ public static final class Builder { private Builder() {} public Builder from(ListFeaturesParams other) { + booleanRequireEvent(other.getBooleanRequireEvent()); + featureType(other.getFeatureType()); ids(other.getIds()); limit(other.getLimit()); offset(other.getOffset()); @@ -163,6 +200,34 @@ public Builder from(ListFeaturesParams other) { return this; } + /** + *

Only return boolean features if there is an associated event. Automatically includes boolean in the feature types filter.

+ */ + @JsonSetter(value = "boolean_require_event", nulls = Nulls.SKIP) + public Builder booleanRequireEvent(Optional booleanRequireEvent) { + this.booleanRequireEvent = booleanRequireEvent; + return this; + } + + public Builder booleanRequireEvent(Boolean booleanRequireEvent) { + this.booleanRequireEvent = Optional.ofNullable(booleanRequireEvent); + return this; + } + + /** + *

Filter by one or more feature types (boolean, event, trait)

+ */ + @JsonSetter(value = "feature_type", nulls = Nulls.SKIP) + public Builder featureType(Optional> featureType) { + this.featureType = featureType; + return this; + } + + public Builder featureType(List featureType) { + this.featureType = Optional.ofNullable(featureType); + return this; + } + @JsonSetter(value = "ids", nulls = Nulls.SKIP) public Builder ids(Optional> ids) { this.ids = ids; @@ -174,6 +239,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -185,6 +253,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -196,6 +267,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Search by feature name or ID

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -207,6 +281,9 @@ public Builder q(String q) { return this; } + /** + *

Filter out features that already have a company override for the specified company ID

+ */ @JsonSetter(value = "without_company_override_for", nulls = Nulls.SKIP) public Builder withoutCompanyOverrideFor(Optional withoutCompanyOverrideFor) { this.withoutCompanyOverrideFor = withoutCompanyOverrideFor; @@ -218,6 +295,9 @@ public Builder withoutCompanyOverrideFor(String withoutCompanyOverrideFor) { return this; } + /** + *

Filter out features that already have a plan entitlement for the specified plan ID

+ */ @JsonSetter(value = "without_plan_entitlement_for", nulls = Nulls.SKIP) public Builder withoutPlanEntitlementFor(Optional withoutPlanEntitlementFor) { this.withoutPlanEntitlementFor = withoutPlanEntitlementFor; @@ -231,7 +311,15 @@ public Builder withoutPlanEntitlementFor(String withoutPlanEntitlementFor) { public ListFeaturesParams build() { return new ListFeaturesParams( - ids, limit, offset, q, withoutCompanyOverrideFor, withoutPlanEntitlementFor, additionalProperties); + booleanRequireEvent, + featureType, + ids, + limit, + offset, + q, + withoutCompanyOverrideFor, + withoutPlanEntitlementFor, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/features/types/ListFeaturesResponse.java b/src/main/java/com/schematic/api/resources/features/types/ListFeaturesResponse.java index 5dea4b6..e70e6e1 100644 --- a/src/main/java/com/schematic/api/resources/features/types/ListFeaturesResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/ListFeaturesResponse.java @@ -36,9 +36,6 @@ private ListFeaturesResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListFeaturesParams params); Builder from(ListFeaturesResponse other); @@ -116,6 +116,7 @@ public Builder from(ListFeaturesResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListFeaturesParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(FeatureDetailResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(FeatureDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/ListFlagsParams.java b/src/main/java/com/schematic/api/resources/features/types/ListFlagsParams.java index b69ca81..c97f41b 100644 --- a/src/main/java/com/schematic/api/resources/features/types/ListFlagsParams.java +++ b/src/main/java/com/schematic/api/resources/features/types/ListFlagsParams.java @@ -74,6 +74,9 @@ public Optional getOffset() { return offset; } + /** + * @return Search by flag name, key, or ID + */ @JsonProperty("q") public Optional getQ() { return q; @@ -160,6 +163,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -171,6 +177,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -182,6 +191,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Search by flag name, key, or ID

+ */ @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; diff --git a/src/main/java/com/schematic/api/resources/features/types/ListFlagsResponse.java b/src/main/java/com/schematic/api/resources/features/types/ListFlagsResponse.java index 9c4be7c..29434aa 100644 --- a/src/main/java/com/schematic/api/resources/features/types/ListFlagsResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/ListFlagsResponse.java @@ -36,9 +36,6 @@ private ListFlagsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListFlagsParams params); Builder from(ListFlagsResponse other); @@ -116,6 +116,7 @@ public Builder from(ListFlagsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListFlagsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(FlagDetailResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(FlagDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureRequestBodyFeatureType.java b/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureRequestBodyFeatureType.java index a9571b3..7c45ffa 100644 --- a/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureRequestBodyFeatureType.java +++ b/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureRequestBodyFeatureType.java @@ -3,24 +3,95 @@ */ package com.schematic.api.resources.features.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateFeatureRequestBodyFeatureType { - BOOLEAN("boolean"), +public final class UpdateFeatureRequestBodyFeatureType { + public static final UpdateFeatureRequestBodyFeatureType TRAIT = + new UpdateFeatureRequestBodyFeatureType(Value.TRAIT, "trait"); - EVENT("event"), + public static final UpdateFeatureRequestBodyFeatureType BOOLEAN = + new UpdateFeatureRequestBodyFeatureType(Value.BOOLEAN, "boolean"); - TRAIT("trait"); + public static final UpdateFeatureRequestBodyFeatureType EVENT = + new UpdateFeatureRequestBodyFeatureType(Value.EVENT, "event"); - private final String value; + private final Value value; - UpdateFeatureRequestBodyFeatureType(String value) { + private final String string; + + UpdateFeatureRequestBodyFeatureType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateFeatureRequestBodyFeatureType + && this.string.equals(((UpdateFeatureRequestBodyFeatureType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case EVENT: + return visitor.visitEvent(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateFeatureRequestBodyFeatureType valueOf(String value) { + switch (value) { + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "event": + return EVENT; + default: + return new UpdateFeatureRequestBodyFeatureType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + EVENT, + + TRAIT, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitEvent(); + + T visitTrait(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureRequestBodyLifecyclePhase.java b/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureRequestBodyLifecyclePhase.java new file mode 100644 index 0000000..255d0d5 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureRequestBodyLifecyclePhase.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.features.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UpdateFeatureRequestBodyLifecyclePhase { + public static final UpdateFeatureRequestBodyLifecyclePhase GA = + new UpdateFeatureRequestBodyLifecyclePhase(Value.GA, "ga"); + + public static final UpdateFeatureRequestBodyLifecyclePhase ALPHA = + new UpdateFeatureRequestBodyLifecyclePhase(Value.ALPHA, "alpha"); + + public static final UpdateFeatureRequestBodyLifecyclePhase BETA = + new UpdateFeatureRequestBodyLifecyclePhase(Value.BETA, "beta"); + + public static final UpdateFeatureRequestBodyLifecyclePhase INACTIVE = + new UpdateFeatureRequestBodyLifecyclePhase(Value.INACTIVE, "inactive"); + + public static final UpdateFeatureRequestBodyLifecyclePhase ADD_ON = + new UpdateFeatureRequestBodyLifecyclePhase(Value.ADD_ON, "add_on"); + + public static final UpdateFeatureRequestBodyLifecyclePhase DEPRECATED = + new UpdateFeatureRequestBodyLifecyclePhase(Value.DEPRECATED, "deprecated"); + + public static final UpdateFeatureRequestBodyLifecyclePhase LEGACY = + new UpdateFeatureRequestBodyLifecyclePhase(Value.LEGACY, "legacy"); + + public static final UpdateFeatureRequestBodyLifecyclePhase INTERNAL_TESTING = + new UpdateFeatureRequestBodyLifecyclePhase(Value.INTERNAL_TESTING, "internal_testing"); + + public static final UpdateFeatureRequestBodyLifecyclePhase IN_PLAN = + new UpdateFeatureRequestBodyLifecyclePhase(Value.IN_PLAN, "in_plan"); + + private final Value value; + + private final String string; + + UpdateFeatureRequestBodyLifecyclePhase(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateFeatureRequestBodyLifecyclePhase + && this.string.equals(((UpdateFeatureRequestBodyLifecyclePhase) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case GA: + return visitor.visitGa(); + case ALPHA: + return visitor.visitAlpha(); + case BETA: + return visitor.visitBeta(); + case INACTIVE: + return visitor.visitInactive(); + case ADD_ON: + return visitor.visitAddOn(); + case DEPRECATED: + return visitor.visitDeprecated(); + case LEGACY: + return visitor.visitLegacy(); + case INTERNAL_TESTING: + return visitor.visitInternalTesting(); + case IN_PLAN: + return visitor.visitInPlan(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateFeatureRequestBodyLifecyclePhase valueOf(String value) { + switch (value) { + case "ga": + return GA; + case "alpha": + return ALPHA; + case "beta": + return BETA; + case "inactive": + return INACTIVE; + case "add_on": + return ADD_ON; + case "deprecated": + return DEPRECATED; + case "legacy": + return LEGACY; + case "internal_testing": + return INTERNAL_TESTING; + case "in_plan": + return IN_PLAN; + default: + return new UpdateFeatureRequestBodyLifecyclePhase(Value.UNKNOWN, value); + } + } + + public enum Value { + ADD_ON, + + ALPHA, + + BETA, + + DEPRECATED, + + GA, + + IN_PLAN, + + INACTIVE, + + INTERNAL_TESTING, + + LEGACY, + + UNKNOWN + } + + public interface Visitor { + T visitAddOn(); + + T visitAlpha(); + + T visitBeta(); + + T visitDeprecated(); + + T visitGa(); + + T visitInPlan(); + + T visitInactive(); + + T visitInternalTesting(); + + T visitLegacy(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureResponse.java b/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureResponse.java index e5a5aa6..32a131c 100644 --- a/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/UpdateFeatureResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateFeatureResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/UpdateFlagResponse.java b/src/main/java/com/schematic/api/resources/features/types/UpdateFlagResponse.java index a04b275..1441a73 100644 --- a/src/main/java/com/schematic/api/resources/features/types/UpdateFlagResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/UpdateFlagResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateFlagResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/features/types/UpdateFlagRulesResponse.java b/src/main/java/com/schematic/api/resources/features/types/UpdateFlagRulesResponse.java index b21c839..a84c734 100644 --- a/src/main/java/com/schematic/api/resources/features/types/UpdateFlagRulesResponse.java +++ b/src/main/java/com/schematic/api/resources/features/types/UpdateFlagRulesResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateFlagRulesResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plangroups/AsyncPlangroupsClient.java b/src/main/java/com/schematic/api/resources/plangroups/AsyncPlangroupsClient.java new file mode 100644 index 0000000..38cd1da --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plangroups/AsyncPlangroupsClient.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plangroups; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.plangroups.requests.CreatePlanGroupRequestBody; +import com.schematic.api.resources.plangroups.requests.UpdatePlanGroupRequestBody; +import com.schematic.api.resources.plangroups.types.CreatePlanGroupResponse; +import com.schematic.api.resources.plangroups.types.GetPlanGroupResponse; +import com.schematic.api.resources.plangroups.types.UpdatePlanGroupResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPlangroupsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPlangroupsClient rawClient; + + public AsyncPlangroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPlangroupsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPlangroupsClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture getPlanGroup() { + return this.rawClient.getPlanGroup().thenApply(response -> response.body()); + } + + public CompletableFuture getPlanGroup(RequestOptions requestOptions) { + return this.rawClient.getPlanGroup(requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createPlanGroup(CreatePlanGroupRequestBody request) { + return this.rawClient.createPlanGroup(request).thenApply(response -> response.body()); + } + + public CompletableFuture createPlanGroup( + CreatePlanGroupRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createPlanGroup(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlanGroup( + String planGroupId, UpdatePlanGroupRequestBody request) { + return this.rawClient.updatePlanGroup(planGroupId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlanGroup( + String planGroupId, UpdatePlanGroupRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updatePlanGroup(planGroupId, request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/plangroups/AsyncRawPlangroupsClient.java b/src/main/java/com/schematic/api/resources/plangroups/AsyncRawPlangroupsClient.java new file mode 100644 index 0000000..7f8a97d --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plangroups/AsyncRawPlangroupsClient.java @@ -0,0 +1,306 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plangroups; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.plangroups.requests.CreatePlanGroupRequestBody; +import com.schematic.api.resources.plangroups.requests.UpdatePlanGroupRequestBody; +import com.schematic.api.resources.plangroups.types.CreatePlanGroupResponse; +import com.schematic.api.resources.plangroups.types.GetPlanGroupResponse; +import com.schematic.api.resources.plangroups.types.UpdatePlanGroupResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPlangroupsClient { + protected final ClientOptions clientOptions; + + public AsyncRawPlangroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> getPlanGroup() { + return getPlanGroup(null); + } + + public CompletableFuture> getPlanGroup( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-groups") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanGroupResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createPlanGroup( + CreatePlanGroupRequestBody request) { + return createPlanGroup(request, null); + } + + public CompletableFuture> createPlanGroup( + CreatePlanGroupRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-groups") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CreatePlanGroupResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updatePlanGroup( + String planGroupId, UpdatePlanGroupRequestBody request) { + return updatePlanGroup(planGroupId, request, null); + } + + public CompletableFuture> updatePlanGroup( + String planGroupId, UpdatePlanGroupRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-groups") + .addPathSegment(planGroupId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdatePlanGroupResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/plangroups/PlangroupsClient.java b/src/main/java/com/schematic/api/resources/plangroups/PlangroupsClient.java index b9465b6..1855b7a 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/PlangroupsClient.java +++ b/src/main/java/com/schematic/api/resources/plangroups/PlangroupsClient.java @@ -3,215 +3,55 @@ */ package com.schematic.api.resources.plangroups; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.NotFoundError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.plangroups.requests.CreatePlanGroupRequestBody; import com.schematic.api.resources.plangroups.requests.UpdatePlanGroupRequestBody; import com.schematic.api.resources.plangroups.types.CreatePlanGroupResponse; import com.schematic.api.resources.plangroups.types.GetPlanGroupResponse; import com.schematic.api.resources.plangroups.types.UpdatePlanGroupResponse; -import com.schematic.api.types.ApiError; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PlangroupsClient { protected final ClientOptions clientOptions; + private final RawPlangroupsClient rawClient; + public PlangroupsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPlangroupsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPlangroupsClient withRawResponse() { + return this.rawClient; } public GetPlanGroupResponse getPlanGroup() { - return getPlanGroup(null); + return this.rawClient.getPlanGroup().body(); } public GetPlanGroupResponse getPlanGroup(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plan-groups") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanGroupResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getPlanGroup(requestOptions).body(); } public CreatePlanGroupResponse createPlanGroup(CreatePlanGroupRequestBody request) { - return createPlanGroup(request, null); + return this.rawClient.createPlanGroup(request).body(); } public CreatePlanGroupResponse createPlanGroup(CreatePlanGroupRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plan-groups") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreatePlanGroupResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.createPlanGroup(request, requestOptions).body(); } public UpdatePlanGroupResponse updatePlanGroup(String planGroupId, UpdatePlanGroupRequestBody request) { - return updatePlanGroup(planGroupId, request, null); + return this.rawClient.updatePlanGroup(planGroupId, request).body(); } public UpdatePlanGroupResponse updatePlanGroup( String planGroupId, UpdatePlanGroupRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plan-groups") - .addPathSegment(planGroupId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdatePlanGroupResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient + .updatePlanGroup(planGroupId, request, requestOptions) + .body(); } } diff --git a/src/main/java/com/schematic/api/resources/plangroups/RawPlangroupsClient.java b/src/main/java/com/schematic/api/resources/plangroups/RawPlangroupsClient.java new file mode 100644 index 0000000..b6c9a0c --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plangroups/RawPlangroupsClient.java @@ -0,0 +1,231 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plangroups; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.plangroups.requests.CreatePlanGroupRequestBody; +import com.schematic.api.resources.plangroups.requests.UpdatePlanGroupRequestBody; +import com.schematic.api.resources.plangroups.types.CreatePlanGroupResponse; +import com.schematic.api.resources.plangroups.types.GetPlanGroupResponse; +import com.schematic.api.resources.plangroups.types.UpdatePlanGroupResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPlangroupsClient { + protected final ClientOptions clientOptions; + + public RawPlangroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse getPlanGroup() { + return getPlanGroup(null); + } + + public BaseSchematicHttpResponse getPlanGroup(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-groups") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanGroupResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createPlanGroup(CreatePlanGroupRequestBody request) { + return createPlanGroup(request, null); + } + + public BaseSchematicHttpResponse createPlanGroup( + CreatePlanGroupRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-groups") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreatePlanGroupResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updatePlanGroup( + String planGroupId, UpdatePlanGroupRequestBody request) { + return updatePlanGroup(planGroupId, request, null); + } + + public BaseSchematicHttpResponse updatePlanGroup( + String planGroupId, UpdatePlanGroupRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plan-groups") + .addPathSegment(planGroupId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdatePlanGroupResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/plangroups/requests/CreatePlanGroupRequestBody.java b/src/main/java/com/schematic/api/resources/plangroups/requests/CreatePlanGroupRequestBody.java index 0d76384..8f9274c 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/requests/CreatePlanGroupRequestBody.java +++ b/src/main/java/com/schematic/api/resources/plangroups/requests/CreatePlanGroupRequestBody.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CompatiblePlans; import com.schematic.api.types.CustomPlanConfig; import com.schematic.api.types.OrderedPlansInGroup; +import com.schematic.api.types.PlanGroupBundleOrder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -24,46 +26,133 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreatePlanGroupRequestBody.Builder.class) public final class CreatePlanGroupRequestBody { + private final Optional> addOnCompatibilities; + private final List addOnIds; + private final boolean checkoutCollectAddress; + + private final boolean checkoutCollectEmail; + + private final boolean checkoutCollectPhone; + private final Optional customPlanConfig; private final Optional customPlanId; - private final Optional defaultPlanId; + private final boolean enableTaxCollection; + + private final Optional fallbackPlanId; + + private final Optional initialPlanId; + + private final Optional initialPlanPriceId; + + private final List orderedAddOns; + + private final List orderedBundleList; private final List orderedPlans; + private final boolean preventDowngradesWhenOverLimit; + + private final boolean showCredits; + + private final boolean showPeriodToggle; + + private final boolean showZeroPriceAsFree; + + private final boolean syncCustomerBillingDetailsForTax; + private final Optional trialDays; + private final Optional trialExpiryPlanId; + + private final Optional trialExpiryPlanPriceId; + private final Optional trialPaymentMethodRequired; private final Map additionalProperties; private CreatePlanGroupRequestBody( + Optional> addOnCompatibilities, List addOnIds, + boolean checkoutCollectAddress, + boolean checkoutCollectEmail, + boolean checkoutCollectPhone, Optional customPlanConfig, Optional customPlanId, - Optional defaultPlanId, + boolean enableTaxCollection, + Optional fallbackPlanId, + Optional initialPlanId, + Optional initialPlanPriceId, + List orderedAddOns, + List orderedBundleList, List orderedPlans, + boolean preventDowngradesWhenOverLimit, + boolean showCredits, + boolean showPeriodToggle, + boolean showZeroPriceAsFree, + boolean syncCustomerBillingDetailsForTax, Optional trialDays, + Optional trialExpiryPlanId, + Optional trialExpiryPlanPriceId, Optional trialPaymentMethodRequired, Map additionalProperties) { + this.addOnCompatibilities = addOnCompatibilities; this.addOnIds = addOnIds; + this.checkoutCollectAddress = checkoutCollectAddress; + this.checkoutCollectEmail = checkoutCollectEmail; + this.checkoutCollectPhone = checkoutCollectPhone; this.customPlanConfig = customPlanConfig; this.customPlanId = customPlanId; - this.defaultPlanId = defaultPlanId; + this.enableTaxCollection = enableTaxCollection; + this.fallbackPlanId = fallbackPlanId; + this.initialPlanId = initialPlanId; + this.initialPlanPriceId = initialPlanPriceId; + this.orderedAddOns = orderedAddOns; + this.orderedBundleList = orderedBundleList; this.orderedPlans = orderedPlans; + this.preventDowngradesWhenOverLimit = preventDowngradesWhenOverLimit; + this.showCredits = showCredits; + this.showPeriodToggle = showPeriodToggle; + this.showZeroPriceAsFree = showZeroPriceAsFree; + this.syncCustomerBillingDetailsForTax = syncCustomerBillingDetailsForTax; this.trialDays = trialDays; + this.trialExpiryPlanId = trialExpiryPlanId; + this.trialExpiryPlanPriceId = trialExpiryPlanPriceId; this.trialPaymentMethodRequired = trialPaymentMethodRequired; this.additionalProperties = additionalProperties; } + @JsonProperty("add_on_compatibilities") + public Optional> getAddOnCompatibilities() { + return addOnCompatibilities; + } + + /** + * @return Use OrderedAddOns instead + */ @JsonProperty("add_on_ids") public List getAddOnIds() { return addOnIds; } + @JsonProperty("checkout_collect_address") + public boolean getCheckoutCollectAddress() { + return checkoutCollectAddress; + } + + @JsonProperty("checkout_collect_email") + public boolean getCheckoutCollectEmail() { + return checkoutCollectEmail; + } + + @JsonProperty("checkout_collect_phone") + public boolean getCheckoutCollectPhone() { + return checkoutCollectPhone; + } + @JsonProperty("custom_plan_config") public Optional getCustomPlanConfig() { return customPlanConfig; @@ -74,9 +163,34 @@ public Optional getCustomPlanId() { return customPlanId; } - @JsonProperty("default_plan_id") - public Optional getDefaultPlanId() { - return defaultPlanId; + @JsonProperty("enable_tax_collection") + public boolean getEnableTaxCollection() { + return enableTaxCollection; + } + + @JsonProperty("fallback_plan_id") + public Optional getFallbackPlanId() { + return fallbackPlanId; + } + + @JsonProperty("initial_plan_id") + public Optional getInitialPlanId() { + return initialPlanId; + } + + @JsonProperty("initial_plan_price_id") + public Optional getInitialPlanPriceId() { + return initialPlanPriceId; + } + + @JsonProperty("ordered_add_ons") + public List getOrderedAddOns() { + return orderedAddOns; + } + + @JsonProperty("ordered_bundle_list") + public List getOrderedBundleList() { + return orderedBundleList; } @JsonProperty("ordered_plans") @@ -84,11 +198,46 @@ public List getOrderedPlans() { return orderedPlans; } + @JsonProperty("prevent_downgrades_when_over_limit") + public boolean getPreventDowngradesWhenOverLimit() { + return preventDowngradesWhenOverLimit; + } + + @JsonProperty("show_credits") + public boolean getShowCredits() { + return showCredits; + } + + @JsonProperty("show_period_toggle") + public boolean getShowPeriodToggle() { + return showPeriodToggle; + } + + @JsonProperty("show_zero_price_as_free") + public boolean getShowZeroPriceAsFree() { + return showZeroPriceAsFree; + } + + @JsonProperty("sync_customer_billing_details_for_tax") + public boolean getSyncCustomerBillingDetailsForTax() { + return syncCustomerBillingDetailsForTax; + } + @JsonProperty("trial_days") public Optional getTrialDays() { return trialDays; } + @JsonProperty("trial_expiry_plan_id") + public Optional getTrialExpiryPlanId() { + return trialExpiryPlanId; + } + + @JsonProperty("trial_expiry_plan_price_id") + public Optional getTrialExpiryPlanPriceId() { + return trialExpiryPlanPriceId; + } + @JsonProperty("trial_payment_method_required") public Optional getTrialPaymentMethodRequired() { return trialPaymentMethodRequired; @@ -106,24 +255,56 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreatePlanGroupRequestBody other) { - return addOnIds.equals(other.addOnIds) + return addOnCompatibilities.equals(other.addOnCompatibilities) + && addOnIds.equals(other.addOnIds) + && checkoutCollectAddress == other.checkoutCollectAddress + && checkoutCollectEmail == other.checkoutCollectEmail + && checkoutCollectPhone == other.checkoutCollectPhone && customPlanConfig.equals(other.customPlanConfig) && customPlanId.equals(other.customPlanId) - && defaultPlanId.equals(other.defaultPlanId) + && enableTaxCollection == other.enableTaxCollection + && fallbackPlanId.equals(other.fallbackPlanId) + && initialPlanId.equals(other.initialPlanId) + && initialPlanPriceId.equals(other.initialPlanPriceId) + && orderedAddOns.equals(other.orderedAddOns) + && orderedBundleList.equals(other.orderedBundleList) && orderedPlans.equals(other.orderedPlans) + && preventDowngradesWhenOverLimit == other.preventDowngradesWhenOverLimit + && showCredits == other.showCredits + && showPeriodToggle == other.showPeriodToggle + && showZeroPriceAsFree == other.showZeroPriceAsFree + && syncCustomerBillingDetailsForTax == other.syncCustomerBillingDetailsForTax && trialDays.equals(other.trialDays) + && trialExpiryPlanId.equals(other.trialExpiryPlanId) + && trialExpiryPlanPriceId.equals(other.trialExpiryPlanPriceId) && trialPaymentMethodRequired.equals(other.trialPaymentMethodRequired); } @java.lang.Override public int hashCode() { return Objects.hash( + this.addOnCompatibilities, this.addOnIds, + this.checkoutCollectAddress, + this.checkoutCollectEmail, + this.checkoutCollectPhone, this.customPlanConfig, this.customPlanId, - this.defaultPlanId, + this.enableTaxCollection, + this.fallbackPlanId, + this.initialPlanId, + this.initialPlanPriceId, + this.orderedAddOns, + this.orderedBundleList, this.orderedPlans, + this.preventDowngradesWhenOverLimit, + this.showCredits, + this.showPeriodToggle, + this.showZeroPriceAsFree, + this.syncCustomerBillingDetailsForTax, this.trialDays, + this.trialExpiryPlanId, + this.trialExpiryPlanPriceId, this.trialPaymentMethodRequired); } @@ -132,139 +313,535 @@ public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static CheckoutCollectAddressStage builder() { return new Builder(); } + public interface CheckoutCollectAddressStage { + CheckoutCollectEmailStage checkoutCollectAddress(boolean checkoutCollectAddress); + + Builder from(CreatePlanGroupRequestBody other); + } + + public interface CheckoutCollectEmailStage { + CheckoutCollectPhoneStage checkoutCollectEmail(boolean checkoutCollectEmail); + } + + public interface CheckoutCollectPhoneStage { + EnableTaxCollectionStage checkoutCollectPhone(boolean checkoutCollectPhone); + } + + public interface EnableTaxCollectionStage { + PreventDowngradesWhenOverLimitStage enableTaxCollection(boolean enableTaxCollection); + } + + public interface PreventDowngradesWhenOverLimitStage { + ShowCreditsStage preventDowngradesWhenOverLimit(boolean preventDowngradesWhenOverLimit); + } + + public interface ShowCreditsStage { + ShowPeriodToggleStage showCredits(boolean showCredits); + } + + public interface ShowPeriodToggleStage { + ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle); + } + + public interface ShowZeroPriceAsFreeStage { + SyncCustomerBillingDetailsForTaxStage showZeroPriceAsFree(boolean showZeroPriceAsFree); + } + + public interface SyncCustomerBillingDetailsForTaxStage { + _FinalStage syncCustomerBillingDetailsForTax(boolean syncCustomerBillingDetailsForTax); + } + + public interface _FinalStage { + CreatePlanGroupRequestBody build(); + + _FinalStage addOnCompatibilities(Optional> addOnCompatibilities); + + _FinalStage addOnCompatibilities(List addOnCompatibilities); + + /** + *

Use OrderedAddOns instead

+ */ + _FinalStage addOnIds(List addOnIds); + + _FinalStage addAddOnIds(String addOnIds); + + _FinalStage addAllAddOnIds(List addOnIds); + + _FinalStage customPlanConfig(Optional customPlanConfig); + + _FinalStage customPlanConfig(CustomPlanConfig customPlanConfig); + + _FinalStage customPlanId(Optional customPlanId); + + _FinalStage customPlanId(String customPlanId); + + _FinalStage fallbackPlanId(Optional fallbackPlanId); + + _FinalStage fallbackPlanId(String fallbackPlanId); + + _FinalStage initialPlanId(Optional initialPlanId); + + _FinalStage initialPlanId(String initialPlanId); + + _FinalStage initialPlanPriceId(Optional initialPlanPriceId); + + _FinalStage initialPlanPriceId(String initialPlanPriceId); + + _FinalStage orderedAddOns(List orderedAddOns); + + _FinalStage addOrderedAddOns(OrderedPlansInGroup orderedAddOns); + + _FinalStage addAllOrderedAddOns(List orderedAddOns); + + _FinalStage orderedBundleList(List orderedBundleList); + + _FinalStage addOrderedBundleList(PlanGroupBundleOrder orderedBundleList); + + _FinalStage addAllOrderedBundleList(List orderedBundleList); + + _FinalStage orderedPlans(List orderedPlans); + + _FinalStage addOrderedPlans(OrderedPlansInGroup orderedPlans); + + _FinalStage addAllOrderedPlans(List orderedPlans); + + _FinalStage trialDays(Optional trialDays); + + _FinalStage trialDays(Integer trialDays); + + _FinalStage trialExpiryPlanId(Optional trialExpiryPlanId); + + _FinalStage trialExpiryPlanId(String trialExpiryPlanId); + + _FinalStage trialExpiryPlanPriceId(Optional trialExpiryPlanPriceId); + + _FinalStage trialExpiryPlanPriceId(String trialExpiryPlanPriceId); + + _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired); + + _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List addOnIds = new ArrayList<>(); + public static final class Builder + implements CheckoutCollectAddressStage, + CheckoutCollectEmailStage, + CheckoutCollectPhoneStage, + EnableTaxCollectionStage, + PreventDowngradesWhenOverLimitStage, + ShowCreditsStage, + ShowPeriodToggleStage, + ShowZeroPriceAsFreeStage, + SyncCustomerBillingDetailsForTaxStage, + _FinalStage { + private boolean checkoutCollectAddress; - private Optional customPlanConfig = Optional.empty(); + private boolean checkoutCollectEmail; - private Optional customPlanId = Optional.empty(); + private boolean checkoutCollectPhone; - private Optional defaultPlanId = Optional.empty(); + private boolean enableTaxCollection; - private List orderedPlans = new ArrayList<>(); + private boolean preventDowngradesWhenOverLimit; - private Optional trialDays = Optional.empty(); + private boolean showCredits; + + private boolean showPeriodToggle; + + private boolean showZeroPriceAsFree; + + private boolean syncCustomerBillingDetailsForTax; private Optional trialPaymentMethodRequired = Optional.empty(); + private Optional trialExpiryPlanPriceId = Optional.empty(); + + private Optional trialExpiryPlanId = Optional.empty(); + + private Optional trialDays = Optional.empty(); + + private List orderedPlans = new ArrayList<>(); + + private List orderedBundleList = new ArrayList<>(); + + private List orderedAddOns = new ArrayList<>(); + + private Optional initialPlanPriceId = Optional.empty(); + + private Optional initialPlanId = Optional.empty(); + + private Optional fallbackPlanId = Optional.empty(); + + private Optional customPlanId = Optional.empty(); + + private Optional customPlanConfig = Optional.empty(); + + private List addOnIds = new ArrayList<>(); + + private Optional> addOnCompatibilities = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} + @java.lang.Override public Builder from(CreatePlanGroupRequestBody other) { + addOnCompatibilities(other.getAddOnCompatibilities()); addOnIds(other.getAddOnIds()); + checkoutCollectAddress(other.getCheckoutCollectAddress()); + checkoutCollectEmail(other.getCheckoutCollectEmail()); + checkoutCollectPhone(other.getCheckoutCollectPhone()); customPlanConfig(other.getCustomPlanConfig()); customPlanId(other.getCustomPlanId()); - defaultPlanId(other.getDefaultPlanId()); + enableTaxCollection(other.getEnableTaxCollection()); + fallbackPlanId(other.getFallbackPlanId()); + initialPlanId(other.getInitialPlanId()); + initialPlanPriceId(other.getInitialPlanPriceId()); + orderedAddOns(other.getOrderedAddOns()); + orderedBundleList(other.getOrderedBundleList()); orderedPlans(other.getOrderedPlans()); + preventDowngradesWhenOverLimit(other.getPreventDowngradesWhenOverLimit()); + showCredits(other.getShowCredits()); + showPeriodToggle(other.getShowPeriodToggle()); + showZeroPriceAsFree(other.getShowZeroPriceAsFree()); + syncCustomerBillingDetailsForTax(other.getSyncCustomerBillingDetailsForTax()); trialDays(other.getTrialDays()); + trialExpiryPlanId(other.getTrialExpiryPlanId()); + trialExpiryPlanPriceId(other.getTrialExpiryPlanPriceId()); trialPaymentMethodRequired(other.getTrialPaymentMethodRequired()); return this; } - @JsonSetter(value = "add_on_ids", nulls = Nulls.SKIP) - public Builder addOnIds(List addOnIds) { - this.addOnIds.clear(); - this.addOnIds.addAll(addOnIds); + @java.lang.Override + @JsonSetter("checkout_collect_address") + public CheckoutCollectEmailStage checkoutCollectAddress(boolean checkoutCollectAddress) { + this.checkoutCollectAddress = checkoutCollectAddress; return this; } - public Builder addAddOnIds(String addOnIds) { - this.addOnIds.add(addOnIds); + @java.lang.Override + @JsonSetter("checkout_collect_email") + public CheckoutCollectPhoneStage checkoutCollectEmail(boolean checkoutCollectEmail) { + this.checkoutCollectEmail = checkoutCollectEmail; return this; } - public Builder addAllAddOnIds(List addOnIds) { - this.addOnIds.addAll(addOnIds); + @java.lang.Override + @JsonSetter("checkout_collect_phone") + public EnableTaxCollectionStage checkoutCollectPhone(boolean checkoutCollectPhone) { + this.checkoutCollectPhone = checkoutCollectPhone; return this; } - @JsonSetter(value = "custom_plan_config", nulls = Nulls.SKIP) - public Builder customPlanConfig(Optional customPlanConfig) { - this.customPlanConfig = customPlanConfig; + @java.lang.Override + @JsonSetter("enable_tax_collection") + public PreventDowngradesWhenOverLimitStage enableTaxCollection(boolean enableTaxCollection) { + this.enableTaxCollection = enableTaxCollection; return this; } - public Builder customPlanConfig(CustomPlanConfig customPlanConfig) { - this.customPlanConfig = Optional.ofNullable(customPlanConfig); + @java.lang.Override + @JsonSetter("prevent_downgrades_when_over_limit") + public ShowCreditsStage preventDowngradesWhenOverLimit(boolean preventDowngradesWhenOverLimit) { + this.preventDowngradesWhenOverLimit = preventDowngradesWhenOverLimit; return this; } - @JsonSetter(value = "custom_plan_id", nulls = Nulls.SKIP) - public Builder customPlanId(Optional customPlanId) { - this.customPlanId = customPlanId; + @java.lang.Override + @JsonSetter("show_credits") + public ShowPeriodToggleStage showCredits(boolean showCredits) { + this.showCredits = showCredits; return this; } - public Builder customPlanId(String customPlanId) { - this.customPlanId = Optional.ofNullable(customPlanId); + @java.lang.Override + @JsonSetter("show_period_toggle") + public ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle) { + this.showPeriodToggle = showPeriodToggle; return this; } - @JsonSetter(value = "default_plan_id", nulls = Nulls.SKIP) - public Builder defaultPlanId(Optional defaultPlanId) { - this.defaultPlanId = defaultPlanId; + @java.lang.Override + @JsonSetter("show_zero_price_as_free") + public SyncCustomerBillingDetailsForTaxStage showZeroPriceAsFree(boolean showZeroPriceAsFree) { + this.showZeroPriceAsFree = showZeroPriceAsFree; return this; } - public Builder defaultPlanId(String defaultPlanId) { - this.defaultPlanId = Optional.ofNullable(defaultPlanId); + @java.lang.Override + @JsonSetter("sync_customer_billing_details_for_tax") + public _FinalStage syncCustomerBillingDetailsForTax(boolean syncCustomerBillingDetailsForTax) { + this.syncCustomerBillingDetailsForTax = syncCustomerBillingDetailsForTax; return this; } - @JsonSetter(value = "ordered_plans", nulls = Nulls.SKIP) - public Builder orderedPlans(List orderedPlans) { - this.orderedPlans.clear(); - this.orderedPlans.addAll(orderedPlans); + @java.lang.Override + public _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { + this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); return this; } - public Builder addOrderedPlans(OrderedPlansInGroup orderedPlans) { - this.orderedPlans.add(orderedPlans); + @java.lang.Override + @JsonSetter(value = "trial_payment_method_required", nulls = Nulls.SKIP) + public _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired) { + this.trialPaymentMethodRequired = trialPaymentMethodRequired; return this; } - public Builder addAllOrderedPlans(List orderedPlans) { - this.orderedPlans.addAll(orderedPlans); + @java.lang.Override + public _FinalStage trialExpiryPlanPriceId(String trialExpiryPlanPriceId) { + this.trialExpiryPlanPriceId = Optional.ofNullable(trialExpiryPlanPriceId); return this; } + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanPriceId(Optional trialExpiryPlanPriceId) { + this.trialExpiryPlanPriceId = trialExpiryPlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage trialExpiryPlanId(String trialExpiryPlanId) { + this.trialExpiryPlanId = Optional.ofNullable(trialExpiryPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_id", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanId(Optional trialExpiryPlanId) { + this.trialExpiryPlanId = trialExpiryPlanId; + return this; + } + + @java.lang.Override + public _FinalStage trialDays(Integer trialDays) { + this.trialDays = Optional.ofNullable(trialDays); + return this; + } + + @java.lang.Override @JsonSetter(value = "trial_days", nulls = Nulls.SKIP) - public Builder trialDays(Optional trialDays) { + public _FinalStage trialDays(Optional trialDays) { this.trialDays = trialDays; return this; } - public Builder trialDays(Integer trialDays) { - this.trialDays = Optional.ofNullable(trialDays); + @java.lang.Override + public _FinalStage addAllOrderedPlans(List orderedPlans) { + if (orderedPlans != null) { + this.orderedPlans.addAll(orderedPlans); + } return this; } - @JsonSetter(value = "trial_payment_method_required", nulls = Nulls.SKIP) - public Builder trialPaymentMethodRequired(Optional trialPaymentMethodRequired) { - this.trialPaymentMethodRequired = trialPaymentMethodRequired; + @java.lang.Override + public _FinalStage addOrderedPlans(OrderedPlansInGroup orderedPlans) { + this.orderedPlans.add(orderedPlans); return this; } - public Builder trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { - this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); + @java.lang.Override + @JsonSetter(value = "ordered_plans", nulls = Nulls.SKIP) + public _FinalStage orderedPlans(List orderedPlans) { + this.orderedPlans.clear(); + if (orderedPlans != null) { + this.orderedPlans.addAll(orderedPlans); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllOrderedBundleList(List orderedBundleList) { + if (orderedBundleList != null) { + this.orderedBundleList.addAll(orderedBundleList); + } + return this; + } + + @java.lang.Override + public _FinalStage addOrderedBundleList(PlanGroupBundleOrder orderedBundleList) { + this.orderedBundleList.add(orderedBundleList); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ordered_bundle_list", nulls = Nulls.SKIP) + public _FinalStage orderedBundleList(List orderedBundleList) { + this.orderedBundleList.clear(); + if (orderedBundleList != null) { + this.orderedBundleList.addAll(orderedBundleList); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllOrderedAddOns(List orderedAddOns) { + if (orderedAddOns != null) { + this.orderedAddOns.addAll(orderedAddOns); + } + return this; + } + + @java.lang.Override + public _FinalStage addOrderedAddOns(OrderedPlansInGroup orderedAddOns) { + this.orderedAddOns.add(orderedAddOns); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ordered_add_ons", nulls = Nulls.SKIP) + public _FinalStage orderedAddOns(List orderedAddOns) { + this.orderedAddOns.clear(); + if (orderedAddOns != null) { + this.orderedAddOns.addAll(orderedAddOns); + } + return this; + } + + @java.lang.Override + public _FinalStage initialPlanPriceId(String initialPlanPriceId) { + this.initialPlanPriceId = Optional.ofNullable(initialPlanPriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage initialPlanPriceId(Optional initialPlanPriceId) { + this.initialPlanPriceId = initialPlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage initialPlanId(String initialPlanId) { + this.initialPlanId = Optional.ofNullable(initialPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_id", nulls = Nulls.SKIP) + public _FinalStage initialPlanId(Optional initialPlanId) { + this.initialPlanId = initialPlanId; + return this; + } + + @java.lang.Override + public _FinalStage fallbackPlanId(String fallbackPlanId) { + this.fallbackPlanId = Optional.ofNullable(fallbackPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "fallback_plan_id", nulls = Nulls.SKIP) + public _FinalStage fallbackPlanId(Optional fallbackPlanId) { + this.fallbackPlanId = fallbackPlanId; + return this; + } + + @java.lang.Override + public _FinalStage customPlanId(String customPlanId) { + this.customPlanId = Optional.ofNullable(customPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "custom_plan_id", nulls = Nulls.SKIP) + public _FinalStage customPlanId(Optional customPlanId) { + this.customPlanId = customPlanId; + return this; + } + + @java.lang.Override + public _FinalStage customPlanConfig(CustomPlanConfig customPlanConfig) { + this.customPlanConfig = Optional.ofNullable(customPlanConfig); + return this; + } + + @java.lang.Override + @JsonSetter(value = "custom_plan_config", nulls = Nulls.SKIP) + public _FinalStage customPlanConfig(Optional customPlanConfig) { + this.customPlanConfig = customPlanConfig; + return this; + } + + /** + *

Use OrderedAddOns instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllAddOnIds(List addOnIds) { + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } + return this; + } + + /** + *

Use OrderedAddOns instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAddOnIds(String addOnIds) { + this.addOnIds.add(addOnIds); + return this; + } + + /** + *

Use OrderedAddOns instead

+ */ + @java.lang.Override + @JsonSetter(value = "add_on_ids", nulls = Nulls.SKIP) + public _FinalStage addOnIds(List addOnIds) { + this.addOnIds.clear(); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addOnCompatibilities(List addOnCompatibilities) { + this.addOnCompatibilities = Optional.ofNullable(addOnCompatibilities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_on_compatibilities", nulls = Nulls.SKIP) + public _FinalStage addOnCompatibilities(Optional> addOnCompatibilities) { + this.addOnCompatibilities = addOnCompatibilities; return this; } + @java.lang.Override public CreatePlanGroupRequestBody build() { return new CreatePlanGroupRequestBody( + addOnCompatibilities, addOnIds, + checkoutCollectAddress, + checkoutCollectEmail, + checkoutCollectPhone, customPlanConfig, customPlanId, - defaultPlanId, + enableTaxCollection, + fallbackPlanId, + initialPlanId, + initialPlanPriceId, + orderedAddOns, + orderedBundleList, orderedPlans, + preventDowngradesWhenOverLimit, + showCredits, + showPeriodToggle, + showZeroPriceAsFree, + syncCustomerBillingDetailsForTax, trialDays, + trialExpiryPlanId, + trialExpiryPlanPriceId, trialPaymentMethodRequired, additionalProperties); } diff --git a/src/main/java/com/schematic/api/resources/plangroups/requests/UpdatePlanGroupRequestBody.java b/src/main/java/com/schematic/api/resources/plangroups/requests/UpdatePlanGroupRequestBody.java index df1e163..f12c5d4 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/requests/UpdatePlanGroupRequestBody.java +++ b/src/main/java/com/schematic/api/resources/plangroups/requests/UpdatePlanGroupRequestBody.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.CompatiblePlans; import com.schematic.api.types.CustomPlanConfig; import com.schematic.api.types.OrderedPlansInGroup; +import com.schematic.api.types.PlanGroupBundleOrder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -24,46 +26,133 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdatePlanGroupRequestBody.Builder.class) public final class UpdatePlanGroupRequestBody { + private final Optional> addOnCompatibilities; + private final List addOnIds; + private final boolean checkoutCollectAddress; + + private final boolean checkoutCollectEmail; + + private final boolean checkoutCollectPhone; + private final Optional customPlanConfig; private final Optional customPlanId; - private final Optional defaultPlanId; + private final boolean enableTaxCollection; + + private final Optional fallbackPlanId; + + private final Optional initialPlanId; + + private final Optional initialPlanPriceId; + + private final List orderedAddOns; + + private final List orderedBundleList; private final List orderedPlans; + private final boolean preventDowngradesWhenOverLimit; + + private final boolean showCredits; + + private final boolean showPeriodToggle; + + private final boolean showZeroPriceAsFree; + + private final boolean syncCustomerBillingDetailsForTax; + private final Optional trialDays; + private final Optional trialExpiryPlanId; + + private final Optional trialExpiryPlanPriceId; + private final Optional trialPaymentMethodRequired; private final Map additionalProperties; private UpdatePlanGroupRequestBody( + Optional> addOnCompatibilities, List addOnIds, + boolean checkoutCollectAddress, + boolean checkoutCollectEmail, + boolean checkoutCollectPhone, Optional customPlanConfig, Optional customPlanId, - Optional defaultPlanId, + boolean enableTaxCollection, + Optional fallbackPlanId, + Optional initialPlanId, + Optional initialPlanPriceId, + List orderedAddOns, + List orderedBundleList, List orderedPlans, + boolean preventDowngradesWhenOverLimit, + boolean showCredits, + boolean showPeriodToggle, + boolean showZeroPriceAsFree, + boolean syncCustomerBillingDetailsForTax, Optional trialDays, + Optional trialExpiryPlanId, + Optional trialExpiryPlanPriceId, Optional trialPaymentMethodRequired, Map additionalProperties) { + this.addOnCompatibilities = addOnCompatibilities; this.addOnIds = addOnIds; + this.checkoutCollectAddress = checkoutCollectAddress; + this.checkoutCollectEmail = checkoutCollectEmail; + this.checkoutCollectPhone = checkoutCollectPhone; this.customPlanConfig = customPlanConfig; this.customPlanId = customPlanId; - this.defaultPlanId = defaultPlanId; + this.enableTaxCollection = enableTaxCollection; + this.fallbackPlanId = fallbackPlanId; + this.initialPlanId = initialPlanId; + this.initialPlanPriceId = initialPlanPriceId; + this.orderedAddOns = orderedAddOns; + this.orderedBundleList = orderedBundleList; this.orderedPlans = orderedPlans; + this.preventDowngradesWhenOverLimit = preventDowngradesWhenOverLimit; + this.showCredits = showCredits; + this.showPeriodToggle = showPeriodToggle; + this.showZeroPriceAsFree = showZeroPriceAsFree; + this.syncCustomerBillingDetailsForTax = syncCustomerBillingDetailsForTax; this.trialDays = trialDays; + this.trialExpiryPlanId = trialExpiryPlanId; + this.trialExpiryPlanPriceId = trialExpiryPlanPriceId; this.trialPaymentMethodRequired = trialPaymentMethodRequired; this.additionalProperties = additionalProperties; } + @JsonProperty("add_on_compatibilities") + public Optional> getAddOnCompatibilities() { + return addOnCompatibilities; + } + + /** + * @return Use OrderedAddOns instead + */ @JsonProperty("add_on_ids") public List getAddOnIds() { return addOnIds; } + @JsonProperty("checkout_collect_address") + public boolean getCheckoutCollectAddress() { + return checkoutCollectAddress; + } + + @JsonProperty("checkout_collect_email") + public boolean getCheckoutCollectEmail() { + return checkoutCollectEmail; + } + + @JsonProperty("checkout_collect_phone") + public boolean getCheckoutCollectPhone() { + return checkoutCollectPhone; + } + @JsonProperty("custom_plan_config") public Optional getCustomPlanConfig() { return customPlanConfig; @@ -74,9 +163,34 @@ public Optional getCustomPlanId() { return customPlanId; } - @JsonProperty("default_plan_id") - public Optional getDefaultPlanId() { - return defaultPlanId; + @JsonProperty("enable_tax_collection") + public boolean getEnableTaxCollection() { + return enableTaxCollection; + } + + @JsonProperty("fallback_plan_id") + public Optional getFallbackPlanId() { + return fallbackPlanId; + } + + @JsonProperty("initial_plan_id") + public Optional getInitialPlanId() { + return initialPlanId; + } + + @JsonProperty("initial_plan_price_id") + public Optional getInitialPlanPriceId() { + return initialPlanPriceId; + } + + @JsonProperty("ordered_add_ons") + public List getOrderedAddOns() { + return orderedAddOns; + } + + @JsonProperty("ordered_bundle_list") + public List getOrderedBundleList() { + return orderedBundleList; } @JsonProperty("ordered_plans") @@ -84,11 +198,46 @@ public List getOrderedPlans() { return orderedPlans; } + @JsonProperty("prevent_downgrades_when_over_limit") + public boolean getPreventDowngradesWhenOverLimit() { + return preventDowngradesWhenOverLimit; + } + + @JsonProperty("show_credits") + public boolean getShowCredits() { + return showCredits; + } + + @JsonProperty("show_period_toggle") + public boolean getShowPeriodToggle() { + return showPeriodToggle; + } + + @JsonProperty("show_zero_price_as_free") + public boolean getShowZeroPriceAsFree() { + return showZeroPriceAsFree; + } + + @JsonProperty("sync_customer_billing_details_for_tax") + public boolean getSyncCustomerBillingDetailsForTax() { + return syncCustomerBillingDetailsForTax; + } + @JsonProperty("trial_days") public Optional getTrialDays() { return trialDays; } + @JsonProperty("trial_expiry_plan_id") + public Optional getTrialExpiryPlanId() { + return trialExpiryPlanId; + } + + @JsonProperty("trial_expiry_plan_price_id") + public Optional getTrialExpiryPlanPriceId() { + return trialExpiryPlanPriceId; + } + @JsonProperty("trial_payment_method_required") public Optional getTrialPaymentMethodRequired() { return trialPaymentMethodRequired; @@ -106,24 +255,56 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdatePlanGroupRequestBody other) { - return addOnIds.equals(other.addOnIds) + return addOnCompatibilities.equals(other.addOnCompatibilities) + && addOnIds.equals(other.addOnIds) + && checkoutCollectAddress == other.checkoutCollectAddress + && checkoutCollectEmail == other.checkoutCollectEmail + && checkoutCollectPhone == other.checkoutCollectPhone && customPlanConfig.equals(other.customPlanConfig) && customPlanId.equals(other.customPlanId) - && defaultPlanId.equals(other.defaultPlanId) + && enableTaxCollection == other.enableTaxCollection + && fallbackPlanId.equals(other.fallbackPlanId) + && initialPlanId.equals(other.initialPlanId) + && initialPlanPriceId.equals(other.initialPlanPriceId) + && orderedAddOns.equals(other.orderedAddOns) + && orderedBundleList.equals(other.orderedBundleList) && orderedPlans.equals(other.orderedPlans) + && preventDowngradesWhenOverLimit == other.preventDowngradesWhenOverLimit + && showCredits == other.showCredits + && showPeriodToggle == other.showPeriodToggle + && showZeroPriceAsFree == other.showZeroPriceAsFree + && syncCustomerBillingDetailsForTax == other.syncCustomerBillingDetailsForTax && trialDays.equals(other.trialDays) + && trialExpiryPlanId.equals(other.trialExpiryPlanId) + && trialExpiryPlanPriceId.equals(other.trialExpiryPlanPriceId) && trialPaymentMethodRequired.equals(other.trialPaymentMethodRequired); } @java.lang.Override public int hashCode() { return Objects.hash( + this.addOnCompatibilities, this.addOnIds, + this.checkoutCollectAddress, + this.checkoutCollectEmail, + this.checkoutCollectPhone, this.customPlanConfig, this.customPlanId, - this.defaultPlanId, + this.enableTaxCollection, + this.fallbackPlanId, + this.initialPlanId, + this.initialPlanPriceId, + this.orderedAddOns, + this.orderedBundleList, this.orderedPlans, + this.preventDowngradesWhenOverLimit, + this.showCredits, + this.showPeriodToggle, + this.showZeroPriceAsFree, + this.syncCustomerBillingDetailsForTax, this.trialDays, + this.trialExpiryPlanId, + this.trialExpiryPlanPriceId, this.trialPaymentMethodRequired); } @@ -132,139 +313,535 @@ public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static CheckoutCollectAddressStage builder() { return new Builder(); } + public interface CheckoutCollectAddressStage { + CheckoutCollectEmailStage checkoutCollectAddress(boolean checkoutCollectAddress); + + Builder from(UpdatePlanGroupRequestBody other); + } + + public interface CheckoutCollectEmailStage { + CheckoutCollectPhoneStage checkoutCollectEmail(boolean checkoutCollectEmail); + } + + public interface CheckoutCollectPhoneStage { + EnableTaxCollectionStage checkoutCollectPhone(boolean checkoutCollectPhone); + } + + public interface EnableTaxCollectionStage { + PreventDowngradesWhenOverLimitStage enableTaxCollection(boolean enableTaxCollection); + } + + public interface PreventDowngradesWhenOverLimitStage { + ShowCreditsStage preventDowngradesWhenOverLimit(boolean preventDowngradesWhenOverLimit); + } + + public interface ShowCreditsStage { + ShowPeriodToggleStage showCredits(boolean showCredits); + } + + public interface ShowPeriodToggleStage { + ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle); + } + + public interface ShowZeroPriceAsFreeStage { + SyncCustomerBillingDetailsForTaxStage showZeroPriceAsFree(boolean showZeroPriceAsFree); + } + + public interface SyncCustomerBillingDetailsForTaxStage { + _FinalStage syncCustomerBillingDetailsForTax(boolean syncCustomerBillingDetailsForTax); + } + + public interface _FinalStage { + UpdatePlanGroupRequestBody build(); + + _FinalStage addOnCompatibilities(Optional> addOnCompatibilities); + + _FinalStage addOnCompatibilities(List addOnCompatibilities); + + /** + *

Use OrderedAddOns instead

+ */ + _FinalStage addOnIds(List addOnIds); + + _FinalStage addAddOnIds(String addOnIds); + + _FinalStage addAllAddOnIds(List addOnIds); + + _FinalStage customPlanConfig(Optional customPlanConfig); + + _FinalStage customPlanConfig(CustomPlanConfig customPlanConfig); + + _FinalStage customPlanId(Optional customPlanId); + + _FinalStage customPlanId(String customPlanId); + + _FinalStage fallbackPlanId(Optional fallbackPlanId); + + _FinalStage fallbackPlanId(String fallbackPlanId); + + _FinalStage initialPlanId(Optional initialPlanId); + + _FinalStage initialPlanId(String initialPlanId); + + _FinalStage initialPlanPriceId(Optional initialPlanPriceId); + + _FinalStage initialPlanPriceId(String initialPlanPriceId); + + _FinalStage orderedAddOns(List orderedAddOns); + + _FinalStage addOrderedAddOns(OrderedPlansInGroup orderedAddOns); + + _FinalStage addAllOrderedAddOns(List orderedAddOns); + + _FinalStage orderedBundleList(List orderedBundleList); + + _FinalStage addOrderedBundleList(PlanGroupBundleOrder orderedBundleList); + + _FinalStage addAllOrderedBundleList(List orderedBundleList); + + _FinalStage orderedPlans(List orderedPlans); + + _FinalStage addOrderedPlans(OrderedPlansInGroup orderedPlans); + + _FinalStage addAllOrderedPlans(List orderedPlans); + + _FinalStage trialDays(Optional trialDays); + + _FinalStage trialDays(Integer trialDays); + + _FinalStage trialExpiryPlanId(Optional trialExpiryPlanId); + + _FinalStage trialExpiryPlanId(String trialExpiryPlanId); + + _FinalStage trialExpiryPlanPriceId(Optional trialExpiryPlanPriceId); + + _FinalStage trialExpiryPlanPriceId(String trialExpiryPlanPriceId); + + _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired); + + _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List addOnIds = new ArrayList<>(); + public static final class Builder + implements CheckoutCollectAddressStage, + CheckoutCollectEmailStage, + CheckoutCollectPhoneStage, + EnableTaxCollectionStage, + PreventDowngradesWhenOverLimitStage, + ShowCreditsStage, + ShowPeriodToggleStage, + ShowZeroPriceAsFreeStage, + SyncCustomerBillingDetailsForTaxStage, + _FinalStage { + private boolean checkoutCollectAddress; - private Optional customPlanConfig = Optional.empty(); + private boolean checkoutCollectEmail; - private Optional customPlanId = Optional.empty(); + private boolean checkoutCollectPhone; - private Optional defaultPlanId = Optional.empty(); + private boolean enableTaxCollection; - private List orderedPlans = new ArrayList<>(); + private boolean preventDowngradesWhenOverLimit; - private Optional trialDays = Optional.empty(); + private boolean showCredits; + + private boolean showPeriodToggle; + + private boolean showZeroPriceAsFree; + + private boolean syncCustomerBillingDetailsForTax; private Optional trialPaymentMethodRequired = Optional.empty(); + private Optional trialExpiryPlanPriceId = Optional.empty(); + + private Optional trialExpiryPlanId = Optional.empty(); + + private Optional trialDays = Optional.empty(); + + private List orderedPlans = new ArrayList<>(); + + private List orderedBundleList = new ArrayList<>(); + + private List orderedAddOns = new ArrayList<>(); + + private Optional initialPlanPriceId = Optional.empty(); + + private Optional initialPlanId = Optional.empty(); + + private Optional fallbackPlanId = Optional.empty(); + + private Optional customPlanId = Optional.empty(); + + private Optional customPlanConfig = Optional.empty(); + + private List addOnIds = new ArrayList<>(); + + private Optional> addOnCompatibilities = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} + @java.lang.Override public Builder from(UpdatePlanGroupRequestBody other) { + addOnCompatibilities(other.getAddOnCompatibilities()); addOnIds(other.getAddOnIds()); + checkoutCollectAddress(other.getCheckoutCollectAddress()); + checkoutCollectEmail(other.getCheckoutCollectEmail()); + checkoutCollectPhone(other.getCheckoutCollectPhone()); customPlanConfig(other.getCustomPlanConfig()); customPlanId(other.getCustomPlanId()); - defaultPlanId(other.getDefaultPlanId()); + enableTaxCollection(other.getEnableTaxCollection()); + fallbackPlanId(other.getFallbackPlanId()); + initialPlanId(other.getInitialPlanId()); + initialPlanPriceId(other.getInitialPlanPriceId()); + orderedAddOns(other.getOrderedAddOns()); + orderedBundleList(other.getOrderedBundleList()); orderedPlans(other.getOrderedPlans()); + preventDowngradesWhenOverLimit(other.getPreventDowngradesWhenOverLimit()); + showCredits(other.getShowCredits()); + showPeriodToggle(other.getShowPeriodToggle()); + showZeroPriceAsFree(other.getShowZeroPriceAsFree()); + syncCustomerBillingDetailsForTax(other.getSyncCustomerBillingDetailsForTax()); trialDays(other.getTrialDays()); + trialExpiryPlanId(other.getTrialExpiryPlanId()); + trialExpiryPlanPriceId(other.getTrialExpiryPlanPriceId()); trialPaymentMethodRequired(other.getTrialPaymentMethodRequired()); return this; } - @JsonSetter(value = "add_on_ids", nulls = Nulls.SKIP) - public Builder addOnIds(List addOnIds) { - this.addOnIds.clear(); - this.addOnIds.addAll(addOnIds); + @java.lang.Override + @JsonSetter("checkout_collect_address") + public CheckoutCollectEmailStage checkoutCollectAddress(boolean checkoutCollectAddress) { + this.checkoutCollectAddress = checkoutCollectAddress; return this; } - public Builder addAddOnIds(String addOnIds) { - this.addOnIds.add(addOnIds); + @java.lang.Override + @JsonSetter("checkout_collect_email") + public CheckoutCollectPhoneStage checkoutCollectEmail(boolean checkoutCollectEmail) { + this.checkoutCollectEmail = checkoutCollectEmail; return this; } - public Builder addAllAddOnIds(List addOnIds) { - this.addOnIds.addAll(addOnIds); + @java.lang.Override + @JsonSetter("checkout_collect_phone") + public EnableTaxCollectionStage checkoutCollectPhone(boolean checkoutCollectPhone) { + this.checkoutCollectPhone = checkoutCollectPhone; return this; } - @JsonSetter(value = "custom_plan_config", nulls = Nulls.SKIP) - public Builder customPlanConfig(Optional customPlanConfig) { - this.customPlanConfig = customPlanConfig; + @java.lang.Override + @JsonSetter("enable_tax_collection") + public PreventDowngradesWhenOverLimitStage enableTaxCollection(boolean enableTaxCollection) { + this.enableTaxCollection = enableTaxCollection; return this; } - public Builder customPlanConfig(CustomPlanConfig customPlanConfig) { - this.customPlanConfig = Optional.ofNullable(customPlanConfig); + @java.lang.Override + @JsonSetter("prevent_downgrades_when_over_limit") + public ShowCreditsStage preventDowngradesWhenOverLimit(boolean preventDowngradesWhenOverLimit) { + this.preventDowngradesWhenOverLimit = preventDowngradesWhenOverLimit; return this; } - @JsonSetter(value = "custom_plan_id", nulls = Nulls.SKIP) - public Builder customPlanId(Optional customPlanId) { - this.customPlanId = customPlanId; + @java.lang.Override + @JsonSetter("show_credits") + public ShowPeriodToggleStage showCredits(boolean showCredits) { + this.showCredits = showCredits; return this; } - public Builder customPlanId(String customPlanId) { - this.customPlanId = Optional.ofNullable(customPlanId); + @java.lang.Override + @JsonSetter("show_period_toggle") + public ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle) { + this.showPeriodToggle = showPeriodToggle; return this; } - @JsonSetter(value = "default_plan_id", nulls = Nulls.SKIP) - public Builder defaultPlanId(Optional defaultPlanId) { - this.defaultPlanId = defaultPlanId; + @java.lang.Override + @JsonSetter("show_zero_price_as_free") + public SyncCustomerBillingDetailsForTaxStage showZeroPriceAsFree(boolean showZeroPriceAsFree) { + this.showZeroPriceAsFree = showZeroPriceAsFree; return this; } - public Builder defaultPlanId(String defaultPlanId) { - this.defaultPlanId = Optional.ofNullable(defaultPlanId); + @java.lang.Override + @JsonSetter("sync_customer_billing_details_for_tax") + public _FinalStage syncCustomerBillingDetailsForTax(boolean syncCustomerBillingDetailsForTax) { + this.syncCustomerBillingDetailsForTax = syncCustomerBillingDetailsForTax; return this; } - @JsonSetter(value = "ordered_plans", nulls = Nulls.SKIP) - public Builder orderedPlans(List orderedPlans) { - this.orderedPlans.clear(); - this.orderedPlans.addAll(orderedPlans); + @java.lang.Override + public _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { + this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); return this; } - public Builder addOrderedPlans(OrderedPlansInGroup orderedPlans) { - this.orderedPlans.add(orderedPlans); + @java.lang.Override + @JsonSetter(value = "trial_payment_method_required", nulls = Nulls.SKIP) + public _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired) { + this.trialPaymentMethodRequired = trialPaymentMethodRequired; return this; } - public Builder addAllOrderedPlans(List orderedPlans) { - this.orderedPlans.addAll(orderedPlans); + @java.lang.Override + public _FinalStage trialExpiryPlanPriceId(String trialExpiryPlanPriceId) { + this.trialExpiryPlanPriceId = Optional.ofNullable(trialExpiryPlanPriceId); return this; } + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanPriceId(Optional trialExpiryPlanPriceId) { + this.trialExpiryPlanPriceId = trialExpiryPlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage trialExpiryPlanId(String trialExpiryPlanId) { + this.trialExpiryPlanId = Optional.ofNullable(trialExpiryPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_id", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanId(Optional trialExpiryPlanId) { + this.trialExpiryPlanId = trialExpiryPlanId; + return this; + } + + @java.lang.Override + public _FinalStage trialDays(Integer trialDays) { + this.trialDays = Optional.ofNullable(trialDays); + return this; + } + + @java.lang.Override @JsonSetter(value = "trial_days", nulls = Nulls.SKIP) - public Builder trialDays(Optional trialDays) { + public _FinalStage trialDays(Optional trialDays) { this.trialDays = trialDays; return this; } - public Builder trialDays(Integer trialDays) { - this.trialDays = Optional.ofNullable(trialDays); + @java.lang.Override + public _FinalStage addAllOrderedPlans(List orderedPlans) { + if (orderedPlans != null) { + this.orderedPlans.addAll(orderedPlans); + } return this; } - @JsonSetter(value = "trial_payment_method_required", nulls = Nulls.SKIP) - public Builder trialPaymentMethodRequired(Optional trialPaymentMethodRequired) { - this.trialPaymentMethodRequired = trialPaymentMethodRequired; + @java.lang.Override + public _FinalStage addOrderedPlans(OrderedPlansInGroup orderedPlans) { + this.orderedPlans.add(orderedPlans); return this; } - public Builder trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { - this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); + @java.lang.Override + @JsonSetter(value = "ordered_plans", nulls = Nulls.SKIP) + public _FinalStage orderedPlans(List orderedPlans) { + this.orderedPlans.clear(); + if (orderedPlans != null) { + this.orderedPlans.addAll(orderedPlans); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllOrderedBundleList(List orderedBundleList) { + if (orderedBundleList != null) { + this.orderedBundleList.addAll(orderedBundleList); + } + return this; + } + + @java.lang.Override + public _FinalStage addOrderedBundleList(PlanGroupBundleOrder orderedBundleList) { + this.orderedBundleList.add(orderedBundleList); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ordered_bundle_list", nulls = Nulls.SKIP) + public _FinalStage orderedBundleList(List orderedBundleList) { + this.orderedBundleList.clear(); + if (orderedBundleList != null) { + this.orderedBundleList.addAll(orderedBundleList); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllOrderedAddOns(List orderedAddOns) { + if (orderedAddOns != null) { + this.orderedAddOns.addAll(orderedAddOns); + } + return this; + } + + @java.lang.Override + public _FinalStage addOrderedAddOns(OrderedPlansInGroup orderedAddOns) { + this.orderedAddOns.add(orderedAddOns); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ordered_add_ons", nulls = Nulls.SKIP) + public _FinalStage orderedAddOns(List orderedAddOns) { + this.orderedAddOns.clear(); + if (orderedAddOns != null) { + this.orderedAddOns.addAll(orderedAddOns); + } + return this; + } + + @java.lang.Override + public _FinalStage initialPlanPriceId(String initialPlanPriceId) { + this.initialPlanPriceId = Optional.ofNullable(initialPlanPriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage initialPlanPriceId(Optional initialPlanPriceId) { + this.initialPlanPriceId = initialPlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage initialPlanId(String initialPlanId) { + this.initialPlanId = Optional.ofNullable(initialPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_id", nulls = Nulls.SKIP) + public _FinalStage initialPlanId(Optional initialPlanId) { + this.initialPlanId = initialPlanId; + return this; + } + + @java.lang.Override + public _FinalStage fallbackPlanId(String fallbackPlanId) { + this.fallbackPlanId = Optional.ofNullable(fallbackPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "fallback_plan_id", nulls = Nulls.SKIP) + public _FinalStage fallbackPlanId(Optional fallbackPlanId) { + this.fallbackPlanId = fallbackPlanId; + return this; + } + + @java.lang.Override + public _FinalStage customPlanId(String customPlanId) { + this.customPlanId = Optional.ofNullable(customPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "custom_plan_id", nulls = Nulls.SKIP) + public _FinalStage customPlanId(Optional customPlanId) { + this.customPlanId = customPlanId; + return this; + } + + @java.lang.Override + public _FinalStage customPlanConfig(CustomPlanConfig customPlanConfig) { + this.customPlanConfig = Optional.ofNullable(customPlanConfig); + return this; + } + + @java.lang.Override + @JsonSetter(value = "custom_plan_config", nulls = Nulls.SKIP) + public _FinalStage customPlanConfig(Optional customPlanConfig) { + this.customPlanConfig = customPlanConfig; + return this; + } + + /** + *

Use OrderedAddOns instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllAddOnIds(List addOnIds) { + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } + return this; + } + + /** + *

Use OrderedAddOns instead

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAddOnIds(String addOnIds) { + this.addOnIds.add(addOnIds); + return this; + } + + /** + *

Use OrderedAddOns instead

+ */ + @java.lang.Override + @JsonSetter(value = "add_on_ids", nulls = Nulls.SKIP) + public _FinalStage addOnIds(List addOnIds) { + this.addOnIds.clear(); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addOnCompatibilities(List addOnCompatibilities) { + this.addOnCompatibilities = Optional.ofNullable(addOnCompatibilities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_on_compatibilities", nulls = Nulls.SKIP) + public _FinalStage addOnCompatibilities(Optional> addOnCompatibilities) { + this.addOnCompatibilities = addOnCompatibilities; return this; } + @java.lang.Override public UpdatePlanGroupRequestBody build() { return new UpdatePlanGroupRequestBody( + addOnCompatibilities, addOnIds, + checkoutCollectAddress, + checkoutCollectEmail, + checkoutCollectPhone, customPlanConfig, customPlanId, - defaultPlanId, + enableTaxCollection, + fallbackPlanId, + initialPlanId, + initialPlanPriceId, + orderedAddOns, + orderedBundleList, orderedPlans, + preventDowngradesWhenOverLimit, + showCredits, + showPeriodToggle, + showZeroPriceAsFree, + syncCustomerBillingDetailsForTax, trialDays, + trialExpiryPlanId, + trialExpiryPlanPriceId, trialPaymentMethodRequired, additionalProperties); } diff --git a/src/main/java/com/schematic/api/resources/plangroups/types/CreatePlanGroupResponse.java b/src/main/java/com/schematic/api/resources/plangroups/types/CreatePlanGroupResponse.java index 8b9e652..8e91d3a 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/types/CreatePlanGroupResponse.java +++ b/src/main/java/com/schematic/api/resources/plangroups/types/CreatePlanGroupResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreatePlanGroupResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plangroups/types/GetPlanGroupResponse.java b/src/main/java/com/schematic/api/resources/plangroups/types/GetPlanGroupResponse.java index 562c1e4..c16d1b6 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/types/GetPlanGroupResponse.java +++ b/src/main/java/com/schematic/api/resources/plangroups/types/GetPlanGroupResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetPlanGroupResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plangroups/types/UpdatePlanGroupResponse.java b/src/main/java/com/schematic/api/resources/plangroups/types/UpdatePlanGroupResponse.java index a2fc7c0..4bec0d7 100644 --- a/src/main/java/com/schematic/api/resources/plangroups/types/UpdatePlanGroupResponse.java +++ b/src/main/java/com/schematic/api/resources/plangroups/types/UpdatePlanGroupResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdatePlanGroupResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/AsyncPlansClient.java b/src/main/java/com/schematic/api/resources/plans/AsyncPlansClient.java new file mode 100644 index 0000000..ec163a0 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plans/AsyncPlansClient.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plans; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.plans.requests.CountPlansRequest; +import com.schematic.api.resources.plans.requests.CreatePlanRequestBody; +import com.schematic.api.resources.plans.requests.ListPlanIssuesRequest; +import com.schematic.api.resources.plans.requests.ListPlansRequest; +import com.schematic.api.resources.plans.requests.UpdateCompanyPlansRequestBody; +import com.schematic.api.resources.plans.requests.UpdatePlanRequestBody; +import com.schematic.api.resources.plans.requests.UpsertBillingProductRequestBody; +import com.schematic.api.resources.plans.types.CountPlansResponse; +import com.schematic.api.resources.plans.types.CreatePlanResponse; +import com.schematic.api.resources.plans.types.DeletePlanResponse; +import com.schematic.api.resources.plans.types.GetPlanResponse; +import com.schematic.api.resources.plans.types.ListPlanIssuesResponse; +import com.schematic.api.resources.plans.types.ListPlansResponse; +import com.schematic.api.resources.plans.types.UpdateCompanyPlansResponse; +import com.schematic.api.resources.plans.types.UpdatePlanResponse; +import com.schematic.api.resources.plans.types.UpsertBillingProductPlanResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPlansClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPlansClient rawClient; + + public AsyncPlansClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPlansClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPlansClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture updateCompanyPlans( + String companyPlanId, UpdateCompanyPlansRequestBody request) { + return this.rawClient.updateCompanyPlans(companyPlanId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateCompanyPlans( + String companyPlanId, UpdateCompanyPlansRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .updateCompanyPlans(companyPlanId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture listPlans() { + return this.rawClient.listPlans().thenApply(response -> response.body()); + } + + public CompletableFuture listPlans(ListPlansRequest request) { + return this.rawClient.listPlans(request).thenApply(response -> response.body()); + } + + public CompletableFuture listPlans(ListPlansRequest request, RequestOptions requestOptions) { + return this.rawClient.listPlans(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createPlan(CreatePlanRequestBody request) { + return this.rawClient.createPlan(request).thenApply(response -> response.body()); + } + + public CompletableFuture createPlan( + CreatePlanRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createPlan(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getPlan(String planId) { + return this.rawClient.getPlan(planId).thenApply(response -> response.body()); + } + + public CompletableFuture getPlan(String planId, RequestOptions requestOptions) { + return this.rawClient.getPlan(planId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlan(String planId, UpdatePlanRequestBody request) { + return this.rawClient.updatePlan(planId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updatePlan( + String planId, UpdatePlanRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updatePlan(planId, request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deletePlan(String planId) { + return this.rawClient.deletePlan(planId).thenApply(response -> response.body()); + } + + public CompletableFuture deletePlan(String planId, RequestOptions requestOptions) { + return this.rawClient.deletePlan(planId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingProductPlan( + String planId, UpsertBillingProductRequestBody request) { + return this.rawClient.upsertBillingProductPlan(planId, request).thenApply(response -> response.body()); + } + + public CompletableFuture upsertBillingProductPlan( + String planId, UpsertBillingProductRequestBody request, RequestOptions requestOptions) { + return this.rawClient + .upsertBillingProductPlan(planId, request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture countPlans() { + return this.rawClient.countPlans().thenApply(response -> response.body()); + } + + public CompletableFuture countPlans(CountPlansRequest request) { + return this.rawClient.countPlans(request).thenApply(response -> response.body()); + } + + public CompletableFuture countPlans(CountPlansRequest request, RequestOptions requestOptions) { + return this.rawClient.countPlans(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listPlanIssues(ListPlanIssuesRequest request) { + return this.rawClient.listPlanIssues(request).thenApply(response -> response.body()); + } + + public CompletableFuture listPlanIssues( + ListPlanIssuesRequest request, RequestOptions requestOptions) { + return this.rawClient.listPlanIssues(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/plans/AsyncRawPlansClient.java b/src/main/java/com/schematic/api/resources/plans/AsyncRawPlansClient.java new file mode 100644 index 0000000..f5b363d --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plans/AsyncRawPlansClient.java @@ -0,0 +1,973 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plans; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.plans.requests.CountPlansRequest; +import com.schematic.api.resources.plans.requests.CreatePlanRequestBody; +import com.schematic.api.resources.plans.requests.ListPlanIssuesRequest; +import com.schematic.api.resources.plans.requests.ListPlansRequest; +import com.schematic.api.resources.plans.requests.UpdateCompanyPlansRequestBody; +import com.schematic.api.resources.plans.requests.UpdatePlanRequestBody; +import com.schematic.api.resources.plans.requests.UpsertBillingProductRequestBody; +import com.schematic.api.resources.plans.types.CountPlansResponse; +import com.schematic.api.resources.plans.types.CreatePlanResponse; +import com.schematic.api.resources.plans.types.DeletePlanResponse; +import com.schematic.api.resources.plans.types.GetPlanResponse; +import com.schematic.api.resources.plans.types.ListPlanIssuesResponse; +import com.schematic.api.resources.plans.types.ListPlansResponse; +import com.schematic.api.resources.plans.types.UpdateCompanyPlansResponse; +import com.schematic.api.resources.plans.types.UpdatePlanResponse; +import com.schematic.api.resources.plans.types.UpsertBillingProductPlanResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPlansClient { + protected final ClientOptions clientOptions; + + public AsyncRawPlansClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> updateCompanyPlans( + String companyPlanId, UpdateCompanyPlansRequestBody request) { + return updateCompanyPlans(companyPlanId, request, null); + } + + public CompletableFuture> updateCompanyPlans( + String companyPlanId, UpdateCompanyPlansRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-plans") + .addPathSegment(companyPlanId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpdateCompanyPlansResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listPlans() { + return listPlans(ListPlansRequest.builder().build()); + } + + public CompletableFuture> listPlans(ListPlansRequest request) { + return listPlans(request, null); + } + + public CompletableFuture> listPlans( + ListPlansRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getForFallbackPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_fallback_plan", request.getForFallbackPlan().get(), false); + } + if (request.getForInitialPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_initial_plan", request.getForInitialPlan().get(), false); + } + if (request.getForTrialExpiryPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "for_trial_expiry_plan", + request.getForTrialExpiryPlan().get(), + false); + } + if (request.getHasProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "has_product_id", request.getHasProductId().get(), false); + } + if (request.getPlanType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_type", request.getPlanType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequiresPaymentMethod().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "requires_payment_method", + request.getRequiresPaymentMethod().get(), + false); + } + if (request.getWithoutEntitlementFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_entitlement_for", + request.getWithoutEntitlementFor().get(), + false); + } + if (request.getWithoutProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_product_id", request.getWithoutProductId().get(), false); + } + if (request.getWithoutPaidProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_paid_product_id", + request.getWithoutPaidProductId().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPlansResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createPlan(CreatePlanRequestBody request) { + return createPlan(request, null); + } + + public CompletableFuture> createPlan( + CreatePlanRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreatePlanResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getPlan(String planId) { + return getPlan(planId, null); + } + + public CompletableFuture> getPlan( + String planId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .addPathSegment(planId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updatePlan( + String planId, UpdatePlanRequestBody request) { + return updatePlan(planId, request, null); + } + + public CompletableFuture> updatePlan( + String planId, UpdatePlanRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .addPathSegment(planId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdatePlanResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deletePlan(String planId) { + return deletePlan(planId, null); + } + + public CompletableFuture> deletePlan( + String planId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .addPathSegment(planId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletePlanResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> upsertBillingProductPlan( + String planId, UpsertBillingProductRequestBody request) { + return upsertBillingProductPlan(planId, request, null); + } + + public CompletableFuture> upsertBillingProductPlan( + String planId, UpsertBillingProductRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .addPathSegment(planId) + .addPathSegments("billing_products") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingProductPlanResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countPlans() { + return countPlans(CountPlansRequest.builder().build()); + } + + public CompletableFuture> countPlans(CountPlansRequest request) { + return countPlans(request, null); + } + + public CompletableFuture> countPlans( + CountPlansRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans/count"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getForFallbackPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_fallback_plan", request.getForFallbackPlan().get(), false); + } + if (request.getForInitialPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_initial_plan", request.getForInitialPlan().get(), false); + } + if (request.getForTrialExpiryPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "for_trial_expiry_plan", + request.getForTrialExpiryPlan().get(), + false); + } + if (request.getHasProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "has_product_id", request.getHasProductId().get(), false); + } + if (request.getPlanType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_type", request.getPlanType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequiresPaymentMethod().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "requires_payment_method", + request.getRequiresPaymentMethod().get(), + false); + } + if (request.getWithoutEntitlementFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_entitlement_for", + request.getWithoutEntitlementFor().get(), + false); + } + if (request.getWithoutProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_product_id", request.getWithoutProductId().get(), false); + } + if (request.getWithoutPaidProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_paid_product_id", + request.getWithoutPaidProductId().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountPlansResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listPlanIssues( + ListPlanIssuesRequest request) { + return listPlanIssues(request, null); + } + + public CompletableFuture> listPlanIssues( + ListPlanIssuesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans/issues"); + QueryStringMapper.addQueryParameter(httpUrl, "plan_id", request.getPlanId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListPlanIssuesResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/plans/PlansClient.java b/src/main/java/com/schematic/api/resources/plans/PlansClient.java index 845ec8b..7754c68 100644 --- a/src/main/java/com/schematic/api/resources/plans/PlansClient.java +++ b/src/main/java/com/schematic/api/resources/plans/PlansClient.java @@ -3,772 +3,126 @@ */ package com.schematic.api.resources.plans; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.NotFoundError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.plans.requests.CountPlansRequest; import com.schematic.api.resources.plans.requests.CreatePlanRequestBody; +import com.schematic.api.resources.plans.requests.ListPlanIssuesRequest; import com.schematic.api.resources.plans.requests.ListPlansRequest; -import com.schematic.api.resources.plans.requests.UpdateAudienceRequestBody; import com.schematic.api.resources.plans.requests.UpdateCompanyPlansRequestBody; import com.schematic.api.resources.plans.requests.UpdatePlanRequestBody; import com.schematic.api.resources.plans.requests.UpsertBillingProductRequestBody; import com.schematic.api.resources.plans.types.CountPlansResponse; import com.schematic.api.resources.plans.types.CreatePlanResponse; -import com.schematic.api.resources.plans.types.DeleteAudienceResponse; import com.schematic.api.resources.plans.types.DeletePlanResponse; -import com.schematic.api.resources.plans.types.GetAudienceResponse; import com.schematic.api.resources.plans.types.GetPlanResponse; +import com.schematic.api.resources.plans.types.ListPlanIssuesResponse; import com.schematic.api.resources.plans.types.ListPlansResponse; -import com.schematic.api.resources.plans.types.UpdateAudienceResponse; import com.schematic.api.resources.plans.types.UpdateCompanyPlansResponse; import com.schematic.api.resources.plans.types.UpdatePlanResponse; import com.schematic.api.resources.plans.types.UpsertBillingProductPlanResponse; -import com.schematic.api.types.ApiError; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PlansClient { protected final ClientOptions clientOptions; + private final RawPlansClient rawClient; + public PlansClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPlansClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPlansClient withRawResponse() { + return this.rawClient; } public UpdateCompanyPlansResponse updateCompanyPlans(String companyPlanId, UpdateCompanyPlansRequestBody request) { - return updateCompanyPlans(companyPlanId, request, null); + return this.rawClient.updateCompanyPlans(companyPlanId, request).body(); } public UpdateCompanyPlansResponse updateCompanyPlans( String companyPlanId, UpdateCompanyPlansRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("company-plans") - .addPathSegment(companyPlanId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateCompanyPlansResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } - } - - public GetAudienceResponse getAudience(String planAudienceId) { - return getAudience(planAudienceId, null); - } - - public GetAudienceResponse getAudience(String planAudienceId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plan-audiences") - .addPathSegment(planAudienceId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetAudienceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } - } - - public UpdateAudienceResponse updateAudience(String planAudienceId, UpdateAudienceRequestBody request) { - return updateAudience(planAudienceId, request, null); - } - - public UpdateAudienceResponse updateAudience( - String planAudienceId, UpdateAudienceRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plan-audiences") - .addPathSegment(planAudienceId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateAudienceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } - } - - public DeleteAudienceResponse deleteAudience(String planAudienceId) { - return deleteAudience(planAudienceId, null); - } - - public DeleteAudienceResponse deleteAudience(String planAudienceId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plan-audiences") - .addPathSegment(planAudienceId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteAudienceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient + .updateCompanyPlans(companyPlanId, request, requestOptions) + .body(); } public ListPlansResponse listPlans() { - return listPlans(ListPlansRequest.builder().build()); + return this.rawClient.listPlans().body(); } public ListPlansResponse listPlans(ListPlansRequest request) { - return listPlans(request, null); + return this.rawClient.listPlans(request).body(); } public ListPlansResponse listPlans(ListPlansRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plans"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getHasProductId().isPresent()) { - httpUrl.addQueryParameter( - "has_product_id", request.getHasProductId().get().toString()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getPlanType().isPresent()) { - httpUrl.addQueryParameter("plan_type", request.getPlanType().get().toString()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getWithoutEntitlementFor().isPresent()) { - httpUrl.addQueryParameter( - "without_entitlement_for", - request.getWithoutEntitlementFor().get()); - } - if (request.getWithoutProductId().isPresent()) { - httpUrl.addQueryParameter( - "without_product_id", request.getWithoutProductId().get().toString()); - } - if (request.getWithoutPaidProductId().isPresent()) { - httpUrl.addQueryParameter( - "without_paid_product_id", - request.getWithoutPaidProductId().get().toString()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPlansResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listPlans(request, requestOptions).body(); } public CreatePlanResponse createPlan(CreatePlanRequestBody request) { - return createPlan(request, null); + return this.rawClient.createPlan(request).body(); } public CreatePlanResponse createPlan(CreatePlanRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plans") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreatePlanResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.createPlan(request, requestOptions).body(); } public GetPlanResponse getPlan(String planId) { - return getPlan(planId, null); + return this.rawClient.getPlan(planId).body(); } public GetPlanResponse getPlan(String planId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plans") - .addPathSegment(planId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getPlan(planId, requestOptions).body(); } public UpdatePlanResponse updatePlan(String planId, UpdatePlanRequestBody request) { - return updatePlan(planId, request, null); + return this.rawClient.updatePlan(planId, request).body(); } public UpdatePlanResponse updatePlan(String planId, UpdatePlanRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plans") - .addPathSegment(planId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdatePlanResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.updatePlan(planId, request, requestOptions).body(); } public DeletePlanResponse deletePlan(String planId) { - return deletePlan(planId, null); + return this.rawClient.deletePlan(planId).body(); } public DeletePlanResponse deletePlan(String planId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plans") - .addPathSegment(planId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletePlanResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.deletePlan(planId, requestOptions).body(); } public UpsertBillingProductPlanResponse upsertBillingProductPlan( String planId, UpsertBillingProductRequestBody request) { - return upsertBillingProductPlan(planId, request, null); + return this.rawClient.upsertBillingProductPlan(planId, request).body(); } public UpsertBillingProductPlanResponse upsertBillingProductPlan( String planId, UpsertBillingProductRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plans") - .addPathSegment(planId) - .addPathSegments("billing_products") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), UpsertBillingProductPlanResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient + .upsertBillingProductPlan(planId, request, requestOptions) + .body(); } public CountPlansResponse countPlans() { - return countPlans(CountPlansRequest.builder().build()); + return this.rawClient.countPlans().body(); } public CountPlansResponse countPlans(CountPlansRequest request) { - return countPlans(request, null); + return this.rawClient.countPlans(request).body(); } public CountPlansResponse countPlans(CountPlansRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("plans/count"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getHasProductId().isPresent()) { - httpUrl.addQueryParameter( - "has_product_id", request.getHasProductId().get().toString()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getPlanType().isPresent()) { - httpUrl.addQueryParameter("plan_type", request.getPlanType().get().toString()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getWithoutEntitlementFor().isPresent()) { - httpUrl.addQueryParameter( - "without_entitlement_for", - request.getWithoutEntitlementFor().get()); - } - if (request.getWithoutProductId().isPresent()) { - httpUrl.addQueryParameter( - "without_product_id", request.getWithoutProductId().get().toString()); - } - if (request.getWithoutPaidProductId().isPresent()) { - httpUrl.addQueryParameter( - "without_paid_product_id", - request.getWithoutPaidProductId().get().toString()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountPlansResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.countPlans(request, requestOptions).body(); + } + + public ListPlanIssuesResponse listPlanIssues(ListPlanIssuesRequest request) { + return this.rawClient.listPlanIssues(request).body(); + } + + public ListPlanIssuesResponse listPlanIssues(ListPlanIssuesRequest request, RequestOptions requestOptions) { + return this.rawClient.listPlanIssues(request, requestOptions).body(); } } diff --git a/src/main/java/com/schematic/api/resources/plans/RawPlansClient.java b/src/main/java/com/schematic/api/resources/plans/RawPlansClient.java new file mode 100644 index 0000000..a9aee7a --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plans/RawPlansClient.java @@ -0,0 +1,751 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plans; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.plans.requests.CountPlansRequest; +import com.schematic.api.resources.plans.requests.CreatePlanRequestBody; +import com.schematic.api.resources.plans.requests.ListPlanIssuesRequest; +import com.schematic.api.resources.plans.requests.ListPlansRequest; +import com.schematic.api.resources.plans.requests.UpdateCompanyPlansRequestBody; +import com.schematic.api.resources.plans.requests.UpdatePlanRequestBody; +import com.schematic.api.resources.plans.requests.UpsertBillingProductRequestBody; +import com.schematic.api.resources.plans.types.CountPlansResponse; +import com.schematic.api.resources.plans.types.CreatePlanResponse; +import com.schematic.api.resources.plans.types.DeletePlanResponse; +import com.schematic.api.resources.plans.types.GetPlanResponse; +import com.schematic.api.resources.plans.types.ListPlanIssuesResponse; +import com.schematic.api.resources.plans.types.ListPlansResponse; +import com.schematic.api.resources.plans.types.UpdateCompanyPlansResponse; +import com.schematic.api.resources.plans.types.UpdatePlanResponse; +import com.schematic.api.resources.plans.types.UpsertBillingProductPlanResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPlansClient { + protected final ClientOptions clientOptions; + + public RawPlansClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse updateCompanyPlans( + String companyPlanId, UpdateCompanyPlansRequestBody request) { + return updateCompanyPlans(companyPlanId, request, null); + } + + public BaseSchematicHttpResponse updateCompanyPlans( + String companyPlanId, UpdateCompanyPlansRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("company-plans") + .addPathSegment(companyPlanId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateCompanyPlansResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listPlans() { + return listPlans(ListPlansRequest.builder().build()); + } + + public BaseSchematicHttpResponse listPlans(ListPlansRequest request) { + return listPlans(request, null); + } + + public BaseSchematicHttpResponse listPlans( + ListPlansRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getForFallbackPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_fallback_plan", request.getForFallbackPlan().get(), false); + } + if (request.getForInitialPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_initial_plan", request.getForInitialPlan().get(), false); + } + if (request.getForTrialExpiryPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "for_trial_expiry_plan", + request.getForTrialExpiryPlan().get(), + false); + } + if (request.getHasProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "has_product_id", request.getHasProductId().get(), false); + } + if (request.getPlanType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_type", request.getPlanType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequiresPaymentMethod().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "requires_payment_method", + request.getRequiresPaymentMethod().get(), + false); + } + if (request.getWithoutEntitlementFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_entitlement_for", + request.getWithoutEntitlementFor().get(), + false); + } + if (request.getWithoutProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_product_id", request.getWithoutProductId().get(), false); + } + if (request.getWithoutPaidProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_paid_product_id", + request.getWithoutPaidProductId().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPlansResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createPlan(CreatePlanRequestBody request) { + return createPlan(request, null); + } + + public BaseSchematicHttpResponse createPlan( + CreatePlanRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreatePlanResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getPlan(String planId) { + return getPlan(planId, null); + } + + public BaseSchematicHttpResponse getPlan(String planId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .addPathSegment(planId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetPlanResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updatePlan(String planId, UpdatePlanRequestBody request) { + return updatePlan(planId, request, null); + } + + public BaseSchematicHttpResponse updatePlan( + String planId, UpdatePlanRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .addPathSegment(planId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdatePlanResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deletePlan(String planId) { + return deletePlan(planId, null); + } + + public BaseSchematicHttpResponse deletePlan(String planId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .addPathSegment(planId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletePlanResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse upsertBillingProductPlan( + String planId, UpsertBillingProductRequestBody request) { + return upsertBillingProductPlan(planId, request, null); + } + + public BaseSchematicHttpResponse upsertBillingProductPlan( + String planId, UpsertBillingProductRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans") + .addPathSegment(planId) + .addPathSegments("billing_products") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), UpsertBillingProductPlanResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countPlans() { + return countPlans(CountPlansRequest.builder().build()); + } + + public BaseSchematicHttpResponse countPlans(CountPlansRequest request) { + return countPlans(request, null); + } + + public BaseSchematicHttpResponse countPlans( + CountPlansRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans/count"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getForFallbackPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_fallback_plan", request.getForFallbackPlan().get(), false); + } + if (request.getForInitialPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "for_initial_plan", request.getForInitialPlan().get(), false); + } + if (request.getForTrialExpiryPlan().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "for_trial_expiry_plan", + request.getForTrialExpiryPlan().get(), + false); + } + if (request.getHasProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "has_product_id", request.getHasProductId().get(), false); + } + if (request.getPlanType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "plan_type", request.getPlanType().get(), false); + } + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getRequiresPaymentMethod().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "requires_payment_method", + request.getRequiresPaymentMethod().get(), + false); + } + if (request.getWithoutEntitlementFor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_entitlement_for", + request.getWithoutEntitlementFor().get(), + false); + } + if (request.getWithoutProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "without_product_id", request.getWithoutProductId().get(), false); + } + if (request.getWithoutPaidProductId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "without_paid_product_id", + request.getWithoutPaidProductId().get(), + false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountPlansResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listPlanIssues(ListPlanIssuesRequest request) { + return listPlanIssues(request, null); + } + + public BaseSchematicHttpResponse listPlanIssues( + ListPlanIssuesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("plans/issues"); + QueryStringMapper.addQueryParameter(httpUrl, "plan_id", request.getPlanId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListPlanIssuesResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/plans/requests/CountPlansRequest.java b/src/main/java/com/schematic/api/resources/plans/requests/CountPlansRequest.java index f674dc9..0700ace 100644 --- a/src/main/java/com/schematic/api/resources/plans/requests/CountPlansRequest.java +++ b/src/main/java/com/schematic/api/resources/plans/requests/CountPlansRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.plans.types.CountPlansRequestPlanType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,16 +23,24 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountPlansRequest.Builder.class) public final class CountPlansRequest { + private final Optional> ids; + private final Optional companyId; - private final Optional hasProductId; + private final Optional forFallbackPlan; + + private final Optional forInitialPlan; - private final Optional ids; + private final Optional forTrialExpiryPlan; + + private final Optional hasProductId; private final Optional planType; private final Optional q; + private final Optional requiresPaymentMethod; + private final Optional withoutEntitlementFor; private final Optional withoutProductId; @@ -44,22 +54,30 @@ public final class CountPlansRequest { private final Map additionalProperties; private CountPlansRequest( + Optional> ids, Optional companyId, + Optional forFallbackPlan, + Optional forInitialPlan, + Optional forTrialExpiryPlan, Optional hasProductId, - Optional ids, Optional planType, Optional q, + Optional requiresPaymentMethod, Optional withoutEntitlementFor, Optional withoutProductId, Optional withoutPaidProductId, Optional limit, Optional offset, Map additionalProperties) { + this.ids = ids; this.companyId = companyId; + this.forFallbackPlan = forFallbackPlan; + this.forInitialPlan = forInitialPlan; + this.forTrialExpiryPlan = forTrialExpiryPlan; this.hasProductId = hasProductId; - this.ids = ids; this.planType = planType; this.q = q; + this.requiresPaymentMethod = requiresPaymentMethod; this.withoutEntitlementFor = withoutEntitlementFor; this.withoutProductId = withoutProductId; this.withoutPaidProductId = withoutPaidProductId; @@ -68,11 +86,40 @@ private CountPlansRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + @JsonProperty("company_id") public Optional getCompanyId() { return companyId; } + /** + * @return Filter for plans valid as fallback plans (not linked to billing) + */ + @JsonProperty("for_fallback_plan") + public Optional getForFallbackPlan() { + return forFallbackPlan; + } + + /** + * @return Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial) + */ + @JsonProperty("for_initial_plan") + public Optional getForInitialPlan() { + return forInitialPlan; + } + + /** + * @return Filter for plans valid as trial expiry plans (not linked to billing or free) + */ + @JsonProperty("for_trial_expiry_plan") + public Optional getForTrialExpiryPlan() { + return forTrialExpiryPlan; + } + /** * @return Filter out plans that do not have a billing product ID */ @@ -81,11 +128,6 @@ public Optional getHasProductId() { return hasProductId; } - @JsonProperty("ids") - public Optional getIds() { - return ids; - } - /** * @return Filter by plan type */ @@ -99,6 +141,14 @@ public Optional getQ() { return q; } + /** + * @return Filter for plans that require a payment method (inverse of ForInitialPlan) + */ + @JsonProperty("requires_payment_method") + public Optional getRequiresPaymentMethod() { + return requiresPaymentMethod; + } + /** * @return Filter out plans that already have a plan entitlement for the specified feature ID */ @@ -151,11 +201,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountPlansRequest other) { - return companyId.equals(other.companyId) + return ids.equals(other.ids) + && companyId.equals(other.companyId) + && forFallbackPlan.equals(other.forFallbackPlan) + && forInitialPlan.equals(other.forInitialPlan) + && forTrialExpiryPlan.equals(other.forTrialExpiryPlan) && hasProductId.equals(other.hasProductId) - && ids.equals(other.ids) && planType.equals(other.planType) && q.equals(other.q) + && requiresPaymentMethod.equals(other.requiresPaymentMethod) && withoutEntitlementFor.equals(other.withoutEntitlementFor) && withoutProductId.equals(other.withoutProductId) && withoutPaidProductId.equals(other.withoutPaidProductId) @@ -166,11 +220,15 @@ private boolean equalTo(CountPlansRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.ids, this.companyId, + this.forFallbackPlan, + this.forInitialPlan, + this.forTrialExpiryPlan, this.hasProductId, - this.ids, this.planType, this.q, + this.requiresPaymentMethod, this.withoutEntitlementFor, this.withoutProductId, this.withoutPaidProductId, @@ -189,16 +247,24 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> ids = Optional.empty(); + private Optional companyId = Optional.empty(); - private Optional hasProductId = Optional.empty(); + private Optional forFallbackPlan = Optional.empty(); + + private Optional forInitialPlan = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional forTrialExpiryPlan = Optional.empty(); + + private Optional hasProductId = Optional.empty(); private Optional planType = Optional.empty(); private Optional q = Optional.empty(); + private Optional requiresPaymentMethod = Optional.empty(); + private Optional withoutEntitlementFor = Optional.empty(); private Optional withoutProductId = Optional.empty(); @@ -215,11 +281,15 @@ public static final class Builder { private Builder() {} public Builder from(CountPlansRequest other) { + ids(other.getIds()); companyId(other.getCompanyId()); + forFallbackPlan(other.getForFallbackPlan()); + forInitialPlan(other.getForInitialPlan()); + forTrialExpiryPlan(other.getForTrialExpiryPlan()); hasProductId(other.getHasProductId()); - ids(other.getIds()); planType(other.getPlanType()); q(other.getQ()); + requiresPaymentMethod(other.getRequiresPaymentMethod()); withoutEntitlementFor(other.getWithoutEntitlementFor()); withoutProductId(other.getWithoutProductId()); withoutPaidProductId(other.getWithoutPaidProductId()); @@ -228,6 +298,22 @@ public Builder from(CountPlansRequest other) { return this; } + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -239,28 +325,65 @@ public Builder companyId(String companyId) { return this; } - @JsonSetter(value = "has_product_id", nulls = Nulls.SKIP) - public Builder hasProductId(Optional hasProductId) { - this.hasProductId = hasProductId; + /** + *

Filter for plans valid as fallback plans (not linked to billing)

+ */ + @JsonSetter(value = "for_fallback_plan", nulls = Nulls.SKIP) + public Builder forFallbackPlan(Optional forFallbackPlan) { + this.forFallbackPlan = forFallbackPlan; return this; } - public Builder hasProductId(Boolean hasProductId) { - this.hasProductId = Optional.ofNullable(hasProductId); + public Builder forFallbackPlan(Boolean forFallbackPlan) { + this.forFallbackPlan = Optional.ofNullable(forFallbackPlan); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + /** + *

Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial)

+ */ + @JsonSetter(value = "for_initial_plan", nulls = Nulls.SKIP) + public Builder forInitialPlan(Optional forInitialPlan) { + this.forInitialPlan = forInitialPlan; return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + public Builder forInitialPlan(Boolean forInitialPlan) { + this.forInitialPlan = Optional.ofNullable(forInitialPlan); + return this; + } + + /** + *

Filter for plans valid as trial expiry plans (not linked to billing or free)

+ */ + @JsonSetter(value = "for_trial_expiry_plan", nulls = Nulls.SKIP) + public Builder forTrialExpiryPlan(Optional forTrialExpiryPlan) { + this.forTrialExpiryPlan = forTrialExpiryPlan; return this; } + public Builder forTrialExpiryPlan(Boolean forTrialExpiryPlan) { + this.forTrialExpiryPlan = Optional.ofNullable(forTrialExpiryPlan); + return this; + } + + /** + *

Filter out plans that do not have a billing product ID

+ */ + @JsonSetter(value = "has_product_id", nulls = Nulls.SKIP) + public Builder hasProductId(Optional hasProductId) { + this.hasProductId = hasProductId; + return this; + } + + public Builder hasProductId(Boolean hasProductId) { + this.hasProductId = Optional.ofNullable(hasProductId); + return this; + } + + /** + *

Filter by plan type

+ */ @JsonSetter(value = "plan_type", nulls = Nulls.SKIP) public Builder planType(Optional planType) { this.planType = planType; @@ -283,6 +406,23 @@ public Builder q(String q) { return this; } + /** + *

Filter for plans that require a payment method (inverse of ForInitialPlan)

+ */ + @JsonSetter(value = "requires_payment_method", nulls = Nulls.SKIP) + public Builder requiresPaymentMethod(Optional requiresPaymentMethod) { + this.requiresPaymentMethod = requiresPaymentMethod; + return this; + } + + public Builder requiresPaymentMethod(Boolean requiresPaymentMethod) { + this.requiresPaymentMethod = Optional.ofNullable(requiresPaymentMethod); + return this; + } + + /** + *

Filter out plans that already have a plan entitlement for the specified feature ID

+ */ @JsonSetter(value = "without_entitlement_for", nulls = Nulls.SKIP) public Builder withoutEntitlementFor(Optional withoutEntitlementFor) { this.withoutEntitlementFor = withoutEntitlementFor; @@ -294,6 +434,9 @@ public Builder withoutEntitlementFor(String withoutEntitlementFor) { return this; } + /** + *

Filter out plans that have a billing product ID

+ */ @JsonSetter(value = "without_product_id", nulls = Nulls.SKIP) public Builder withoutProductId(Optional withoutProductId) { this.withoutProductId = withoutProductId; @@ -305,6 +448,9 @@ public Builder withoutProductId(Boolean withoutProductId) { return this; } + /** + *

Filter out plans that have a paid billing product ID

+ */ @JsonSetter(value = "without_paid_product_id", nulls = Nulls.SKIP) public Builder withoutPaidProductId(Optional withoutPaidProductId) { this.withoutPaidProductId = withoutPaidProductId; @@ -316,6 +462,9 @@ public Builder withoutPaidProductId(Boolean withoutPaidProductId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -327,6 +476,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -340,11 +492,15 @@ public Builder offset(Integer offset) { public CountPlansRequest build() { return new CountPlansRequest( + ids, companyId, + forFallbackPlan, + forInitialPlan, + forTrialExpiryPlan, hasProductId, - ids, planType, q, + requiresPaymentMethod, withoutEntitlementFor, withoutProductId, withoutPaidProductId, diff --git a/src/main/java/com/schematic/api/resources/plans/requests/ListPlanIssuesRequest.java b/src/main/java/com/schematic/api/resources/plans/requests/ListPlanIssuesRequest.java new file mode 100644 index 0000000..4f73caf --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plans/requests/ListPlanIssuesRequest.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plans.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanIssuesRequest.Builder.class) +public final class ListPlanIssuesRequest { + private final String planId; + + private final Map additionalProperties; + + private ListPlanIssuesRequest(String planId, Map additionalProperties) { + this.planId = planId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanIssuesRequest && equalTo((ListPlanIssuesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanIssuesRequest other) { + return planId.equals(other.planId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.planId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PlanIdStage builder() { + return new Builder(); + } + + public interface PlanIdStage { + _FinalStage planId(@NotNull String planId); + + Builder from(ListPlanIssuesRequest other); + } + + public interface _FinalStage { + ListPlanIssuesRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PlanIdStage, _FinalStage { + private String planId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListPlanIssuesRequest other) { + planId(other.getPlanId()); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public _FinalStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + public ListPlanIssuesRequest build() { + return new ListPlanIssuesRequest(planId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/plans/requests/ListPlansRequest.java b/src/main/java/com/schematic/api/resources/plans/requests/ListPlansRequest.java index d2330ad..59b1d53 100644 --- a/src/main/java/com/schematic/api/resources/plans/requests/ListPlansRequest.java +++ b/src/main/java/com/schematic/api/resources/plans/requests/ListPlansRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.plans.types.ListPlansRequestPlanType; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,16 +23,24 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListPlansRequest.Builder.class) public final class ListPlansRequest { + private final Optional> ids; + private final Optional companyId; - private final Optional hasProductId; + private final Optional forFallbackPlan; + + private final Optional forInitialPlan; - private final Optional ids; + private final Optional forTrialExpiryPlan; + + private final Optional hasProductId; private final Optional planType; private final Optional q; + private final Optional requiresPaymentMethod; + private final Optional withoutEntitlementFor; private final Optional withoutProductId; @@ -44,22 +54,30 @@ public final class ListPlansRequest { private final Map additionalProperties; private ListPlansRequest( + Optional> ids, Optional companyId, + Optional forFallbackPlan, + Optional forInitialPlan, + Optional forTrialExpiryPlan, Optional hasProductId, - Optional ids, Optional planType, Optional q, + Optional requiresPaymentMethod, Optional withoutEntitlementFor, Optional withoutProductId, Optional withoutPaidProductId, Optional limit, Optional offset, Map additionalProperties) { + this.ids = ids; this.companyId = companyId; + this.forFallbackPlan = forFallbackPlan; + this.forInitialPlan = forInitialPlan; + this.forTrialExpiryPlan = forTrialExpiryPlan; this.hasProductId = hasProductId; - this.ids = ids; this.planType = planType; this.q = q; + this.requiresPaymentMethod = requiresPaymentMethod; this.withoutEntitlementFor = withoutEntitlementFor; this.withoutProductId = withoutProductId; this.withoutPaidProductId = withoutPaidProductId; @@ -68,11 +86,40 @@ private ListPlansRequest( this.additionalProperties = additionalProperties; } + @JsonProperty("ids") + public Optional> getIds() { + return ids; + } + @JsonProperty("company_id") public Optional getCompanyId() { return companyId; } + /** + * @return Filter for plans valid as fallback plans (not linked to billing) + */ + @JsonProperty("for_fallback_plan") + public Optional getForFallbackPlan() { + return forFallbackPlan; + } + + /** + * @return Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial) + */ + @JsonProperty("for_initial_plan") + public Optional getForInitialPlan() { + return forInitialPlan; + } + + /** + * @return Filter for plans valid as trial expiry plans (not linked to billing or free) + */ + @JsonProperty("for_trial_expiry_plan") + public Optional getForTrialExpiryPlan() { + return forTrialExpiryPlan; + } + /** * @return Filter out plans that do not have a billing product ID */ @@ -81,11 +128,6 @@ public Optional getHasProductId() { return hasProductId; } - @JsonProperty("ids") - public Optional getIds() { - return ids; - } - /** * @return Filter by plan type */ @@ -99,6 +141,14 @@ public Optional getQ() { return q; } + /** + * @return Filter for plans that require a payment method (inverse of ForInitialPlan) + */ + @JsonProperty("requires_payment_method") + public Optional getRequiresPaymentMethod() { + return requiresPaymentMethod; + } + /** * @return Filter out plans that already have a plan entitlement for the specified feature ID */ @@ -151,11 +201,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListPlansRequest other) { - return companyId.equals(other.companyId) + return ids.equals(other.ids) + && companyId.equals(other.companyId) + && forFallbackPlan.equals(other.forFallbackPlan) + && forInitialPlan.equals(other.forInitialPlan) + && forTrialExpiryPlan.equals(other.forTrialExpiryPlan) && hasProductId.equals(other.hasProductId) - && ids.equals(other.ids) && planType.equals(other.planType) && q.equals(other.q) + && requiresPaymentMethod.equals(other.requiresPaymentMethod) && withoutEntitlementFor.equals(other.withoutEntitlementFor) && withoutProductId.equals(other.withoutProductId) && withoutPaidProductId.equals(other.withoutPaidProductId) @@ -166,11 +220,15 @@ private boolean equalTo(ListPlansRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.ids, this.companyId, + this.forFallbackPlan, + this.forInitialPlan, + this.forTrialExpiryPlan, this.hasProductId, - this.ids, this.planType, this.q, + this.requiresPaymentMethod, this.withoutEntitlementFor, this.withoutProductId, this.withoutPaidProductId, @@ -189,16 +247,24 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> ids = Optional.empty(); + private Optional companyId = Optional.empty(); - private Optional hasProductId = Optional.empty(); + private Optional forFallbackPlan = Optional.empty(); + + private Optional forInitialPlan = Optional.empty(); - private Optional ids = Optional.empty(); + private Optional forTrialExpiryPlan = Optional.empty(); + + private Optional hasProductId = Optional.empty(); private Optional planType = Optional.empty(); private Optional q = Optional.empty(); + private Optional requiresPaymentMethod = Optional.empty(); + private Optional withoutEntitlementFor = Optional.empty(); private Optional withoutProductId = Optional.empty(); @@ -215,11 +281,15 @@ public static final class Builder { private Builder() {} public Builder from(ListPlansRequest other) { + ids(other.getIds()); companyId(other.getCompanyId()); + forFallbackPlan(other.getForFallbackPlan()); + forInitialPlan(other.getForInitialPlan()); + forTrialExpiryPlan(other.getForTrialExpiryPlan()); hasProductId(other.getHasProductId()); - ids(other.getIds()); planType(other.getPlanType()); q(other.getQ()); + requiresPaymentMethod(other.getRequiresPaymentMethod()); withoutEntitlementFor(other.getWithoutEntitlementFor()); withoutProductId(other.getWithoutProductId()); withoutPaidProductId(other.getWithoutPaidProductId()); @@ -228,6 +298,22 @@ public Builder from(ListPlansRequest other) { return this; } + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional> ids) { + this.ids = ids; + return this; + } + + public Builder ids(List ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -239,28 +325,65 @@ public Builder companyId(String companyId) { return this; } - @JsonSetter(value = "has_product_id", nulls = Nulls.SKIP) - public Builder hasProductId(Optional hasProductId) { - this.hasProductId = hasProductId; + /** + *

Filter for plans valid as fallback plans (not linked to billing)

+ */ + @JsonSetter(value = "for_fallback_plan", nulls = Nulls.SKIP) + public Builder forFallbackPlan(Optional forFallbackPlan) { + this.forFallbackPlan = forFallbackPlan; return this; } - public Builder hasProductId(Boolean hasProductId) { - this.hasProductId = Optional.ofNullable(hasProductId); + public Builder forFallbackPlan(Boolean forFallbackPlan) { + this.forFallbackPlan = Optional.ofNullable(forFallbackPlan); return this; } - @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { - this.ids = ids; + /** + *

Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial)

+ */ + @JsonSetter(value = "for_initial_plan", nulls = Nulls.SKIP) + public Builder forInitialPlan(Optional forInitialPlan) { + this.forInitialPlan = forInitialPlan; return this; } - public Builder ids(String ids) { - this.ids = Optional.ofNullable(ids); + public Builder forInitialPlan(Boolean forInitialPlan) { + this.forInitialPlan = Optional.ofNullable(forInitialPlan); + return this; + } + + /** + *

Filter for plans valid as trial expiry plans (not linked to billing or free)

+ */ + @JsonSetter(value = "for_trial_expiry_plan", nulls = Nulls.SKIP) + public Builder forTrialExpiryPlan(Optional forTrialExpiryPlan) { + this.forTrialExpiryPlan = forTrialExpiryPlan; return this; } + public Builder forTrialExpiryPlan(Boolean forTrialExpiryPlan) { + this.forTrialExpiryPlan = Optional.ofNullable(forTrialExpiryPlan); + return this; + } + + /** + *

Filter out plans that do not have a billing product ID

+ */ + @JsonSetter(value = "has_product_id", nulls = Nulls.SKIP) + public Builder hasProductId(Optional hasProductId) { + this.hasProductId = hasProductId; + return this; + } + + public Builder hasProductId(Boolean hasProductId) { + this.hasProductId = Optional.ofNullable(hasProductId); + return this; + } + + /** + *

Filter by plan type

+ */ @JsonSetter(value = "plan_type", nulls = Nulls.SKIP) public Builder planType(Optional planType) { this.planType = planType; @@ -283,6 +406,23 @@ public Builder q(String q) { return this; } + /** + *

Filter for plans that require a payment method (inverse of ForInitialPlan)

+ */ + @JsonSetter(value = "requires_payment_method", nulls = Nulls.SKIP) + public Builder requiresPaymentMethod(Optional requiresPaymentMethod) { + this.requiresPaymentMethod = requiresPaymentMethod; + return this; + } + + public Builder requiresPaymentMethod(Boolean requiresPaymentMethod) { + this.requiresPaymentMethod = Optional.ofNullable(requiresPaymentMethod); + return this; + } + + /** + *

Filter out plans that already have a plan entitlement for the specified feature ID

+ */ @JsonSetter(value = "without_entitlement_for", nulls = Nulls.SKIP) public Builder withoutEntitlementFor(Optional withoutEntitlementFor) { this.withoutEntitlementFor = withoutEntitlementFor; @@ -294,6 +434,9 @@ public Builder withoutEntitlementFor(String withoutEntitlementFor) { return this; } + /** + *

Filter out plans that have a billing product ID

+ */ @JsonSetter(value = "without_product_id", nulls = Nulls.SKIP) public Builder withoutProductId(Optional withoutProductId) { this.withoutProductId = withoutProductId; @@ -305,6 +448,9 @@ public Builder withoutProductId(Boolean withoutProductId) { return this; } + /** + *

Filter out plans that have a paid billing product ID

+ */ @JsonSetter(value = "without_paid_product_id", nulls = Nulls.SKIP) public Builder withoutPaidProductId(Optional withoutPaidProductId) { this.withoutPaidProductId = withoutPaidProductId; @@ -316,6 +462,9 @@ public Builder withoutPaidProductId(Boolean withoutPaidProductId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -327,6 +476,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -340,11 +492,15 @@ public Builder offset(Integer offset) { public ListPlansRequest build() { return new ListPlansRequest( + ids, companyId, + forFallbackPlan, + forInitialPlan, + forTrialExpiryPlan, hasProductId, - ids, planType, q, + requiresPaymentMethod, withoutEntitlementFor, withoutProductId, withoutPaidProductId, diff --git a/src/main/java/com/schematic/api/resources/plans/requests/UpdateAudienceRequestBody.java b/src/main/java/com/schematic/api/resources/plans/requests/UpdateAudienceRequestBody.java deleted file mode 100644 index bd08550..0000000 --- a/src/main/java/com/schematic/api/resources/plans/requests/UpdateAudienceRequestBody.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.schematic.api.resources.plans.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.schematic.api.core.ObjectMappers; -import com.schematic.api.types.CreateOrUpdateConditionGroupRequestBody; -import com.schematic.api.types.CreateOrUpdateConditionRequestBody; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = UpdateAudienceRequestBody.Builder.class) -public final class UpdateAudienceRequestBody { - private final List conditionGroups; - - private final List conditions; - - private final Map additionalProperties; - - private UpdateAudienceRequestBody( - List conditionGroups, - List conditions, - Map additionalProperties) { - this.conditionGroups = conditionGroups; - this.conditions = conditions; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("condition_groups") - public List getConditionGroups() { - return conditionGroups; - } - - @JsonProperty("conditions") - public List getConditions() { - return conditions; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UpdateAudienceRequestBody && equalTo((UpdateAudienceRequestBody) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UpdateAudienceRequestBody other) { - return conditionGroups.equals(other.conditionGroups) && conditions.equals(other.conditions); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.conditionGroups, this.conditions); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List conditionGroups = new ArrayList<>(); - - private List conditions = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(UpdateAudienceRequestBody other) { - conditionGroups(other.getConditionGroups()); - conditions(other.getConditions()); - return this; - } - - @JsonSetter(value = "condition_groups", nulls = Nulls.SKIP) - public Builder conditionGroups(List conditionGroups) { - this.conditionGroups.clear(); - this.conditionGroups.addAll(conditionGroups); - return this; - } - - public Builder addConditionGroups(CreateOrUpdateConditionGroupRequestBody conditionGroups) { - this.conditionGroups.add(conditionGroups); - return this; - } - - public Builder addAllConditionGroups(List conditionGroups) { - this.conditionGroups.addAll(conditionGroups); - return this; - } - - @JsonSetter(value = "conditions", nulls = Nulls.SKIP) - public Builder conditions(List conditions) { - this.conditions.clear(); - this.conditions.addAll(conditions); - return this; - } - - public Builder addConditions(CreateOrUpdateConditionRequestBody conditions) { - this.conditions.add(conditions); - return this; - } - - public Builder addAllConditions(List conditions) { - this.conditions.addAll(conditions); - return this; - } - - public UpdateAudienceRequestBody build() { - return new UpdateAudienceRequestBody(conditionGroups, conditions, additionalProperties); - } - } -} diff --git a/src/main/java/com/schematic/api/resources/plans/requests/UpdateCompanyPlansRequestBody.java b/src/main/java/com/schematic/api/resources/plans/requests/UpdateCompanyPlansRequestBody.java index 318023e..aac98f2 100644 --- a/src/main/java/com/schematic/api/resources/plans/requests/UpdateCompanyPlansRequestBody.java +++ b/src/main/java/com/schematic/api/resources/plans/requests/UpdateCompanyPlansRequestBody.java @@ -94,7 +94,9 @@ public Builder from(UpdateCompanyPlansRequestBody other) { @JsonSetter(value = "add_on_ids", nulls = Nulls.SKIP) public Builder addOnIds(List addOnIds) { this.addOnIds.clear(); - this.addOnIds.addAll(addOnIds); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } return this; } @@ -104,7 +106,9 @@ public Builder addAddOnIds(String addOnIds) { } public Builder addAllAddOnIds(List addOnIds) { - this.addOnIds.addAll(addOnIds); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/requests/UpsertBillingProductRequestBody.java b/src/main/java/com/schematic/api/resources/plans/requests/UpsertBillingProductRequestBody.java index 8926824..4102bf4 100644 --- a/src/main/java/com/schematic/api/resources/plans/requests/UpsertBillingProductRequestBody.java +++ b/src/main/java/com/schematic/api/resources/plans/requests/UpsertBillingProductRequestBody.java @@ -12,41 +12,63 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.plans.types.UpsertBillingProductRequestBodyChargeType; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; +import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpsertBillingProductRequestBody.Builder.class) public final class UpsertBillingProductRequestBody { private final Optional billingProductId; - private final boolean isFreePlan; + private final UpsertBillingProductRequestBodyChargeType chargeType; + + private final Optional currency; private final boolean isTrialable; + private final Optional monthlyPrice; + private final Optional monthlyPriceId; + private final Optional oneTimePrice; + + private final Optional oneTimePriceId; + private final Optional trialDays; + private final Optional yearlyPrice; + private final Optional yearlyPriceId; private final Map additionalProperties; private UpsertBillingProductRequestBody( Optional billingProductId, - boolean isFreePlan, + UpsertBillingProductRequestBodyChargeType chargeType, + Optional currency, boolean isTrialable, + Optional monthlyPrice, Optional monthlyPriceId, + Optional oneTimePrice, + Optional oneTimePriceId, Optional trialDays, + Optional yearlyPrice, Optional yearlyPriceId, Map additionalProperties) { this.billingProductId = billingProductId; - this.isFreePlan = isFreePlan; + this.chargeType = chargeType; + this.currency = currency; this.isTrialable = isTrialable; + this.monthlyPrice = monthlyPrice; this.monthlyPriceId = monthlyPriceId; + this.oneTimePrice = oneTimePrice; + this.oneTimePriceId = oneTimePriceId; this.trialDays = trialDays; + this.yearlyPrice = yearlyPrice; this.yearlyPriceId = yearlyPriceId; this.additionalProperties = additionalProperties; } @@ -56,9 +78,14 @@ public Optional getBillingProductId() { return billingProductId; } - @JsonProperty("is_free_plan") - public boolean getIsFreePlan() { - return isFreePlan; + @JsonProperty("charge_type") + public UpsertBillingProductRequestBodyChargeType getChargeType() { + return chargeType; + } + + @JsonProperty("currency") + public Optional getCurrency() { + return currency; } @JsonProperty("is_trialable") @@ -66,16 +93,36 @@ public boolean getIsTrialable() { return isTrialable; } + @JsonProperty("monthly_price") + public Optional getMonthlyPrice() { + return monthlyPrice; + } + @JsonProperty("monthly_price_id") public Optional getMonthlyPriceId() { return monthlyPriceId; } + @JsonProperty("one_time_price") + public Optional getOneTimePrice() { + return oneTimePrice; + } + + @JsonProperty("one_time_price_id") + public Optional getOneTimePriceId() { + return oneTimePriceId; + } + @JsonProperty("trial_days") public Optional getTrialDays() { return trialDays; } + @JsonProperty("yearly_price") + public Optional getYearlyPrice() { + return yearlyPrice; + } + @JsonProperty("yearly_price_id") public Optional getYearlyPriceId() { return yearlyPriceId; @@ -94,10 +141,15 @@ public Map getAdditionalProperties() { private boolean equalTo(UpsertBillingProductRequestBody other) { return billingProductId.equals(other.billingProductId) - && isFreePlan == other.isFreePlan + && chargeType.equals(other.chargeType) + && currency.equals(other.currency) && isTrialable == other.isTrialable + && monthlyPrice.equals(other.monthlyPrice) && monthlyPriceId.equals(other.monthlyPriceId) + && oneTimePrice.equals(other.oneTimePrice) + && oneTimePriceId.equals(other.oneTimePriceId) && trialDays.equals(other.trialDays) + && yearlyPrice.equals(other.yearlyPrice) && yearlyPriceId.equals(other.yearlyPriceId); } @@ -105,10 +157,15 @@ private boolean equalTo(UpsertBillingProductRequestBody other) { public int hashCode() { return Objects.hash( this.billingProductId, - this.isFreePlan, + this.chargeType, + this.currency, this.isTrialable, + this.monthlyPrice, this.monthlyPriceId, + this.oneTimePrice, + this.oneTimePriceId, this.trialDays, + this.yearlyPrice, this.yearlyPriceId); } @@ -117,12 +174,12 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IsFreePlanStage builder() { + public static ChargeTypeStage builder() { return new Builder(); } - public interface IsFreePlanStage { - IsTrialableStage isFreePlan(boolean isFreePlan); + public interface ChargeTypeStage { + IsTrialableStage chargeType(@NotNull UpsertBillingProductRequestBodyChargeType chargeType); Builder from(UpsertBillingProductRequestBody other); } @@ -138,31 +195,61 @@ public interface _FinalStage { _FinalStage billingProductId(String billingProductId); + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + + _FinalStage monthlyPrice(Optional monthlyPrice); + + _FinalStage monthlyPrice(Integer monthlyPrice); + _FinalStage monthlyPriceId(Optional monthlyPriceId); _FinalStage monthlyPriceId(String monthlyPriceId); + _FinalStage oneTimePrice(Optional oneTimePrice); + + _FinalStage oneTimePrice(Integer oneTimePrice); + + _FinalStage oneTimePriceId(Optional oneTimePriceId); + + _FinalStage oneTimePriceId(String oneTimePriceId); + _FinalStage trialDays(Optional trialDays); _FinalStage trialDays(Integer trialDays); + _FinalStage yearlyPrice(Optional yearlyPrice); + + _FinalStage yearlyPrice(Integer yearlyPrice); + _FinalStage yearlyPriceId(Optional yearlyPriceId); _FinalStage yearlyPriceId(String yearlyPriceId); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IsFreePlanStage, IsTrialableStage, _FinalStage { - private boolean isFreePlan; + public static final class Builder implements ChargeTypeStage, IsTrialableStage, _FinalStage { + private UpsertBillingProductRequestBodyChargeType chargeType; private boolean isTrialable; private Optional yearlyPriceId = Optional.empty(); + private Optional yearlyPrice = Optional.empty(); + private Optional trialDays = Optional.empty(); + private Optional oneTimePriceId = Optional.empty(); + + private Optional oneTimePrice = Optional.empty(); + private Optional monthlyPriceId = Optional.empty(); + private Optional monthlyPrice = Optional.empty(); + + private Optional currency = Optional.empty(); + private Optional billingProductId = Optional.empty(); @JsonAnySetter @@ -173,18 +260,23 @@ private Builder() {} @java.lang.Override public Builder from(UpsertBillingProductRequestBody other) { billingProductId(other.getBillingProductId()); - isFreePlan(other.getIsFreePlan()); + chargeType(other.getChargeType()); + currency(other.getCurrency()); isTrialable(other.getIsTrialable()); + monthlyPrice(other.getMonthlyPrice()); monthlyPriceId(other.getMonthlyPriceId()); + oneTimePrice(other.getOneTimePrice()); + oneTimePriceId(other.getOneTimePriceId()); trialDays(other.getTrialDays()); + yearlyPrice(other.getYearlyPrice()); yearlyPriceId(other.getYearlyPriceId()); return this; } @java.lang.Override - @JsonSetter("is_free_plan") - public IsTrialableStage isFreePlan(boolean isFreePlan) { - this.isFreePlan = isFreePlan; + @JsonSetter("charge_type") + public IsTrialableStage chargeType(@NotNull UpsertBillingProductRequestBodyChargeType chargeType) { + this.chargeType = Objects.requireNonNull(chargeType, "chargeType must not be null"); return this; } @@ -208,6 +300,19 @@ public _FinalStage yearlyPriceId(Optional yearlyPriceId) { return this; } + @java.lang.Override + public _FinalStage yearlyPrice(Integer yearlyPrice) { + this.yearlyPrice = Optional.ofNullable(yearlyPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_price", nulls = Nulls.SKIP) + public _FinalStage yearlyPrice(Optional yearlyPrice) { + this.yearlyPrice = yearlyPrice; + return this; + } + @java.lang.Override public _FinalStage trialDays(Integer trialDays) { this.trialDays = Optional.ofNullable(trialDays); @@ -221,6 +326,32 @@ public _FinalStage trialDays(Optional trialDays) { return this; } + @java.lang.Override + public _FinalStage oneTimePriceId(String oneTimePriceId) { + this.oneTimePriceId = Optional.ofNullable(oneTimePriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "one_time_price_id", nulls = Nulls.SKIP) + public _FinalStage oneTimePriceId(Optional oneTimePriceId) { + this.oneTimePriceId = oneTimePriceId; + return this; + } + + @java.lang.Override + public _FinalStage oneTimePrice(Integer oneTimePrice) { + this.oneTimePrice = Optional.ofNullable(oneTimePrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "one_time_price", nulls = Nulls.SKIP) + public _FinalStage oneTimePrice(Optional oneTimePrice) { + this.oneTimePrice = oneTimePrice; + return this; + } + @java.lang.Override public _FinalStage monthlyPriceId(String monthlyPriceId) { this.monthlyPriceId = Optional.ofNullable(monthlyPriceId); @@ -234,6 +365,32 @@ public _FinalStage monthlyPriceId(Optional monthlyPriceId) { return this; } + @java.lang.Override + public _FinalStage monthlyPrice(Integer monthlyPrice) { + this.monthlyPrice = Optional.ofNullable(monthlyPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_price", nulls = Nulls.SKIP) + public _FinalStage monthlyPrice(Optional monthlyPrice) { + this.monthlyPrice = monthlyPrice; + return this; + } + + @java.lang.Override + public _FinalStage currency(String currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; + return this; + } + @java.lang.Override public _FinalStage billingProductId(String billingProductId) { this.billingProductId = Optional.ofNullable(billingProductId); @@ -251,10 +408,15 @@ public _FinalStage billingProductId(Optional billingProductId) { public UpsertBillingProductRequestBody build() { return new UpsertBillingProductRequestBody( billingProductId, - isFreePlan, + chargeType, + currency, isTrialable, + monthlyPrice, monthlyPriceId, + oneTimePrice, + oneTimePriceId, trialDays, + yearlyPrice, yearlyPriceId, additionalProperties); } diff --git a/src/main/java/com/schematic/api/resources/plans/types/CountPlansParams.java b/src/main/java/com/schematic/api/resources/plans/types/CountPlansParams.java index c7d73ef..2995339 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/CountPlansParams.java +++ b/src/main/java/com/schematic/api/resources/plans/types/CountPlansParams.java @@ -23,6 +23,12 @@ public final class CountPlansParams { private final Optional companyId; + private final Optional forFallbackPlan; + + private final Optional forInitialPlan; + + private final Optional forTrialExpiryPlan; + private final Optional hasProductId; private final Optional> ids; @@ -35,6 +41,8 @@ public final class CountPlansParams { private final Optional q; + private final Optional requiresPaymentMethod; + private final Optional withoutEntitlementFor; private final Optional withoutPaidProductId; @@ -45,23 +53,31 @@ public final class CountPlansParams { private CountPlansParams( Optional companyId, + Optional forFallbackPlan, + Optional forInitialPlan, + Optional forTrialExpiryPlan, Optional hasProductId, Optional> ids, Optional limit, Optional offset, Optional planType, Optional q, + Optional requiresPaymentMethod, Optional withoutEntitlementFor, Optional withoutPaidProductId, Optional withoutProductId, Map additionalProperties) { this.companyId = companyId; + this.forFallbackPlan = forFallbackPlan; + this.forInitialPlan = forInitialPlan; + this.forTrialExpiryPlan = forTrialExpiryPlan; this.hasProductId = hasProductId; this.ids = ids; this.limit = limit; this.offset = offset; this.planType = planType; this.q = q; + this.requiresPaymentMethod = requiresPaymentMethod; this.withoutEntitlementFor = withoutEntitlementFor; this.withoutPaidProductId = withoutPaidProductId; this.withoutProductId = withoutProductId; @@ -73,6 +89,30 @@ public Optional getCompanyId() { return companyId; } + /** + * @return Filter for plans valid as fallback plans (not linked to billing) + */ + @JsonProperty("for_fallback_plan") + public Optional getForFallbackPlan() { + return forFallbackPlan; + } + + /** + * @return Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial) + */ + @JsonProperty("for_initial_plan") + public Optional getForInitialPlan() { + return forInitialPlan; + } + + /** + * @return Filter for plans valid as trial expiry plans (not linked to billing or free) + */ + @JsonProperty("for_trial_expiry_plan") + public Optional getForTrialExpiryPlan() { + return forTrialExpiryPlan; + } + /** * @return Filter out plans that do not have a billing product ID */ @@ -115,6 +155,14 @@ public Optional getQ() { return q; } + /** + * @return Filter for plans that require a payment method (inverse of ForInitialPlan) + */ + @JsonProperty("requires_payment_method") + public Optional getRequiresPaymentMethod() { + return requiresPaymentMethod; + } + /** * @return Filter out plans that already have a plan entitlement for the specified feature ID */ @@ -152,12 +200,16 @@ public Map getAdditionalProperties() { private boolean equalTo(CountPlansParams other) { return companyId.equals(other.companyId) + && forFallbackPlan.equals(other.forFallbackPlan) + && forInitialPlan.equals(other.forInitialPlan) + && forTrialExpiryPlan.equals(other.forTrialExpiryPlan) && hasProductId.equals(other.hasProductId) && ids.equals(other.ids) && limit.equals(other.limit) && offset.equals(other.offset) && planType.equals(other.planType) && q.equals(other.q) + && requiresPaymentMethod.equals(other.requiresPaymentMethod) && withoutEntitlementFor.equals(other.withoutEntitlementFor) && withoutPaidProductId.equals(other.withoutPaidProductId) && withoutProductId.equals(other.withoutProductId); @@ -167,12 +219,16 @@ private boolean equalTo(CountPlansParams other) { public int hashCode() { return Objects.hash( this.companyId, + this.forFallbackPlan, + this.forInitialPlan, + this.forTrialExpiryPlan, this.hasProductId, this.ids, this.limit, this.offset, this.planType, this.q, + this.requiresPaymentMethod, this.withoutEntitlementFor, this.withoutPaidProductId, this.withoutProductId); @@ -191,6 +247,12 @@ public static Builder builder() { public static final class Builder { private Optional companyId = Optional.empty(); + private Optional forFallbackPlan = Optional.empty(); + + private Optional forInitialPlan = Optional.empty(); + + private Optional forTrialExpiryPlan = Optional.empty(); + private Optional hasProductId = Optional.empty(); private Optional> ids = Optional.empty(); @@ -203,6 +265,8 @@ public static final class Builder { private Optional q = Optional.empty(); + private Optional requiresPaymentMethod = Optional.empty(); + private Optional withoutEntitlementFor = Optional.empty(); private Optional withoutPaidProductId = Optional.empty(); @@ -216,12 +280,16 @@ private Builder() {} public Builder from(CountPlansParams other) { companyId(other.getCompanyId()); + forFallbackPlan(other.getForFallbackPlan()); + forInitialPlan(other.getForInitialPlan()); + forTrialExpiryPlan(other.getForTrialExpiryPlan()); hasProductId(other.getHasProductId()); ids(other.getIds()); limit(other.getLimit()); offset(other.getOffset()); planType(other.getPlanType()); q(other.getQ()); + requiresPaymentMethod(other.getRequiresPaymentMethod()); withoutEntitlementFor(other.getWithoutEntitlementFor()); withoutPaidProductId(other.getWithoutPaidProductId()); withoutProductId(other.getWithoutProductId()); @@ -239,6 +307,51 @@ public Builder companyId(String companyId) { return this; } + /** + *

Filter for plans valid as fallback plans (not linked to billing)

+ */ + @JsonSetter(value = "for_fallback_plan", nulls = Nulls.SKIP) + public Builder forFallbackPlan(Optional forFallbackPlan) { + this.forFallbackPlan = forFallbackPlan; + return this; + } + + public Builder forFallbackPlan(Boolean forFallbackPlan) { + this.forFallbackPlan = Optional.ofNullable(forFallbackPlan); + return this; + } + + /** + *

Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial)

+ */ + @JsonSetter(value = "for_initial_plan", nulls = Nulls.SKIP) + public Builder forInitialPlan(Optional forInitialPlan) { + this.forInitialPlan = forInitialPlan; + return this; + } + + public Builder forInitialPlan(Boolean forInitialPlan) { + this.forInitialPlan = Optional.ofNullable(forInitialPlan); + return this; + } + + /** + *

Filter for plans valid as trial expiry plans (not linked to billing or free)

+ */ + @JsonSetter(value = "for_trial_expiry_plan", nulls = Nulls.SKIP) + public Builder forTrialExpiryPlan(Optional forTrialExpiryPlan) { + this.forTrialExpiryPlan = forTrialExpiryPlan; + return this; + } + + public Builder forTrialExpiryPlan(Boolean forTrialExpiryPlan) { + this.forTrialExpiryPlan = Optional.ofNullable(forTrialExpiryPlan); + return this; + } + + /** + *

Filter out plans that do not have a billing product ID

+ */ @JsonSetter(value = "has_product_id", nulls = Nulls.SKIP) public Builder hasProductId(Optional hasProductId) { this.hasProductId = hasProductId; @@ -261,6 +374,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -272,6 +388,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -283,6 +402,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Filter by plan type

+ */ @JsonSetter(value = "plan_type", nulls = Nulls.SKIP) public Builder planType(Optional planType) { this.planType = planType; @@ -305,6 +427,23 @@ public Builder q(String q) { return this; } + /** + *

Filter for plans that require a payment method (inverse of ForInitialPlan)

+ */ + @JsonSetter(value = "requires_payment_method", nulls = Nulls.SKIP) + public Builder requiresPaymentMethod(Optional requiresPaymentMethod) { + this.requiresPaymentMethod = requiresPaymentMethod; + return this; + } + + public Builder requiresPaymentMethod(Boolean requiresPaymentMethod) { + this.requiresPaymentMethod = Optional.ofNullable(requiresPaymentMethod); + return this; + } + + /** + *

Filter out plans that already have a plan entitlement for the specified feature ID

+ */ @JsonSetter(value = "without_entitlement_for", nulls = Nulls.SKIP) public Builder withoutEntitlementFor(Optional withoutEntitlementFor) { this.withoutEntitlementFor = withoutEntitlementFor; @@ -316,6 +455,9 @@ public Builder withoutEntitlementFor(String withoutEntitlementFor) { return this; } + /** + *

Filter out plans that have a paid billing product ID

+ */ @JsonSetter(value = "without_paid_product_id", nulls = Nulls.SKIP) public Builder withoutPaidProductId(Optional withoutPaidProductId) { this.withoutPaidProductId = withoutPaidProductId; @@ -327,6 +469,9 @@ public Builder withoutPaidProductId(Boolean withoutPaidProductId) { return this; } + /** + *

Filter out plans that have a billing product ID

+ */ @JsonSetter(value = "without_product_id", nulls = Nulls.SKIP) public Builder withoutProductId(Optional withoutProductId) { this.withoutProductId = withoutProductId; @@ -341,12 +486,16 @@ public Builder withoutProductId(Boolean withoutProductId) { public CountPlansParams build() { return new CountPlansParams( companyId, + forFallbackPlan, + forInitialPlan, + forTrialExpiryPlan, hasProductId, ids, limit, offset, planType, q, + requiresPaymentMethod, withoutEntitlementFor, withoutPaidProductId, withoutProductId, diff --git a/src/main/java/com/schematic/api/resources/plans/types/CountPlansRequestPlanType.java b/src/main/java/com/schematic/api/resources/plans/types/CountPlansRequestPlanType.java index ed0b348..d3f97fa 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/CountPlansRequestPlanType.java +++ b/src/main/java/com/schematic/api/resources/plans/types/CountPlansRequestPlanType.java @@ -3,22 +3,82 @@ */ package com.schematic.api.resources.plans.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountPlansRequestPlanType { - PLAN("plan"), +public final class CountPlansRequestPlanType { + public static final CountPlansRequestPlanType PLAN = new CountPlansRequestPlanType(Value.PLAN, "plan"); - ADD_ON("add_on"); + public static final CountPlansRequestPlanType ADD_ON = new CountPlansRequestPlanType(Value.ADD_ON, "add_on"); - private final String value; + private final Value value; - CountPlansRequestPlanType(String value) { + private final String string; + + CountPlansRequestPlanType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountPlansRequestPlanType + && this.string.equals(((CountPlansRequestPlanType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAN: + return visitor.visitPlan(); + case ADD_ON: + return visitor.visitAddOn(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountPlansRequestPlanType valueOf(String value) { + switch (value) { + case "plan": + return PLAN; + case "add_on": + return ADD_ON; + default: + return new CountPlansRequestPlanType(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN, + + ADD_ON, + + UNKNOWN + } + + public interface Visitor { + T visitPlan(); + + T visitAddOn(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponse.java b/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponse.java index 743a1cf..ba47ef9 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponse.java @@ -81,6 +81,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountPlansParams params); } @@ -114,6 +117,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponseParamsPlanType.java b/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponseParamsPlanType.java index 40a44c7..a5b4212 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponseParamsPlanType.java +++ b/src/main/java/com/schematic/api/resources/plans/types/CountPlansResponseParamsPlanType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.plans.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CountPlansResponseParamsPlanType { - PLAN("plan"), +public final class CountPlansResponseParamsPlanType { + public static final CountPlansResponseParamsPlanType PLAN = + new CountPlansResponseParamsPlanType(Value.PLAN, "plan"); - ADD_ON("add_on"); + public static final CountPlansResponseParamsPlanType ADD_ON = + new CountPlansResponseParamsPlanType(Value.ADD_ON, "add_on"); - private final String value; + private final Value value; - CountPlansResponseParamsPlanType(String value) { + private final String string; + + CountPlansResponseParamsPlanType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CountPlansResponseParamsPlanType + && this.string.equals(((CountPlansResponseParamsPlanType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAN: + return visitor.visitPlan(); + case ADD_ON: + return visitor.visitAddOn(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CountPlansResponseParamsPlanType valueOf(String value) { + switch (value) { + case "plan": + return PLAN; + case "add_on": + return ADD_ON; + default: + return new CountPlansResponseParamsPlanType(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN, + + ADD_ON, + + UNKNOWN + } + + public interface Visitor { + T visitPlan(); + + T visitAddOn(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/plans/types/CreatePlanRequestBodyPlanType.java b/src/main/java/com/schematic/api/resources/plans/types/CreatePlanRequestBodyPlanType.java index 447c3e0..3381e61 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/CreatePlanRequestBodyPlanType.java +++ b/src/main/java/com/schematic/api/resources/plans/types/CreatePlanRequestBodyPlanType.java @@ -3,22 +3,83 @@ */ package com.schematic.api.resources.plans.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreatePlanRequestBodyPlanType { - PLAN("plan"), +public final class CreatePlanRequestBodyPlanType { + public static final CreatePlanRequestBodyPlanType PLAN = new CreatePlanRequestBodyPlanType(Value.PLAN, "plan"); - ADD_ON("add_on"); + public static final CreatePlanRequestBodyPlanType ADD_ON = + new CreatePlanRequestBodyPlanType(Value.ADD_ON, "add_on"); - private final String value; + private final Value value; - CreatePlanRequestBodyPlanType(String value) { + private final String string; + + CreatePlanRequestBodyPlanType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreatePlanRequestBodyPlanType + && this.string.equals(((CreatePlanRequestBodyPlanType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAN: + return visitor.visitPlan(); + case ADD_ON: + return visitor.visitAddOn(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreatePlanRequestBodyPlanType valueOf(String value) { + switch (value) { + case "plan": + return PLAN; + case "add_on": + return ADD_ON; + default: + return new CreatePlanRequestBodyPlanType(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN, + + ADD_ON, + + UNKNOWN + } + + public interface Visitor { + T visitPlan(); + + T visitAddOn(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/plans/types/CreatePlanResponse.java b/src/main/java/com/schematic/api/resources/plans/types/CreatePlanResponse.java index 766558c..d3041cc 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/CreatePlanResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/CreatePlanResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreatePlanResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/DeletePlanResponse.java b/src/main/java/com/schematic/api/resources/plans/types/DeletePlanResponse.java index 0a82d99..1e736ad 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/DeletePlanResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/DeletePlanResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeletePlanResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/GetPlanResponse.java b/src/main/java/com/schematic/api/resources/plans/types/GetPlanResponse.java index 080f857..9e61a73 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/GetPlanResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/GetPlanResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetPlanResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesParams.java b/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesParams.java new file mode 100644 index 0000000..ab6dde5 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesParams.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plans.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanIssuesParams.Builder.class) +public final class ListPlanIssuesParams { + private final Optional planId; + + private final Map additionalProperties; + + private ListPlanIssuesParams(Optional planId, Map additionalProperties) { + this.planId = planId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanIssuesParams && equalTo((ListPlanIssuesParams) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanIssuesParams other) { + return planId.equals(other.planId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.planId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional planId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListPlanIssuesParams other) { + planId(other.getPlanId()); + return this; + } + + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public Builder planId(Optional planId) { + this.planId = planId; + return this; + } + + public Builder planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + public ListPlanIssuesParams build() { + return new ListPlanIssuesParams(planId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesResponse.java b/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesResponse.java new file mode 100644 index 0000000..f162749 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plans/types/ListPlanIssuesResponse.java @@ -0,0 +1,159 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plans.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.types.PlanIssueResponseData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListPlanIssuesResponse.Builder.class) +public final class ListPlanIssuesResponse { + private final List data; + + private final ListPlanIssuesParams params; + + private final Map additionalProperties; + + private ListPlanIssuesResponse( + List data, ListPlanIssuesParams params, Map additionalProperties) { + this.data = data; + this.params = params; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("data") + public List getData() { + return data; + } + + /** + * @return Input parameters + */ + @JsonProperty("params") + public ListPlanIssuesParams getParams() { + return params; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListPlanIssuesResponse && equalTo((ListPlanIssuesResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListPlanIssuesResponse other) { + return data.equals(other.data) && params.equals(other.params); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.data, this.params); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ParamsStage builder() { + return new Builder(); + } + + public interface ParamsStage { + /** + *

Input parameters

+ */ + _FinalStage params(@NotNull ListPlanIssuesParams params); + + Builder from(ListPlanIssuesResponse other); + } + + public interface _FinalStage { + ListPlanIssuesResponse build(); + + _FinalStage data(List data); + + _FinalStage addData(PlanIssueResponseData data); + + _FinalStage addAllData(List data); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ParamsStage, _FinalStage { + private ListPlanIssuesParams params; + + private List data = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListPlanIssuesResponse other) { + data(other.getData()); + params(other.getParams()); + return this; + } + + /** + *

Input parameters

+ *

Input parameters

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("params") + public _FinalStage params(@NotNull ListPlanIssuesParams params) { + this.params = Objects.requireNonNull(params, "params must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllData(List data) { + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public _FinalStage addData(PlanIssueResponseData data) { + this.data.add(data); + return this; + } + + @java.lang.Override + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public _FinalStage data(List data) { + this.data.clear(); + if (data != null) { + this.data.addAll(data); + } + return this; + } + + @java.lang.Override + public ListPlanIssuesResponse build() { + return new ListPlanIssuesResponse(data, params, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListPlansParams.java b/src/main/java/com/schematic/api/resources/plans/types/ListPlansParams.java index c1c57ab..37a3c82 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/ListPlansParams.java +++ b/src/main/java/com/schematic/api/resources/plans/types/ListPlansParams.java @@ -23,6 +23,12 @@ public final class ListPlansParams { private final Optional companyId; + private final Optional forFallbackPlan; + + private final Optional forInitialPlan; + + private final Optional forTrialExpiryPlan; + private final Optional hasProductId; private final Optional> ids; @@ -35,6 +41,8 @@ public final class ListPlansParams { private final Optional q; + private final Optional requiresPaymentMethod; + private final Optional withoutEntitlementFor; private final Optional withoutPaidProductId; @@ -45,23 +53,31 @@ public final class ListPlansParams { private ListPlansParams( Optional companyId, + Optional forFallbackPlan, + Optional forInitialPlan, + Optional forTrialExpiryPlan, Optional hasProductId, Optional> ids, Optional limit, Optional offset, Optional planType, Optional q, + Optional requiresPaymentMethod, Optional withoutEntitlementFor, Optional withoutPaidProductId, Optional withoutProductId, Map additionalProperties) { this.companyId = companyId; + this.forFallbackPlan = forFallbackPlan; + this.forInitialPlan = forInitialPlan; + this.forTrialExpiryPlan = forTrialExpiryPlan; this.hasProductId = hasProductId; this.ids = ids; this.limit = limit; this.offset = offset; this.planType = planType; this.q = q; + this.requiresPaymentMethod = requiresPaymentMethod; this.withoutEntitlementFor = withoutEntitlementFor; this.withoutPaidProductId = withoutPaidProductId; this.withoutProductId = withoutProductId; @@ -73,6 +89,30 @@ public Optional getCompanyId() { return companyId; } + /** + * @return Filter for plans valid as fallback plans (not linked to billing) + */ + @JsonProperty("for_fallback_plan") + public Optional getForFallbackPlan() { + return forFallbackPlan; + } + + /** + * @return Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial) + */ + @JsonProperty("for_initial_plan") + public Optional getForInitialPlan() { + return forInitialPlan; + } + + /** + * @return Filter for plans valid as trial expiry plans (not linked to billing or free) + */ + @JsonProperty("for_trial_expiry_plan") + public Optional getForTrialExpiryPlan() { + return forTrialExpiryPlan; + } + /** * @return Filter out plans that do not have a billing product ID */ @@ -115,6 +155,14 @@ public Optional getQ() { return q; } + /** + * @return Filter for plans that require a payment method (inverse of ForInitialPlan) + */ + @JsonProperty("requires_payment_method") + public Optional getRequiresPaymentMethod() { + return requiresPaymentMethod; + } + /** * @return Filter out plans that already have a plan entitlement for the specified feature ID */ @@ -152,12 +200,16 @@ public Map getAdditionalProperties() { private boolean equalTo(ListPlansParams other) { return companyId.equals(other.companyId) + && forFallbackPlan.equals(other.forFallbackPlan) + && forInitialPlan.equals(other.forInitialPlan) + && forTrialExpiryPlan.equals(other.forTrialExpiryPlan) && hasProductId.equals(other.hasProductId) && ids.equals(other.ids) && limit.equals(other.limit) && offset.equals(other.offset) && planType.equals(other.planType) && q.equals(other.q) + && requiresPaymentMethod.equals(other.requiresPaymentMethod) && withoutEntitlementFor.equals(other.withoutEntitlementFor) && withoutPaidProductId.equals(other.withoutPaidProductId) && withoutProductId.equals(other.withoutProductId); @@ -167,12 +219,16 @@ private boolean equalTo(ListPlansParams other) { public int hashCode() { return Objects.hash( this.companyId, + this.forFallbackPlan, + this.forInitialPlan, + this.forTrialExpiryPlan, this.hasProductId, this.ids, this.limit, this.offset, this.planType, this.q, + this.requiresPaymentMethod, this.withoutEntitlementFor, this.withoutPaidProductId, this.withoutProductId); @@ -191,6 +247,12 @@ public static Builder builder() { public static final class Builder { private Optional companyId = Optional.empty(); + private Optional forFallbackPlan = Optional.empty(); + + private Optional forInitialPlan = Optional.empty(); + + private Optional forTrialExpiryPlan = Optional.empty(); + private Optional hasProductId = Optional.empty(); private Optional> ids = Optional.empty(); @@ -203,6 +265,8 @@ public static final class Builder { private Optional q = Optional.empty(); + private Optional requiresPaymentMethod = Optional.empty(); + private Optional withoutEntitlementFor = Optional.empty(); private Optional withoutPaidProductId = Optional.empty(); @@ -216,12 +280,16 @@ private Builder() {} public Builder from(ListPlansParams other) { companyId(other.getCompanyId()); + forFallbackPlan(other.getForFallbackPlan()); + forInitialPlan(other.getForInitialPlan()); + forTrialExpiryPlan(other.getForTrialExpiryPlan()); hasProductId(other.getHasProductId()); ids(other.getIds()); limit(other.getLimit()); offset(other.getOffset()); planType(other.getPlanType()); q(other.getQ()); + requiresPaymentMethod(other.getRequiresPaymentMethod()); withoutEntitlementFor(other.getWithoutEntitlementFor()); withoutPaidProductId(other.getWithoutPaidProductId()); withoutProductId(other.getWithoutProductId()); @@ -239,6 +307,51 @@ public Builder companyId(String companyId) { return this; } + /** + *

Filter for plans valid as fallback plans (not linked to billing)

+ */ + @JsonSetter(value = "for_fallback_plan", nulls = Nulls.SKIP) + public Builder forFallbackPlan(Optional forFallbackPlan) { + this.forFallbackPlan = forFallbackPlan; + return this; + } + + public Builder forFallbackPlan(Boolean forFallbackPlan) { + this.forFallbackPlan = Optional.ofNullable(forFallbackPlan); + return this; + } + + /** + *

Filter for plans valid as initial plans (not linked to billing, free, or auto-cancelling trial)

+ */ + @JsonSetter(value = "for_initial_plan", nulls = Nulls.SKIP) + public Builder forInitialPlan(Optional forInitialPlan) { + this.forInitialPlan = forInitialPlan; + return this; + } + + public Builder forInitialPlan(Boolean forInitialPlan) { + this.forInitialPlan = Optional.ofNullable(forInitialPlan); + return this; + } + + /** + *

Filter for plans valid as trial expiry plans (not linked to billing or free)

+ */ + @JsonSetter(value = "for_trial_expiry_plan", nulls = Nulls.SKIP) + public Builder forTrialExpiryPlan(Optional forTrialExpiryPlan) { + this.forTrialExpiryPlan = forTrialExpiryPlan; + return this; + } + + public Builder forTrialExpiryPlan(Boolean forTrialExpiryPlan) { + this.forTrialExpiryPlan = Optional.ofNullable(forTrialExpiryPlan); + return this; + } + + /** + *

Filter out plans that do not have a billing product ID

+ */ @JsonSetter(value = "has_product_id", nulls = Nulls.SKIP) public Builder hasProductId(Optional hasProductId) { this.hasProductId = hasProductId; @@ -261,6 +374,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -272,6 +388,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; @@ -283,6 +402,9 @@ public Builder offset(Integer offset) { return this; } + /** + *

Filter by plan type

+ */ @JsonSetter(value = "plan_type", nulls = Nulls.SKIP) public Builder planType(Optional planType) { this.planType = planType; @@ -305,6 +427,23 @@ public Builder q(String q) { return this; } + /** + *

Filter for plans that require a payment method (inverse of ForInitialPlan)

+ */ + @JsonSetter(value = "requires_payment_method", nulls = Nulls.SKIP) + public Builder requiresPaymentMethod(Optional requiresPaymentMethod) { + this.requiresPaymentMethod = requiresPaymentMethod; + return this; + } + + public Builder requiresPaymentMethod(Boolean requiresPaymentMethod) { + this.requiresPaymentMethod = Optional.ofNullable(requiresPaymentMethod); + return this; + } + + /** + *

Filter out plans that already have a plan entitlement for the specified feature ID

+ */ @JsonSetter(value = "without_entitlement_for", nulls = Nulls.SKIP) public Builder withoutEntitlementFor(Optional withoutEntitlementFor) { this.withoutEntitlementFor = withoutEntitlementFor; @@ -316,6 +455,9 @@ public Builder withoutEntitlementFor(String withoutEntitlementFor) { return this; } + /** + *

Filter out plans that have a paid billing product ID

+ */ @JsonSetter(value = "without_paid_product_id", nulls = Nulls.SKIP) public Builder withoutPaidProductId(Optional withoutPaidProductId) { this.withoutPaidProductId = withoutPaidProductId; @@ -327,6 +469,9 @@ public Builder withoutPaidProductId(Boolean withoutPaidProductId) { return this; } + /** + *

Filter out plans that have a billing product ID

+ */ @JsonSetter(value = "without_product_id", nulls = Nulls.SKIP) public Builder withoutProductId(Optional withoutProductId) { this.withoutProductId = withoutProductId; @@ -341,12 +486,16 @@ public Builder withoutProductId(Boolean withoutProductId) { public ListPlansParams build() { return new ListPlansParams( companyId, + forFallbackPlan, + forInitialPlan, + forTrialExpiryPlan, hasProductId, ids, limit, offset, planType, q, + requiresPaymentMethod, withoutEntitlementFor, withoutPaidProductId, withoutProductId, diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListPlansRequestPlanType.java b/src/main/java/com/schematic/api/resources/plans/types/ListPlansRequestPlanType.java index a371dbe..b34f28c 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/ListPlansRequestPlanType.java +++ b/src/main/java/com/schematic/api/resources/plans/types/ListPlansRequestPlanType.java @@ -3,22 +3,82 @@ */ package com.schematic.api.resources.plans.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListPlansRequestPlanType { - PLAN("plan"), +public final class ListPlansRequestPlanType { + public static final ListPlansRequestPlanType PLAN = new ListPlansRequestPlanType(Value.PLAN, "plan"); - ADD_ON("add_on"); + public static final ListPlansRequestPlanType ADD_ON = new ListPlansRequestPlanType(Value.ADD_ON, "add_on"); - private final String value; + private final Value value; - ListPlansRequestPlanType(String value) { + private final String string; + + ListPlansRequestPlanType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListPlansRequestPlanType + && this.string.equals(((ListPlansRequestPlanType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAN: + return visitor.visitPlan(); + case ADD_ON: + return visitor.visitAddOn(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListPlansRequestPlanType valueOf(String value) { + switch (value) { + case "plan": + return PLAN; + case "add_on": + return ADD_ON; + default: + return new ListPlansRequestPlanType(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN, + + ADD_ON, + + UNKNOWN + } + + public interface Visitor { + T visitPlan(); + + T visitAddOn(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponse.java b/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponse.java index 7b0ea90..9e7d30b 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponse.java @@ -36,9 +36,6 @@ private ListPlansResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListPlansParams params); Builder from(ListPlansResponse other); @@ -116,6 +116,7 @@ public Builder from(ListPlansResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListPlansParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(PlanDetailResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(PlanDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponseParamsPlanType.java b/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponseParamsPlanType.java index 8509fae..04b4065 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponseParamsPlanType.java +++ b/src/main/java/com/schematic/api/resources/plans/types/ListPlansResponseParamsPlanType.java @@ -3,22 +3,83 @@ */ package com.schematic.api.resources.plans.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ListPlansResponseParamsPlanType { - PLAN("plan"), +public final class ListPlansResponseParamsPlanType { + public static final ListPlansResponseParamsPlanType PLAN = new ListPlansResponseParamsPlanType(Value.PLAN, "plan"); - ADD_ON("add_on"); + public static final ListPlansResponseParamsPlanType ADD_ON = + new ListPlansResponseParamsPlanType(Value.ADD_ON, "add_on"); - private final String value; + private final Value value; - ListPlansResponseParamsPlanType(String value) { + private final String string; + + ListPlansResponseParamsPlanType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListPlansResponseParamsPlanType + && this.string.equals(((ListPlansResponseParamsPlanType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAN: + return visitor.visitPlan(); + case ADD_ON: + return visitor.visitAddOn(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListPlansResponseParamsPlanType valueOf(String value) { + switch (value) { + case "plan": + return PLAN; + case "add_on": + return ADD_ON; + default: + return new ListPlansResponseParamsPlanType(Value.UNKNOWN, value); + } + } + + public enum Value { + PLAN, + + ADD_ON, + + UNKNOWN + } + + public interface Visitor { + T visitPlan(); + + T visitAddOn(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/plans/types/UpdateCompanyPlansResponse.java b/src/main/java/com/schematic/api/resources/plans/types/UpdateCompanyPlansResponse.java index f03027e..8f99476 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/UpdateCompanyPlansResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/UpdateCompanyPlansResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateCompanyPlansResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/UpdatePlanResponse.java b/src/main/java/com/schematic/api/resources/plans/types/UpdatePlanResponse.java index 3b73e34..5fbdb3a 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/UpdatePlanResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/UpdatePlanResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdatePlanResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/UpsertBillingProductPlanResponse.java b/src/main/java/com/schematic/api/resources/plans/types/UpsertBillingProductPlanResponse.java index 75c65a5..deb0112 100644 --- a/src/main/java/com/schematic/api/resources/plans/types/UpsertBillingProductPlanResponse.java +++ b/src/main/java/com/schematic/api/resources/plans/types/UpsertBillingProductPlanResponse.java @@ -89,6 +89,9 @@ public interface DataStage { public interface _FinalStage { UpsertBillingProductPlanResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -137,15 +140,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/plans/types/UpsertBillingProductRequestBodyChargeType.java b/src/main/java/com/schematic/api/resources/plans/types/UpsertBillingProductRequestBodyChargeType.java new file mode 100644 index 0000000..6c96d66 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/plans/types/UpsertBillingProductRequestBodyChargeType.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.plans.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UpsertBillingProductRequestBodyChargeType { + public static final UpsertBillingProductRequestBodyChargeType RECURRING = + new UpsertBillingProductRequestBodyChargeType(Value.RECURRING, "recurring"); + + public static final UpsertBillingProductRequestBodyChargeType ONE_TIME = + new UpsertBillingProductRequestBodyChargeType(Value.ONE_TIME, "one_time"); + + public static final UpsertBillingProductRequestBodyChargeType FREE = + new UpsertBillingProductRequestBodyChargeType(Value.FREE, "free"); + + private final Value value; + + private final String string; + + UpsertBillingProductRequestBodyChargeType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpsertBillingProductRequestBodyChargeType + && this.string.equals(((UpsertBillingProductRequestBodyChargeType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case RECURRING: + return visitor.visitRecurring(); + case ONE_TIME: + return visitor.visitOneTime(); + case FREE: + return visitor.visitFree(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpsertBillingProductRequestBodyChargeType valueOf(String value) { + switch (value) { + case "recurring": + return RECURRING; + case "one_time": + return ONE_TIME; + case "free": + return FREE; + default: + return new UpsertBillingProductRequestBodyChargeType(Value.UNKNOWN, value); + } + } + + public enum Value { + ONE_TIME, + + RECURRING, + + FREE, + + UNKNOWN + } + + public interface Visitor { + T visitOneTime(); + + T visitRecurring(); + + T visitFree(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java new file mode 100644 index 0000000..0dff711 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/webhooks/AsyncRawWebhooksClient.java @@ -0,0 +1,887 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.webhooks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.webhooks.requests.CountWebhookEventsRequest; +import com.schematic.api.resources.webhooks.requests.CountWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; +import com.schematic.api.resources.webhooks.requests.ListWebhookEventsRequest; +import com.schematic.api.resources.webhooks.requests.ListWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.UpdateWebhookRequestBody; +import com.schematic.api.resources.webhooks.types.CountWebhookEventsResponse; +import com.schematic.api.resources.webhooks.types.CountWebhooksResponse; +import com.schematic.api.resources.webhooks.types.CreateWebhookResponse; +import com.schematic.api.resources.webhooks.types.DeleteWebhookResponse; +import com.schematic.api.resources.webhooks.types.GetWebhookEventResponse; +import com.schematic.api.resources.webhooks.types.GetWebhookResponse; +import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; +import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; +import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawWebhooksClient { + protected final ClientOptions clientOptions; + + public AsyncRawWebhooksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> listWebhookEvents() { + return listWebhookEvents(ListWebhookEventsRequest.builder().build()); + } + + public CompletableFuture> listWebhookEvents( + ListWebhookEventsRequest request) { + return listWebhookEvents(request, null); + } + + public CompletableFuture> listWebhookEvents( + ListWebhookEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhook-events"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWebhookId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "webhook_id", request.getWebhookId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ListWebhookEventsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getWebhookEvent( + String webhookEventId) { + return getWebhookEvent(webhookEventId, null); + } + + public CompletableFuture> getWebhookEvent( + String webhookEventId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhook-events") + .addPathSegment(webhookEventId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetWebhookEventResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countWebhookEvents() { + return countWebhookEvents(CountWebhookEventsRequest.builder().build()); + } + + public CompletableFuture> countWebhookEvents( + CountWebhookEventsRequest request) { + return countWebhookEvents(request, null); + } + + public CompletableFuture> countWebhookEvents( + CountWebhookEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhook-events/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWebhookId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "webhook_id", request.getWebhookId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CountWebhookEventsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> listWebhooks() { + return listWebhooks(ListWebhooksRequest.builder().build()); + } + + public CompletableFuture> listWebhooks( + ListWebhooksRequest request) { + return listWebhooks(request, null); + } + + public CompletableFuture> listWebhooks( + ListWebhooksRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListWebhooksResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> createWebhook( + CreateWebhookRequestBody request) { + return createWebhook(request, null); + } + + public CompletableFuture> createWebhook( + CreateWebhookRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateWebhookResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getWebhook(String webhookId) { + return getWebhook(webhookId, null); + } + + public CompletableFuture> getWebhook( + String webhookId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .addPathSegment(webhookId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetWebhookResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateWebhook(String webhookId) { + return updateWebhook(webhookId, UpdateWebhookRequestBody.builder().build()); + } + + public CompletableFuture> updateWebhook( + String webhookId, UpdateWebhookRequestBody request) { + return updateWebhook(webhookId, request, null); + } + + public CompletableFuture> updateWebhook( + String webhookId, UpdateWebhookRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .addPathSegment(webhookId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateWebhookResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> deleteWebhook(String webhookId) { + return deleteWebhook(webhookId, null); + } + + public CompletableFuture> deleteWebhook( + String webhookId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .addPathSegment(webhookId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteWebhookResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> countWebhooks() { + return countWebhooks(CountWebhooksRequest.builder().build()); + } + + public CompletableFuture> countWebhooks( + CountWebhooksRequest request) { + return countWebhooks(request, null); + } + + public CompletableFuture> countWebhooks( + CountWebhooksRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountWebhooksResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new BaseSchematicException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/schematic/api/resources/webhooks/AsyncWebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/AsyncWebhooksClient.java new file mode 100644 index 0000000..e6769e2 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/webhooks/AsyncWebhooksClient.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.webhooks; + +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.resources.webhooks.requests.CountWebhookEventsRequest; +import com.schematic.api.resources.webhooks.requests.CountWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; +import com.schematic.api.resources.webhooks.requests.ListWebhookEventsRequest; +import com.schematic.api.resources.webhooks.requests.ListWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.UpdateWebhookRequestBody; +import com.schematic.api.resources.webhooks.types.CountWebhookEventsResponse; +import com.schematic.api.resources.webhooks.types.CountWebhooksResponse; +import com.schematic.api.resources.webhooks.types.CreateWebhookResponse; +import com.schematic.api.resources.webhooks.types.DeleteWebhookResponse; +import com.schematic.api.resources.webhooks.types.GetWebhookEventResponse; +import com.schematic.api.resources.webhooks.types.GetWebhookResponse; +import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; +import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; +import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncWebhooksClient { + protected final ClientOptions clientOptions; + + private final AsyncRawWebhooksClient rawClient; + + public AsyncWebhooksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawWebhooksClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawWebhooksClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture listWebhookEvents() { + return this.rawClient.listWebhookEvents().thenApply(response -> response.body()); + } + + public CompletableFuture listWebhookEvents(ListWebhookEventsRequest request) { + return this.rawClient.listWebhookEvents(request).thenApply(response -> response.body()); + } + + public CompletableFuture listWebhookEvents( + ListWebhookEventsRequest request, RequestOptions requestOptions) { + return this.rawClient.listWebhookEvents(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getWebhookEvent(String webhookEventId) { + return this.rawClient.getWebhookEvent(webhookEventId).thenApply(response -> response.body()); + } + + public CompletableFuture getWebhookEvent( + String webhookEventId, RequestOptions requestOptions) { + return this.rawClient.getWebhookEvent(webhookEventId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countWebhookEvents() { + return this.rawClient.countWebhookEvents().thenApply(response -> response.body()); + } + + public CompletableFuture countWebhookEvents(CountWebhookEventsRequest request) { + return this.rawClient.countWebhookEvents(request).thenApply(response -> response.body()); + } + + public CompletableFuture countWebhookEvents( + CountWebhookEventsRequest request, RequestOptions requestOptions) { + return this.rawClient.countWebhookEvents(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture listWebhooks() { + return this.rawClient.listWebhooks().thenApply(response -> response.body()); + } + + public CompletableFuture listWebhooks(ListWebhooksRequest request) { + return this.rawClient.listWebhooks(request).thenApply(response -> response.body()); + } + + public CompletableFuture listWebhooks( + ListWebhooksRequest request, RequestOptions requestOptions) { + return this.rawClient.listWebhooks(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture createWebhook(CreateWebhookRequestBody request) { + return this.rawClient.createWebhook(request).thenApply(response -> response.body()); + } + + public CompletableFuture createWebhook( + CreateWebhookRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createWebhook(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getWebhook(String webhookId) { + return this.rawClient.getWebhook(webhookId).thenApply(response -> response.body()); + } + + public CompletableFuture getWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.getWebhook(webhookId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateWebhook(String webhookId) { + return this.rawClient.updateWebhook(webhookId).thenApply(response -> response.body()); + } + + public CompletableFuture updateWebhook(String webhookId, UpdateWebhookRequestBody request) { + return this.rawClient.updateWebhook(webhookId, request).thenApply(response -> response.body()); + } + + public CompletableFuture updateWebhook( + String webhookId, UpdateWebhookRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateWebhook(webhookId, request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture deleteWebhook(String webhookId) { + return this.rawClient.deleteWebhook(webhookId).thenApply(response -> response.body()); + } + + public CompletableFuture deleteWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.deleteWebhook(webhookId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture countWebhooks() { + return this.rawClient.countWebhooks().thenApply(response -> response.body()); + } + + public CompletableFuture countWebhooks(CountWebhooksRequest request) { + return this.rawClient.countWebhooks(request).thenApply(response -> response.body()); + } + + public CompletableFuture countWebhooks( + CountWebhooksRequest request, RequestOptions requestOptions) { + return this.rawClient.countWebhooks(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java new file mode 100644 index 0000000..ce52b98 --- /dev/null +++ b/src/main/java/com/schematic/api/resources/webhooks/RawWebhooksClient.java @@ -0,0 +1,669 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.resources.webhooks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.schematic.api.core.BaseSchematicApiException; +import com.schematic.api.core.BaseSchematicException; +import com.schematic.api.core.BaseSchematicHttpResponse; +import com.schematic.api.core.ClientOptions; +import com.schematic.api.core.MediaTypes; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.QueryStringMapper; +import com.schematic.api.core.RequestOptions; +import com.schematic.api.errors.BadRequestError; +import com.schematic.api.errors.ForbiddenError; +import com.schematic.api.errors.InternalServerError; +import com.schematic.api.errors.NotFoundError; +import com.schematic.api.errors.UnauthorizedError; +import com.schematic.api.resources.webhooks.requests.CountWebhookEventsRequest; +import com.schematic.api.resources.webhooks.requests.CountWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; +import com.schematic.api.resources.webhooks.requests.ListWebhookEventsRequest; +import com.schematic.api.resources.webhooks.requests.ListWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.UpdateWebhookRequestBody; +import com.schematic.api.resources.webhooks.types.CountWebhookEventsResponse; +import com.schematic.api.resources.webhooks.types.CountWebhooksResponse; +import com.schematic.api.resources.webhooks.types.CreateWebhookResponse; +import com.schematic.api.resources.webhooks.types.DeleteWebhookResponse; +import com.schematic.api.resources.webhooks.types.GetWebhookEventResponse; +import com.schematic.api.resources.webhooks.types.GetWebhookResponse; +import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; +import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; +import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; +import com.schematic.api.types.ApiError; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawWebhooksClient { + protected final ClientOptions clientOptions; + + public RawWebhooksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public BaseSchematicHttpResponse listWebhookEvents() { + return listWebhookEvents(ListWebhookEventsRequest.builder().build()); + } + + public BaseSchematicHttpResponse listWebhookEvents(ListWebhookEventsRequest request) { + return listWebhookEvents(request, null); + } + + public BaseSchematicHttpResponse listWebhookEvents( + ListWebhookEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhook-events"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWebhookId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "webhook_id", request.getWebhookId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListWebhookEventsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getWebhookEvent(String webhookEventId) { + return getWebhookEvent(webhookEventId, null); + } + + public BaseSchematicHttpResponse getWebhookEvent( + String webhookEventId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhook-events") + .addPathSegment(webhookEventId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetWebhookEventResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countWebhookEvents() { + return countWebhookEvents(CountWebhookEventsRequest.builder().build()); + } + + public BaseSchematicHttpResponse countWebhookEvents(CountWebhookEventsRequest request) { + return countWebhookEvents(request, null); + } + + public BaseSchematicHttpResponse countWebhookEvents( + CountWebhookEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhook-events/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getWebhookId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "webhook_id", request.getWebhookId().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), true); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountWebhookEventsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse listWebhooks() { + return listWebhooks(ListWebhooksRequest.builder().build()); + } + + public BaseSchematicHttpResponse listWebhooks(ListWebhooksRequest request) { + return listWebhooks(request, null); + } + + public BaseSchematicHttpResponse listWebhooks( + ListWebhooksRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListWebhooksResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse createWebhook(CreateWebhookRequestBody request) { + return createWebhook(request, null); + } + + public BaseSchematicHttpResponse createWebhook( + CreateWebhookRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateWebhookResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse getWebhook(String webhookId) { + return getWebhook(webhookId, null); + } + + public BaseSchematicHttpResponse getWebhook(String webhookId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .addPathSegment(webhookId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetWebhookResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse updateWebhook(String webhookId) { + return updateWebhook(webhookId, UpdateWebhookRequestBody.builder().build()); + } + + public BaseSchematicHttpResponse updateWebhook( + String webhookId, UpdateWebhookRequestBody request) { + return updateWebhook(webhookId, request, null); + } + + public BaseSchematicHttpResponse updateWebhook( + String webhookId, UpdateWebhookRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .addPathSegment(webhookId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new BaseSchematicException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateWebhookResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse deleteWebhook(String webhookId) { + return deleteWebhook(webhookId, null); + } + + public BaseSchematicHttpResponse deleteWebhook( + String webhookId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks") + .addPathSegment(webhookId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteWebhookResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } + + public BaseSchematicHttpResponse countWebhooks() { + return countWebhooks(CountWebhooksRequest.builder().build()); + } + + public BaseSchematicHttpResponse countWebhooks(CountWebhooksRequest request) { + return countWebhooks(request, null); + } + + public BaseSchematicHttpResponse countWebhooks( + CountWebhooksRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("webhooks/count"); + if (request.getQ().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ().get(), false); + } + if (request.getLimit().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "limit", request.getLimit().get(), false); + } + if (request.getOffset().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offset", request.getOffset().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new BaseSchematicHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountWebhooksResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new BaseSchematicApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new BaseSchematicException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/schematic/api/resources/webhooks/WebhooksClient.java b/src/main/java/com/schematic/api/resources/webhooks/WebhooksClient.java index 093a786..c0b692e 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/WebhooksClient.java +++ b/src/main/java/com/schematic/api/resources/webhooks/WebhooksClient.java @@ -3,18 +3,8 @@ */ package com.schematic.api.resources.webhooks; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.schematic.api.core.BaseSchematicApiException; -import com.schematic.api.core.BaseSchematicException; import com.schematic.api.core.ClientOptions; -import com.schematic.api.core.MediaTypes; -import com.schematic.api.core.ObjectMappers; import com.schematic.api.core.RequestOptions; -import com.schematic.api.errors.BadRequestError; -import com.schematic.api.errors.ForbiddenError; -import com.schematic.api.errors.InternalServerError; -import com.schematic.api.errors.NotFoundError; -import com.schematic.api.errors.UnauthorizedError; import com.schematic.api.resources.webhooks.requests.CountWebhookEventsRequest; import com.schematic.api.resources.webhooks.requests.CountWebhooksRequest; import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; @@ -30,585 +20,116 @@ import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; -import com.schematic.api.types.ApiError; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class WebhooksClient { protected final ClientOptions clientOptions; + private final RawWebhooksClient rawClient; + public WebhooksClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawWebhooksClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawWebhooksClient withRawResponse() { + return this.rawClient; } public ListWebhookEventsResponse listWebhookEvents() { - return listWebhookEvents(ListWebhookEventsRequest.builder().build()); + return this.rawClient.listWebhookEvents().body(); } public ListWebhookEventsResponse listWebhookEvents(ListWebhookEventsRequest request) { - return listWebhookEvents(request, null); + return this.rawClient.listWebhookEvents(request).body(); } public ListWebhookEventsResponse listWebhookEvents( ListWebhookEventsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhook-events"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getWebhookId().isPresent()) { - httpUrl.addQueryParameter("webhook_id", request.getWebhookId().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListWebhookEventsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listWebhookEvents(request, requestOptions).body(); } public GetWebhookEventResponse getWebhookEvent(String webhookEventId) { - return getWebhookEvent(webhookEventId, null); + return this.rawClient.getWebhookEvent(webhookEventId).body(); } public GetWebhookEventResponse getWebhookEvent(String webhookEventId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhook-events") - .addPathSegment(webhookEventId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetWebhookEventResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getWebhookEvent(webhookEventId, requestOptions).body(); } public CountWebhookEventsResponse countWebhookEvents() { - return countWebhookEvents(CountWebhookEventsRequest.builder().build()); + return this.rawClient.countWebhookEvents().body(); } public CountWebhookEventsResponse countWebhookEvents(CountWebhookEventsRequest request) { - return countWebhookEvents(request, null); + return this.rawClient.countWebhookEvents(request).body(); } public CountWebhookEventsResponse countWebhookEvents( CountWebhookEventsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhook-events/count"); - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getWebhookId().isPresent()) { - httpUrl.addQueryParameter("webhook_id", request.getWebhookId().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountWebhookEventsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.countWebhookEvents(request, requestOptions).body(); } public ListWebhooksResponse listWebhooks() { - return listWebhooks(ListWebhooksRequest.builder().build()); + return this.rawClient.listWebhooks().body(); } public ListWebhooksResponse listWebhooks(ListWebhooksRequest request) { - return listWebhooks(request, null); + return this.rawClient.listWebhooks(request).body(); } public ListWebhooksResponse listWebhooks(ListWebhooksRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhooks"); - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListWebhooksResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.listWebhooks(request, requestOptions).body(); } public CreateWebhookResponse createWebhook(CreateWebhookRequestBody request) { - return createWebhook(request, null); + return this.rawClient.createWebhook(request).body(); } public CreateWebhookResponse createWebhook(CreateWebhookRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhooks") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateWebhookResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.createWebhook(request, requestOptions).body(); } public GetWebhookResponse getWebhook(String webhookId) { - return getWebhook(webhookId, null); + return this.rawClient.getWebhook(webhookId).body(); } public GetWebhookResponse getWebhook(String webhookId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhooks") - .addPathSegment(webhookId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetWebhookResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.getWebhook(webhookId, requestOptions).body(); } public UpdateWebhookResponse updateWebhook(String webhookId) { - return updateWebhook(webhookId, UpdateWebhookRequestBody.builder().build()); + return this.rawClient.updateWebhook(webhookId).body(); } public UpdateWebhookResponse updateWebhook(String webhookId, UpdateWebhookRequestBody request) { - return updateWebhook(webhookId, request, null); + return this.rawClient.updateWebhook(webhookId, request).body(); } public UpdateWebhookResponse updateWebhook( String webhookId, UpdateWebhookRequestBody request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhooks") - .addPathSegment(webhookId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new BaseSchematicException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateWebhookResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 404: - throw new NotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.updateWebhook(webhookId, request, requestOptions).body(); } public DeleteWebhookResponse deleteWebhook(String webhookId) { - return deleteWebhook(webhookId, null); + return this.rawClient.deleteWebhook(webhookId).body(); } public DeleteWebhookResponse deleteWebhook(String webhookId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhooks") - .addPathSegment(webhookId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteWebhookResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.deleteWebhook(webhookId, requestOptions).body(); } public CountWebhooksResponse countWebhooks() { - return countWebhooks(CountWebhooksRequest.builder().build()); + return this.rawClient.countWebhooks().body(); } public CountWebhooksResponse countWebhooks(CountWebhooksRequest request) { - return countWebhooks(request, null); + return this.rawClient.countWebhooks(request).body(); } public CountWebhooksResponse countWebhooks(CountWebhooksRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("webhooks/count"); - if (request.getQ().isPresent()) { - httpUrl.addQueryParameter("q", request.getQ().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getOffset().isPresent()) { - httpUrl.addQueryParameter("offset", request.getOffset().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CountWebhooksResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ApiError.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new BaseSchematicApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new BaseSchematicException("Network error executing HTTP request", e); - } + return this.rawClient.countWebhooks(request, requestOptions).body(); } } diff --git a/src/main/java/com/schematic/api/resources/webhooks/requests/CountWebhookEventsRequest.java b/src/main/java/com/schematic/api/resources/webhooks/requests/CountWebhookEventsRequest.java index ec41ae0..1b8db1e 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/requests/CountWebhookEventsRequest.java +++ b/src/main/java/com/schematic/api/resources/webhooks/requests/CountWebhookEventsRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,7 +22,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountWebhookEventsRequest.Builder.class) public final class CountWebhookEventsRequest { - private final Optional ids; + private final Optional> ids; private final Optional q; @@ -33,7 +35,7 @@ public final class CountWebhookEventsRequest { private final Map additionalProperties; private CountWebhookEventsRequest( - Optional ids, + Optional> ids, Optional q, Optional webhookId, Optional limit, @@ -48,7 +50,7 @@ private CountWebhookEventsRequest( } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -113,7 +115,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional q = Optional.empty(); @@ -138,16 +140,21 @@ public Builder from(CountWebhookEventsRequest other) { } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -170,6 +177,9 @@ public Builder webhookId(String webhookId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -181,6 +191,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/webhooks/requests/CountWebhooksRequest.java b/src/main/java/com/schematic/api/resources/webhooks/requests/CountWebhooksRequest.java index 0726cbf..a52f48a 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/requests/CountWebhooksRequest.java +++ b/src/main/java/com/schematic/api/resources/webhooks/requests/CountWebhooksRequest.java @@ -120,6 +120,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -131,6 +134,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/webhooks/requests/CreateWebhookRequestBody.java b/src/main/java/com/schematic/api/resources/webhooks/requests/CreateWebhookRequestBody.java index 5a2879d..3135da0 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/requests/CreateWebhookRequestBody.java +++ b/src/main/java/com/schematic/api/resources/webhooks/requests/CreateWebhookRequestBody.java @@ -13,16 +13,23 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.webhooks.types.CreateWebhookRequestBodyRequestTypesItem; +import com.schematic.api.types.CreditTriggerConfig; +import com.schematic.api.types.EntitlementTriggerConfig; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreateWebhookRequestBody.Builder.class) public final class CreateWebhookRequestBody { + private final Optional> creditTriggerConfigs; + + private final Optional> entitlementTriggerConfigs; + private final String name; private final List requestTypes; @@ -32,16 +39,30 @@ public final class CreateWebhookRequestBody { private final Map additionalProperties; private CreateWebhookRequestBody( + Optional> creditTriggerConfigs, + Optional> entitlementTriggerConfigs, String name, List requestTypes, String url, Map additionalProperties) { + this.creditTriggerConfigs = creditTriggerConfigs; + this.entitlementTriggerConfigs = entitlementTriggerConfigs; this.name = name; this.requestTypes = requestTypes; this.url = url; this.additionalProperties = additionalProperties; } + @JsonProperty("credit_trigger_configs") + public Optional> getCreditTriggerConfigs() { + return creditTriggerConfigs; + } + + @JsonProperty("entitlement_trigger_configs") + public Optional> getEntitlementTriggerConfigs() { + return entitlementTriggerConfigs; + } + @JsonProperty("name") public String getName() { return name; @@ -69,12 +90,17 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateWebhookRequestBody other) { - return name.equals(other.name) && requestTypes.equals(other.requestTypes) && url.equals(other.url); + return creditTriggerConfigs.equals(other.creditTriggerConfigs) + && entitlementTriggerConfigs.equals(other.entitlementTriggerConfigs) + && name.equals(other.name) + && requestTypes.equals(other.requestTypes) + && url.equals(other.url); } @java.lang.Override public int hashCode() { - return Objects.hash(this.name, this.requestTypes, this.url); + return Objects.hash( + this.creditTriggerConfigs, this.entitlementTriggerConfigs, this.name, this.requestTypes, this.url); } @java.lang.Override @@ -99,6 +125,14 @@ public interface UrlStage { public interface _FinalStage { CreateWebhookRequestBody build(); + _FinalStage creditTriggerConfigs(Optional> creditTriggerConfigs); + + _FinalStage creditTriggerConfigs(List creditTriggerConfigs); + + _FinalStage entitlementTriggerConfigs(Optional> entitlementTriggerConfigs); + + _FinalStage entitlementTriggerConfigs(List entitlementTriggerConfigs); + _FinalStage requestTypes(List requestTypes); _FinalStage addRequestTypes(CreateWebhookRequestBodyRequestTypesItem requestTypes); @@ -114,6 +148,10 @@ public static final class Builder implements NameStage, UrlStage, _FinalStage { private List requestTypes = new ArrayList<>(); + private Optional> entitlementTriggerConfigs = Optional.empty(); + + private Optional> creditTriggerConfigs = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -121,6 +159,8 @@ private Builder() {} @java.lang.Override public Builder from(CreateWebhookRequestBody other) { + creditTriggerConfigs(other.getCreditTriggerConfigs()); + entitlementTriggerConfigs(other.getEntitlementTriggerConfigs()); name(other.getName()); requestTypes(other.getRequestTypes()); url(other.getUrl()); @@ -143,7 +183,9 @@ public _FinalStage url(@NotNull String url) { @java.lang.Override public _FinalStage addAllRequestTypes(List requestTypes) { - this.requestTypes.addAll(requestTypes); + if (requestTypes != null) { + this.requestTypes.addAll(requestTypes); + } return this; } @@ -157,13 +199,43 @@ public _FinalStage addRequestTypes(CreateWebhookRequestBodyRequestTypesItem requ @JsonSetter(value = "request_types", nulls = Nulls.SKIP) public _FinalStage requestTypes(List requestTypes) { this.requestTypes.clear(); - this.requestTypes.addAll(requestTypes); + if (requestTypes != null) { + this.requestTypes.addAll(requestTypes); + } + return this; + } + + @java.lang.Override + public _FinalStage entitlementTriggerConfigs(List entitlementTriggerConfigs) { + this.entitlementTriggerConfigs = Optional.ofNullable(entitlementTriggerConfigs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "entitlement_trigger_configs", nulls = Nulls.SKIP) + public _FinalStage entitlementTriggerConfigs( + Optional> entitlementTriggerConfigs) { + this.entitlementTriggerConfigs = entitlementTriggerConfigs; + return this; + } + + @java.lang.Override + public _FinalStage creditTriggerConfigs(List creditTriggerConfigs) { + this.creditTriggerConfigs = Optional.ofNullable(creditTriggerConfigs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_trigger_configs", nulls = Nulls.SKIP) + public _FinalStage creditTriggerConfigs(Optional> creditTriggerConfigs) { + this.creditTriggerConfigs = creditTriggerConfigs; return this; } @java.lang.Override public CreateWebhookRequestBody build() { - return new CreateWebhookRequestBody(name, requestTypes, url, additionalProperties); + return new CreateWebhookRequestBody( + creditTriggerConfigs, entitlementTriggerConfigs, name, requestTypes, url, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/webhooks/requests/ListWebhookEventsRequest.java b/src/main/java/com/schematic/api/resources/webhooks/requests/ListWebhookEventsRequest.java index 83527d0..cd8585a 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/requests/ListWebhookEventsRequest.java +++ b/src/main/java/com/schematic/api/resources/webhooks/requests/ListWebhookEventsRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,7 +22,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ListWebhookEventsRequest.Builder.class) public final class ListWebhookEventsRequest { - private final Optional ids; + private final Optional> ids; private final Optional q; @@ -33,7 +35,7 @@ public final class ListWebhookEventsRequest { private final Map additionalProperties; private ListWebhookEventsRequest( - Optional ids, + Optional> ids, Optional q, Optional webhookId, Optional limit, @@ -48,7 +50,7 @@ private ListWebhookEventsRequest( } @JsonProperty("ids") - public Optional getIds() { + public Optional> getIds() { return ids; } @@ -113,7 +115,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional ids = Optional.empty(); + private Optional> ids = Optional.empty(); private Optional q = Optional.empty(); @@ -138,16 +140,21 @@ public Builder from(ListWebhookEventsRequest other) { } @JsonSetter(value = "ids", nulls = Nulls.SKIP) - public Builder ids(Optional ids) { + public Builder ids(Optional> ids) { this.ids = ids; return this; } - public Builder ids(String ids) { + public Builder ids(List ids) { this.ids = Optional.ofNullable(ids); return this; } + public Builder ids(String ids) { + this.ids = Optional.of(Collections.singletonList(ids)); + return this; + } + @JsonSetter(value = "q", nulls = Nulls.SKIP) public Builder q(Optional q) { this.q = q; @@ -170,6 +177,9 @@ public Builder webhookId(String webhookId) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -181,6 +191,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/webhooks/requests/ListWebhooksRequest.java b/src/main/java/com/schematic/api/resources/webhooks/requests/ListWebhooksRequest.java index 4276071..4dc7f30 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/requests/ListWebhooksRequest.java +++ b/src/main/java/com/schematic/api/resources/webhooks/requests/ListWebhooksRequest.java @@ -120,6 +120,9 @@ public Builder q(String q) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -131,6 +134,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/webhooks/requests/UpdateWebhookRequestBody.java b/src/main/java/com/schematic/api/resources/webhooks/requests/UpdateWebhookRequestBody.java index 68846e5..4c4d797 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/requests/UpdateWebhookRequestBody.java +++ b/src/main/java/com/schematic/api/resources/webhooks/requests/UpdateWebhookRequestBody.java @@ -14,6 +14,8 @@ import com.schematic.api.core.ObjectMappers; import com.schematic.api.resources.webhooks.types.UpdateWebhookRequestBodyRequestTypesItem; import com.schematic.api.resources.webhooks.types.UpdateWebhookRequestBodyStatus; +import com.schematic.api.types.CreditTriggerConfig; +import com.schematic.api.types.EntitlementTriggerConfig; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -23,6 +25,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateWebhookRequestBody.Builder.class) public final class UpdateWebhookRequestBody { + private final Optional> creditTriggerConfigs; + + private final Optional> entitlementTriggerConfigs; + private final Optional name; private final Optional> requestTypes; @@ -34,11 +40,15 @@ public final class UpdateWebhookRequestBody { private final Map additionalProperties; private UpdateWebhookRequestBody( + Optional> creditTriggerConfigs, + Optional> entitlementTriggerConfigs, Optional name, Optional> requestTypes, Optional status, Optional url, Map additionalProperties) { + this.creditTriggerConfigs = creditTriggerConfigs; + this.entitlementTriggerConfigs = entitlementTriggerConfigs; this.name = name; this.requestTypes = requestTypes; this.status = status; @@ -46,6 +56,16 @@ private UpdateWebhookRequestBody( this.additionalProperties = additionalProperties; } + @JsonProperty("credit_trigger_configs") + public Optional> getCreditTriggerConfigs() { + return creditTriggerConfigs; + } + + @JsonProperty("entitlement_trigger_configs") + public Optional> getEntitlementTriggerConfigs() { + return entitlementTriggerConfigs; + } + @JsonProperty("name") public Optional getName() { return name; @@ -78,7 +98,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateWebhookRequestBody other) { - return name.equals(other.name) + return creditTriggerConfigs.equals(other.creditTriggerConfigs) + && entitlementTriggerConfigs.equals(other.entitlementTriggerConfigs) + && name.equals(other.name) && requestTypes.equals(other.requestTypes) && status.equals(other.status) && url.equals(other.url); @@ -86,7 +108,13 @@ private boolean equalTo(UpdateWebhookRequestBody other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.name, this.requestTypes, this.status, this.url); + return Objects.hash( + this.creditTriggerConfigs, + this.entitlementTriggerConfigs, + this.name, + this.requestTypes, + this.status, + this.url); } @java.lang.Override @@ -100,6 +128,10 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> creditTriggerConfigs = Optional.empty(); + + private Optional> entitlementTriggerConfigs = Optional.empty(); + private Optional name = Optional.empty(); private Optional> requestTypes = Optional.empty(); @@ -114,6 +146,8 @@ public static final class Builder { private Builder() {} public Builder from(UpdateWebhookRequestBody other) { + creditTriggerConfigs(other.getCreditTriggerConfigs()); + entitlementTriggerConfigs(other.getEntitlementTriggerConfigs()); name(other.getName()); requestTypes(other.getRequestTypes()); status(other.getStatus()); @@ -121,6 +155,28 @@ public Builder from(UpdateWebhookRequestBody other) { return this; } + @JsonSetter(value = "credit_trigger_configs", nulls = Nulls.SKIP) + public Builder creditTriggerConfigs(Optional> creditTriggerConfigs) { + this.creditTriggerConfigs = creditTriggerConfigs; + return this; + } + + public Builder creditTriggerConfigs(List creditTriggerConfigs) { + this.creditTriggerConfigs = Optional.ofNullable(creditTriggerConfigs); + return this; + } + + @JsonSetter(value = "entitlement_trigger_configs", nulls = Nulls.SKIP) + public Builder entitlementTriggerConfigs(Optional> entitlementTriggerConfigs) { + this.entitlementTriggerConfigs = entitlementTriggerConfigs; + return this; + } + + public Builder entitlementTriggerConfigs(List entitlementTriggerConfigs) { + this.entitlementTriggerConfigs = Optional.ofNullable(entitlementTriggerConfigs); + return this; + } + @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -166,7 +222,14 @@ public Builder url(String url) { } public UpdateWebhookRequestBody build() { - return new UpdateWebhookRequestBody(name, requestTypes, status, url, additionalProperties); + return new UpdateWebhookRequestBody( + creditTriggerConfigs, + entitlementTriggerConfigs, + name, + requestTypes, + status, + url, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsParams.java b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsParams.java index 06d7132..a0dc1c3 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsParams.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsParams.java @@ -149,6 +149,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -160,6 +163,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsResponse.java index 2ff91c6..ea4e14b 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhookEventsResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountWebhookEventsParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksParams.java b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksParams.java index 29f2e53..f17a2f4 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksParams.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksParams.java @@ -109,6 +109,9 @@ public Builder from(CountWebhooksParams other) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -120,6 +123,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksResponse.java index 976383e..5d9cd4f 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/CountWebhooksResponse.java @@ -82,6 +82,9 @@ public interface DataStage { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull CountWebhooksParams params); } @@ -115,6 +118,7 @@ public ParamsStage data(@NotNull CountResponse data) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/CreateWebhookRequestBodyRequestTypesItem.java b/src/main/java/com/schematic/api/resources/webhooks/types/CreateWebhookRequestBodyRequestTypesItem.java index adc3bd1..b4d25ed 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/CreateWebhookRequestBodyRequestTypesItem.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/CreateWebhookRequestBodyRequestTypesItem.java @@ -3,66 +3,429 @@ */ package com.schematic.api.resources.webhooks.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateWebhookRequestBodyRequestTypesItem { - COMPANY_UPDATED("company.updated"), +public final class CreateWebhookRequestBodyRequestTypesItem { + public static final CreateWebhookRequestBodyRequestTypesItem COMPANY_DELETED = + new CreateWebhookRequestBodyRequestTypesItem(Value.COMPANY_DELETED, "company.deleted"); - USER_UPDATED("user.updated"), + public static final CreateWebhookRequestBodyRequestTypesItem COMPANY_OVERRIDE_UPDATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.COMPANY_OVERRIDE_UPDATED, "company.override.updated"); - PLAN_UPDATED("plan.updated"), + public static final CreateWebhookRequestBodyRequestTypesItem FLAG_UPDATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.FLAG_UPDATED, "flag.updated"); - PLAN_ENTITLEMENT_UPDATED("plan.entitlement.updated"), + public static final CreateWebhookRequestBodyRequestTypesItem FEATURE_UPDATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.FEATURE_UPDATED, "feature.updated"); - COMPANY_OVERRIDE_UPDATED("company.override.updated"), + public static final CreateWebhookRequestBodyRequestTypesItem FLAG_RULES_UPDATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.FLAG_RULES_UPDATED, "flag_rules.updated"); - FEATURE_UPDATED("feature.updated"), + public static final CreateWebhookRequestBodyRequestTypesItem USER_UPDATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.USER_UPDATED, "user.updated"); - FLAG_UPDATED("flag.updated"), + public static final CreateWebhookRequestBodyRequestTypesItem PLAN_DELETED = + new CreateWebhookRequestBodyRequestTypesItem(Value.PLAN_DELETED, "plan.deleted"); - FLAG_RULES_UPDATED("flag_rules.updated"), + public static final CreateWebhookRequestBodyRequestTypesItem PLAN_ENTITLEMENT_UPDATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.PLAN_ENTITLEMENT_UPDATED, "plan.entitlement.updated"); - COMPANY_CREATED("company.created"), + public static final CreateWebhookRequestBodyRequestTypesItem COMPANY_OVERRIDE_DELETED = + new CreateWebhookRequestBodyRequestTypesItem(Value.COMPANY_OVERRIDE_DELETED, "company.override.deleted"); - USER_CREATED("user.created"), + public static final CreateWebhookRequestBodyRequestTypesItem USER_CREATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.USER_CREATED, "user.created"); - PLAN_CREATED("plan.created"), + public static final CreateWebhookRequestBodyRequestTypesItem FEATURE_DELETED = + new CreateWebhookRequestBodyRequestTypesItem(Value.FEATURE_DELETED, "feature.deleted"); - PLAN_ENTITLEMENT_CREATED("plan.entitlement.created"), + public static final CreateWebhookRequestBodyRequestTypesItem CREDIT_LIMIT_REACHED = + new CreateWebhookRequestBodyRequestTypesItem(Value.CREDIT_LIMIT_REACHED, "credit.limit.reached"); - COMPANY_OVERRIDE_CREATED("company.override.created"), + public static final CreateWebhookRequestBodyRequestTypesItem ENTITLEMENT_SOFT_LIMIT_REACHED = + new CreateWebhookRequestBodyRequestTypesItem( + Value.ENTITLEMENT_SOFT_LIMIT_REACHED, "entitlement.soft_limit.reached"); - FEATURE_CREATED("feature.created"), + public static final CreateWebhookRequestBodyRequestTypesItem SUBSCRIPTION_TRIAL_ENDED = + new CreateWebhookRequestBodyRequestTypesItem(Value.SUBSCRIPTION_TRIAL_ENDED, "subscription.trial.ended"); - FLAG_CREATED("flag.created"), + public static final CreateWebhookRequestBodyRequestTypesItem ENTITLEMENT_LIMIT_REACHED = + new CreateWebhookRequestBodyRequestTypesItem(Value.ENTITLEMENT_LIMIT_REACHED, "entitlement.limit.reached"); - COMPANY_DELETED("company.deleted"), + public static final CreateWebhookRequestBodyRequestTypesItem COMPANY_OVERRIDE_CREATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.COMPANY_OVERRIDE_CREATED, "company.override.created"); - USER_DELETED("user.deleted"), + public static final CreateWebhookRequestBodyRequestTypesItem FLAG_CREATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.FLAG_CREATED, "flag.created"); - PLAN_DELETED("plan.deleted"), + public static final CreateWebhookRequestBodyRequestTypesItem PLAN_ENTITLEMENT_DELETED = + new CreateWebhookRequestBodyRequestTypesItem(Value.PLAN_ENTITLEMENT_DELETED, "plan.entitlement.deleted"); - PLAN_ENTITLEMENT_DELETED("plan.entitlement.deleted"), + public static final CreateWebhookRequestBodyRequestTypesItem USER_DELETED = + new CreateWebhookRequestBodyRequestTypesItem(Value.USER_DELETED, "user.deleted"); - COMPANY_OVERRIDE_DELETED("company.override.deleted"), + public static final CreateWebhookRequestBodyRequestTypesItem PLAN_UPDATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.PLAN_UPDATED, "plan.updated"); - FEATURE_DELETED("feature.deleted"), + public static final CreateWebhookRequestBodyRequestTypesItem ENTITLEMENT_LIMIT_WARNING = + new CreateWebhookRequestBodyRequestTypesItem(Value.ENTITLEMENT_LIMIT_WARNING, "entitlement.limit.warning"); - FLAG_DELETED("flag.deleted"), + public static final CreateWebhookRequestBodyRequestTypesItem CREDIT_LIMIT_WARNING = + new CreateWebhookRequestBodyRequestTypesItem(Value.CREDIT_LIMIT_WARNING, "credit.limit.warning"); - TEST_SEND("test.send"), + public static final CreateWebhookRequestBodyRequestTypesItem FEATURE_CREATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.FEATURE_CREATED, "feature.created"); - SUBSCRIPTION_TRIAL_ENDED("subscription.trial.ended"); + public static final CreateWebhookRequestBodyRequestTypesItem ENTITLEMENT_SOFT_LIMIT_WARNING = + new CreateWebhookRequestBodyRequestTypesItem( + Value.ENTITLEMENT_SOFT_LIMIT_WARNING, "entitlement.soft_limit.warning"); - private final String value; + public static final CreateWebhookRequestBodyRequestTypesItem COMPANY_UPDATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.COMPANY_UPDATED, "company.updated"); - CreateWebhookRequestBodyRequestTypesItem(String value) { + public static final CreateWebhookRequestBodyRequestTypesItem ENTITLEMENT_TIER_LIMIT_REACHED = + new CreateWebhookRequestBodyRequestTypesItem( + Value.ENTITLEMENT_TIER_LIMIT_REACHED, "entitlement.tier_limit.reached"); + + public static final CreateWebhookRequestBodyRequestTypesItem FLAG_DELETED = + new CreateWebhookRequestBodyRequestTypesItem(Value.FLAG_DELETED, "flag.deleted"); + + public static final CreateWebhookRequestBodyRequestTypesItem COMPANY_CREATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.COMPANY_CREATED, "company.created"); + + public static final CreateWebhookRequestBodyRequestTypesItem PLAN_ENTITLEMENT_CREATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.PLAN_ENTITLEMENT_CREATED, "plan.entitlement.created"); + + public static final CreateWebhookRequestBodyRequestTypesItem ENTITLEMENT_TIER_LIMIT_WARNING = + new CreateWebhookRequestBodyRequestTypesItem( + Value.ENTITLEMENT_TIER_LIMIT_WARNING, "entitlement.tier_limit.warning"); + + public static final CreateWebhookRequestBodyRequestTypesItem COMPANY_PLAN_CHANGE = + new CreateWebhookRequestBodyRequestTypesItem(Value.COMPANY_PLAN_CHANGE, "company.plan_change"); + + public static final CreateWebhookRequestBodyRequestTypesItem PLAN_CREATED = + new CreateWebhookRequestBodyRequestTypesItem(Value.PLAN_CREATED, "plan.created"); + + public static final CreateWebhookRequestBodyRequestTypesItem TEST_SEND = + new CreateWebhookRequestBodyRequestTypesItem(Value.TEST_SEND, "test.send"); + + private final Value value; + + private final String string; + + CreateWebhookRequestBodyRequestTypesItem(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateWebhookRequestBodyRequestTypesItem + && this.string.equals(((CreateWebhookRequestBodyRequestTypesItem) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case COMPANY_DELETED: + return visitor.visitCompanyDeleted(); + case COMPANY_OVERRIDE_UPDATED: + return visitor.visitCompanyOverrideUpdated(); + case FLAG_UPDATED: + return visitor.visitFlagUpdated(); + case FEATURE_UPDATED: + return visitor.visitFeatureUpdated(); + case FLAG_RULES_UPDATED: + return visitor.visitFlagRulesUpdated(); + case USER_UPDATED: + return visitor.visitUserUpdated(); + case PLAN_DELETED: + return visitor.visitPlanDeleted(); + case PLAN_ENTITLEMENT_UPDATED: + return visitor.visitPlanEntitlementUpdated(); + case COMPANY_OVERRIDE_DELETED: + return visitor.visitCompanyOverrideDeleted(); + case USER_CREATED: + return visitor.visitUserCreated(); + case FEATURE_DELETED: + return visitor.visitFeatureDeleted(); + case CREDIT_LIMIT_REACHED: + return visitor.visitCreditLimitReached(); + case ENTITLEMENT_SOFT_LIMIT_REACHED: + return visitor.visitEntitlementSoftLimitReached(); + case SUBSCRIPTION_TRIAL_ENDED: + return visitor.visitSubscriptionTrialEnded(); + case ENTITLEMENT_LIMIT_REACHED: + return visitor.visitEntitlementLimitReached(); + case COMPANY_OVERRIDE_CREATED: + return visitor.visitCompanyOverrideCreated(); + case FLAG_CREATED: + return visitor.visitFlagCreated(); + case PLAN_ENTITLEMENT_DELETED: + return visitor.visitPlanEntitlementDeleted(); + case USER_DELETED: + return visitor.visitUserDeleted(); + case PLAN_UPDATED: + return visitor.visitPlanUpdated(); + case ENTITLEMENT_LIMIT_WARNING: + return visitor.visitEntitlementLimitWarning(); + case CREDIT_LIMIT_WARNING: + return visitor.visitCreditLimitWarning(); + case FEATURE_CREATED: + return visitor.visitFeatureCreated(); + case ENTITLEMENT_SOFT_LIMIT_WARNING: + return visitor.visitEntitlementSoftLimitWarning(); + case COMPANY_UPDATED: + return visitor.visitCompanyUpdated(); + case ENTITLEMENT_TIER_LIMIT_REACHED: + return visitor.visitEntitlementTierLimitReached(); + case FLAG_DELETED: + return visitor.visitFlagDeleted(); + case COMPANY_CREATED: + return visitor.visitCompanyCreated(); + case PLAN_ENTITLEMENT_CREATED: + return visitor.visitPlanEntitlementCreated(); + case ENTITLEMENT_TIER_LIMIT_WARNING: + return visitor.visitEntitlementTierLimitWarning(); + case COMPANY_PLAN_CHANGE: + return visitor.visitCompanyPlanChange(); + case PLAN_CREATED: + return visitor.visitPlanCreated(); + case TEST_SEND: + return visitor.visitTestSend(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateWebhookRequestBodyRequestTypesItem valueOf(String value) { + switch (value) { + case "company.deleted": + return COMPANY_DELETED; + case "company.override.updated": + return COMPANY_OVERRIDE_UPDATED; + case "flag.updated": + return FLAG_UPDATED; + case "feature.updated": + return FEATURE_UPDATED; + case "flag_rules.updated": + return FLAG_RULES_UPDATED; + case "user.updated": + return USER_UPDATED; + case "plan.deleted": + return PLAN_DELETED; + case "plan.entitlement.updated": + return PLAN_ENTITLEMENT_UPDATED; + case "company.override.deleted": + return COMPANY_OVERRIDE_DELETED; + case "user.created": + return USER_CREATED; + case "feature.deleted": + return FEATURE_DELETED; + case "credit.limit.reached": + return CREDIT_LIMIT_REACHED; + case "entitlement.soft_limit.reached": + return ENTITLEMENT_SOFT_LIMIT_REACHED; + case "subscription.trial.ended": + return SUBSCRIPTION_TRIAL_ENDED; + case "entitlement.limit.reached": + return ENTITLEMENT_LIMIT_REACHED; + case "company.override.created": + return COMPANY_OVERRIDE_CREATED; + case "flag.created": + return FLAG_CREATED; + case "plan.entitlement.deleted": + return PLAN_ENTITLEMENT_DELETED; + case "user.deleted": + return USER_DELETED; + case "plan.updated": + return PLAN_UPDATED; + case "entitlement.limit.warning": + return ENTITLEMENT_LIMIT_WARNING; + case "credit.limit.warning": + return CREDIT_LIMIT_WARNING; + case "feature.created": + return FEATURE_CREATED; + case "entitlement.soft_limit.warning": + return ENTITLEMENT_SOFT_LIMIT_WARNING; + case "company.updated": + return COMPANY_UPDATED; + case "entitlement.tier_limit.reached": + return ENTITLEMENT_TIER_LIMIT_REACHED; + case "flag.deleted": + return FLAG_DELETED; + case "company.created": + return COMPANY_CREATED; + case "plan.entitlement.created": + return PLAN_ENTITLEMENT_CREATED; + case "entitlement.tier_limit.warning": + return ENTITLEMENT_TIER_LIMIT_WARNING; + case "company.plan_change": + return COMPANY_PLAN_CHANGE; + case "plan.created": + return PLAN_CREATED; + case "test.send": + return TEST_SEND; + default: + return new CreateWebhookRequestBodyRequestTypesItem(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY_UPDATED, + + USER_UPDATED, + + PLAN_UPDATED, + + PLAN_ENTITLEMENT_UPDATED, + + COMPANY_OVERRIDE_UPDATED, + + FEATURE_UPDATED, + + FLAG_UPDATED, + + FLAG_RULES_UPDATED, + + COMPANY_CREATED, + + USER_CREATED, + + PLAN_CREATED, + + PLAN_ENTITLEMENT_CREATED, + + COMPANY_OVERRIDE_CREATED, + + FEATURE_CREATED, + + FLAG_CREATED, + + COMPANY_DELETED, + + USER_DELETED, + + PLAN_DELETED, + + PLAN_ENTITLEMENT_DELETED, + + COMPANY_OVERRIDE_DELETED, + + FEATURE_DELETED, + + FLAG_DELETED, + + TEST_SEND, + + SUBSCRIPTION_TRIAL_ENDED, + + ENTITLEMENT_LIMIT_WARNING, + + ENTITLEMENT_LIMIT_REACHED, + + ENTITLEMENT_SOFT_LIMIT_WARNING, + + ENTITLEMENT_SOFT_LIMIT_REACHED, + + ENTITLEMENT_TIER_LIMIT_WARNING, + + ENTITLEMENT_TIER_LIMIT_REACHED, + + CREDIT_LIMIT_WARNING, + + CREDIT_LIMIT_REACHED, + + COMPANY_PLAN_CHANGE, + + UNKNOWN + } + + public interface Visitor { + T visitCompanyUpdated(); + + T visitUserUpdated(); + + T visitPlanUpdated(); + + T visitPlanEntitlementUpdated(); + + T visitCompanyOverrideUpdated(); + + T visitFeatureUpdated(); + + T visitFlagUpdated(); + + T visitFlagRulesUpdated(); + + T visitCompanyCreated(); + + T visitUserCreated(); + + T visitPlanCreated(); + + T visitPlanEntitlementCreated(); + + T visitCompanyOverrideCreated(); + + T visitFeatureCreated(); + + T visitFlagCreated(); + + T visitCompanyDeleted(); + + T visitUserDeleted(); + + T visitPlanDeleted(); + + T visitPlanEntitlementDeleted(); + + T visitCompanyOverrideDeleted(); + + T visitFeatureDeleted(); + + T visitFlagDeleted(); + + T visitTestSend(); + + T visitSubscriptionTrialEnded(); + + T visitEntitlementLimitWarning(); + + T visitEntitlementLimitReached(); + + T visitEntitlementSoftLimitWarning(); + + T visitEntitlementSoftLimitReached(); + + T visitEntitlementTierLimitWarning(); + + T visitEntitlementTierLimitReached(); + + T visitCreditLimitWarning(); + + T visitCreditLimitReached(); + + T visitCompanyPlanChange(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/CreateWebhookResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/CreateWebhookResponse.java index 0591e7f..752a326 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/CreateWebhookResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/CreateWebhookResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { CreateWebhookResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/DeleteWebhookResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/DeleteWebhookResponse.java index 5f17a05..d8fe5ac 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/DeleteWebhookResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/DeleteWebhookResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { DeleteWebhookResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/GetWebhookEventResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/GetWebhookEventResponse.java index 90a37f4..9f7aacf 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/GetWebhookEventResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/GetWebhookEventResponse.java @@ -89,6 +89,9 @@ public interface DataStage { public interface _FinalStage { GetWebhookEventResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -137,15 +140,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/GetWebhookResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/GetWebhookResponse.java index d2b127d..1f7e92b 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/GetWebhookResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/GetWebhookResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { GetWebhookResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsParams.java b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsParams.java index 6a4e368..7aed7a8 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsParams.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsParams.java @@ -149,6 +149,9 @@ public Builder ids(List ids) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -160,6 +163,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsResponse.java index 4d98046..99ae3cd 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhookEventsResponse.java @@ -38,9 +38,6 @@ private ListWebhookEventsResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -84,6 +81,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListWebhookEventsParams params); Builder from(ListWebhookEventsResponse other); @@ -118,6 +118,7 @@ public Builder from(ListWebhookEventsResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -128,20 +129,14 @@ public _FinalStage params(@NotNull ListWebhookEventsParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(WebhookEventDetailResponseData data) { this.data.add(data); @@ -152,7 +147,9 @@ public _FinalStage addData(WebhookEventDetailResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksParams.java b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksParams.java index 0b1b0c6..be1e9f1 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksParams.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksParams.java @@ -109,6 +109,9 @@ public Builder from(ListWebhooksParams other) { return this; } + /** + *

Page limit (default 100)

+ */ @JsonSetter(value = "limit", nulls = Nulls.SKIP) public Builder limit(Optional limit) { this.limit = limit; @@ -120,6 +123,9 @@ public Builder limit(Integer limit) { return this; } + /** + *

Page offset (default 0)

+ */ @JsonSetter(value = "offset", nulls = Nulls.SKIP) public Builder offset(Optional offset) { this.offset = offset; diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksResponse.java index 8144ec8..085afe7 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/ListWebhooksResponse.java @@ -36,9 +36,6 @@ private ListWebhooksResponse( this.additionalProperties = additionalProperties; } - /** - * @return The returned resources - */ @JsonProperty("data") public List getData() { return data; @@ -82,6 +79,9 @@ public static ParamsStage builder() { } public interface ParamsStage { + /** + *

Input parameters

+ */ _FinalStage params(@NotNull ListWebhooksParams params); Builder from(ListWebhooksResponse other); @@ -116,6 +116,7 @@ public Builder from(ListWebhooksResponse other) { } /** + *

Input parameters

*

Input parameters

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -126,20 +127,14 @@ public _FinalStage params(@NotNull ListWebhooksParams params) { return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addAllData(List data) { - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } - /** - *

The returned resources

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage addData(WebhookResponseData data) { this.data.add(data); @@ -150,7 +145,9 @@ public _FinalStage addData(WebhookResponseData data) { @JsonSetter(value = "data", nulls = Nulls.SKIP) public _FinalStage data(List data) { this.data.clear(); - this.data.addAll(data); + if (data != null) { + this.data.addAll(data); + } return this; } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookRequestBodyRequestTypesItem.java b/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookRequestBodyRequestTypesItem.java index 426ae36..8209bff 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookRequestBodyRequestTypesItem.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookRequestBodyRequestTypesItem.java @@ -3,66 +3,429 @@ */ package com.schematic.api.resources.webhooks.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateWebhookRequestBodyRequestTypesItem { - COMPANY_UPDATED("company.updated"), +public final class UpdateWebhookRequestBodyRequestTypesItem { + public static final UpdateWebhookRequestBodyRequestTypesItem COMPANY_DELETED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.COMPANY_DELETED, "company.deleted"); - USER_UPDATED("user.updated"), + public static final UpdateWebhookRequestBodyRequestTypesItem COMPANY_OVERRIDE_UPDATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.COMPANY_OVERRIDE_UPDATED, "company.override.updated"); - PLAN_UPDATED("plan.updated"), + public static final UpdateWebhookRequestBodyRequestTypesItem FLAG_UPDATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.FLAG_UPDATED, "flag.updated"); - PLAN_ENTITLEMENT_UPDATED("plan.entitlement.updated"), + public static final UpdateWebhookRequestBodyRequestTypesItem FEATURE_UPDATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.FEATURE_UPDATED, "feature.updated"); - COMPANY_OVERRIDE_UPDATED("company.override.updated"), + public static final UpdateWebhookRequestBodyRequestTypesItem FLAG_RULES_UPDATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.FLAG_RULES_UPDATED, "flag_rules.updated"); - FEATURE_UPDATED("feature.updated"), + public static final UpdateWebhookRequestBodyRequestTypesItem USER_UPDATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.USER_UPDATED, "user.updated"); - FLAG_UPDATED("flag.updated"), + public static final UpdateWebhookRequestBodyRequestTypesItem PLAN_DELETED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.PLAN_DELETED, "plan.deleted"); - FLAG_RULES_UPDATED("flag_rules.updated"), + public static final UpdateWebhookRequestBodyRequestTypesItem PLAN_ENTITLEMENT_UPDATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.PLAN_ENTITLEMENT_UPDATED, "plan.entitlement.updated"); - COMPANY_CREATED("company.created"), + public static final UpdateWebhookRequestBodyRequestTypesItem COMPANY_OVERRIDE_DELETED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.COMPANY_OVERRIDE_DELETED, "company.override.deleted"); - USER_CREATED("user.created"), + public static final UpdateWebhookRequestBodyRequestTypesItem USER_CREATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.USER_CREATED, "user.created"); - PLAN_CREATED("plan.created"), + public static final UpdateWebhookRequestBodyRequestTypesItem FEATURE_DELETED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.FEATURE_DELETED, "feature.deleted"); - PLAN_ENTITLEMENT_CREATED("plan.entitlement.created"), + public static final UpdateWebhookRequestBodyRequestTypesItem CREDIT_LIMIT_REACHED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.CREDIT_LIMIT_REACHED, "credit.limit.reached"); - COMPANY_OVERRIDE_CREATED("company.override.created"), + public static final UpdateWebhookRequestBodyRequestTypesItem ENTITLEMENT_SOFT_LIMIT_REACHED = + new UpdateWebhookRequestBodyRequestTypesItem( + Value.ENTITLEMENT_SOFT_LIMIT_REACHED, "entitlement.soft_limit.reached"); - FEATURE_CREATED("feature.created"), + public static final UpdateWebhookRequestBodyRequestTypesItem SUBSCRIPTION_TRIAL_ENDED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.SUBSCRIPTION_TRIAL_ENDED, "subscription.trial.ended"); - FLAG_CREATED("flag.created"), + public static final UpdateWebhookRequestBodyRequestTypesItem ENTITLEMENT_LIMIT_REACHED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.ENTITLEMENT_LIMIT_REACHED, "entitlement.limit.reached"); - COMPANY_DELETED("company.deleted"), + public static final UpdateWebhookRequestBodyRequestTypesItem COMPANY_OVERRIDE_CREATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.COMPANY_OVERRIDE_CREATED, "company.override.created"); - USER_DELETED("user.deleted"), + public static final UpdateWebhookRequestBodyRequestTypesItem FLAG_CREATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.FLAG_CREATED, "flag.created"); - PLAN_DELETED("plan.deleted"), + public static final UpdateWebhookRequestBodyRequestTypesItem PLAN_ENTITLEMENT_DELETED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.PLAN_ENTITLEMENT_DELETED, "plan.entitlement.deleted"); - PLAN_ENTITLEMENT_DELETED("plan.entitlement.deleted"), + public static final UpdateWebhookRequestBodyRequestTypesItem USER_DELETED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.USER_DELETED, "user.deleted"); - COMPANY_OVERRIDE_DELETED("company.override.deleted"), + public static final UpdateWebhookRequestBodyRequestTypesItem PLAN_UPDATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.PLAN_UPDATED, "plan.updated"); - FEATURE_DELETED("feature.deleted"), + public static final UpdateWebhookRequestBodyRequestTypesItem ENTITLEMENT_LIMIT_WARNING = + new UpdateWebhookRequestBodyRequestTypesItem(Value.ENTITLEMENT_LIMIT_WARNING, "entitlement.limit.warning"); - FLAG_DELETED("flag.deleted"), + public static final UpdateWebhookRequestBodyRequestTypesItem CREDIT_LIMIT_WARNING = + new UpdateWebhookRequestBodyRequestTypesItem(Value.CREDIT_LIMIT_WARNING, "credit.limit.warning"); - TEST_SEND("test.send"), + public static final UpdateWebhookRequestBodyRequestTypesItem FEATURE_CREATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.FEATURE_CREATED, "feature.created"); - SUBSCRIPTION_TRIAL_ENDED("subscription.trial.ended"); + public static final UpdateWebhookRequestBodyRequestTypesItem ENTITLEMENT_SOFT_LIMIT_WARNING = + new UpdateWebhookRequestBodyRequestTypesItem( + Value.ENTITLEMENT_SOFT_LIMIT_WARNING, "entitlement.soft_limit.warning"); - private final String value; + public static final UpdateWebhookRequestBodyRequestTypesItem COMPANY_UPDATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.COMPANY_UPDATED, "company.updated"); - UpdateWebhookRequestBodyRequestTypesItem(String value) { + public static final UpdateWebhookRequestBodyRequestTypesItem ENTITLEMENT_TIER_LIMIT_REACHED = + new UpdateWebhookRequestBodyRequestTypesItem( + Value.ENTITLEMENT_TIER_LIMIT_REACHED, "entitlement.tier_limit.reached"); + + public static final UpdateWebhookRequestBodyRequestTypesItem FLAG_DELETED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.FLAG_DELETED, "flag.deleted"); + + public static final UpdateWebhookRequestBodyRequestTypesItem COMPANY_CREATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.COMPANY_CREATED, "company.created"); + + public static final UpdateWebhookRequestBodyRequestTypesItem PLAN_ENTITLEMENT_CREATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.PLAN_ENTITLEMENT_CREATED, "plan.entitlement.created"); + + public static final UpdateWebhookRequestBodyRequestTypesItem ENTITLEMENT_TIER_LIMIT_WARNING = + new UpdateWebhookRequestBodyRequestTypesItem( + Value.ENTITLEMENT_TIER_LIMIT_WARNING, "entitlement.tier_limit.warning"); + + public static final UpdateWebhookRequestBodyRequestTypesItem COMPANY_PLAN_CHANGE = + new UpdateWebhookRequestBodyRequestTypesItem(Value.COMPANY_PLAN_CHANGE, "company.plan_change"); + + public static final UpdateWebhookRequestBodyRequestTypesItem PLAN_CREATED = + new UpdateWebhookRequestBodyRequestTypesItem(Value.PLAN_CREATED, "plan.created"); + + public static final UpdateWebhookRequestBodyRequestTypesItem TEST_SEND = + new UpdateWebhookRequestBodyRequestTypesItem(Value.TEST_SEND, "test.send"); + + private final Value value; + + private final String string; + + UpdateWebhookRequestBodyRequestTypesItem(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateWebhookRequestBodyRequestTypesItem + && this.string.equals(((UpdateWebhookRequestBodyRequestTypesItem) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case COMPANY_DELETED: + return visitor.visitCompanyDeleted(); + case COMPANY_OVERRIDE_UPDATED: + return visitor.visitCompanyOverrideUpdated(); + case FLAG_UPDATED: + return visitor.visitFlagUpdated(); + case FEATURE_UPDATED: + return visitor.visitFeatureUpdated(); + case FLAG_RULES_UPDATED: + return visitor.visitFlagRulesUpdated(); + case USER_UPDATED: + return visitor.visitUserUpdated(); + case PLAN_DELETED: + return visitor.visitPlanDeleted(); + case PLAN_ENTITLEMENT_UPDATED: + return visitor.visitPlanEntitlementUpdated(); + case COMPANY_OVERRIDE_DELETED: + return visitor.visitCompanyOverrideDeleted(); + case USER_CREATED: + return visitor.visitUserCreated(); + case FEATURE_DELETED: + return visitor.visitFeatureDeleted(); + case CREDIT_LIMIT_REACHED: + return visitor.visitCreditLimitReached(); + case ENTITLEMENT_SOFT_LIMIT_REACHED: + return visitor.visitEntitlementSoftLimitReached(); + case SUBSCRIPTION_TRIAL_ENDED: + return visitor.visitSubscriptionTrialEnded(); + case ENTITLEMENT_LIMIT_REACHED: + return visitor.visitEntitlementLimitReached(); + case COMPANY_OVERRIDE_CREATED: + return visitor.visitCompanyOverrideCreated(); + case FLAG_CREATED: + return visitor.visitFlagCreated(); + case PLAN_ENTITLEMENT_DELETED: + return visitor.visitPlanEntitlementDeleted(); + case USER_DELETED: + return visitor.visitUserDeleted(); + case PLAN_UPDATED: + return visitor.visitPlanUpdated(); + case ENTITLEMENT_LIMIT_WARNING: + return visitor.visitEntitlementLimitWarning(); + case CREDIT_LIMIT_WARNING: + return visitor.visitCreditLimitWarning(); + case FEATURE_CREATED: + return visitor.visitFeatureCreated(); + case ENTITLEMENT_SOFT_LIMIT_WARNING: + return visitor.visitEntitlementSoftLimitWarning(); + case COMPANY_UPDATED: + return visitor.visitCompanyUpdated(); + case ENTITLEMENT_TIER_LIMIT_REACHED: + return visitor.visitEntitlementTierLimitReached(); + case FLAG_DELETED: + return visitor.visitFlagDeleted(); + case COMPANY_CREATED: + return visitor.visitCompanyCreated(); + case PLAN_ENTITLEMENT_CREATED: + return visitor.visitPlanEntitlementCreated(); + case ENTITLEMENT_TIER_LIMIT_WARNING: + return visitor.visitEntitlementTierLimitWarning(); + case COMPANY_PLAN_CHANGE: + return visitor.visitCompanyPlanChange(); + case PLAN_CREATED: + return visitor.visitPlanCreated(); + case TEST_SEND: + return visitor.visitTestSend(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateWebhookRequestBodyRequestTypesItem valueOf(String value) { + switch (value) { + case "company.deleted": + return COMPANY_DELETED; + case "company.override.updated": + return COMPANY_OVERRIDE_UPDATED; + case "flag.updated": + return FLAG_UPDATED; + case "feature.updated": + return FEATURE_UPDATED; + case "flag_rules.updated": + return FLAG_RULES_UPDATED; + case "user.updated": + return USER_UPDATED; + case "plan.deleted": + return PLAN_DELETED; + case "plan.entitlement.updated": + return PLAN_ENTITLEMENT_UPDATED; + case "company.override.deleted": + return COMPANY_OVERRIDE_DELETED; + case "user.created": + return USER_CREATED; + case "feature.deleted": + return FEATURE_DELETED; + case "credit.limit.reached": + return CREDIT_LIMIT_REACHED; + case "entitlement.soft_limit.reached": + return ENTITLEMENT_SOFT_LIMIT_REACHED; + case "subscription.trial.ended": + return SUBSCRIPTION_TRIAL_ENDED; + case "entitlement.limit.reached": + return ENTITLEMENT_LIMIT_REACHED; + case "company.override.created": + return COMPANY_OVERRIDE_CREATED; + case "flag.created": + return FLAG_CREATED; + case "plan.entitlement.deleted": + return PLAN_ENTITLEMENT_DELETED; + case "user.deleted": + return USER_DELETED; + case "plan.updated": + return PLAN_UPDATED; + case "entitlement.limit.warning": + return ENTITLEMENT_LIMIT_WARNING; + case "credit.limit.warning": + return CREDIT_LIMIT_WARNING; + case "feature.created": + return FEATURE_CREATED; + case "entitlement.soft_limit.warning": + return ENTITLEMENT_SOFT_LIMIT_WARNING; + case "company.updated": + return COMPANY_UPDATED; + case "entitlement.tier_limit.reached": + return ENTITLEMENT_TIER_LIMIT_REACHED; + case "flag.deleted": + return FLAG_DELETED; + case "company.created": + return COMPANY_CREATED; + case "plan.entitlement.created": + return PLAN_ENTITLEMENT_CREATED; + case "entitlement.tier_limit.warning": + return ENTITLEMENT_TIER_LIMIT_WARNING; + case "company.plan_change": + return COMPANY_PLAN_CHANGE; + case "plan.created": + return PLAN_CREATED; + case "test.send": + return TEST_SEND; + default: + return new UpdateWebhookRequestBodyRequestTypesItem(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY_UPDATED, + + USER_UPDATED, + + PLAN_UPDATED, + + PLAN_ENTITLEMENT_UPDATED, + + COMPANY_OVERRIDE_UPDATED, + + FEATURE_UPDATED, + + FLAG_UPDATED, + + FLAG_RULES_UPDATED, + + COMPANY_CREATED, + + USER_CREATED, + + PLAN_CREATED, + + PLAN_ENTITLEMENT_CREATED, + + COMPANY_OVERRIDE_CREATED, + + FEATURE_CREATED, + + FLAG_CREATED, + + COMPANY_DELETED, + + USER_DELETED, + + PLAN_DELETED, + + PLAN_ENTITLEMENT_DELETED, + + COMPANY_OVERRIDE_DELETED, + + FEATURE_DELETED, + + FLAG_DELETED, + + TEST_SEND, + + SUBSCRIPTION_TRIAL_ENDED, + + ENTITLEMENT_LIMIT_WARNING, + + ENTITLEMENT_LIMIT_REACHED, + + ENTITLEMENT_SOFT_LIMIT_WARNING, + + ENTITLEMENT_SOFT_LIMIT_REACHED, + + ENTITLEMENT_TIER_LIMIT_WARNING, + + ENTITLEMENT_TIER_LIMIT_REACHED, + + CREDIT_LIMIT_WARNING, + + CREDIT_LIMIT_REACHED, + + COMPANY_PLAN_CHANGE, + + UNKNOWN + } + + public interface Visitor { + T visitCompanyUpdated(); + + T visitUserUpdated(); + + T visitPlanUpdated(); + + T visitPlanEntitlementUpdated(); + + T visitCompanyOverrideUpdated(); + + T visitFeatureUpdated(); + + T visitFlagUpdated(); + + T visitFlagRulesUpdated(); + + T visitCompanyCreated(); + + T visitUserCreated(); + + T visitPlanCreated(); + + T visitPlanEntitlementCreated(); + + T visitCompanyOverrideCreated(); + + T visitFeatureCreated(); + + T visitFlagCreated(); + + T visitCompanyDeleted(); + + T visitUserDeleted(); + + T visitPlanDeleted(); + + T visitPlanEntitlementDeleted(); + + T visitCompanyOverrideDeleted(); + + T visitFeatureDeleted(); + + T visitFlagDeleted(); + + T visitTestSend(); + + T visitSubscriptionTrialEnded(); + + T visitEntitlementLimitWarning(); + + T visitEntitlementLimitReached(); + + T visitEntitlementSoftLimitWarning(); + + T visitEntitlementSoftLimitReached(); + + T visitEntitlementTierLimitWarning(); + + T visitEntitlementTierLimitReached(); + + T visitCreditLimitWarning(); + + T visitCreditLimitReached(); + + T visitCompanyPlanChange(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookRequestBodyStatus.java b/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookRequestBodyStatus.java index 90ba85b..0b973d7 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookRequestBodyStatus.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookRequestBodyStatus.java @@ -3,22 +3,84 @@ */ package com.schematic.api.resources.webhooks.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateWebhookRequestBodyStatus { - ACTIVE("active"), +public final class UpdateWebhookRequestBodyStatus { + public static final UpdateWebhookRequestBodyStatus INACTIVE = + new UpdateWebhookRequestBodyStatus(Value.INACTIVE, "inactive"); - INACTIVE("inactive"); + public static final UpdateWebhookRequestBodyStatus ACTIVE = + new UpdateWebhookRequestBodyStatus(Value.ACTIVE, "active"); - private final String value; + private final Value value; - UpdateWebhookRequestBodyStatus(String value) { + private final String string; + + UpdateWebhookRequestBodyStatus(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateWebhookRequestBodyStatus + && this.string.equals(((UpdateWebhookRequestBodyStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case INACTIVE: + return visitor.visitInactive(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateWebhookRequestBodyStatus valueOf(String value) { + switch (value) { + case "inactive": + return INACTIVE; + case "active": + return ACTIVE; + default: + return new UpdateWebhookRequestBodyStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + INACTIVE, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitInactive(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookResponse.java b/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookResponse.java index 9f94716..53d451e 100644 --- a/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookResponse.java +++ b/src/main/java/com/schematic/api/resources/webhooks/types/UpdateWebhookResponse.java @@ -87,6 +87,9 @@ public interface DataStage { public interface _FinalStage { UpdateWebhookResponse build(); + /** + *

Input parameters

+ */ _FinalStage params(Map params); _FinalStage putAllParams(Map params); @@ -135,15 +138,22 @@ public _FinalStage params(String key, JsonNode value) { */ @java.lang.Override public _FinalStage putAllParams(Map params) { - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } + /** + *

Input parameters

+ */ @java.lang.Override @JsonSetter(value = "params", nulls = Nulls.SKIP) public _FinalStage params(Map params) { this.params.clear(); - this.params.putAll(params); + if (params != null) { + this.params.putAll(params); + } return this; } diff --git a/src/main/java/com/schematic/api/types/ApiError.java b/src/main/java/com/schematic/api/types/ApiError.java index 5643bf1..e4e4841 100644 --- a/src/main/java/com/schematic/api/types/ApiError.java +++ b/src/main/java/com/schematic/api/types/ApiError.java @@ -66,6 +66,9 @@ public static ErrorStage builder() { } public interface ErrorStage { + /** + *

Error message

+ */ _FinalStage error(@NotNull String error); Builder from(ApiError other); @@ -91,6 +94,7 @@ public Builder from(ApiError other) { } /** + *

Error message

*

Error message

* @return Reference to {@code this} so that method calls can be chained together. */ diff --git a/src/main/java/com/schematic/api/types/ApiKeyCreateResponseData.java b/src/main/java/com/schematic/api/types/ApiKeyCreateResponseData.java index f503e7b..fbc055f 100644 --- a/src/main/java/com/schematic/api/types/ApiKeyCreateResponseData.java +++ b/src/main/java/com/schematic/api/types/ApiKeyCreateResponseData.java @@ -279,7 +279,9 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { @java.lang.Override public _FinalStage addAllScopes(List scopes) { - this.scopes.addAll(scopes); + if (scopes != null) { + this.scopes.addAll(scopes); + } return this; } @@ -293,7 +295,9 @@ public _FinalStage addScopes(String scopes) { @JsonSetter(value = "scopes", nulls = Nulls.SKIP) public _FinalStage scopes(List scopes) { this.scopes.clear(); - this.scopes.addAll(scopes); + if (scopes != null) { + this.scopes.addAll(scopes); + } return this; } diff --git a/src/main/java/com/schematic/api/types/ApiKeyRequestResponseData.java b/src/main/java/com/schematic/api/types/ApiKeyRequestResponseData.java index 1b6ff57..20b4b89 100644 --- a/src/main/java/com/schematic/api/types/ApiKeyRequestResponseData.java +++ b/src/main/java/com/schematic/api/types/ApiKeyRequestResponseData.java @@ -22,6 +22,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ApiKeyRequestResponseData.Builder.class) public final class ApiKeyRequestResponseData { + private final Optional apiKey; + private final String apiKeyId; private final Optional endedAt; @@ -63,6 +65,7 @@ public final class ApiKeyRequestResponseData { private final Map additionalProperties; private ApiKeyRequestResponseData( + Optional apiKey, String apiKeyId, Optional endedAt, Optional environmentId, @@ -83,6 +86,7 @@ private ApiKeyRequestResponseData( Optional userId, Optional userName, Map additionalProperties) { + this.apiKey = apiKey; this.apiKeyId = apiKeyId; this.endedAt = endedAt; this.environmentId = environmentId; @@ -105,6 +109,11 @@ private ApiKeyRequestResponseData( this.additionalProperties = additionalProperties; } + @JsonProperty("api_key") + public Optional getApiKey() { + return apiKey; + } + @JsonProperty("api_key_id") public String getApiKeyId() { return apiKeyId; @@ -212,7 +221,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(ApiKeyRequestResponseData other) { - return apiKeyId.equals(other.apiKeyId) + return apiKey.equals(other.apiKey) + && apiKeyId.equals(other.apiKeyId) && endedAt.equals(other.endedAt) && environmentId.equals(other.environmentId) && id.equals(other.id) @@ -236,6 +246,7 @@ private boolean equalTo(ApiKeyRequestResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.apiKey, this.apiKeyId, this.endedAt, this.environmentId, @@ -291,6 +302,10 @@ public interface UrlStage { public interface _FinalStage { ApiKeyRequestResponseData build(); + _FinalStage apiKey(Optional apiKey); + + _FinalStage apiKey(ApiKeyResponseData apiKey); + _FinalStage endedAt(Optional endedAt); _FinalStage endedAt(OffsetDateTime endedAt); @@ -389,6 +404,8 @@ public static final class Builder private Optional endedAt = Optional.empty(); + private Optional apiKey = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -396,6 +413,7 @@ private Builder() {} @java.lang.Override public Builder from(ApiKeyRequestResponseData other) { + apiKey(other.getApiKey()); apiKeyId(other.getApiKeyId()); endedAt(other.getEndedAt()); environmentId(other.getEnvironmentId()); @@ -635,9 +653,23 @@ public _FinalStage endedAt(Optional endedAt) { return this; } + @java.lang.Override + public _FinalStage apiKey(ApiKeyResponseData apiKey) { + this.apiKey = Optional.ofNullable(apiKey); + return this; + } + + @java.lang.Override + @JsonSetter(value = "api_key", nulls = Nulls.SKIP) + public _FinalStage apiKey(Optional apiKey) { + this.apiKey = apiKey; + return this; + } + @java.lang.Override public ApiKeyRequestResponseData build() { return new ApiKeyRequestResponseData( + apiKey, apiKeyId, endedAt, environmentId, diff --git a/src/main/java/com/schematic/api/types/ApiKeyResponseData.java b/src/main/java/com/schematic/api/types/ApiKeyResponseData.java index 80a1f55..292ef9f 100644 --- a/src/main/java/com/schematic/api/types/ApiKeyResponseData.java +++ b/src/main/java/com/schematic/api/types/ApiKeyResponseData.java @@ -253,7 +253,9 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { @java.lang.Override public _FinalStage addAllScopes(List scopes) { - this.scopes.addAll(scopes); + if (scopes != null) { + this.scopes.addAll(scopes); + } return this; } @@ -267,7 +269,9 @@ public _FinalStage addScopes(String scopes) { @JsonSetter(value = "scopes", nulls = Nulls.SKIP) public _FinalStage scopes(List scopes) { this.scopes.clear(); - this.scopes.addAll(scopes); + if (scopes != null) { + this.scopes.addAll(scopes); + } return this; } diff --git a/src/main/java/com/schematic/api/types/BillingCouponResponseData.java b/src/main/java/com/schematic/api/types/BillingCouponResponseData.java index bc30aa3..0829f1f 100644 --- a/src/main/java/com/schematic/api/types/BillingCouponResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingCouponResponseData.java @@ -48,7 +48,7 @@ public final class BillingCouponResponseData { private final String name; - private final Optional percentOff; + private final Optional percentOff; private final int timesRedeemed; @@ -71,7 +71,7 @@ private BillingCouponResponseData( Optional maxRedemptions, Map metadata, String name, - Optional percentOff, + Optional percentOff, int timesRedeemed, Optional validFrom, Optional validUntil, @@ -156,7 +156,7 @@ public String getName() { } @JsonProperty("percent_off") - public Optional getPercentOff() { + public Optional getPercentOff() { return percentOff; } @@ -294,9 +294,9 @@ public interface _FinalStage { _FinalStage metadata(String key, JsonNode value); - _FinalStage percentOff(Optional percentOff); + _FinalStage percentOff(Optional percentOff); - _FinalStage percentOff(Integer percentOff); + _FinalStage percentOff(Double percentOff); _FinalStage validFrom(Optional validFrom); @@ -335,7 +335,7 @@ public static final class Builder private Optional validFrom = Optional.empty(); - private Optional percentOff = Optional.empty(); + private Optional percentOff = Optional.empty(); private Map metadata = new LinkedHashMap<>(); @@ -451,14 +451,14 @@ public _FinalStage validFrom(Optional validFrom) { } @java.lang.Override - public _FinalStage percentOff(Integer percentOff) { + public _FinalStage percentOff(Double percentOff) { this.percentOff = Optional.ofNullable(percentOff); return this; } @java.lang.Override @JsonSetter(value = "percent_off", nulls = Nulls.SKIP) - public _FinalStage percentOff(Optional percentOff) { + public _FinalStage percentOff(Optional percentOff) { this.percentOff = percentOff; return this; } @@ -471,7 +471,9 @@ public _FinalStage metadata(String key, JsonNode value) { @java.lang.Override public _FinalStage putAllMetadata(Map metadata) { - this.metadata.putAll(metadata); + if (metadata != null) { + this.metadata.putAll(metadata); + } return this; } @@ -479,7 +481,9 @@ public _FinalStage putAllMetadata(Map metadata) { @JsonSetter(value = "metadata", nulls = Nulls.SKIP) public _FinalStage metadata(Map metadata) { this.metadata.clear(); - this.metadata.putAll(metadata); + if (metadata != null) { + this.metadata.putAll(metadata); + } return this; } diff --git a/src/main/java/com/schematic/api/types/BillingCreditBundleResponseData.java b/src/main/java/com/schematic/api/types/BillingCreditBundleResponseData.java new file mode 100644 index 0000000..79d696e --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingCreditBundleResponseData.java @@ -0,0 +1,670 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingCreditBundleResponseData.Builder.class) +public final class BillingCreditBundleResponseData { + private final Optional billingInvoiceId; + + private final String bundleType; + + private final OffsetDateTime createdAt; + + private final Optional creditDescription; + + private final Optional creditIcon; + + private final String creditId; + + private final String creditName; + + private final String expiryType; + + private final String expiryUnit; + + private final Optional expiryUnitCount; + + private final boolean hasGrants; + + private final String id; + + private final String name; + + private final Optional pluralName; + + private final Optional price; + + private final Optional quantity; + + private final Optional singularName; + + private final String status; + + private final Optional unitPrice; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private BillingCreditBundleResponseData( + Optional billingInvoiceId, + String bundleType, + OffsetDateTime createdAt, + Optional creditDescription, + Optional creditIcon, + String creditId, + String creditName, + String expiryType, + String expiryUnit, + Optional expiryUnitCount, + boolean hasGrants, + String id, + String name, + Optional pluralName, + Optional price, + Optional quantity, + Optional singularName, + String status, + Optional unitPrice, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.billingInvoiceId = billingInvoiceId; + this.bundleType = bundleType; + this.createdAt = createdAt; + this.creditDescription = creditDescription; + this.creditIcon = creditIcon; + this.creditId = creditId; + this.creditName = creditName; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.hasGrants = hasGrants; + this.id = id; + this.name = name; + this.pluralName = pluralName; + this.price = price; + this.quantity = quantity; + this.singularName = singularName; + this.status = status; + this.unitPrice = unitPrice; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_invoice_id") + public Optional getBillingInvoiceId() { + return billingInvoiceId; + } + + @JsonProperty("bundle_type") + public String getBundleType() { + return bundleType; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("credit_description") + public Optional getCreditDescription() { + return creditDescription; + } + + @JsonProperty("credit_icon") + public Optional getCreditIcon() { + return creditIcon; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @JsonProperty("credit_name") + public String getCreditName() { + return creditName; + } + + @JsonProperty("expiry_type") + public String getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public String getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("has_grants") + public boolean getHasGrants() { + return hasGrants; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("plural_name") + public Optional getPluralName() { + return pluralName; + } + + @JsonProperty("price") + public Optional getPrice() { + return price; + } + + @JsonProperty("quantity") + public Optional getQuantity() { + return quantity; + } + + @JsonProperty("singular_name") + public Optional getSingularName() { + return singularName; + } + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @JsonProperty("unit_price") + public Optional getUnitPrice() { + return unitPrice; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingCreditBundleResponseData && equalTo((BillingCreditBundleResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingCreditBundleResponseData other) { + return billingInvoiceId.equals(other.billingInvoiceId) + && bundleType.equals(other.bundleType) + && createdAt.equals(other.createdAt) + && creditDescription.equals(other.creditDescription) + && creditIcon.equals(other.creditIcon) + && creditId.equals(other.creditId) + && creditName.equals(other.creditName) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && hasGrants == other.hasGrants + && id.equals(other.id) + && name.equals(other.name) + && pluralName.equals(other.pluralName) + && price.equals(other.price) + && quantity.equals(other.quantity) + && singularName.equals(other.singularName) + && status.equals(other.status) + && unitPrice.equals(other.unitPrice) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingInvoiceId, + this.bundleType, + this.createdAt, + this.creditDescription, + this.creditIcon, + this.creditId, + this.creditName, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.hasGrants, + this.id, + this.name, + this.pluralName, + this.price, + this.quantity, + this.singularName, + this.status, + this.unitPrice, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BundleTypeStage builder() { + return new Builder(); + } + + public interface BundleTypeStage { + CreatedAtStage bundleType(@NotNull String bundleType); + + Builder from(BillingCreditBundleResponseData other); + } + + public interface CreatedAtStage { + CreditIdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface CreditIdStage { + CreditNameStage creditId(@NotNull String creditId); + } + + public interface CreditNameStage { + ExpiryTypeStage creditName(@NotNull String creditName); + } + + public interface ExpiryTypeStage { + ExpiryUnitStage expiryType(@NotNull String expiryType); + } + + public interface ExpiryUnitStage { + HasGrantsStage expiryUnit(@NotNull String expiryUnit); + } + + public interface HasGrantsStage { + IdStage hasGrants(boolean hasGrants); + } + + public interface IdStage { + NameStage id(@NotNull String id); + } + + public interface NameStage { + StatusStage name(@NotNull String name); + } + + public interface StatusStage { + UpdatedAtStage status(@NotNull String status); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + BillingCreditBundleResponseData build(); + + _FinalStage billingInvoiceId(Optional billingInvoiceId); + + _FinalStage billingInvoiceId(String billingInvoiceId); + + _FinalStage creditDescription(Optional creditDescription); + + _FinalStage creditDescription(String creditDescription); + + _FinalStage creditIcon(Optional creditIcon); + + _FinalStage creditIcon(String creditIcon); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + + _FinalStage pluralName(Optional pluralName); + + _FinalStage pluralName(String pluralName); + + _FinalStage price(Optional price); + + _FinalStage price(BillingPriceResponseData price); + + _FinalStage quantity(Optional quantity); + + _FinalStage quantity(Integer quantity); + + _FinalStage singularName(Optional singularName); + + _FinalStage singularName(String singularName); + + _FinalStage unitPrice(Optional unitPrice); + + _FinalStage unitPrice(BillingPriceResponseData unitPrice); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements BundleTypeStage, + CreatedAtStage, + CreditIdStage, + CreditNameStage, + ExpiryTypeStage, + ExpiryUnitStage, + HasGrantsStage, + IdStage, + NameStage, + StatusStage, + UpdatedAtStage, + _FinalStage { + private String bundleType; + + private OffsetDateTime createdAt; + + private String creditId; + + private String creditName; + + private String expiryType; + + private String expiryUnit; + + private boolean hasGrants; + + private String id; + + private String name; + + private String status; + + private OffsetDateTime updatedAt; + + private Optional unitPrice = Optional.empty(); + + private Optional singularName = Optional.empty(); + + private Optional quantity = Optional.empty(); + + private Optional price = Optional.empty(); + + private Optional pluralName = Optional.empty(); + + private Optional expiryUnitCount = Optional.empty(); + + private Optional creditIcon = Optional.empty(); + + private Optional creditDescription = Optional.empty(); + + private Optional billingInvoiceId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingCreditBundleResponseData other) { + billingInvoiceId(other.getBillingInvoiceId()); + bundleType(other.getBundleType()); + createdAt(other.getCreatedAt()); + creditDescription(other.getCreditDescription()); + creditIcon(other.getCreditIcon()); + creditId(other.getCreditId()); + creditName(other.getCreditName()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + hasGrants(other.getHasGrants()); + id(other.getId()); + name(other.getName()); + pluralName(other.getPluralName()); + price(other.getPrice()); + quantity(other.getQuantity()); + singularName(other.getSingularName()); + status(other.getStatus()); + unitPrice(other.getUnitPrice()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("bundle_type") + public CreatedAtStage bundleType(@NotNull String bundleType) { + this.bundleType = Objects.requireNonNull(bundleType, "bundleType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public CreditIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public CreditNameStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_name") + public ExpiryTypeStage creditName(@NotNull String creditName) { + this.creditName = Objects.requireNonNull(creditName, "creditName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("expiry_type") + public ExpiryUnitStage expiryType(@NotNull String expiryType) { + this.expiryType = Objects.requireNonNull(expiryType, "expiryType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("expiry_unit") + public HasGrantsStage expiryUnit(@NotNull String expiryUnit) { + this.expiryUnit = Objects.requireNonNull(expiryUnit, "expiryUnit must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("has_grants") + public IdStage hasGrants(boolean hasGrants) { + this.hasGrants = hasGrants; + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public StatusStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("status") + public UpdatedAtStage status(@NotNull String status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage unitPrice(BillingPriceResponseData unitPrice) { + this.unitPrice = Optional.ofNullable(unitPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "unit_price", nulls = Nulls.SKIP) + public _FinalStage unitPrice(Optional unitPrice) { + this.unitPrice = unitPrice; + return this; + } + + @java.lang.Override + public _FinalStage singularName(String singularName) { + this.singularName = Optional.ofNullable(singularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "singular_name", nulls = Nulls.SKIP) + public _FinalStage singularName(Optional singularName) { + this.singularName = singularName; + return this; + } + + @java.lang.Override + public _FinalStage quantity(Integer quantity) { + this.quantity = Optional.ofNullable(quantity); + return this; + } + + @java.lang.Override + @JsonSetter(value = "quantity", nulls = Nulls.SKIP) + public _FinalStage quantity(Optional quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + public _FinalStage price(BillingPriceResponseData price) { + this.price = Optional.ofNullable(price); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price", nulls = Nulls.SKIP) + public _FinalStage price(Optional price) { + this.price = price; + return this; + } + + @java.lang.Override + public _FinalStage pluralName(String pluralName) { + this.pluralName = Optional.ofNullable(pluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plural_name", nulls = Nulls.SKIP) + public _FinalStage pluralName(Optional pluralName) { + this.pluralName = pluralName; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage creditIcon(String creditIcon) { + this.creditIcon = Optional.ofNullable(creditIcon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_icon", nulls = Nulls.SKIP) + public _FinalStage creditIcon(Optional creditIcon) { + this.creditIcon = creditIcon; + return this; + } + + @java.lang.Override + public _FinalStage creditDescription(String creditDescription) { + this.creditDescription = Optional.ofNullable(creditDescription); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_description", nulls = Nulls.SKIP) + public _FinalStage creditDescription(Optional creditDescription) { + this.creditDescription = creditDescription; + return this; + } + + @java.lang.Override + public _FinalStage billingInvoiceId(String billingInvoiceId) { + this.billingInvoiceId = Optional.ofNullable(billingInvoiceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_invoice_id", nulls = Nulls.SKIP) + public _FinalStage billingInvoiceId(Optional billingInvoiceId) { + this.billingInvoiceId = billingInvoiceId; + return this; + } + + @java.lang.Override + public BillingCreditBundleResponseData build() { + return new BillingCreditBundleResponseData( + billingInvoiceId, + bundleType, + createdAt, + creditDescription, + creditIcon, + creditId, + creditName, + expiryType, + expiryUnit, + expiryUnitCount, + hasGrants, + id, + name, + pluralName, + price, + quantity, + singularName, + status, + unitPrice, + updatedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingCreditBundleView.java b/src/main/java/com/schematic/api/types/BillingCreditBundleView.java new file mode 100644 index 0000000..401c6b5 --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingCreditBundleView.java @@ -0,0 +1,670 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingCreditBundleView.Builder.class) +public final class BillingCreditBundleView { + private final Optional billingInvoiceId; + + private final String bundleType; + + private final OffsetDateTime createdAt; + + private final Optional creditDescription; + + private final Optional creditIcon; + + private final String creditId; + + private final String creditName; + + private final String expiryType; + + private final String expiryUnit; + + private final Optional expiryUnitCount; + + private final boolean hasGrants; + + private final String id; + + private final String name; + + private final Optional pluralName; + + private final Optional price; + + private final Optional quantity; + + private final Optional singularName; + + private final String status; + + private final Optional unitPrice; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private BillingCreditBundleView( + Optional billingInvoiceId, + String bundleType, + OffsetDateTime createdAt, + Optional creditDescription, + Optional creditIcon, + String creditId, + String creditName, + String expiryType, + String expiryUnit, + Optional expiryUnitCount, + boolean hasGrants, + String id, + String name, + Optional pluralName, + Optional price, + Optional quantity, + Optional singularName, + String status, + Optional unitPrice, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.billingInvoiceId = billingInvoiceId; + this.bundleType = bundleType; + this.createdAt = createdAt; + this.creditDescription = creditDescription; + this.creditIcon = creditIcon; + this.creditId = creditId; + this.creditName = creditName; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.hasGrants = hasGrants; + this.id = id; + this.name = name; + this.pluralName = pluralName; + this.price = price; + this.quantity = quantity; + this.singularName = singularName; + this.status = status; + this.unitPrice = unitPrice; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_invoice_id") + public Optional getBillingInvoiceId() { + return billingInvoiceId; + } + + @JsonProperty("bundle_type") + public String getBundleType() { + return bundleType; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("credit_description") + public Optional getCreditDescription() { + return creditDescription; + } + + @JsonProperty("credit_icon") + public Optional getCreditIcon() { + return creditIcon; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @JsonProperty("credit_name") + public String getCreditName() { + return creditName; + } + + @JsonProperty("expiry_type") + public String getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public String getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("has_grants") + public boolean getHasGrants() { + return hasGrants; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("plural_name") + public Optional getPluralName() { + return pluralName; + } + + @JsonProperty("price") + public Optional getPrice() { + return price; + } + + @JsonProperty("quantity") + public Optional getQuantity() { + return quantity; + } + + @JsonProperty("singular_name") + public Optional getSingularName() { + return singularName; + } + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @JsonProperty("unit_price") + public Optional getUnitPrice() { + return unitPrice; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingCreditBundleView && equalTo((BillingCreditBundleView) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingCreditBundleView other) { + return billingInvoiceId.equals(other.billingInvoiceId) + && bundleType.equals(other.bundleType) + && createdAt.equals(other.createdAt) + && creditDescription.equals(other.creditDescription) + && creditIcon.equals(other.creditIcon) + && creditId.equals(other.creditId) + && creditName.equals(other.creditName) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && hasGrants == other.hasGrants + && id.equals(other.id) + && name.equals(other.name) + && pluralName.equals(other.pluralName) + && price.equals(other.price) + && quantity.equals(other.quantity) + && singularName.equals(other.singularName) + && status.equals(other.status) + && unitPrice.equals(other.unitPrice) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingInvoiceId, + this.bundleType, + this.createdAt, + this.creditDescription, + this.creditIcon, + this.creditId, + this.creditName, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.hasGrants, + this.id, + this.name, + this.pluralName, + this.price, + this.quantity, + this.singularName, + this.status, + this.unitPrice, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BundleTypeStage builder() { + return new Builder(); + } + + public interface BundleTypeStage { + CreatedAtStage bundleType(@NotNull String bundleType); + + Builder from(BillingCreditBundleView other); + } + + public interface CreatedAtStage { + CreditIdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface CreditIdStage { + CreditNameStage creditId(@NotNull String creditId); + } + + public interface CreditNameStage { + ExpiryTypeStage creditName(@NotNull String creditName); + } + + public interface ExpiryTypeStage { + ExpiryUnitStage expiryType(@NotNull String expiryType); + } + + public interface ExpiryUnitStage { + HasGrantsStage expiryUnit(@NotNull String expiryUnit); + } + + public interface HasGrantsStage { + IdStage hasGrants(boolean hasGrants); + } + + public interface IdStage { + NameStage id(@NotNull String id); + } + + public interface NameStage { + StatusStage name(@NotNull String name); + } + + public interface StatusStage { + UpdatedAtStage status(@NotNull String status); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + BillingCreditBundleView build(); + + _FinalStage billingInvoiceId(Optional billingInvoiceId); + + _FinalStage billingInvoiceId(String billingInvoiceId); + + _FinalStage creditDescription(Optional creditDescription); + + _FinalStage creditDescription(String creditDescription); + + _FinalStage creditIcon(Optional creditIcon); + + _FinalStage creditIcon(String creditIcon); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + + _FinalStage pluralName(Optional pluralName); + + _FinalStage pluralName(String pluralName); + + _FinalStage price(Optional price); + + _FinalStage price(BillingProductPriceResponseData price); + + _FinalStage quantity(Optional quantity); + + _FinalStage quantity(Integer quantity); + + _FinalStage singularName(Optional singularName); + + _FinalStage singularName(String singularName); + + _FinalStage unitPrice(Optional unitPrice); + + _FinalStage unitPrice(BillingProductPriceResponseData unitPrice); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements BundleTypeStage, + CreatedAtStage, + CreditIdStage, + CreditNameStage, + ExpiryTypeStage, + ExpiryUnitStage, + HasGrantsStage, + IdStage, + NameStage, + StatusStage, + UpdatedAtStage, + _FinalStage { + private String bundleType; + + private OffsetDateTime createdAt; + + private String creditId; + + private String creditName; + + private String expiryType; + + private String expiryUnit; + + private boolean hasGrants; + + private String id; + + private String name; + + private String status; + + private OffsetDateTime updatedAt; + + private Optional unitPrice = Optional.empty(); + + private Optional singularName = Optional.empty(); + + private Optional quantity = Optional.empty(); + + private Optional price = Optional.empty(); + + private Optional pluralName = Optional.empty(); + + private Optional expiryUnitCount = Optional.empty(); + + private Optional creditIcon = Optional.empty(); + + private Optional creditDescription = Optional.empty(); + + private Optional billingInvoiceId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingCreditBundleView other) { + billingInvoiceId(other.getBillingInvoiceId()); + bundleType(other.getBundleType()); + createdAt(other.getCreatedAt()); + creditDescription(other.getCreditDescription()); + creditIcon(other.getCreditIcon()); + creditId(other.getCreditId()); + creditName(other.getCreditName()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + hasGrants(other.getHasGrants()); + id(other.getId()); + name(other.getName()); + pluralName(other.getPluralName()); + price(other.getPrice()); + quantity(other.getQuantity()); + singularName(other.getSingularName()); + status(other.getStatus()); + unitPrice(other.getUnitPrice()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("bundle_type") + public CreatedAtStage bundleType(@NotNull String bundleType) { + this.bundleType = Objects.requireNonNull(bundleType, "bundleType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public CreditIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public CreditNameStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_name") + public ExpiryTypeStage creditName(@NotNull String creditName) { + this.creditName = Objects.requireNonNull(creditName, "creditName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("expiry_type") + public ExpiryUnitStage expiryType(@NotNull String expiryType) { + this.expiryType = Objects.requireNonNull(expiryType, "expiryType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("expiry_unit") + public HasGrantsStage expiryUnit(@NotNull String expiryUnit) { + this.expiryUnit = Objects.requireNonNull(expiryUnit, "expiryUnit must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("has_grants") + public IdStage hasGrants(boolean hasGrants) { + this.hasGrants = hasGrants; + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public StatusStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("status") + public UpdatedAtStage status(@NotNull String status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage unitPrice(BillingProductPriceResponseData unitPrice) { + this.unitPrice = Optional.ofNullable(unitPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "unit_price", nulls = Nulls.SKIP) + public _FinalStage unitPrice(Optional unitPrice) { + this.unitPrice = unitPrice; + return this; + } + + @java.lang.Override + public _FinalStage singularName(String singularName) { + this.singularName = Optional.ofNullable(singularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "singular_name", nulls = Nulls.SKIP) + public _FinalStage singularName(Optional singularName) { + this.singularName = singularName; + return this; + } + + @java.lang.Override + public _FinalStage quantity(Integer quantity) { + this.quantity = Optional.ofNullable(quantity); + return this; + } + + @java.lang.Override + @JsonSetter(value = "quantity", nulls = Nulls.SKIP) + public _FinalStage quantity(Optional quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + public _FinalStage price(BillingProductPriceResponseData price) { + this.price = Optional.ofNullable(price); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price", nulls = Nulls.SKIP) + public _FinalStage price(Optional price) { + this.price = price; + return this; + } + + @java.lang.Override + public _FinalStage pluralName(String pluralName) { + this.pluralName = Optional.ofNullable(pluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plural_name", nulls = Nulls.SKIP) + public _FinalStage pluralName(Optional pluralName) { + this.pluralName = pluralName; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage creditIcon(String creditIcon) { + this.creditIcon = Optional.ofNullable(creditIcon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_icon", nulls = Nulls.SKIP) + public _FinalStage creditIcon(Optional creditIcon) { + this.creditIcon = creditIcon; + return this; + } + + @java.lang.Override + public _FinalStage creditDescription(String creditDescription) { + this.creditDescription = Optional.ofNullable(creditDescription); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_description", nulls = Nulls.SKIP) + public _FinalStage creditDescription(Optional creditDescription) { + this.creditDescription = creditDescription; + return this; + } + + @java.lang.Override + public _FinalStage billingInvoiceId(String billingInvoiceId) { + this.billingInvoiceId = Optional.ofNullable(billingInvoiceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_invoice_id", nulls = Nulls.SKIP) + public _FinalStage billingInvoiceId(Optional billingInvoiceId) { + this.billingInvoiceId = billingInvoiceId; + return this; + } + + @java.lang.Override + public BillingCreditBundleView build() { + return new BillingCreditBundleView( + billingInvoiceId, + bundleType, + createdAt, + creditDescription, + creditIcon, + creditId, + creditName, + expiryType, + expiryUnit, + expiryUnitCount, + hasGrants, + id, + name, + pluralName, + price, + quantity, + singularName, + status, + unitPrice, + updatedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingCreditGrantResponseData.java b/src/main/java/com/schematic/api/types/BillingCreditGrantResponseData.java new file mode 100644 index 0000000..7d9975c --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingCreditGrantResponseData.java @@ -0,0 +1,665 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingCreditGrantResponseData.Builder.class) +public final class BillingCreditGrantResponseData { + private final String companyId; + + private final String companyName; + + private final OffsetDateTime createdAt; + + private final Optional creditIcon; + + private final String creditId; + + private final String creditName; + + private final Optional expiresAt; + + private final String grantReason; + + private final String id; + + private final Optional planId; + + private final Optional planName; + + private final Optional price; + + private final int quantity; + + private final double quantityRemaining; + + private final double quantityUsed; + + private final String sourceLabel; + + private final OffsetDateTime updatedAt; + + private final Optional validFrom; + + private final Optional zeroedOutDate; + + private final Optional zeroedOutReason; + + private final Map additionalProperties; + + private BillingCreditGrantResponseData( + String companyId, + String companyName, + OffsetDateTime createdAt, + Optional creditIcon, + String creditId, + String creditName, + Optional expiresAt, + String grantReason, + String id, + Optional planId, + Optional planName, + Optional price, + int quantity, + double quantityRemaining, + double quantityUsed, + String sourceLabel, + OffsetDateTime updatedAt, + Optional validFrom, + Optional zeroedOutDate, + Optional zeroedOutReason, + Map additionalProperties) { + this.companyId = companyId; + this.companyName = companyName; + this.createdAt = createdAt; + this.creditIcon = creditIcon; + this.creditId = creditId; + this.creditName = creditName; + this.expiresAt = expiresAt; + this.grantReason = grantReason; + this.id = id; + this.planId = planId; + this.planName = planName; + this.price = price; + this.quantity = quantity; + this.quantityRemaining = quantityRemaining; + this.quantityUsed = quantityUsed; + this.sourceLabel = sourceLabel; + this.updatedAt = updatedAt; + this.validFrom = validFrom; + this.zeroedOutDate = zeroedOutDate; + this.zeroedOutReason = zeroedOutReason; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("company_name") + public String getCompanyName() { + return companyName; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("credit_icon") + public Optional getCreditIcon() { + return creditIcon; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @JsonProperty("credit_name") + public String getCreditName() { + return creditName; + } + + @JsonProperty("expires_at") + public Optional getExpiresAt() { + return expiresAt; + } + + @JsonProperty("grant_reason") + public String getGrantReason() { + return grantReason; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @JsonProperty("plan_name") + public Optional getPlanName() { + return planName; + } + + @JsonProperty("price") + public Optional getPrice() { + return price; + } + + @JsonProperty("quantity") + public int getQuantity() { + return quantity; + } + + @JsonProperty("quantity_remaining") + public double getQuantityRemaining() { + return quantityRemaining; + } + + @JsonProperty("quantity_used") + public double getQuantityUsed() { + return quantityUsed; + } + + @JsonProperty("source_label") + public String getSourceLabel() { + return sourceLabel; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("valid_from") + public Optional getValidFrom() { + return validFrom; + } + + @JsonProperty("zeroed_out_date") + public Optional getZeroedOutDate() { + return zeroedOutDate; + } + + @JsonProperty("zeroed_out_reason") + public Optional getZeroedOutReason() { + return zeroedOutReason; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingCreditGrantResponseData && equalTo((BillingCreditGrantResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingCreditGrantResponseData other) { + return companyId.equals(other.companyId) + && companyName.equals(other.companyName) + && createdAt.equals(other.createdAt) + && creditIcon.equals(other.creditIcon) + && creditId.equals(other.creditId) + && creditName.equals(other.creditName) + && expiresAt.equals(other.expiresAt) + && grantReason.equals(other.grantReason) + && id.equals(other.id) + && planId.equals(other.planId) + && planName.equals(other.planName) + && price.equals(other.price) + && quantity == other.quantity + && quantityRemaining == other.quantityRemaining + && quantityUsed == other.quantityUsed + && sourceLabel.equals(other.sourceLabel) + && updatedAt.equals(other.updatedAt) + && validFrom.equals(other.validFrom) + && zeroedOutDate.equals(other.zeroedOutDate) + && zeroedOutReason.equals(other.zeroedOutReason); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.companyId, + this.companyName, + this.createdAt, + this.creditIcon, + this.creditId, + this.creditName, + this.expiresAt, + this.grantReason, + this.id, + this.planId, + this.planName, + this.price, + this.quantity, + this.quantityRemaining, + this.quantityUsed, + this.sourceLabel, + this.updatedAt, + this.validFrom, + this.zeroedOutDate, + this.zeroedOutReason); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + CompanyNameStage companyId(@NotNull String companyId); + + Builder from(BillingCreditGrantResponseData other); + } + + public interface CompanyNameStage { + CreatedAtStage companyName(@NotNull String companyName); + } + + public interface CreatedAtStage { + CreditIdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface CreditIdStage { + CreditNameStage creditId(@NotNull String creditId); + } + + public interface CreditNameStage { + GrantReasonStage creditName(@NotNull String creditName); + } + + public interface GrantReasonStage { + IdStage grantReason(@NotNull String grantReason); + } + + public interface IdStage { + QuantityStage id(@NotNull String id); + } + + public interface QuantityStage { + QuantityRemainingStage quantity(int quantity); + } + + public interface QuantityRemainingStage { + QuantityUsedStage quantityRemaining(double quantityRemaining); + } + + public interface QuantityUsedStage { + SourceLabelStage quantityUsed(double quantityUsed); + } + + public interface SourceLabelStage { + UpdatedAtStage sourceLabel(@NotNull String sourceLabel); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + BillingCreditGrantResponseData build(); + + _FinalStage creditIcon(Optional creditIcon); + + _FinalStage creditIcon(String creditIcon); + + _FinalStage expiresAt(Optional expiresAt); + + _FinalStage expiresAt(OffsetDateTime expiresAt); + + _FinalStage planId(Optional planId); + + _FinalStage planId(String planId); + + _FinalStage planName(Optional planName); + + _FinalStage planName(String planName); + + _FinalStage price(Optional price); + + _FinalStage price(BillingPriceResponseData price); + + _FinalStage validFrom(Optional validFrom); + + _FinalStage validFrom(OffsetDateTime validFrom); + + _FinalStage zeroedOutDate(Optional zeroedOutDate); + + _FinalStage zeroedOutDate(OffsetDateTime zeroedOutDate); + + _FinalStage zeroedOutReason(Optional zeroedOutReason); + + _FinalStage zeroedOutReason(String zeroedOutReason); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CompanyIdStage, + CompanyNameStage, + CreatedAtStage, + CreditIdStage, + CreditNameStage, + GrantReasonStage, + IdStage, + QuantityStage, + QuantityRemainingStage, + QuantityUsedStage, + SourceLabelStage, + UpdatedAtStage, + _FinalStage { + private String companyId; + + private String companyName; + + private OffsetDateTime createdAt; + + private String creditId; + + private String creditName; + + private String grantReason; + + private String id; + + private int quantity; + + private double quantityRemaining; + + private double quantityUsed; + + private String sourceLabel; + + private OffsetDateTime updatedAt; + + private Optional zeroedOutReason = Optional.empty(); + + private Optional zeroedOutDate = Optional.empty(); + + private Optional validFrom = Optional.empty(); + + private Optional price = Optional.empty(); + + private Optional planName = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional expiresAt = Optional.empty(); + + private Optional creditIcon = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingCreditGrantResponseData other) { + companyId(other.getCompanyId()); + companyName(other.getCompanyName()); + createdAt(other.getCreatedAt()); + creditIcon(other.getCreditIcon()); + creditId(other.getCreditId()); + creditName(other.getCreditName()); + expiresAt(other.getExpiresAt()); + grantReason(other.getGrantReason()); + id(other.getId()); + planId(other.getPlanId()); + planName(other.getPlanName()); + price(other.getPrice()); + quantity(other.getQuantity()); + quantityRemaining(other.getQuantityRemaining()); + quantityUsed(other.getQuantityUsed()); + sourceLabel(other.getSourceLabel()); + updatedAt(other.getUpdatedAt()); + validFrom(other.getValidFrom()); + zeroedOutDate(other.getZeroedOutDate()); + zeroedOutReason(other.getZeroedOutReason()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public CompanyNameStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("company_name") + public CreatedAtStage companyName(@NotNull String companyName) { + this.companyName = Objects.requireNonNull(companyName, "companyName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public CreditIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public CreditNameStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_name") + public GrantReasonStage creditName(@NotNull String creditName) { + this.creditName = Objects.requireNonNull(creditName, "creditName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("grant_reason") + public IdStage grantReason(@NotNull String grantReason) { + this.grantReason = Objects.requireNonNull(grantReason, "grantReason must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public QuantityStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("quantity") + public QuantityRemainingStage quantity(int quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + @JsonSetter("quantity_remaining") + public QuantityUsedStage quantityRemaining(double quantityRemaining) { + this.quantityRemaining = quantityRemaining; + return this; + } + + @java.lang.Override + @JsonSetter("quantity_used") + public SourceLabelStage quantityUsed(double quantityUsed) { + this.quantityUsed = quantityUsed; + return this; + } + + @java.lang.Override + @JsonSetter("source_label") + public UpdatedAtStage sourceLabel(@NotNull String sourceLabel) { + this.sourceLabel = Objects.requireNonNull(sourceLabel, "sourceLabel must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage zeroedOutReason(String zeroedOutReason) { + this.zeroedOutReason = Optional.ofNullable(zeroedOutReason); + return this; + } + + @java.lang.Override + @JsonSetter(value = "zeroed_out_reason", nulls = Nulls.SKIP) + public _FinalStage zeroedOutReason(Optional zeroedOutReason) { + this.zeroedOutReason = zeroedOutReason; + return this; + } + + @java.lang.Override + public _FinalStage zeroedOutDate(OffsetDateTime zeroedOutDate) { + this.zeroedOutDate = Optional.ofNullable(zeroedOutDate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "zeroed_out_date", nulls = Nulls.SKIP) + public _FinalStage zeroedOutDate(Optional zeroedOutDate) { + this.zeroedOutDate = zeroedOutDate; + return this; + } + + @java.lang.Override + public _FinalStage validFrom(OffsetDateTime validFrom) { + this.validFrom = Optional.ofNullable(validFrom); + return this; + } + + @java.lang.Override + @JsonSetter(value = "valid_from", nulls = Nulls.SKIP) + public _FinalStage validFrom(Optional validFrom) { + this.validFrom = validFrom; + return this; + } + + @java.lang.Override + public _FinalStage price(BillingPriceResponseData price) { + this.price = Optional.ofNullable(price); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price", nulls = Nulls.SKIP) + public _FinalStage price(Optional price) { + this.price = price; + return this; + } + + @java.lang.Override + public _FinalStage planName(String planName) { + this.planName = Optional.ofNullable(planName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan_name", nulls = Nulls.SKIP) + public _FinalStage planName(Optional planName) { + this.planName = planName; + return this; + } + + @java.lang.Override + public _FinalStage planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public _FinalStage planId(Optional planId) { + this.planId = planId; + return this; + } + + @java.lang.Override + public _FinalStage expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = Optional.ofNullable(expiresAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) + public _FinalStage expiresAt(Optional expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + @java.lang.Override + public _FinalStage creditIcon(String creditIcon) { + this.creditIcon = Optional.ofNullable(creditIcon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_icon", nulls = Nulls.SKIP) + public _FinalStage creditIcon(Optional creditIcon) { + this.creditIcon = creditIcon; + return this; + } + + @java.lang.Override + public BillingCreditGrantResponseData build() { + return new BillingCreditGrantResponseData( + companyId, + companyName, + createdAt, + creditIcon, + creditId, + creditName, + expiresAt, + grantReason, + id, + planId, + planName, + price, + quantity, + quantityRemaining, + quantityUsed, + sourceLabel, + updatedAt, + validFrom, + zeroedOutDate, + zeroedOutReason, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingCreditLedgerResponseData.java b/src/main/java/com/schematic/api/types/BillingCreditLedgerResponseData.java new file mode 100644 index 0000000..5427992 --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingCreditLedgerResponseData.java @@ -0,0 +1,251 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingCreditLedgerResponseData.Builder.class) +public final class BillingCreditLedgerResponseData { + private final Optional description; + + private final Optional icon; + + private final String id; + + private final String name; + + private final Optional pluralName; + + private final Optional singularName; + + private final Map additionalProperties; + + private BillingCreditLedgerResponseData( + Optional description, + Optional icon, + String id, + String name, + Optional pluralName, + Optional singularName, + Map additionalProperties) { + this.description = description; + this.icon = icon; + this.id = id; + this.name = name; + this.pluralName = pluralName; + this.singularName = singularName; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("plural_name") + public Optional getPluralName() { + return pluralName; + } + + @JsonProperty("singular_name") + public Optional getSingularName() { + return singularName; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingCreditLedgerResponseData && equalTo((BillingCreditLedgerResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingCreditLedgerResponseData other) { + return description.equals(other.description) + && icon.equals(other.icon) + && id.equals(other.id) + && name.equals(other.name) + && pluralName.equals(other.pluralName) + && singularName.equals(other.singularName); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.description, this.icon, this.id, this.name, this.pluralName, this.singularName); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(BillingCreditLedgerResponseData other); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + BillingCreditLedgerResponseData build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage icon(Optional icon); + + _FinalStage icon(String icon); + + _FinalStage pluralName(Optional pluralName); + + _FinalStage pluralName(String pluralName); + + _FinalStage singularName(Optional singularName); + + _FinalStage singularName(String singularName); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, _FinalStage { + private String id; + + private String name; + + private Optional singularName = Optional.empty(); + + private Optional pluralName = Optional.empty(); + + private Optional icon = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingCreditLedgerResponseData other) { + description(other.getDescription()); + icon(other.getIcon()); + id(other.getId()); + name(other.getName()); + pluralName(other.getPluralName()); + singularName(other.getSingularName()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage singularName(String singularName) { + this.singularName = Optional.ofNullable(singularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "singular_name", nulls = Nulls.SKIP) + public _FinalStage singularName(Optional singularName) { + this.singularName = singularName; + return this; + } + + @java.lang.Override + public _FinalStage pluralName(String pluralName) { + this.pluralName = Optional.ofNullable(pluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plural_name", nulls = Nulls.SKIP) + public _FinalStage pluralName(Optional pluralName) { + this.pluralName = pluralName; + return this; + } + + @java.lang.Override + public _FinalStage icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public _FinalStage icon(Optional icon) { + this.icon = icon; + return this; + } + + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public BillingCreditLedgerResponseData build() { + return new BillingCreditLedgerResponseData( + description, icon, id, name, pluralName, singularName, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingCreditResponseData.java b/src/main/java/com/schematic/api/types/BillingCreditResponseData.java new file mode 100644 index 0000000..5ae6253 --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingCreditResponseData.java @@ -0,0 +1,494 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingCreditResponseData.Builder.class) +public final class BillingCreditResponseData { + private final String burnStrategy; + + private final OffsetDateTime createdAt; + + private final String defaultExpiryUnit; + + private final Optional defaultExpiryUnitCount; + + private final String defaultRolloverPolicy; + + private final String description; + + private final Optional icon; + + private final String id; + + private final String name; + + private final Optional pluralName; + + private final Optional price; + + private final Optional product; + + private final Optional singularName; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private BillingCreditResponseData( + String burnStrategy, + OffsetDateTime createdAt, + String defaultExpiryUnit, + Optional defaultExpiryUnitCount, + String defaultRolloverPolicy, + String description, + Optional icon, + String id, + String name, + Optional pluralName, + Optional price, + Optional product, + Optional singularName, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.burnStrategy = burnStrategy; + this.createdAt = createdAt; + this.defaultExpiryUnit = defaultExpiryUnit; + this.defaultExpiryUnitCount = defaultExpiryUnitCount; + this.defaultRolloverPolicy = defaultRolloverPolicy; + this.description = description; + this.icon = icon; + this.id = id; + this.name = name; + this.pluralName = pluralName; + this.price = price; + this.product = product; + this.singularName = singularName; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("burn_strategy") + public String getBurnStrategy() { + return burnStrategy; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("default_expiry_unit") + public String getDefaultExpiryUnit() { + return defaultExpiryUnit; + } + + @JsonProperty("default_expiry_unit_count") + public Optional getDefaultExpiryUnitCount() { + return defaultExpiryUnitCount; + } + + @JsonProperty("default_rollover_policy") + public String getDefaultRolloverPolicy() { + return defaultRolloverPolicy; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("plural_name") + public Optional getPluralName() { + return pluralName; + } + + @JsonProperty("price") + public Optional getPrice() { + return price; + } + + @JsonProperty("product") + public Optional getProduct() { + return product; + } + + @JsonProperty("singular_name") + public Optional getSingularName() { + return singularName; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingCreditResponseData && equalTo((BillingCreditResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingCreditResponseData other) { + return burnStrategy.equals(other.burnStrategy) + && createdAt.equals(other.createdAt) + && defaultExpiryUnit.equals(other.defaultExpiryUnit) + && defaultExpiryUnitCount.equals(other.defaultExpiryUnitCount) + && defaultRolloverPolicy.equals(other.defaultRolloverPolicy) + && description.equals(other.description) + && icon.equals(other.icon) + && id.equals(other.id) + && name.equals(other.name) + && pluralName.equals(other.pluralName) + && price.equals(other.price) + && product.equals(other.product) + && singularName.equals(other.singularName) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.burnStrategy, + this.createdAt, + this.defaultExpiryUnit, + this.defaultExpiryUnitCount, + this.defaultRolloverPolicy, + this.description, + this.icon, + this.id, + this.name, + this.pluralName, + this.price, + this.product, + this.singularName, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BurnStrategyStage builder() { + return new Builder(); + } + + public interface BurnStrategyStage { + CreatedAtStage burnStrategy(@NotNull String burnStrategy); + + Builder from(BillingCreditResponseData other); + } + + public interface CreatedAtStage { + DefaultExpiryUnitStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface DefaultExpiryUnitStage { + DefaultRolloverPolicyStage defaultExpiryUnit(@NotNull String defaultExpiryUnit); + } + + public interface DefaultRolloverPolicyStage { + DescriptionStage defaultRolloverPolicy(@NotNull String defaultRolloverPolicy); + } + + public interface DescriptionStage { + IdStage description(@NotNull String description); + } + + public interface IdStage { + NameStage id(@NotNull String id); + } + + public interface NameStage { + UpdatedAtStage name(@NotNull String name); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + BillingCreditResponseData build(); + + _FinalStage defaultExpiryUnitCount(Optional defaultExpiryUnitCount); + + _FinalStage defaultExpiryUnitCount(Integer defaultExpiryUnitCount); + + _FinalStage icon(Optional icon); + + _FinalStage icon(String icon); + + _FinalStage pluralName(Optional pluralName); + + _FinalStage pluralName(String pluralName); + + _FinalStage price(Optional price); + + _FinalStage price(BillingPriceResponseData price); + + _FinalStage product(Optional product); + + _FinalStage product(BillingProductResponseData product); + + _FinalStage singularName(Optional singularName); + + _FinalStage singularName(String singularName); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements BurnStrategyStage, + CreatedAtStage, + DefaultExpiryUnitStage, + DefaultRolloverPolicyStage, + DescriptionStage, + IdStage, + NameStage, + UpdatedAtStage, + _FinalStage { + private String burnStrategy; + + private OffsetDateTime createdAt; + + private String defaultExpiryUnit; + + private String defaultRolloverPolicy; + + private String description; + + private String id; + + private String name; + + private OffsetDateTime updatedAt; + + private Optional singularName = Optional.empty(); + + private Optional product = Optional.empty(); + + private Optional price = Optional.empty(); + + private Optional pluralName = Optional.empty(); + + private Optional icon = Optional.empty(); + + private Optional defaultExpiryUnitCount = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingCreditResponseData other) { + burnStrategy(other.getBurnStrategy()); + createdAt(other.getCreatedAt()); + defaultExpiryUnit(other.getDefaultExpiryUnit()); + defaultExpiryUnitCount(other.getDefaultExpiryUnitCount()); + defaultRolloverPolicy(other.getDefaultRolloverPolicy()); + description(other.getDescription()); + icon(other.getIcon()); + id(other.getId()); + name(other.getName()); + pluralName(other.getPluralName()); + price(other.getPrice()); + product(other.getProduct()); + singularName(other.getSingularName()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("burn_strategy") + public CreatedAtStage burnStrategy(@NotNull String burnStrategy) { + this.burnStrategy = Objects.requireNonNull(burnStrategy, "burnStrategy must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public DefaultExpiryUnitStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("default_expiry_unit") + public DefaultRolloverPolicyStage defaultExpiryUnit(@NotNull String defaultExpiryUnit) { + this.defaultExpiryUnit = Objects.requireNonNull(defaultExpiryUnit, "defaultExpiryUnit must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("default_rollover_policy") + public DescriptionStage defaultRolloverPolicy(@NotNull String defaultRolloverPolicy) { + this.defaultRolloverPolicy = + Objects.requireNonNull(defaultRolloverPolicy, "defaultRolloverPolicy must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("description") + public IdStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public UpdatedAtStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage singularName(String singularName) { + this.singularName = Optional.ofNullable(singularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "singular_name", nulls = Nulls.SKIP) + public _FinalStage singularName(Optional singularName) { + this.singularName = singularName; + return this; + } + + @java.lang.Override + public _FinalStage product(BillingProductResponseData product) { + this.product = Optional.ofNullable(product); + return this; + } + + @java.lang.Override + @JsonSetter(value = "product", nulls = Nulls.SKIP) + public _FinalStage product(Optional product) { + this.product = product; + return this; + } + + @java.lang.Override + public _FinalStage price(BillingPriceResponseData price) { + this.price = Optional.ofNullable(price); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price", nulls = Nulls.SKIP) + public _FinalStage price(Optional price) { + this.price = price; + return this; + } + + @java.lang.Override + public _FinalStage pluralName(String pluralName) { + this.pluralName = Optional.ofNullable(pluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plural_name", nulls = Nulls.SKIP) + public _FinalStage pluralName(Optional pluralName) { + this.pluralName = pluralName; + return this; + } + + @java.lang.Override + public _FinalStage icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public _FinalStage icon(Optional icon) { + this.icon = icon; + return this; + } + + @java.lang.Override + public _FinalStage defaultExpiryUnitCount(Integer defaultExpiryUnitCount) { + this.defaultExpiryUnitCount = Optional.ofNullable(defaultExpiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage defaultExpiryUnitCount(Optional defaultExpiryUnitCount) { + this.defaultExpiryUnitCount = defaultExpiryUnitCount; + return this; + } + + @java.lang.Override + public BillingCreditResponseData build() { + return new BillingCreditResponseData( + burnStrategy, + createdAt, + defaultExpiryUnit, + defaultExpiryUnitCount, + defaultRolloverPolicy, + description, + icon, + id, + name, + pluralName, + price, + product, + singularName, + updatedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingCustomerWithSubscriptionsResponseData.java b/src/main/java/com/schematic/api/types/BillingCustomerWithSubscriptionsResponseData.java index 633ed57..f89fb4c 100644 --- a/src/main/java/com/schematic/api/types/BillingCustomerWithSubscriptionsResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingCustomerWithSubscriptionsResponseData.java @@ -293,7 +293,9 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { @java.lang.Override public _FinalStage addAllSubscriptions(List subscriptions) { - this.subscriptions.addAll(subscriptions); + if (subscriptions != null) { + this.subscriptions.addAll(subscriptions); + } return this; } @@ -307,7 +309,9 @@ public _FinalStage addSubscriptions(BillingCustomerSubscription subscriptions) { @JsonSetter(value = "subscriptions", nulls = Nulls.SKIP) public _FinalStage subscriptions(List subscriptions) { this.subscriptions.clear(); - this.subscriptions.addAll(subscriptions); + if (subscriptions != null) { + this.subscriptions.addAll(subscriptions); + } return this; } diff --git a/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResponseData.java b/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResponseData.java new file mode 100644 index 0000000..b8b7dbf --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingPlanCreditGrantResponseData.java @@ -0,0 +1,548 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingPlanCreditGrantResponseData.Builder.class) +public final class BillingPlanCreditGrantResponseData { + private final OffsetDateTime createdAt; + + private final int creditAmount; + + private final String creditId; + + private final String creditName; + + private final Optional creditPluralName; + + private final Optional creditSingularName; + + private final Optional expiryType; + + private final Optional expiryUnit; + + private final Optional expiryUnitCount; + + private final String id; + + private final String planId; + + private final String planName; + + private final String resetCadence; + + private final String resetStart; + + private final Optional resetType; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private BillingPlanCreditGrantResponseData( + OffsetDateTime createdAt, + int creditAmount, + String creditId, + String creditName, + Optional creditPluralName, + Optional creditSingularName, + Optional expiryType, + Optional expiryUnit, + Optional expiryUnitCount, + String id, + String planId, + String planName, + String resetCadence, + String resetStart, + Optional resetType, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.createdAt = createdAt; + this.creditAmount = creditAmount; + this.creditId = creditId; + this.creditName = creditName; + this.creditPluralName = creditPluralName; + this.creditSingularName = creditSingularName; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.id = id; + this.planId = planId; + this.planName = planName; + this.resetCadence = resetCadence; + this.resetStart = resetStart; + this.resetType = resetType; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("credit_amount") + public int getCreditAmount() { + return creditAmount; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @JsonProperty("credit_name") + public String getCreditName() { + return creditName; + } + + @JsonProperty("credit_plural_name") + public Optional getCreditPluralName() { + return creditPluralName; + } + + @JsonProperty("credit_singular_name") + public Optional getCreditSingularName() { + return creditSingularName; + } + + @JsonProperty("expiry_type") + public Optional getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public Optional getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @JsonProperty("plan_name") + public String getPlanName() { + return planName; + } + + @JsonProperty("reset_cadence") + public String getResetCadence() { + return resetCadence; + } + + @JsonProperty("reset_start") + public String getResetStart() { + return resetStart; + } + + @JsonProperty("reset_type") + public Optional getResetType() { + return resetType; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingPlanCreditGrantResponseData + && equalTo((BillingPlanCreditGrantResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingPlanCreditGrantResponseData other) { + return createdAt.equals(other.createdAt) + && creditAmount == other.creditAmount + && creditId.equals(other.creditId) + && creditName.equals(other.creditName) + && creditPluralName.equals(other.creditPluralName) + && creditSingularName.equals(other.creditSingularName) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && id.equals(other.id) + && planId.equals(other.planId) + && planName.equals(other.planName) + && resetCadence.equals(other.resetCadence) + && resetStart.equals(other.resetStart) + && resetType.equals(other.resetType) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.createdAt, + this.creditAmount, + this.creditId, + this.creditName, + this.creditPluralName, + this.creditSingularName, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.id, + this.planId, + this.planName, + this.resetCadence, + this.resetStart, + this.resetType, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtStage builder() { + return new Builder(); + } + + public interface CreatedAtStage { + CreditAmountStage createdAt(@NotNull OffsetDateTime createdAt); + + Builder from(BillingPlanCreditGrantResponseData other); + } + + public interface CreditAmountStage { + CreditIdStage creditAmount(int creditAmount); + } + + public interface CreditIdStage { + CreditNameStage creditId(@NotNull String creditId); + } + + public interface CreditNameStage { + IdStage creditName(@NotNull String creditName); + } + + public interface IdStage { + PlanIdStage id(@NotNull String id); + } + + public interface PlanIdStage { + PlanNameStage planId(@NotNull String planId); + } + + public interface PlanNameStage { + ResetCadenceStage planName(@NotNull String planName); + } + + public interface ResetCadenceStage { + ResetStartStage resetCadence(@NotNull String resetCadence); + } + + public interface ResetStartStage { + UpdatedAtStage resetStart(@NotNull String resetStart); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + BillingPlanCreditGrantResponseData build(); + + _FinalStage creditPluralName(Optional creditPluralName); + + _FinalStage creditPluralName(String creditPluralName); + + _FinalStage creditSingularName(Optional creditSingularName); + + _FinalStage creditSingularName(String creditSingularName); + + _FinalStage expiryType(Optional expiryType); + + _FinalStage expiryType(String expiryType); + + _FinalStage expiryUnit(Optional expiryUnit); + + _FinalStage expiryUnit(String expiryUnit); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + + _FinalStage resetType(Optional resetType); + + _FinalStage resetType(String resetType); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CreatedAtStage, + CreditAmountStage, + CreditIdStage, + CreditNameStage, + IdStage, + PlanIdStage, + PlanNameStage, + ResetCadenceStage, + ResetStartStage, + UpdatedAtStage, + _FinalStage { + private OffsetDateTime createdAt; + + private int creditAmount; + + private String creditId; + + private String creditName; + + private String id; + + private String planId; + + private String planName; + + private String resetCadence; + + private String resetStart; + + private OffsetDateTime updatedAt; + + private Optional resetType = Optional.empty(); + + private Optional expiryUnitCount = Optional.empty(); + + private Optional expiryUnit = Optional.empty(); + + private Optional expiryType = Optional.empty(); + + private Optional creditSingularName = Optional.empty(); + + private Optional creditPluralName = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BillingPlanCreditGrantResponseData other) { + createdAt(other.getCreatedAt()); + creditAmount(other.getCreditAmount()); + creditId(other.getCreditId()); + creditName(other.getCreditName()); + creditPluralName(other.getCreditPluralName()); + creditSingularName(other.getCreditSingularName()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + id(other.getId()); + planId(other.getPlanId()); + planName(other.getPlanName()); + resetCadence(other.getResetCadence()); + resetStart(other.getResetStart()); + resetType(other.getResetType()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public CreditAmountStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_amount") + public CreditIdStage creditAmount(int creditAmount) { + this.creditAmount = creditAmount; + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public CreditNameStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_name") + public IdStage creditName(@NotNull String creditName) { + this.creditName = Objects.requireNonNull(creditName, "creditName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public PlanIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public PlanNameStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("plan_name") + public ResetCadenceStage planName(@NotNull String planName) { + this.planName = Objects.requireNonNull(planName, "planName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("reset_cadence") + public ResetStartStage resetCadence(@NotNull String resetCadence) { + this.resetCadence = Objects.requireNonNull(resetCadence, "resetCadence must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("reset_start") + public UpdatedAtStage resetStart(@NotNull String resetStart) { + this.resetStart = Objects.requireNonNull(resetStart, "resetStart must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage resetType(String resetType) { + this.resetType = Optional.ofNullable(resetType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "reset_type", nulls = Nulls.SKIP) + public _FinalStage resetType(Optional resetType) { + this.resetType = resetType; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnit(String expiryUnit) { + this.expiryUnit = Optional.ofNullable(expiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit", nulls = Nulls.SKIP) + public _FinalStage expiryUnit(Optional expiryUnit) { + this.expiryUnit = expiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage expiryType(String expiryType) { + this.expiryType = Optional.ofNullable(expiryType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_type", nulls = Nulls.SKIP) + public _FinalStage expiryType(Optional expiryType) { + this.expiryType = expiryType; + return this; + } + + @java.lang.Override + public _FinalStage creditSingularName(String creditSingularName) { + this.creditSingularName = Optional.ofNullable(creditSingularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_singular_name", nulls = Nulls.SKIP) + public _FinalStage creditSingularName(Optional creditSingularName) { + this.creditSingularName = creditSingularName; + return this; + } + + @java.lang.Override + public _FinalStage creditPluralName(String creditPluralName) { + this.creditPluralName = Optional.ofNullable(creditPluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_plural_name", nulls = Nulls.SKIP) + public _FinalStage creditPluralName(Optional creditPluralName) { + this.creditPluralName = creditPluralName; + return this; + } + + @java.lang.Override + public BillingPlanCreditGrantResponseData build() { + return new BillingPlanCreditGrantResponseData( + createdAt, + creditAmount, + creditId, + creditName, + creditPluralName, + creditSingularName, + expiryType, + expiryUnit, + expiryUnitCount, + id, + planId, + planName, + resetCadence, + resetStart, + resetType, + updatedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingPriceResponseData.java b/src/main/java/com/schematic/api/types/BillingPriceResponseData.java index 9193142..b784b88 100644 --- a/src/main/java/com/schematic/api/types/BillingPriceResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingPriceResponseData.java @@ -9,11 +9,13 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -29,6 +31,10 @@ public final class BillingPriceResponseData { private final int price; + private final Optional priceDecimal; + + private final String scheme; + private final Map additionalProperties; private BillingPriceResponseData( @@ -37,12 +43,16 @@ private BillingPriceResponseData( String id, String interval, int price, + Optional priceDecimal, + String scheme, Map additionalProperties) { this.currency = currency; this.externalPriceId = externalPriceId; this.id = id; this.interval = interval; this.price = price; + this.priceDecimal = priceDecimal; + this.scheme = scheme; this.additionalProperties = additionalProperties; } @@ -71,6 +81,16 @@ public int getPrice() { return price; } + @JsonProperty("price_decimal") + public Optional getPriceDecimal() { + return priceDecimal; + } + + @JsonProperty("scheme") + public String getScheme() { + return scheme; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -87,12 +107,21 @@ private boolean equalTo(BillingPriceResponseData other) { && externalPriceId.equals(other.externalPriceId) && id.equals(other.id) && interval.equals(other.interval) - && price == other.price; + && price == other.price + && priceDecimal.equals(other.priceDecimal) + && scheme.equals(other.scheme); } @java.lang.Override public int hashCode() { - return Objects.hash(this.currency, this.externalPriceId, this.id, this.interval, this.price); + return Objects.hash( + this.currency, + this.externalPriceId, + this.id, + this.interval, + this.price, + this.priceDecimal, + this.scheme); } @java.lang.Override @@ -123,16 +152,30 @@ public interface IntervalStage { } public interface PriceStage { - _FinalStage price(int price); + SchemeStage price(int price); + } + + public interface SchemeStage { + _FinalStage scheme(@NotNull String scheme); } public interface _FinalStage { BillingPriceResponseData build(); + + _FinalStage priceDecimal(Optional priceDecimal); + + _FinalStage priceDecimal(String priceDecimal); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CurrencyStage, ExternalPriceIdStage, IdStage, IntervalStage, PriceStage, _FinalStage { + implements CurrencyStage, + ExternalPriceIdStage, + IdStage, + IntervalStage, + PriceStage, + SchemeStage, + _FinalStage { private String currency; private String externalPriceId; @@ -143,6 +186,10 @@ public static final class Builder private int price; + private String scheme; + + private Optional priceDecimal = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -155,6 +202,8 @@ public Builder from(BillingPriceResponseData other) { id(other.getId()); interval(other.getInterval()); price(other.getPrice()); + priceDecimal(other.getPriceDecimal()); + scheme(other.getScheme()); return this; } @@ -188,14 +237,35 @@ public PriceStage interval(@NotNull String interval) { @java.lang.Override @JsonSetter("price") - public _FinalStage price(int price) { + public SchemeStage price(int price) { this.price = price; return this; } + @java.lang.Override + @JsonSetter("scheme") + public _FinalStage scheme(@NotNull String scheme) { + this.scheme = Objects.requireNonNull(scheme, "scheme must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage priceDecimal(String priceDecimal) { + this.priceDecimal = Optional.ofNullable(priceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_decimal", nulls = Nulls.SKIP) + public _FinalStage priceDecimal(Optional priceDecimal) { + this.priceDecimal = priceDecimal; + return this; + } + @java.lang.Override public BillingPriceResponseData build() { - return new BillingPriceResponseData(currency, externalPriceId, id, interval, price, additionalProperties); + return new BillingPriceResponseData( + currency, externalPriceId, id, interval, price, priceDecimal, scheme, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/BillingPriceView.java b/src/main/java/com/schematic/api/types/BillingPriceView.java index 9436d2d..d76838a 100644 --- a/src/main/java/com/schematic/api/types/BillingPriceView.java +++ b/src/main/java/com/schematic/api/types/BillingPriceView.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingPriceView.Builder.class) public final class BillingPriceView { + private final String billingScheme; + private final OffsetDateTime createdAt; private final String currency; @@ -32,20 +36,32 @@ public final class BillingPriceView { private final boolean isActive; + private final Optional meterEventName; + + private final Optional meterEventPayloadKey; + private final Optional meterId; + private final int packageSize; + private final int price; + private final Optional priceDecimal; + private final String priceExternalId; private final String priceId; + private final List priceTier; + private final String productExternalId; private final String productId; private final String productName; + private final Optional tiersMode; + private final OffsetDateTime updatedAt; private final String usageType; @@ -53,38 +69,57 @@ public final class BillingPriceView { private final Map additionalProperties; private BillingPriceView( + String billingScheme, OffsetDateTime createdAt, String currency, String id, String interval, boolean isActive, + Optional meterEventName, + Optional meterEventPayloadKey, Optional meterId, + int packageSize, int price, + Optional priceDecimal, String priceExternalId, String priceId, + List priceTier, String productExternalId, String productId, String productName, + Optional tiersMode, OffsetDateTime updatedAt, String usageType, Map additionalProperties) { + this.billingScheme = billingScheme; this.createdAt = createdAt; this.currency = currency; this.id = id; this.interval = interval; this.isActive = isActive; + this.meterEventName = meterEventName; + this.meterEventPayloadKey = meterEventPayloadKey; this.meterId = meterId; + this.packageSize = packageSize; this.price = price; + this.priceDecimal = priceDecimal; this.priceExternalId = priceExternalId; this.priceId = priceId; + this.priceTier = priceTier; this.productExternalId = productExternalId; this.productId = productId; this.productName = productName; + this.tiersMode = tiersMode; this.updatedAt = updatedAt; this.usageType = usageType; this.additionalProperties = additionalProperties; } + @JsonProperty("billing_scheme") + public String getBillingScheme() { + return billingScheme; + } + @JsonProperty("created_at") public OffsetDateTime getCreatedAt() { return createdAt; @@ -110,16 +145,36 @@ public boolean getIsActive() { return isActive; } + @JsonProperty("meter_event_name") + public Optional getMeterEventName() { + return meterEventName; + } + + @JsonProperty("meter_event_payload_key") + public Optional getMeterEventPayloadKey() { + return meterEventPayloadKey; + } + @JsonProperty("meter_id") public Optional getMeterId() { return meterId; } + @JsonProperty("package_size") + public int getPackageSize() { + return packageSize; + } + @JsonProperty("price") public int getPrice() { return price; } + @JsonProperty("price_decimal") + public Optional getPriceDecimal() { + return priceDecimal; + } + @JsonProperty("price_external_id") public String getPriceExternalId() { return priceExternalId; @@ -130,6 +185,11 @@ public String getPriceId() { return priceId; } + @JsonProperty("price_tier") + public List getPriceTier() { + return priceTier; + } + @JsonProperty("product_external_id") public String getProductExternalId() { return productExternalId; @@ -145,6 +205,11 @@ public String getProductName() { return productName; } + @JsonProperty("tiers_mode") + public Optional getTiersMode() { + return tiersMode; + } + @JsonProperty("updated_at") public OffsetDateTime getUpdatedAt() { return updatedAt; @@ -167,18 +232,25 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingPriceView other) { - return createdAt.equals(other.createdAt) + return billingScheme.equals(other.billingScheme) + && createdAt.equals(other.createdAt) && currency.equals(other.currency) && id.equals(other.id) && interval.equals(other.interval) && isActive == other.isActive + && meterEventName.equals(other.meterEventName) + && meterEventPayloadKey.equals(other.meterEventPayloadKey) && meterId.equals(other.meterId) + && packageSize == other.packageSize && price == other.price + && priceDecimal.equals(other.priceDecimal) && priceExternalId.equals(other.priceExternalId) && priceId.equals(other.priceId) + && priceTier.equals(other.priceTier) && productExternalId.equals(other.productExternalId) && productId.equals(other.productId) && productName.equals(other.productName) + && tiersMode.equals(other.tiersMode) && updatedAt.equals(other.updatedAt) && usageType.equals(other.usageType); } @@ -186,18 +258,25 @@ private boolean equalTo(BillingPriceView other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.billingScheme, this.createdAt, this.currency, this.id, this.interval, this.isActive, + this.meterEventName, + this.meterEventPayloadKey, this.meterId, + this.packageSize, this.price, + this.priceDecimal, this.priceExternalId, this.priceId, + this.priceTier, this.productExternalId, this.productId, this.productName, + this.tiersMode, this.updatedAt, this.usageType); } @@ -207,16 +286,20 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CreatedAtStage builder() { + public static BillingSchemeStage builder() { return new Builder(); } - public interface CreatedAtStage { - CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); + public interface BillingSchemeStage { + CreatedAtStage billingScheme(@NotNull String billingScheme); Builder from(BillingPriceView other); } + public interface CreatedAtStage { + CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); + } + public interface CurrencyStage { IdStage currency(@NotNull String currency); } @@ -230,7 +313,11 @@ public interface IntervalStage { } public interface IsActiveStage { - PriceStage isActive(boolean isActive); + PackageSizeStage isActive(boolean isActive); + } + + public interface PackageSizeStage { + PriceStage packageSize(int packageSize); } public interface PriceStage { @@ -268,18 +355,42 @@ public interface UsageTypeStage { public interface _FinalStage { BillingPriceView build(); + _FinalStage meterEventName(Optional meterEventName); + + _FinalStage meterEventName(String meterEventName); + + _FinalStage meterEventPayloadKey(Optional meterEventPayloadKey); + + _FinalStage meterEventPayloadKey(String meterEventPayloadKey); + _FinalStage meterId(Optional meterId); _FinalStage meterId(String meterId); + + _FinalStage priceDecimal(Optional priceDecimal); + + _FinalStage priceDecimal(String priceDecimal); + + _FinalStage priceTier(List priceTier); + + _FinalStage addPriceTier(BillingProductPriceTierResponseData priceTier); + + _FinalStage addAllPriceTier(List priceTier); + + _FinalStage tiersMode(Optional tiersMode); + + _FinalStage tiersMode(String tiersMode); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CreatedAtStage, + implements BillingSchemeStage, + CreatedAtStage, CurrencyStage, IdStage, IntervalStage, IsActiveStage, + PackageSizeStage, PriceStage, PriceExternalIdStage, PriceIdStage, @@ -289,6 +400,8 @@ public static final class Builder UpdatedAtStage, UsageTypeStage, _FinalStage { + private String billingScheme; + private OffsetDateTime createdAt; private String currency; @@ -299,6 +412,8 @@ public static final class Builder private boolean isActive; + private int packageSize; + private int price; private String priceExternalId; @@ -315,8 +430,18 @@ public static final class Builder private String usageType; + private Optional tiersMode = Optional.empty(); + + private List priceTier = new ArrayList<>(); + + private Optional priceDecimal = Optional.empty(); + private Optional meterId = Optional.empty(); + private Optional meterEventPayloadKey = Optional.empty(); + + private Optional meterEventName = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -324,23 +449,37 @@ private Builder() {} @java.lang.Override public Builder from(BillingPriceView other) { + billingScheme(other.getBillingScheme()); createdAt(other.getCreatedAt()); currency(other.getCurrency()); id(other.getId()); interval(other.getInterval()); isActive(other.getIsActive()); + meterEventName(other.getMeterEventName()); + meterEventPayloadKey(other.getMeterEventPayloadKey()); meterId(other.getMeterId()); + packageSize(other.getPackageSize()); price(other.getPrice()); + priceDecimal(other.getPriceDecimal()); priceExternalId(other.getPriceExternalId()); priceId(other.getPriceId()); + priceTier(other.getPriceTier()); productExternalId(other.getProductExternalId()); productId(other.getProductId()); productName(other.getProductName()); + tiersMode(other.getTiersMode()); updatedAt(other.getUpdatedAt()); usageType(other.getUsageType()); return this; } + @java.lang.Override + @JsonSetter("billing_scheme") + public CreatedAtStage billingScheme(@NotNull String billingScheme) { + this.billingScheme = Objects.requireNonNull(billingScheme, "billingScheme must not be null"); + return this; + } + @java.lang.Override @JsonSetter("created_at") public CurrencyStage createdAt(@NotNull OffsetDateTime createdAt) { @@ -371,11 +510,18 @@ public IsActiveStage interval(@NotNull String interval) { @java.lang.Override @JsonSetter("is_active") - public PriceStage isActive(boolean isActive) { + public PackageSizeStage isActive(boolean isActive) { this.isActive = isActive; return this; } + @java.lang.Override + @JsonSetter("package_size") + public PriceStage packageSize(int packageSize) { + this.packageSize = packageSize; + return this; + } + @java.lang.Override @JsonSetter("price") public PriceExternalIdStage price(int price) { @@ -432,6 +578,56 @@ public _FinalStage usageType(@NotNull String usageType) { return this; } + @java.lang.Override + public _FinalStage tiersMode(String tiersMode) { + this.tiersMode = Optional.ofNullable(tiersMode); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tiers_mode", nulls = Nulls.SKIP) + public _FinalStage tiersMode(Optional tiersMode) { + this.tiersMode = tiersMode; + return this; + } + + @java.lang.Override + public _FinalStage addAllPriceTier(List priceTier) { + if (priceTier != null) { + this.priceTier.addAll(priceTier); + } + return this; + } + + @java.lang.Override + public _FinalStage addPriceTier(BillingProductPriceTierResponseData priceTier) { + this.priceTier.add(priceTier); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_tier", nulls = Nulls.SKIP) + public _FinalStage priceTier(List priceTier) { + this.priceTier.clear(); + if (priceTier != null) { + this.priceTier.addAll(priceTier); + } + return this; + } + + @java.lang.Override + public _FinalStage priceDecimal(String priceDecimal) { + this.priceDecimal = Optional.ofNullable(priceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_decimal", nulls = Nulls.SKIP) + public _FinalStage priceDecimal(Optional priceDecimal) { + this.priceDecimal = priceDecimal; + return this; + } + @java.lang.Override public _FinalStage meterId(String meterId) { this.meterId = Optional.ofNullable(meterId); @@ -445,21 +641,54 @@ public _FinalStage meterId(Optional meterId) { return this; } + @java.lang.Override + public _FinalStage meterEventPayloadKey(String meterEventPayloadKey) { + this.meterEventPayloadKey = Optional.ofNullable(meterEventPayloadKey); + return this; + } + + @java.lang.Override + @JsonSetter(value = "meter_event_payload_key", nulls = Nulls.SKIP) + public _FinalStage meterEventPayloadKey(Optional meterEventPayloadKey) { + this.meterEventPayloadKey = meterEventPayloadKey; + return this; + } + + @java.lang.Override + public _FinalStage meterEventName(String meterEventName) { + this.meterEventName = Optional.ofNullable(meterEventName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "meter_event_name", nulls = Nulls.SKIP) + public _FinalStage meterEventName(Optional meterEventName) { + this.meterEventName = meterEventName; + return this; + } + @java.lang.Override public BillingPriceView build() { return new BillingPriceView( + billingScheme, createdAt, currency, id, interval, isActive, + meterEventName, + meterEventPayloadKey, meterId, + packageSize, price, + priceDecimal, priceExternalId, priceId, + priceTier, productExternalId, productId, productName, + tiersMode, updatedAt, usageType, additionalProperties); diff --git a/src/main/java/com/schematic/api/types/BillingProductDetailResponseData.java b/src/main/java/com/schematic/api/types/BillingProductDetailResponseData.java index ea0cfb8..f1406f4 100644 --- a/src/main/java/com/schematic/api/types/BillingProductDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingProductDetailResponseData.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -27,16 +28,20 @@ public final class BillingProductDetailResponseData { private final OffsetDateTime createdAt; - private final String currency; + private final Optional currency; private final String environmentId; private final String externalId; + private final boolean isActive; + private final String name; private final double price; + private final Optional priceDecimal; + private final List prices; private final String productId; @@ -52,11 +57,13 @@ public final class BillingProductDetailResponseData { private BillingProductDetailResponseData( String accountId, OffsetDateTime createdAt, - String currency, + Optional currency, String environmentId, String externalId, + boolean isActive, String name, double price, + Optional priceDecimal, List prices, String productId, double quantity, @@ -68,8 +75,10 @@ private BillingProductDetailResponseData( this.currency = currency; this.environmentId = environmentId; this.externalId = externalId; + this.isActive = isActive; this.name = name; this.price = price; + this.priceDecimal = priceDecimal; this.prices = prices; this.productId = productId; this.quantity = quantity; @@ -88,8 +97,11 @@ public OffsetDateTime getCreatedAt() { return createdAt; } + /** + * @return Deprecated; currencies are associated with prices, not products + */ @JsonProperty("currency") - public String getCurrency() { + public Optional getCurrency() { return currency; } @@ -103,6 +115,11 @@ public String getExternalId() { return externalId; } + @JsonProperty("is_active") + public boolean getIsActive() { + return isActive; + } + @JsonProperty("name") public String getName() { return name; @@ -113,6 +130,11 @@ public double getPrice() { return price; } + @JsonProperty("price_decimal") + public Optional getPriceDecimal() { + return priceDecimal; + } + @JsonProperty("prices") public List getPrices() { return prices; @@ -155,8 +177,10 @@ private boolean equalTo(BillingProductDetailResponseData other) { && currency.equals(other.currency) && environmentId.equals(other.environmentId) && externalId.equals(other.externalId) + && isActive == other.isActive && name.equals(other.name) && price == other.price + && priceDecimal.equals(other.priceDecimal) && prices.equals(other.prices) && productId.equals(other.productId) && quantity == other.quantity @@ -172,8 +196,10 @@ public int hashCode() { this.currency, this.environmentId, this.externalId, + this.isActive, this.name, this.price, + this.priceDecimal, this.prices, this.productId, this.quantity, @@ -197,11 +223,7 @@ public interface AccountIdStage { } public interface CreatedAtStage { - CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); - } - - public interface CurrencyStage { - EnvironmentIdStage currency(@NotNull String currency); + EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); } public interface EnvironmentIdStage { @@ -209,7 +231,11 @@ public interface EnvironmentIdStage { } public interface ExternalIdStage { - NameStage externalId(@NotNull String externalId); + IsActiveStage externalId(@NotNull String externalId); + } + + public interface IsActiveStage { + NameStage isActive(boolean isActive); } public interface NameStage { @@ -239,6 +265,17 @@ public interface UpdatedAtStage { public interface _FinalStage { BillingProductDetailResponseData build(); + /** + *

Deprecated; currencies are associated with prices, not products

+ */ + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + + _FinalStage priceDecimal(Optional priceDecimal); + + _FinalStage priceDecimal(String priceDecimal); + _FinalStage prices(List prices); _FinalStage addPrices(BillingPriceResponseData prices); @@ -250,9 +287,9 @@ public interface _FinalStage { public static final class Builder implements AccountIdStage, CreatedAtStage, - CurrencyStage, EnvironmentIdStage, ExternalIdStage, + IsActiveStage, NameStage, PriceStage, ProductIdStage, @@ -264,12 +301,12 @@ public static final class Builder private OffsetDateTime createdAt; - private String currency; - private String environmentId; private String externalId; + private boolean isActive; + private String name; private double price; @@ -284,6 +321,10 @@ public static final class Builder private List prices = new ArrayList<>(); + private Optional priceDecimal = Optional.empty(); + + private Optional currency = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -296,8 +337,10 @@ public Builder from(BillingProductDetailResponseData other) { currency(other.getCurrency()); environmentId(other.getEnvironmentId()); externalId(other.getExternalId()); + isActive(other.getIsActive()); name(other.getName()); price(other.getPrice()); + priceDecimal(other.getPriceDecimal()); prices(other.getPrices()); productId(other.getProductId()); quantity(other.getQuantity()); @@ -315,18 +358,11 @@ public CreatedAtStage accountId(@NotNull String accountId) { @java.lang.Override @JsonSetter("created_at") - public CurrencyStage createdAt(@NotNull OffsetDateTime createdAt) { + public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); return this; } - @java.lang.Override - @JsonSetter("currency") - public EnvironmentIdStage currency(@NotNull String currency) { - this.currency = Objects.requireNonNull(currency, "currency must not be null"); - return this; - } - @java.lang.Override @JsonSetter("environment_id") public ExternalIdStage environmentId(@NotNull String environmentId) { @@ -336,11 +372,18 @@ public ExternalIdStage environmentId(@NotNull String environmentId) { @java.lang.Override @JsonSetter("external_id") - public NameStage externalId(@NotNull String externalId) { + public IsActiveStage externalId(@NotNull String externalId) { this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); return this; } + @java.lang.Override + @JsonSetter("is_active") + public NameStage isActive(boolean isActive) { + this.isActive = isActive; + return this; + } + @java.lang.Override @JsonSetter("name") public PriceStage name(@NotNull String name) { @@ -385,7 +428,9 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { @java.lang.Override public _FinalStage addAllPrices(List prices) { - this.prices.addAll(prices); + if (prices != null) { + this.prices.addAll(prices); + } return this; } @@ -399,7 +444,42 @@ public _FinalStage addPrices(BillingPriceResponseData prices) { @JsonSetter(value = "prices", nulls = Nulls.SKIP) public _FinalStage prices(List prices) { this.prices.clear(); - this.prices.addAll(prices); + if (prices != null) { + this.prices.addAll(prices); + } + return this; + } + + @java.lang.Override + public _FinalStage priceDecimal(String priceDecimal) { + this.priceDecimal = Optional.ofNullable(priceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_decimal", nulls = Nulls.SKIP) + public _FinalStage priceDecimal(Optional priceDecimal) { + this.priceDecimal = priceDecimal; + return this; + } + + /** + *

Deprecated; currencies are associated with prices, not products

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage currency(String currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + /** + *

Deprecated; currencies are associated with prices, not products

+ */ + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; return this; } @@ -411,8 +491,10 @@ public BillingProductDetailResponseData build() { currency, environmentId, externalId, + isActive, name, price, + priceDecimal, prices, productId, quantity, diff --git a/src/main/java/com/schematic/api/types/BillingProductForSubscriptionResponseData.java b/src/main/java/com/schematic/api/types/BillingProductForSubscriptionResponseData.java index 7c59f35..8043ec6 100644 --- a/src/main/java/com/schematic/api/types/BillingProductForSubscriptionResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingProductForSubscriptionResponseData.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingProductForSubscriptionResponseData.Builder.class) public final class BillingProductForSubscriptionResponseData { + private final String billingScheme; + + private final Optional billingThreshold; + private final OffsetDateTime createdAt; private final String currency; @@ -38,16 +44,24 @@ public final class BillingProductForSubscriptionResponseData { private final String name; + private final int packageSize; + private final int price; + private final Optional priceDecimal; + private final String priceExternalId; private final String priceId; + private final List priceTier; + private final double quantity; private final String subscriptionId; + private final Optional subscriptionItemExternalId; + private final OffsetDateTime updatedAt; private final String usageType; @@ -55,6 +69,8 @@ public final class BillingProductForSubscriptionResponseData { private final Map additionalProperties; private BillingProductForSubscriptionResponseData( + String billingScheme, + Optional billingThreshold, OffsetDateTime createdAt, String currency, String environmentId, @@ -63,14 +79,20 @@ private BillingProductForSubscriptionResponseData( String interval, Optional meterId, String name, + int packageSize, int price, + Optional priceDecimal, String priceExternalId, String priceId, + List priceTier, double quantity, String subscriptionId, + Optional subscriptionItemExternalId, OffsetDateTime updatedAt, String usageType, Map additionalProperties) { + this.billingScheme = billingScheme; + this.billingThreshold = billingThreshold; this.createdAt = createdAt; this.currency = currency; this.environmentId = environmentId; @@ -79,16 +101,30 @@ private BillingProductForSubscriptionResponseData( this.interval = interval; this.meterId = meterId; this.name = name; + this.packageSize = packageSize; this.price = price; + this.priceDecimal = priceDecimal; this.priceExternalId = priceExternalId; this.priceId = priceId; + this.priceTier = priceTier; this.quantity = quantity; this.subscriptionId = subscriptionId; + this.subscriptionItemExternalId = subscriptionItemExternalId; this.updatedAt = updatedAt; this.usageType = usageType; this.additionalProperties = additionalProperties; } + @JsonProperty("billing_scheme") + public String getBillingScheme() { + return billingScheme; + } + + @JsonProperty("billing_threshold") + public Optional getBillingThreshold() { + return billingThreshold; + } + @JsonProperty("created_at") public OffsetDateTime getCreatedAt() { return createdAt; @@ -129,11 +165,21 @@ public String getName() { return name; } + @JsonProperty("package_size") + public int getPackageSize() { + return packageSize; + } + @JsonProperty("price") public int getPrice() { return price; } + @JsonProperty("price_decimal") + public Optional getPriceDecimal() { + return priceDecimal; + } + @JsonProperty("price_external_id") public String getPriceExternalId() { return priceExternalId; @@ -144,6 +190,11 @@ public String getPriceId() { return priceId; } + @JsonProperty("price_tier") + public List getPriceTier() { + return priceTier; + } + @JsonProperty("quantity") public double getQuantity() { return quantity; @@ -154,6 +205,11 @@ public String getSubscriptionId() { return subscriptionId; } + @JsonProperty("subscription_item_external_id") + public Optional getSubscriptionItemExternalId() { + return subscriptionItemExternalId; + } + @JsonProperty("updated_at") public OffsetDateTime getUpdatedAt() { return updatedAt; @@ -177,7 +233,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingProductForSubscriptionResponseData other) { - return createdAt.equals(other.createdAt) + return billingScheme.equals(other.billingScheme) + && billingThreshold.equals(other.billingThreshold) + && createdAt.equals(other.createdAt) && currency.equals(other.currency) && environmentId.equals(other.environmentId) && externalId.equals(other.externalId) @@ -185,11 +243,15 @@ private boolean equalTo(BillingProductForSubscriptionResponseData other) { && interval.equals(other.interval) && meterId.equals(other.meterId) && name.equals(other.name) + && packageSize == other.packageSize && price == other.price + && priceDecimal.equals(other.priceDecimal) && priceExternalId.equals(other.priceExternalId) && priceId.equals(other.priceId) + && priceTier.equals(other.priceTier) && quantity == other.quantity && subscriptionId.equals(other.subscriptionId) + && subscriptionItemExternalId.equals(other.subscriptionItemExternalId) && updatedAt.equals(other.updatedAt) && usageType.equals(other.usageType); } @@ -197,6 +259,8 @@ private boolean equalTo(BillingProductForSubscriptionResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.billingScheme, + this.billingThreshold, this.createdAt, this.currency, this.environmentId, @@ -205,11 +269,15 @@ public int hashCode() { this.interval, this.meterId, this.name, + this.packageSize, this.price, + this.priceDecimal, this.priceExternalId, this.priceId, + this.priceTier, this.quantity, this.subscriptionId, + this.subscriptionItemExternalId, this.updatedAt, this.usageType); } @@ -219,16 +287,20 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CreatedAtStage builder() { + public static BillingSchemeStage builder() { return new Builder(); } - public interface CreatedAtStage { - CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); + public interface BillingSchemeStage { + CreatedAtStage billingScheme(@NotNull String billingScheme); Builder from(BillingProductForSubscriptionResponseData other); } + public interface CreatedAtStage { + CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); + } + public interface CurrencyStage { EnvironmentIdStage currency(@NotNull String currency); } @@ -250,7 +322,11 @@ public interface IntervalStage { } public interface NameStage { - PriceStage name(@NotNull String name); + PackageSizeStage name(@NotNull String name); + } + + public interface PackageSizeStage { + PriceStage packageSize(int packageSize); } public interface PriceStage { @@ -284,20 +360,40 @@ public interface UsageTypeStage { public interface _FinalStage { BillingProductForSubscriptionResponseData build(); + _FinalStage billingThreshold(Optional billingThreshold); + + _FinalStage billingThreshold(Integer billingThreshold); + _FinalStage meterId(Optional meterId); _FinalStage meterId(String meterId); + + _FinalStage priceDecimal(Optional priceDecimal); + + _FinalStage priceDecimal(String priceDecimal); + + _FinalStage priceTier(List priceTier); + + _FinalStage addPriceTier(BillingProductPriceTierResponseData priceTier); + + _FinalStage addAllPriceTier(List priceTier); + + _FinalStage subscriptionItemExternalId(Optional subscriptionItemExternalId); + + _FinalStage subscriptionItemExternalId(String subscriptionItemExternalId); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CreatedAtStage, + implements BillingSchemeStage, + CreatedAtStage, CurrencyStage, EnvironmentIdStage, ExternalIdStage, IdStage, IntervalStage, NameStage, + PackageSizeStage, PriceStage, PriceExternalIdStage, PriceIdStage, @@ -306,6 +402,8 @@ public static final class Builder UpdatedAtStage, UsageTypeStage, _FinalStage { + private String billingScheme; + private OffsetDateTime createdAt; private String currency; @@ -320,6 +418,8 @@ public static final class Builder private String name; + private int packageSize; + private int price; private String priceExternalId; @@ -334,8 +434,16 @@ public static final class Builder private String usageType; + private Optional subscriptionItemExternalId = Optional.empty(); + + private List priceTier = new ArrayList<>(); + + private Optional priceDecimal = Optional.empty(); + private Optional meterId = Optional.empty(); + private Optional billingThreshold = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -343,6 +451,8 @@ private Builder() {} @java.lang.Override public Builder from(BillingProductForSubscriptionResponseData other) { + billingScheme(other.getBillingScheme()); + billingThreshold(other.getBillingThreshold()); createdAt(other.getCreatedAt()); currency(other.getCurrency()); environmentId(other.getEnvironmentId()); @@ -351,16 +461,27 @@ public Builder from(BillingProductForSubscriptionResponseData other) { interval(other.getInterval()); meterId(other.getMeterId()); name(other.getName()); + packageSize(other.getPackageSize()); price(other.getPrice()); + priceDecimal(other.getPriceDecimal()); priceExternalId(other.getPriceExternalId()); priceId(other.getPriceId()); + priceTier(other.getPriceTier()); quantity(other.getQuantity()); subscriptionId(other.getSubscriptionId()); + subscriptionItemExternalId(other.getSubscriptionItemExternalId()); updatedAt(other.getUpdatedAt()); usageType(other.getUsageType()); return this; } + @java.lang.Override + @JsonSetter("billing_scheme") + public CreatedAtStage billingScheme(@NotNull String billingScheme) { + this.billingScheme = Objects.requireNonNull(billingScheme, "billingScheme must not be null"); + return this; + } + @java.lang.Override @JsonSetter("created_at") public CurrencyStage createdAt(@NotNull OffsetDateTime createdAt) { @@ -405,11 +526,18 @@ public NameStage interval(@NotNull String interval) { @java.lang.Override @JsonSetter("name") - public PriceStage name(@NotNull String name) { + public PackageSizeStage name(@NotNull String name) { this.name = Objects.requireNonNull(name, "name must not be null"); return this; } + @java.lang.Override + @JsonSetter("package_size") + public PriceStage packageSize(int packageSize) { + this.packageSize = packageSize; + return this; + } + @java.lang.Override @JsonSetter("price") public PriceExternalIdStage price(int price) { @@ -459,6 +587,56 @@ public _FinalStage usageType(@NotNull String usageType) { return this; } + @java.lang.Override + public _FinalStage subscriptionItemExternalId(String subscriptionItemExternalId) { + this.subscriptionItemExternalId = Optional.ofNullable(subscriptionItemExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "subscription_item_external_id", nulls = Nulls.SKIP) + public _FinalStage subscriptionItemExternalId(Optional subscriptionItemExternalId) { + this.subscriptionItemExternalId = subscriptionItemExternalId; + return this; + } + + @java.lang.Override + public _FinalStage addAllPriceTier(List priceTier) { + if (priceTier != null) { + this.priceTier.addAll(priceTier); + } + return this; + } + + @java.lang.Override + public _FinalStage addPriceTier(BillingProductPriceTierResponseData priceTier) { + this.priceTier.add(priceTier); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_tier", nulls = Nulls.SKIP) + public _FinalStage priceTier(List priceTier) { + this.priceTier.clear(); + if (priceTier != null) { + this.priceTier.addAll(priceTier); + } + return this; + } + + @java.lang.Override + public _FinalStage priceDecimal(String priceDecimal) { + this.priceDecimal = Optional.ofNullable(priceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_decimal", nulls = Nulls.SKIP) + public _FinalStage priceDecimal(Optional priceDecimal) { + this.priceDecimal = priceDecimal; + return this; + } + @java.lang.Override public _FinalStage meterId(String meterId) { this.meterId = Optional.ofNullable(meterId); @@ -472,9 +650,24 @@ public _FinalStage meterId(Optional meterId) { return this; } + @java.lang.Override + public _FinalStage billingThreshold(Integer billingThreshold) { + this.billingThreshold = Optional.ofNullable(billingThreshold); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_threshold", nulls = Nulls.SKIP) + public _FinalStage billingThreshold(Optional billingThreshold) { + this.billingThreshold = billingThreshold; + return this; + } + @java.lang.Override public BillingProductForSubscriptionResponseData build() { return new BillingProductForSubscriptionResponseData( + billingScheme, + billingThreshold, createdAt, currency, environmentId, @@ -483,11 +676,15 @@ public BillingProductForSubscriptionResponseData build() { interval, meterId, name, + packageSize, price, + priceDecimal, priceExternalId, priceId, + priceTier, quantity, subscriptionId, + subscriptionItemExternalId, updatedAt, usageType, additionalProperties); diff --git a/src/main/java/com/schematic/api/types/BillingProductPlanResponseData.java b/src/main/java/com/schematic/api/types/BillingProductPlanResponseData.java index 4fa4eff..0a458e5 100644 --- a/src/main/java/com/schematic/api/types/BillingProductPlanResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingProductPlanResponseData.java @@ -25,12 +25,18 @@ public final class BillingProductPlanResponseData { private final String billingProductId; + private final String chargeType; + + private final String controlledBy; + private final String environmentId; private final boolean isTrialable; private final Optional monthlyPriceId; + private final Optional oneTimePriceId; + private final String planId; private final Optional trialDays; @@ -42,18 +48,24 @@ public final class BillingProductPlanResponseData { private BillingProductPlanResponseData( String accountId, String billingProductId, + String chargeType, + String controlledBy, String environmentId, boolean isTrialable, Optional monthlyPriceId, + Optional oneTimePriceId, String planId, Optional trialDays, Optional yearlyPriceId, Map additionalProperties) { this.accountId = accountId; this.billingProductId = billingProductId; + this.chargeType = chargeType; + this.controlledBy = controlledBy; this.environmentId = environmentId; this.isTrialable = isTrialable; this.monthlyPriceId = monthlyPriceId; + this.oneTimePriceId = oneTimePriceId; this.planId = planId; this.trialDays = trialDays; this.yearlyPriceId = yearlyPriceId; @@ -70,6 +82,16 @@ public String getBillingProductId() { return billingProductId; } + @JsonProperty("charge_type") + public String getChargeType() { + return chargeType; + } + + @JsonProperty("controlled_by") + public String getControlledBy() { + return controlledBy; + } + @JsonProperty("environment_id") public String getEnvironmentId() { return environmentId; @@ -85,6 +107,11 @@ public Optional getMonthlyPriceId() { return monthlyPriceId; } + @JsonProperty("one_time_price_id") + public Optional getOneTimePriceId() { + return oneTimePriceId; + } + @JsonProperty("plan_id") public String getPlanId() { return planId; @@ -114,9 +141,12 @@ public Map getAdditionalProperties() { private boolean equalTo(BillingProductPlanResponseData other) { return accountId.equals(other.accountId) && billingProductId.equals(other.billingProductId) + && chargeType.equals(other.chargeType) + && controlledBy.equals(other.controlledBy) && environmentId.equals(other.environmentId) && isTrialable == other.isTrialable && monthlyPriceId.equals(other.monthlyPriceId) + && oneTimePriceId.equals(other.oneTimePriceId) && planId.equals(other.planId) && trialDays.equals(other.trialDays) && yearlyPriceId.equals(other.yearlyPriceId); @@ -127,9 +157,12 @@ public int hashCode() { return Objects.hash( this.accountId, this.billingProductId, + this.chargeType, + this.controlledBy, this.environmentId, this.isTrialable, this.monthlyPriceId, + this.oneTimePriceId, this.planId, this.trialDays, this.yearlyPriceId); @@ -151,7 +184,15 @@ public interface AccountIdStage { } public interface BillingProductIdStage { - EnvironmentIdStage billingProductId(@NotNull String billingProductId); + ChargeTypeStage billingProductId(@NotNull String billingProductId); + } + + public interface ChargeTypeStage { + ControlledByStage chargeType(@NotNull String chargeType); + } + + public interface ControlledByStage { + EnvironmentIdStage controlledBy(@NotNull String controlledBy); } public interface EnvironmentIdStage { @@ -173,6 +214,10 @@ public interface _FinalStage { _FinalStage monthlyPriceId(String monthlyPriceId); + _FinalStage oneTimePriceId(Optional oneTimePriceId); + + _FinalStage oneTimePriceId(String oneTimePriceId); + _FinalStage trialDays(Optional trialDays); _FinalStage trialDays(Integer trialDays); @@ -186,6 +231,8 @@ public interface _FinalStage { public static final class Builder implements AccountIdStage, BillingProductIdStage, + ChargeTypeStage, + ControlledByStage, EnvironmentIdStage, IsTrialableStage, PlanIdStage, @@ -194,6 +241,10 @@ public static final class Builder private String billingProductId; + private String chargeType; + + private String controlledBy; + private String environmentId; private boolean isTrialable; @@ -204,6 +255,8 @@ public static final class Builder private Optional trialDays = Optional.empty(); + private Optional oneTimePriceId = Optional.empty(); + private Optional monthlyPriceId = Optional.empty(); @JsonAnySetter @@ -215,9 +268,12 @@ private Builder() {} public Builder from(BillingProductPlanResponseData other) { accountId(other.getAccountId()); billingProductId(other.getBillingProductId()); + chargeType(other.getChargeType()); + controlledBy(other.getControlledBy()); environmentId(other.getEnvironmentId()); isTrialable(other.getIsTrialable()); monthlyPriceId(other.getMonthlyPriceId()); + oneTimePriceId(other.getOneTimePriceId()); planId(other.getPlanId()); trialDays(other.getTrialDays()); yearlyPriceId(other.getYearlyPriceId()); @@ -233,11 +289,25 @@ public BillingProductIdStage accountId(@NotNull String accountId) { @java.lang.Override @JsonSetter("billing_product_id") - public EnvironmentIdStage billingProductId(@NotNull String billingProductId) { + public ChargeTypeStage billingProductId(@NotNull String billingProductId) { this.billingProductId = Objects.requireNonNull(billingProductId, "billingProductId must not be null"); return this; } + @java.lang.Override + @JsonSetter("charge_type") + public ControlledByStage chargeType(@NotNull String chargeType) { + this.chargeType = Objects.requireNonNull(chargeType, "chargeType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("controlled_by") + public EnvironmentIdStage controlledBy(@NotNull String controlledBy) { + this.controlledBy = Objects.requireNonNull(controlledBy, "controlledBy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("environment_id") public IsTrialableStage environmentId(@NotNull String environmentId) { @@ -285,6 +355,19 @@ public _FinalStage trialDays(Optional trialDays) { return this; } + @java.lang.Override + public _FinalStage oneTimePriceId(String oneTimePriceId) { + this.oneTimePriceId = Optional.ofNullable(oneTimePriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "one_time_price_id", nulls = Nulls.SKIP) + public _FinalStage oneTimePriceId(Optional oneTimePriceId) { + this.oneTimePriceId = oneTimePriceId; + return this; + } + @java.lang.Override public _FinalStage monthlyPriceId(String monthlyPriceId) { this.monthlyPriceId = Optional.ofNullable(monthlyPriceId); @@ -303,9 +386,12 @@ public BillingProductPlanResponseData build() { return new BillingProductPlanResponseData( accountId, billingProductId, + chargeType, + controlledBy, environmentId, isTrialable, monthlyPriceId, + oneTimePriceId, planId, trialDays, yearlyPriceId, diff --git a/src/main/java/com/schematic/api/types/BillingProductPriceResponseData.java b/src/main/java/com/schematic/api/types/BillingProductPriceResponseData.java index 016d990..0073959 100644 --- a/src/main/java/com/schematic/api/types/BillingProductPriceResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingProductPriceResponseData.java @@ -22,6 +22,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingProductPriceResponseData.Builder.class) public final class BillingProductPriceResponseData { + private final String billingScheme; + private final OffsetDateTime createdAt; private final String currency; @@ -34,12 +36,18 @@ public final class BillingProductPriceResponseData { private final Optional meterId; + private final int packageSize; + private final int price; + private final Optional priceDecimal; + private final String priceExternalId; private final String productExternalId; + private final Optional tiersMode; + private final OffsetDateTime updatedAt; private final String usageType; @@ -47,32 +55,45 @@ public final class BillingProductPriceResponseData { private final Map additionalProperties; private BillingProductPriceResponseData( + String billingScheme, OffsetDateTime createdAt, String currency, String id, String interval, boolean isActive, Optional meterId, + int packageSize, int price, + Optional priceDecimal, String priceExternalId, String productExternalId, + Optional tiersMode, OffsetDateTime updatedAt, String usageType, Map additionalProperties) { + this.billingScheme = billingScheme; this.createdAt = createdAt; this.currency = currency; this.id = id; this.interval = interval; this.isActive = isActive; this.meterId = meterId; + this.packageSize = packageSize; this.price = price; + this.priceDecimal = priceDecimal; this.priceExternalId = priceExternalId; this.productExternalId = productExternalId; + this.tiersMode = tiersMode; this.updatedAt = updatedAt; this.usageType = usageType; this.additionalProperties = additionalProperties; } + @JsonProperty("billing_scheme") + public String getBillingScheme() { + return billingScheme; + } + @JsonProperty("created_at") public OffsetDateTime getCreatedAt() { return createdAt; @@ -103,11 +124,21 @@ public Optional getMeterId() { return meterId; } + @JsonProperty("package_size") + public int getPackageSize() { + return packageSize; + } + @JsonProperty("price") public int getPrice() { return price; } + @JsonProperty("price_decimal") + public Optional getPriceDecimal() { + return priceDecimal; + } + @JsonProperty("price_external_id") public String getPriceExternalId() { return priceExternalId; @@ -118,6 +149,11 @@ public String getProductExternalId() { return productExternalId; } + @JsonProperty("tiers_mode") + public Optional getTiersMode() { + return tiersMode; + } + @JsonProperty("updated_at") public OffsetDateTime getUpdatedAt() { return updatedAt; @@ -140,15 +176,19 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingProductPriceResponseData other) { - return createdAt.equals(other.createdAt) + return billingScheme.equals(other.billingScheme) + && createdAt.equals(other.createdAt) && currency.equals(other.currency) && id.equals(other.id) && interval.equals(other.interval) && isActive == other.isActive && meterId.equals(other.meterId) + && packageSize == other.packageSize && price == other.price + && priceDecimal.equals(other.priceDecimal) && priceExternalId.equals(other.priceExternalId) && productExternalId.equals(other.productExternalId) + && tiersMode.equals(other.tiersMode) && updatedAt.equals(other.updatedAt) && usageType.equals(other.usageType); } @@ -156,15 +196,19 @@ private boolean equalTo(BillingProductPriceResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.billingScheme, this.createdAt, this.currency, this.id, this.interval, this.isActive, this.meterId, + this.packageSize, this.price, + this.priceDecimal, this.priceExternalId, this.productExternalId, + this.tiersMode, this.updatedAt, this.usageType); } @@ -174,16 +218,20 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CreatedAtStage builder() { + public static BillingSchemeStage builder() { return new Builder(); } - public interface CreatedAtStage { - CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); + public interface BillingSchemeStage { + CreatedAtStage billingScheme(@NotNull String billingScheme); Builder from(BillingProductPriceResponseData other); } + public interface CreatedAtStage { + CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); + } + public interface CurrencyStage { IdStage currency(@NotNull String currency); } @@ -197,7 +245,11 @@ public interface IntervalStage { } public interface IsActiveStage { - PriceStage isActive(boolean isActive); + PackageSizeStage isActive(boolean isActive); + } + + public interface PackageSizeStage { + PriceStage packageSize(int packageSize); } public interface PriceStage { @@ -226,21 +278,33 @@ public interface _FinalStage { _FinalStage meterId(Optional meterId); _FinalStage meterId(String meterId); + + _FinalStage priceDecimal(Optional priceDecimal); + + _FinalStage priceDecimal(String priceDecimal); + + _FinalStage tiersMode(Optional tiersMode); + + _FinalStage tiersMode(String tiersMode); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CreatedAtStage, + implements BillingSchemeStage, + CreatedAtStage, CurrencyStage, IdStage, IntervalStage, IsActiveStage, + PackageSizeStage, PriceStage, PriceExternalIdStage, ProductExternalIdStage, UpdatedAtStage, UsageTypeStage, _FinalStage { + private String billingScheme; + private OffsetDateTime createdAt; private String currency; @@ -251,6 +315,8 @@ public static final class Builder private boolean isActive; + private int packageSize; + private int price; private String priceExternalId; @@ -261,6 +327,10 @@ public static final class Builder private String usageType; + private Optional tiersMode = Optional.empty(); + + private Optional priceDecimal = Optional.empty(); + private Optional meterId = Optional.empty(); @JsonAnySetter @@ -270,20 +340,31 @@ private Builder() {} @java.lang.Override public Builder from(BillingProductPriceResponseData other) { + billingScheme(other.getBillingScheme()); createdAt(other.getCreatedAt()); currency(other.getCurrency()); id(other.getId()); interval(other.getInterval()); isActive(other.getIsActive()); meterId(other.getMeterId()); + packageSize(other.getPackageSize()); price(other.getPrice()); + priceDecimal(other.getPriceDecimal()); priceExternalId(other.getPriceExternalId()); productExternalId(other.getProductExternalId()); + tiersMode(other.getTiersMode()); updatedAt(other.getUpdatedAt()); usageType(other.getUsageType()); return this; } + @java.lang.Override + @JsonSetter("billing_scheme") + public CreatedAtStage billingScheme(@NotNull String billingScheme) { + this.billingScheme = Objects.requireNonNull(billingScheme, "billingScheme must not be null"); + return this; + } + @java.lang.Override @JsonSetter("created_at") public CurrencyStage createdAt(@NotNull OffsetDateTime createdAt) { @@ -314,11 +395,18 @@ public IsActiveStage interval(@NotNull String interval) { @java.lang.Override @JsonSetter("is_active") - public PriceStage isActive(boolean isActive) { + public PackageSizeStage isActive(boolean isActive) { this.isActive = isActive; return this; } + @java.lang.Override + @JsonSetter("package_size") + public PriceStage packageSize(int packageSize) { + this.packageSize = packageSize; + return this; + } + @java.lang.Override @JsonSetter("price") public PriceExternalIdStage price(int price) { @@ -354,6 +442,32 @@ public _FinalStage usageType(@NotNull String usageType) { return this; } + @java.lang.Override + public _FinalStage tiersMode(String tiersMode) { + this.tiersMode = Optional.ofNullable(tiersMode); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tiers_mode", nulls = Nulls.SKIP) + public _FinalStage tiersMode(Optional tiersMode) { + this.tiersMode = tiersMode; + return this; + } + + @java.lang.Override + public _FinalStage priceDecimal(String priceDecimal) { + this.priceDecimal = Optional.ofNullable(priceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_decimal", nulls = Nulls.SKIP) + public _FinalStage priceDecimal(Optional priceDecimal) { + this.priceDecimal = priceDecimal; + return this; + } + @java.lang.Override public _FinalStage meterId(String meterId) { this.meterId = Optional.ofNullable(meterId); @@ -370,15 +484,19 @@ public _FinalStage meterId(Optional meterId) { @java.lang.Override public BillingProductPriceResponseData build() { return new BillingProductPriceResponseData( + billingScheme, createdAt, currency, id, interval, isActive, meterId, + packageSize, price, + priceDecimal, priceExternalId, productExternalId, + tiersMode, updatedAt, usageType, additionalProperties); diff --git a/src/main/java/com/schematic/api/types/BillingProductPriceTierResponseData.java b/src/main/java/com/schematic/api/types/BillingProductPriceTierResponseData.java new file mode 100644 index 0000000..a86b7a1 --- /dev/null +++ b/src/main/java/com/schematic/api/types/BillingProductPriceTierResponseData.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BillingProductPriceTierResponseData.Builder.class) +public final class BillingProductPriceTierResponseData { + private final Optional flatAmount; + + private final Optional perUnitPrice; + + private final Optional perUnitPriceDecimal; + + private final Optional upTo; + + private final Map additionalProperties; + + private BillingProductPriceTierResponseData( + Optional flatAmount, + Optional perUnitPrice, + Optional perUnitPriceDecimal, + Optional upTo, + Map additionalProperties) { + this.flatAmount = flatAmount; + this.perUnitPrice = perUnitPrice; + this.perUnitPriceDecimal = perUnitPriceDecimal; + this.upTo = upTo; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("flat_amount") + public Optional getFlatAmount() { + return flatAmount; + } + + @JsonProperty("per_unit_price") + public Optional getPerUnitPrice() { + return perUnitPrice; + } + + @JsonProperty("per_unit_price_decimal") + public Optional getPerUnitPriceDecimal() { + return perUnitPriceDecimal; + } + + @JsonProperty("up_to") + public Optional getUpTo() { + return upTo; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BillingProductPriceTierResponseData + && equalTo((BillingProductPriceTierResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BillingProductPriceTierResponseData other) { + return flatAmount.equals(other.flatAmount) + && perUnitPrice.equals(other.perUnitPrice) + && perUnitPriceDecimal.equals(other.perUnitPriceDecimal) + && upTo.equals(other.upTo); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.flatAmount, this.perUnitPrice, this.perUnitPriceDecimal, this.upTo); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional flatAmount = Optional.empty(); + + private Optional perUnitPrice = Optional.empty(); + + private Optional perUnitPriceDecimal = Optional.empty(); + + private Optional upTo = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(BillingProductPriceTierResponseData other) { + flatAmount(other.getFlatAmount()); + perUnitPrice(other.getPerUnitPrice()); + perUnitPriceDecimal(other.getPerUnitPriceDecimal()); + upTo(other.getUpTo()); + return this; + } + + @JsonSetter(value = "flat_amount", nulls = Nulls.SKIP) + public Builder flatAmount(Optional flatAmount) { + this.flatAmount = flatAmount; + return this; + } + + public Builder flatAmount(Integer flatAmount) { + this.flatAmount = Optional.ofNullable(flatAmount); + return this; + } + + @JsonSetter(value = "per_unit_price", nulls = Nulls.SKIP) + public Builder perUnitPrice(Optional perUnitPrice) { + this.perUnitPrice = perUnitPrice; + return this; + } + + public Builder perUnitPrice(Integer perUnitPrice) { + this.perUnitPrice = Optional.ofNullable(perUnitPrice); + return this; + } + + @JsonSetter(value = "per_unit_price_decimal", nulls = Nulls.SKIP) + public Builder perUnitPriceDecimal(Optional perUnitPriceDecimal) { + this.perUnitPriceDecimal = perUnitPriceDecimal; + return this; + } + + public Builder perUnitPriceDecimal(String perUnitPriceDecimal) { + this.perUnitPriceDecimal = Optional.ofNullable(perUnitPriceDecimal); + return this; + } + + @JsonSetter(value = "up_to", nulls = Nulls.SKIP) + public Builder upTo(Optional upTo) { + this.upTo = upTo; + return this; + } + + public Builder upTo(Integer upTo) { + this.upTo = Optional.ofNullable(upTo); + return this; + } + + public BillingProductPriceTierResponseData build() { + return new BillingProductPriceTierResponseData( + flatAmount, perUnitPrice, perUnitPriceDecimal, upTo, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/BillingProductPricing.java b/src/main/java/com/schematic/api/types/BillingProductPricing.java index 4ef0d08..0325a7f 100644 --- a/src/main/java/com/schematic/api/types/BillingProductPricing.java +++ b/src/main/java/com/schematic/api/types/BillingProductPricing.java @@ -21,45 +21,66 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BillingProductPricing.Builder.class) public final class BillingProductPricing { + private final Optional billingThreshold; + private final String currency; private final String interval; private final Optional meterId; + private final Optional packageSize; + private final int price; + private final Optional priceDecimal; + private final String priceExternalId; private final String productExternalId; private final int quantity; + private final Optional subscriptionItemExternalId; + private final BillingProductPricingUsageType usageType; private final Map additionalProperties; private BillingProductPricing( + Optional billingThreshold, String currency, String interval, Optional meterId, + Optional packageSize, int price, + Optional priceDecimal, String priceExternalId, String productExternalId, int quantity, + Optional subscriptionItemExternalId, BillingProductPricingUsageType usageType, Map additionalProperties) { + this.billingThreshold = billingThreshold; this.currency = currency; this.interval = interval; this.meterId = meterId; + this.packageSize = packageSize; this.price = price; + this.priceDecimal = priceDecimal; this.priceExternalId = priceExternalId; this.productExternalId = productExternalId; this.quantity = quantity; + this.subscriptionItemExternalId = subscriptionItemExternalId; this.usageType = usageType; this.additionalProperties = additionalProperties; } + @JsonProperty("billing_threshold") + public Optional getBillingThreshold() { + return billingThreshold; + } + @JsonProperty("currency") public String getCurrency() { return currency; @@ -75,11 +96,21 @@ public Optional getMeterId() { return meterId; } + @JsonProperty("package_size") + public Optional getPackageSize() { + return packageSize; + } + @JsonProperty("price") public int getPrice() { return price; } + @JsonProperty("price_decimal") + public Optional getPriceDecimal() { + return priceDecimal; + } + @JsonProperty("price_external_id") public String getPriceExternalId() { return priceExternalId; @@ -95,6 +126,11 @@ public int getQuantity() { return quantity; } + @JsonProperty("subscription_item_external_id") + public Optional getSubscriptionItemExternalId() { + return subscriptionItemExternalId; + } + @JsonProperty("usage_type") public BillingProductPricingUsageType getUsageType() { return usageType; @@ -112,26 +148,34 @@ public Map getAdditionalProperties() { } private boolean equalTo(BillingProductPricing other) { - return currency.equals(other.currency) + return billingThreshold.equals(other.billingThreshold) + && currency.equals(other.currency) && interval.equals(other.interval) && meterId.equals(other.meterId) + && packageSize.equals(other.packageSize) && price == other.price + && priceDecimal.equals(other.priceDecimal) && priceExternalId.equals(other.priceExternalId) && productExternalId.equals(other.productExternalId) && quantity == other.quantity + && subscriptionItemExternalId.equals(other.subscriptionItemExternalId) && usageType.equals(other.usageType); } @java.lang.Override public int hashCode() { return Objects.hash( + this.billingThreshold, this.currency, this.interval, this.meterId, + this.packageSize, this.price, + this.priceDecimal, this.priceExternalId, this.productExternalId, this.quantity, + this.subscriptionItemExternalId, this.usageType); } @@ -177,9 +221,25 @@ public interface UsageTypeStage { public interface _FinalStage { BillingProductPricing build(); + _FinalStage billingThreshold(Optional billingThreshold); + + _FinalStage billingThreshold(Integer billingThreshold); + _FinalStage meterId(Optional meterId); _FinalStage meterId(String meterId); + + _FinalStage packageSize(Optional packageSize); + + _FinalStage packageSize(Integer packageSize); + + _FinalStage priceDecimal(Optional priceDecimal); + + _FinalStage priceDecimal(String priceDecimal); + + _FinalStage subscriptionItemExternalId(Optional subscriptionItemExternalId); + + _FinalStage subscriptionItemExternalId(String subscriptionItemExternalId); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -206,8 +266,16 @@ public static final class Builder private BillingProductPricingUsageType usageType; + private Optional subscriptionItemExternalId = Optional.empty(); + + private Optional priceDecimal = Optional.empty(); + + private Optional packageSize = Optional.empty(); + private Optional meterId = Optional.empty(); + private Optional billingThreshold = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -215,13 +283,17 @@ private Builder() {} @java.lang.Override public Builder from(BillingProductPricing other) { + billingThreshold(other.getBillingThreshold()); currency(other.getCurrency()); interval(other.getInterval()); meterId(other.getMeterId()); + packageSize(other.getPackageSize()); price(other.getPrice()); + priceDecimal(other.getPriceDecimal()); priceExternalId(other.getPriceExternalId()); productExternalId(other.getProductExternalId()); quantity(other.getQuantity()); + subscriptionItemExternalId(other.getSubscriptionItemExternalId()); usageType(other.getUsageType()); return this; } @@ -275,6 +347,45 @@ public _FinalStage usageType(@NotNull BillingProductPricingUsageType usageType) return this; } + @java.lang.Override + public _FinalStage subscriptionItemExternalId(String subscriptionItemExternalId) { + this.subscriptionItemExternalId = Optional.ofNullable(subscriptionItemExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "subscription_item_external_id", nulls = Nulls.SKIP) + public _FinalStage subscriptionItemExternalId(Optional subscriptionItemExternalId) { + this.subscriptionItemExternalId = subscriptionItemExternalId; + return this; + } + + @java.lang.Override + public _FinalStage priceDecimal(String priceDecimal) { + this.priceDecimal = Optional.ofNullable(priceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_decimal", nulls = Nulls.SKIP) + public _FinalStage priceDecimal(Optional priceDecimal) { + this.priceDecimal = priceDecimal; + return this; + } + + @java.lang.Override + public _FinalStage packageSize(Integer packageSize) { + this.packageSize = Optional.ofNullable(packageSize); + return this; + } + + @java.lang.Override + @JsonSetter(value = "package_size", nulls = Nulls.SKIP) + public _FinalStage packageSize(Optional packageSize) { + this.packageSize = packageSize; + return this; + } + @java.lang.Override public _FinalStage meterId(String meterId) { this.meterId = Optional.ofNullable(meterId); @@ -288,16 +399,33 @@ public _FinalStage meterId(Optional meterId) { return this; } + @java.lang.Override + public _FinalStage billingThreshold(Integer billingThreshold) { + this.billingThreshold = Optional.ofNullable(billingThreshold); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_threshold", nulls = Nulls.SKIP) + public _FinalStage billingThreshold(Optional billingThreshold) { + this.billingThreshold = billingThreshold; + return this; + } + @java.lang.Override public BillingProductPricing build() { return new BillingProductPricing( + billingThreshold, currency, interval, meterId, + packageSize, price, + priceDecimal, priceExternalId, productExternalId, quantity, + subscriptionItemExternalId, usageType, additionalProperties); } diff --git a/src/main/java/com/schematic/api/types/BillingProductPricingUsageType.java b/src/main/java/com/schematic/api/types/BillingProductPricingUsageType.java index fda45ce..9e7a437 100644 --- a/src/main/java/com/schematic/api/types/BillingProductPricingUsageType.java +++ b/src/main/java/com/schematic/api/types/BillingProductPricingUsageType.java @@ -3,22 +3,84 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum BillingProductPricingUsageType { - LICENSED("licensed"), +public final class BillingProductPricingUsageType { + public static final BillingProductPricingUsageType METERED = + new BillingProductPricingUsageType(Value.METERED, "metered"); - METERED("metered"); + public static final BillingProductPricingUsageType LICENSED = + new BillingProductPricingUsageType(Value.LICENSED, "licensed"); - private final String value; + private final Value value; - BillingProductPricingUsageType(String value) { + private final String string; + + BillingProductPricingUsageType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof BillingProductPricingUsageType + && this.string.equals(((BillingProductPricingUsageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case METERED: + return visitor.visitMetered(); + case LICENSED: + return visitor.visitLicensed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static BillingProductPricingUsageType valueOf(String value) { + switch (value) { + case "metered": + return METERED; + case "licensed": + return LICENSED; + default: + return new BillingProductPricingUsageType(Value.UNKNOWN, value); + } + } + + public enum Value { + LICENSED, + + METERED, + + UNKNOWN + } + + public interface Visitor { + T visitLicensed(); + + T visitMetered(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/BillingProductResponseData.java b/src/main/java/com/schematic/api/types/BillingProductResponseData.java index 6287eeb..edb4cff 100644 --- a/src/main/java/com/schematic/api/types/BillingProductResponseData.java +++ b/src/main/java/com/schematic/api/types/BillingProductResponseData.java @@ -9,12 +9,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.time.OffsetDateTime; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -24,16 +26,20 @@ public final class BillingProductResponseData { private final OffsetDateTime createdAt; - private final String currency; + private final Optional currency; private final String environmentId; private final String externalId; + private final boolean isActive; + private final String name; private final double price; + private final Optional priceDecimal; + private final String productId; private final double quantity; @@ -45,11 +51,13 @@ public final class BillingProductResponseData { private BillingProductResponseData( String accountId, OffsetDateTime createdAt, - String currency, + Optional currency, String environmentId, String externalId, + boolean isActive, String name, double price, + Optional priceDecimal, String productId, double quantity, OffsetDateTime updatedAt, @@ -59,8 +67,10 @@ private BillingProductResponseData( this.currency = currency; this.environmentId = environmentId; this.externalId = externalId; + this.isActive = isActive; this.name = name; this.price = price; + this.priceDecimal = priceDecimal; this.productId = productId; this.quantity = quantity; this.updatedAt = updatedAt; @@ -77,8 +87,11 @@ public OffsetDateTime getCreatedAt() { return createdAt; } + /** + * @return Deprecated; currencies are associated with prices, not products + */ @JsonProperty("currency") - public String getCurrency() { + public Optional getCurrency() { return currency; } @@ -92,6 +105,11 @@ public String getExternalId() { return externalId; } + @JsonProperty("is_active") + public boolean getIsActive() { + return isActive; + } + @JsonProperty("name") public String getName() { return name; @@ -102,6 +120,11 @@ public double getPrice() { return price; } + @JsonProperty("price_decimal") + public Optional getPriceDecimal() { + return priceDecimal; + } + @JsonProperty("product_id") public String getProductId() { return productId; @@ -134,8 +157,10 @@ private boolean equalTo(BillingProductResponseData other) { && currency.equals(other.currency) && environmentId.equals(other.environmentId) && externalId.equals(other.externalId) + && isActive == other.isActive && name.equals(other.name) && price == other.price + && priceDecimal.equals(other.priceDecimal) && productId.equals(other.productId) && quantity == other.quantity && updatedAt.equals(other.updatedAt); @@ -149,8 +174,10 @@ public int hashCode() { this.currency, this.environmentId, this.externalId, + this.isActive, this.name, this.price, + this.priceDecimal, this.productId, this.quantity, this.updatedAt); @@ -172,11 +199,7 @@ public interface AccountIdStage { } public interface CreatedAtStage { - CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); - } - - public interface CurrencyStage { - EnvironmentIdStage currency(@NotNull String currency); + EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); } public interface EnvironmentIdStage { @@ -184,7 +207,11 @@ public interface EnvironmentIdStage { } public interface ExternalIdStage { - NameStage externalId(@NotNull String externalId); + IsActiveStage externalId(@NotNull String externalId); + } + + public interface IsActiveStage { + NameStage isActive(boolean isActive); } public interface NameStage { @@ -209,15 +236,26 @@ public interface UpdatedAtStage { public interface _FinalStage { BillingProductResponseData build(); + + /** + *

Deprecated; currencies are associated with prices, not products

+ */ + _FinalStage currency(Optional currency); + + _FinalStage currency(String currency); + + _FinalStage priceDecimal(Optional priceDecimal); + + _FinalStage priceDecimal(String priceDecimal); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements AccountIdStage, CreatedAtStage, - CurrencyStage, EnvironmentIdStage, ExternalIdStage, + IsActiveStage, NameStage, PriceStage, ProductIdStage, @@ -228,12 +266,12 @@ public static final class Builder private OffsetDateTime createdAt; - private String currency; - private String environmentId; private String externalId; + private boolean isActive; + private String name; private double price; @@ -244,6 +282,10 @@ public static final class Builder private OffsetDateTime updatedAt; + private Optional priceDecimal = Optional.empty(); + + private Optional currency = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -256,8 +298,10 @@ public Builder from(BillingProductResponseData other) { currency(other.getCurrency()); environmentId(other.getEnvironmentId()); externalId(other.getExternalId()); + isActive(other.getIsActive()); name(other.getName()); price(other.getPrice()); + priceDecimal(other.getPriceDecimal()); productId(other.getProductId()); quantity(other.getQuantity()); updatedAt(other.getUpdatedAt()); @@ -273,18 +317,11 @@ public CreatedAtStage accountId(@NotNull String accountId) { @java.lang.Override @JsonSetter("created_at") - public CurrencyStage createdAt(@NotNull OffsetDateTime createdAt) { + public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); return this; } - @java.lang.Override - @JsonSetter("currency") - public EnvironmentIdStage currency(@NotNull String currency) { - this.currency = Objects.requireNonNull(currency, "currency must not be null"); - return this; - } - @java.lang.Override @JsonSetter("environment_id") public ExternalIdStage environmentId(@NotNull String environmentId) { @@ -294,11 +331,18 @@ public ExternalIdStage environmentId(@NotNull String environmentId) { @java.lang.Override @JsonSetter("external_id") - public NameStage externalId(@NotNull String externalId) { + public IsActiveStage externalId(@NotNull String externalId) { this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); return this; } + @java.lang.Override + @JsonSetter("is_active") + public NameStage isActive(boolean isActive) { + this.isActive = isActive; + return this; + } + @java.lang.Override @JsonSetter("name") public PriceStage name(@NotNull String name) { @@ -334,6 +378,39 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { return this; } + @java.lang.Override + public _FinalStage priceDecimal(String priceDecimal) { + this.priceDecimal = Optional.ofNullable(priceDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_decimal", nulls = Nulls.SKIP) + public _FinalStage priceDecimal(Optional priceDecimal) { + this.priceDecimal = priceDecimal; + return this; + } + + /** + *

Deprecated; currencies are associated with prices, not products

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage currency(String currency) { + this.currency = Optional.ofNullable(currency); + return this; + } + + /** + *

Deprecated; currencies are associated with prices, not products

+ */ + @java.lang.Override + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public _FinalStage currency(Optional currency) { + this.currency = currency; + return this; + } + @java.lang.Override public BillingProductResponseData build() { return new BillingProductResponseData( @@ -342,8 +419,10 @@ public BillingProductResponseData build() { currency, environmentId, externalId, + isActive, name, price, + priceDecimal, productId, quantity, updatedAt, diff --git a/src/main/java/com/schematic/api/types/BillingSubscriptionView.java b/src/main/java/com/schematic/api/types/BillingSubscriptionView.java index e23e4ba..897f01c 100644 --- a/src/main/java/com/schematic/api/types/BillingSubscriptionView.java +++ b/src/main/java/com/schematic/api/types/BillingSubscriptionView.java @@ -596,7 +596,9 @@ public _FinalStage trialEnd(Optional trialEnd) { @java.lang.Override public _FinalStage addAllProducts(List products) { - this.products.addAll(products); + if (products != null) { + this.products.addAll(products); + } return this; } @@ -610,7 +612,9 @@ public _FinalStage addProducts(BillingProductForSubscriptionResponseData product @JsonSetter(value = "products", nulls = Nulls.SKIP) public _FinalStage products(List products) { this.products.clear(); - this.products.addAll(products); + if (products != null) { + this.products.addAll(products); + } return this; } @@ -668,7 +672,9 @@ public _FinalStage expiredAt(Optional expiredAt) { @java.lang.Override public _FinalStage addAllDiscounts(List discounts) { - this.discounts.addAll(discounts); + if (discounts != null) { + this.discounts.addAll(discounts); + } return this; } @@ -682,7 +688,9 @@ public _FinalStage addDiscounts(BillingSubscriptionDiscountView discounts) { @JsonSetter(value = "discounts", nulls = Nulls.SKIP) public _FinalStage discounts(List discounts) { this.discounts.clear(); - this.discounts.addAll(discounts); + if (discounts != null) { + this.discounts.addAll(discounts); + } return this; } diff --git a/src/main/java/com/schematic/api/types/ChangeSubscriptionInternalRequestBody.java b/src/main/java/com/schematic/api/types/ChangeSubscriptionInternalRequestBody.java index 96e1195..0b247cd 100644 --- a/src/main/java/com/schematic/api/types/ChangeSubscriptionInternalRequestBody.java +++ b/src/main/java/com/schematic/api/types/ChangeSubscriptionInternalRequestBody.java @@ -29,6 +29,8 @@ public final class ChangeSubscriptionInternalRequestBody { private final Optional couponExternalId; + private final List creditBundles; + private final String newPlanId; private final String newPriceId; @@ -39,26 +41,32 @@ public final class ChangeSubscriptionInternalRequestBody { private final Optional promoCode; + private final boolean skipTrial; + private final Map additionalProperties; private ChangeSubscriptionInternalRequestBody( List addOnIds, String companyId, Optional couponExternalId, + List creditBundles, String newPlanId, String newPriceId, List payInAdvance, Optional paymentMethodId, Optional promoCode, + boolean skipTrial, Map additionalProperties) { this.addOnIds = addOnIds; this.companyId = companyId; this.couponExternalId = couponExternalId; + this.creditBundles = creditBundles; this.newPlanId = newPlanId; this.newPriceId = newPriceId; this.payInAdvance = payInAdvance; this.paymentMethodId = paymentMethodId; this.promoCode = promoCode; + this.skipTrial = skipTrial; this.additionalProperties = additionalProperties; } @@ -77,6 +85,11 @@ public Optional getCouponExternalId() { return couponExternalId; } + @JsonProperty("credit_bundles") + public List getCreditBundles() { + return creditBundles; + } + @JsonProperty("new_plan_id") public String getNewPlanId() { return newPlanId; @@ -102,6 +115,11 @@ public Optional getPromoCode() { return promoCode; } + @JsonProperty("skip_trial") + public boolean getSkipTrial() { + return skipTrial; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -118,11 +136,13 @@ private boolean equalTo(ChangeSubscriptionInternalRequestBody other) { return addOnIds.equals(other.addOnIds) && companyId.equals(other.companyId) && couponExternalId.equals(other.couponExternalId) + && creditBundles.equals(other.creditBundles) && newPlanId.equals(other.newPlanId) && newPriceId.equals(other.newPriceId) && payInAdvance.equals(other.payInAdvance) && paymentMethodId.equals(other.paymentMethodId) - && promoCode.equals(other.promoCode); + && promoCode.equals(other.promoCode) + && skipTrial == other.skipTrial; } @java.lang.Override @@ -131,11 +151,13 @@ public int hashCode() { this.addOnIds, this.companyId, this.couponExternalId, + this.creditBundles, this.newPlanId, this.newPriceId, this.payInAdvance, this.paymentMethodId, - this.promoCode); + this.promoCode, + this.skipTrial); } @java.lang.Override @@ -158,7 +180,11 @@ public interface NewPlanIdStage { } public interface NewPriceIdStage { - _FinalStage newPriceId(@NotNull String newPriceId); + SkipTrialStage newPriceId(@NotNull String newPriceId); + } + + public interface SkipTrialStage { + _FinalStage skipTrial(boolean skipTrial); } public interface _FinalStage { @@ -174,6 +200,12 @@ public interface _FinalStage { _FinalStage couponExternalId(String couponExternalId); + _FinalStage creditBundles(List creditBundles); + + _FinalStage addCreditBundles(UpdateCreditBundleRequestBody creditBundles); + + _FinalStage addAllCreditBundles(List creditBundles); + _FinalStage payInAdvance(List payInAdvance); _FinalStage addPayInAdvance(UpdatePayInAdvanceRequestBody payInAdvance); @@ -190,19 +222,24 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements CompanyIdStage, NewPlanIdStage, NewPriceIdStage, _FinalStage { + public static final class Builder + implements CompanyIdStage, NewPlanIdStage, NewPriceIdStage, SkipTrialStage, _FinalStage { private String companyId; private String newPlanId; private String newPriceId; + private boolean skipTrial; + private Optional promoCode = Optional.empty(); private Optional paymentMethodId = Optional.empty(); private List payInAdvance = new ArrayList<>(); + private List creditBundles = new ArrayList<>(); + private Optional couponExternalId = Optional.empty(); private List addOnIds = new ArrayList<>(); @@ -217,11 +254,13 @@ public Builder from(ChangeSubscriptionInternalRequestBody other) { addOnIds(other.getAddOnIds()); companyId(other.getCompanyId()); couponExternalId(other.getCouponExternalId()); + creditBundles(other.getCreditBundles()); newPlanId(other.getNewPlanId()); newPriceId(other.getNewPriceId()); payInAdvance(other.getPayInAdvance()); paymentMethodId(other.getPaymentMethodId()); promoCode(other.getPromoCode()); + skipTrial(other.getSkipTrial()); return this; } @@ -241,11 +280,18 @@ public NewPriceIdStage newPlanId(@NotNull String newPlanId) { @java.lang.Override @JsonSetter("new_price_id") - public _FinalStage newPriceId(@NotNull String newPriceId) { + public SkipTrialStage newPriceId(@NotNull String newPriceId) { this.newPriceId = Objects.requireNonNull(newPriceId, "newPriceId must not be null"); return this; } + @java.lang.Override + @JsonSetter("skip_trial") + public _FinalStage skipTrial(boolean skipTrial) { + this.skipTrial = skipTrial; + return this; + } + @java.lang.Override public _FinalStage promoCode(String promoCode) { this.promoCode = Optional.ofNullable(promoCode); @@ -274,7 +320,9 @@ public _FinalStage paymentMethodId(Optional paymentMethodId) { @java.lang.Override public _FinalStage addAllPayInAdvance(List payInAdvance) { - this.payInAdvance.addAll(payInAdvance); + if (payInAdvance != null) { + this.payInAdvance.addAll(payInAdvance); + } return this; } @@ -288,7 +336,33 @@ public _FinalStage addPayInAdvance(UpdatePayInAdvanceRequestBody payInAdvance) { @JsonSetter(value = "pay_in_advance", nulls = Nulls.SKIP) public _FinalStage payInAdvance(List payInAdvance) { this.payInAdvance.clear(); - this.payInAdvance.addAll(payInAdvance); + if (payInAdvance != null) { + this.payInAdvance.addAll(payInAdvance); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllCreditBundles(List creditBundles) { + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } + return this; + } + + @java.lang.Override + public _FinalStage addCreditBundles(UpdateCreditBundleRequestBody creditBundles) { + this.creditBundles.add(creditBundles); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_bundles", nulls = Nulls.SKIP) + public _FinalStage creditBundles(List creditBundles) { + this.creditBundles.clear(); + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } return this; } @@ -307,7 +381,9 @@ public _FinalStage couponExternalId(Optional couponExternalId) { @java.lang.Override public _FinalStage addAllAddOnIds(List addOnIds) { - this.addOnIds.addAll(addOnIds); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } return this; } @@ -321,7 +397,9 @@ public _FinalStage addAddOnIds(UpdateAddOnRequestBody addOnIds) { @JsonSetter(value = "add_on_ids", nulls = Nulls.SKIP) public _FinalStage addOnIds(List addOnIds) { this.addOnIds.clear(); - this.addOnIds.addAll(addOnIds); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } return this; } @@ -331,11 +409,13 @@ public ChangeSubscriptionInternalRequestBody build() { addOnIds, companyId, couponExternalId, + creditBundles, newPlanId, newPriceId, payInAdvance, paymentMethodId, promoCode, + skipTrial, additionalProperties); } } diff --git a/src/main/java/com/schematic/api/types/ChangeSubscriptionRequestBody.java b/src/main/java/com/schematic/api/types/ChangeSubscriptionRequestBody.java index 544a797..ecc9fc6 100644 --- a/src/main/java/com/schematic/api/types/ChangeSubscriptionRequestBody.java +++ b/src/main/java/com/schematic/api/types/ChangeSubscriptionRequestBody.java @@ -27,6 +27,8 @@ public final class ChangeSubscriptionRequestBody { private final Optional couponExternalId; + private final List creditBundles; + private final String newPlanId; private final String newPriceId; @@ -37,24 +39,30 @@ public final class ChangeSubscriptionRequestBody { private final Optional promoCode; + private final boolean skipTrial; + private final Map additionalProperties; private ChangeSubscriptionRequestBody( List addOnIds, Optional couponExternalId, + List creditBundles, String newPlanId, String newPriceId, List payInAdvance, Optional paymentMethodId, Optional promoCode, + boolean skipTrial, Map additionalProperties) { this.addOnIds = addOnIds; this.couponExternalId = couponExternalId; + this.creditBundles = creditBundles; this.newPlanId = newPlanId; this.newPriceId = newPriceId; this.payInAdvance = payInAdvance; this.paymentMethodId = paymentMethodId; this.promoCode = promoCode; + this.skipTrial = skipTrial; this.additionalProperties = additionalProperties; } @@ -68,6 +76,11 @@ public Optional getCouponExternalId() { return couponExternalId; } + @JsonProperty("credit_bundles") + public List getCreditBundles() { + return creditBundles; + } + @JsonProperty("new_plan_id") public String getNewPlanId() { return newPlanId; @@ -93,6 +106,11 @@ public Optional getPromoCode() { return promoCode; } + @JsonProperty("skip_trial") + public boolean getSkipTrial() { + return skipTrial; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -107,11 +125,13 @@ public Map getAdditionalProperties() { private boolean equalTo(ChangeSubscriptionRequestBody other) { return addOnIds.equals(other.addOnIds) && couponExternalId.equals(other.couponExternalId) + && creditBundles.equals(other.creditBundles) && newPlanId.equals(other.newPlanId) && newPriceId.equals(other.newPriceId) && payInAdvance.equals(other.payInAdvance) && paymentMethodId.equals(other.paymentMethodId) - && promoCode.equals(other.promoCode); + && promoCode.equals(other.promoCode) + && skipTrial == other.skipTrial; } @java.lang.Override @@ -119,11 +139,13 @@ public int hashCode() { return Objects.hash( this.addOnIds, this.couponExternalId, + this.creditBundles, this.newPlanId, this.newPriceId, this.payInAdvance, this.paymentMethodId, - this.promoCode); + this.promoCode, + this.skipTrial); } @java.lang.Override @@ -142,7 +164,11 @@ public interface NewPlanIdStage { } public interface NewPriceIdStage { - _FinalStage newPriceId(@NotNull String newPriceId); + SkipTrialStage newPriceId(@NotNull String newPriceId); + } + + public interface SkipTrialStage { + _FinalStage skipTrial(boolean skipTrial); } public interface _FinalStage { @@ -158,6 +184,12 @@ public interface _FinalStage { _FinalStage couponExternalId(String couponExternalId); + _FinalStage creditBundles(List creditBundles); + + _FinalStage addCreditBundles(UpdateCreditBundleRequestBody creditBundles); + + _FinalStage addAllCreditBundles(List creditBundles); + _FinalStage payInAdvance(List payInAdvance); _FinalStage addPayInAdvance(UpdatePayInAdvanceRequestBody payInAdvance); @@ -174,17 +206,21 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NewPlanIdStage, NewPriceIdStage, _FinalStage { + public static final class Builder implements NewPlanIdStage, NewPriceIdStage, SkipTrialStage, _FinalStage { private String newPlanId; private String newPriceId; + private boolean skipTrial; + private Optional promoCode = Optional.empty(); private Optional paymentMethodId = Optional.empty(); private List payInAdvance = new ArrayList<>(); + private List creditBundles = new ArrayList<>(); + private Optional couponExternalId = Optional.empty(); private List addOnIds = new ArrayList<>(); @@ -198,11 +234,13 @@ private Builder() {} public Builder from(ChangeSubscriptionRequestBody other) { addOnIds(other.getAddOnIds()); couponExternalId(other.getCouponExternalId()); + creditBundles(other.getCreditBundles()); newPlanId(other.getNewPlanId()); newPriceId(other.getNewPriceId()); payInAdvance(other.getPayInAdvance()); paymentMethodId(other.getPaymentMethodId()); promoCode(other.getPromoCode()); + skipTrial(other.getSkipTrial()); return this; } @@ -215,11 +253,18 @@ public NewPriceIdStage newPlanId(@NotNull String newPlanId) { @java.lang.Override @JsonSetter("new_price_id") - public _FinalStage newPriceId(@NotNull String newPriceId) { + public SkipTrialStage newPriceId(@NotNull String newPriceId) { this.newPriceId = Objects.requireNonNull(newPriceId, "newPriceId must not be null"); return this; } + @java.lang.Override + @JsonSetter("skip_trial") + public _FinalStage skipTrial(boolean skipTrial) { + this.skipTrial = skipTrial; + return this; + } + @java.lang.Override public _FinalStage promoCode(String promoCode) { this.promoCode = Optional.ofNullable(promoCode); @@ -248,7 +293,9 @@ public _FinalStage paymentMethodId(Optional paymentMethodId) { @java.lang.Override public _FinalStage addAllPayInAdvance(List payInAdvance) { - this.payInAdvance.addAll(payInAdvance); + if (payInAdvance != null) { + this.payInAdvance.addAll(payInAdvance); + } return this; } @@ -262,7 +309,33 @@ public _FinalStage addPayInAdvance(UpdatePayInAdvanceRequestBody payInAdvance) { @JsonSetter(value = "pay_in_advance", nulls = Nulls.SKIP) public _FinalStage payInAdvance(List payInAdvance) { this.payInAdvance.clear(); - this.payInAdvance.addAll(payInAdvance); + if (payInAdvance != null) { + this.payInAdvance.addAll(payInAdvance); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllCreditBundles(List creditBundles) { + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } + return this; + } + + @java.lang.Override + public _FinalStage addCreditBundles(UpdateCreditBundleRequestBody creditBundles) { + this.creditBundles.add(creditBundles); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_bundles", nulls = Nulls.SKIP) + public _FinalStage creditBundles(List creditBundles) { + this.creditBundles.clear(); + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } return this; } @@ -281,7 +354,9 @@ public _FinalStage couponExternalId(Optional couponExternalId) { @java.lang.Override public _FinalStage addAllAddOnIds(List addOnIds) { - this.addOnIds.addAll(addOnIds); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } return this; } @@ -295,7 +370,9 @@ public _FinalStage addAddOnIds(UpdateAddOnRequestBody addOnIds) { @JsonSetter(value = "add_on_ids", nulls = Nulls.SKIP) public _FinalStage addOnIds(List addOnIds) { this.addOnIds.clear(); - this.addOnIds.addAll(addOnIds); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } return this; } @@ -304,11 +381,13 @@ public ChangeSubscriptionRequestBody build() { return new ChangeSubscriptionRequestBody( addOnIds, couponExternalId, + creditBundles, newPlanId, newPriceId, payInAdvance, paymentMethodId, promoCode, + skipTrial, additionalProperties); } } diff --git a/src/main/java/com/schematic/api/types/CheckFlagResponseData.java b/src/main/java/com/schematic/api/types/CheckFlagResponseData.java index 59f6f4e..60a627b 100644 --- a/src/main/java/com/schematic/api/types/CheckFlagResponseData.java +++ b/src/main/java/com/schematic/api/types/CheckFlagResponseData.java @@ -30,6 +30,8 @@ public final class CheckFlagResponseData { private final Optional featureUsage; + private final Optional featureUsageEvent; + private final Optional featureUsagePeriod; private final Optional featureUsageResetAt; @@ -55,6 +57,7 @@ private CheckFlagResponseData( Optional error, Optional featureAllocation, Optional featureUsage, + Optional featureUsageEvent, Optional featureUsagePeriod, Optional featureUsageResetAt, String flag, @@ -69,6 +72,7 @@ private CheckFlagResponseData( this.error = error; this.featureAllocation = featureAllocation; this.featureUsage = featureUsage; + this.featureUsageEvent = featureUsageEvent; this.featureUsagePeriod = featureUsagePeriod; this.featureUsageResetAt = featureUsageResetAt; this.flag = flag; @@ -113,6 +117,14 @@ public Optional getFeatureUsage() { return featureUsage; } + /** + * @return If an event-based numeric feature entitlement rule was matched, the event used to track its usage + */ + @JsonProperty("feature_usage_event") + public Optional getFeatureUsageEvent() { + return featureUsageEvent; + } + /** * @return For event-based feature entitlement rules, the period over which usage is tracked (current_month, current_day, current_week, all_time) */ @@ -201,6 +213,7 @@ private boolean equalTo(CheckFlagResponseData other) { && error.equals(other.error) && featureAllocation.equals(other.featureAllocation) && featureUsage.equals(other.featureUsage) + && featureUsageEvent.equals(other.featureUsageEvent) && featureUsagePeriod.equals(other.featureUsagePeriod) && featureUsageResetAt.equals(other.featureUsageResetAt) && flag.equals(other.flag) @@ -219,6 +232,7 @@ public int hashCode() { this.error, this.featureAllocation, this.featureUsage, + this.featureUsageEvent, this.featureUsagePeriod, this.featureUsageResetAt, this.flag, @@ -240,58 +254,104 @@ public static FlagStage builder() { } public interface FlagStage { + /** + *

The key used to check the flag

+ */ ReasonStage flag(@NotNull String flag); Builder from(CheckFlagResponseData other); } public interface ReasonStage { + /** + *

A human-readable explanation of the result

+ */ ValueStage reason(@NotNull String reason); } public interface ValueStage { + /** + *

A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted

+ */ _FinalStage value(boolean value); } public interface _FinalStage { CheckFlagResponseData build(); + /** + *

If company keys were provided and matched a company, its ID

+ */ _FinalStage companyId(Optional companyId); _FinalStage companyId(String companyId); + /** + *

If an error occurred while checking the flag, the error message

+ */ _FinalStage error(Optional error); _FinalStage error(String error); + /** + *

If a numeric feature entitlement rule was matched, its allocation

+ */ _FinalStage featureAllocation(Optional featureAllocation); _FinalStage featureAllocation(Integer featureAllocation); + /** + *

If a numeric feature entitlement rule was matched, the company's usage

+ */ _FinalStage featureUsage(Optional featureUsage); _FinalStage featureUsage(Integer featureUsage); + /** + *

If an event-based numeric feature entitlement rule was matched, the event used to track its usage

+ */ + _FinalStage featureUsageEvent(Optional featureUsageEvent); + + _FinalStage featureUsageEvent(String featureUsageEvent); + + /** + *

For event-based feature entitlement rules, the period over which usage is tracked (current_month, current_day, current_week, all_time)

+ */ _FinalStage featureUsagePeriod(Optional featureUsagePeriod); _FinalStage featureUsagePeriod(String featureUsagePeriod); + /** + *

For event-based feature entitlement rules, when the usage period will reset

+ */ _FinalStage featureUsageResetAt(Optional featureUsageResetAt); _FinalStage featureUsageResetAt(OffsetDateTime featureUsageResetAt); + /** + *

If a flag was found, its ID

+ */ _FinalStage flagId(Optional flagId); _FinalStage flagId(String flagId); + /** + *

If a rule was found, its ID

+ */ _FinalStage ruleId(Optional ruleId); _FinalStage ruleId(String ruleId); + /** + *

If a rule was found, its type

+ */ _FinalStage ruleType(Optional ruleType); _FinalStage ruleType(String ruleType); + /** + *

If user keys were provided and matched a user, its ID

+ */ _FinalStage userId(Optional userId); _FinalStage userId(String userId); @@ -317,6 +377,8 @@ public static final class Builder implements FlagStage, ReasonStage, ValueStage, private Optional featureUsagePeriod = Optional.empty(); + private Optional featureUsageEvent = Optional.empty(); + private Optional featureUsage = Optional.empty(); private Optional featureAllocation = Optional.empty(); @@ -336,6 +398,7 @@ public Builder from(CheckFlagResponseData other) { error(other.getError()); featureAllocation(other.getFeatureAllocation()); featureUsage(other.getFeatureUsage()); + featureUsageEvent(other.getFeatureUsageEvent()); featureUsagePeriod(other.getFeatureUsagePeriod()); featureUsageResetAt(other.getFeatureUsageResetAt()); flag(other.getFlag()); @@ -349,6 +412,7 @@ public Builder from(CheckFlagResponseData other) { } /** + *

The key used to check the flag

*

The key used to check the flag

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -360,6 +424,7 @@ public ReasonStage flag(@NotNull String flag) { } /** + *

A human-readable explanation of the result

*

A human-readable explanation of the result

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -371,6 +436,7 @@ public ValueStage reason(@NotNull String reason) { } /** + *

A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted

*

A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -391,6 +457,9 @@ public _FinalStage userId(String userId) { return this; } + /** + *

If user keys were provided and matched a user, its ID

+ */ @java.lang.Override @JsonSetter(value = "user_id", nulls = Nulls.SKIP) public _FinalStage userId(Optional userId) { @@ -408,6 +477,9 @@ public _FinalStage ruleType(String ruleType) { return this; } + /** + *

If a rule was found, its type

+ */ @java.lang.Override @JsonSetter(value = "rule_type", nulls = Nulls.SKIP) public _FinalStage ruleType(Optional ruleType) { @@ -425,6 +497,9 @@ public _FinalStage ruleId(String ruleId) { return this; } + /** + *

If a rule was found, its ID

+ */ @java.lang.Override @JsonSetter(value = "rule_id", nulls = Nulls.SKIP) public _FinalStage ruleId(Optional ruleId) { @@ -442,6 +517,9 @@ public _FinalStage flagId(String flagId) { return this; } + /** + *

If a flag was found, its ID

+ */ @java.lang.Override @JsonSetter(value = "flag_id", nulls = Nulls.SKIP) public _FinalStage flagId(Optional flagId) { @@ -459,6 +537,9 @@ public _FinalStage featureUsageResetAt(OffsetDateTime featureUsageResetAt) { return this; } + /** + *

For event-based feature entitlement rules, when the usage period will reset

+ */ @java.lang.Override @JsonSetter(value = "feature_usage_reset_at", nulls = Nulls.SKIP) public _FinalStage featureUsageResetAt(Optional featureUsageResetAt) { @@ -476,6 +557,9 @@ public _FinalStage featureUsagePeriod(String featureUsagePeriod) { return this; } + /** + *

For event-based feature entitlement rules, the period over which usage is tracked (current_month, current_day, current_week, all_time)

+ */ @java.lang.Override @JsonSetter(value = "feature_usage_period", nulls = Nulls.SKIP) public _FinalStage featureUsagePeriod(Optional featureUsagePeriod) { @@ -483,6 +567,26 @@ public _FinalStage featureUsagePeriod(Optional featureUsagePeriod) { return this; } + /** + *

If an event-based numeric feature entitlement rule was matched, the event used to track its usage

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage featureUsageEvent(String featureUsageEvent) { + this.featureUsageEvent = Optional.ofNullable(featureUsageEvent); + return this; + } + + /** + *

If an event-based numeric feature entitlement rule was matched, the event used to track its usage

+ */ + @java.lang.Override + @JsonSetter(value = "feature_usage_event", nulls = Nulls.SKIP) + public _FinalStage featureUsageEvent(Optional featureUsageEvent) { + this.featureUsageEvent = featureUsageEvent; + return this; + } + /** *

If a numeric feature entitlement rule was matched, the company's usage

* @return Reference to {@code this} so that method calls can be chained together. @@ -493,6 +597,9 @@ public _FinalStage featureUsage(Integer featureUsage) { return this; } + /** + *

If a numeric feature entitlement rule was matched, the company's usage

+ */ @java.lang.Override @JsonSetter(value = "feature_usage", nulls = Nulls.SKIP) public _FinalStage featureUsage(Optional featureUsage) { @@ -510,6 +617,9 @@ public _FinalStage featureAllocation(Integer featureAllocation) { return this; } + /** + *

If a numeric feature entitlement rule was matched, its allocation

+ */ @java.lang.Override @JsonSetter(value = "feature_allocation", nulls = Nulls.SKIP) public _FinalStage featureAllocation(Optional featureAllocation) { @@ -527,6 +637,9 @@ public _FinalStage error(String error) { return this; } + /** + *

If an error occurred while checking the flag, the error message

+ */ @java.lang.Override @JsonSetter(value = "error", nulls = Nulls.SKIP) public _FinalStage error(Optional error) { @@ -544,6 +657,9 @@ public _FinalStage companyId(String companyId) { return this; } + /** + *

If company keys were provided and matched a company, its ID

+ */ @java.lang.Override @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public _FinalStage companyId(Optional companyId) { @@ -558,6 +674,7 @@ public CheckFlagResponseData build() { error, featureAllocation, featureUsage, + featureUsageEvent, featureUsagePeriod, featureUsageResetAt, flag, diff --git a/src/main/java/com/schematic/api/types/CheckFlagsResponseData.java b/src/main/java/com/schematic/api/types/CheckFlagsResponseData.java index 0375f8f..76eba1e 100644 --- a/src/main/java/com/schematic/api/types/CheckFlagsResponseData.java +++ b/src/main/java/com/schematic/api/types/CheckFlagsResponseData.java @@ -81,7 +81,9 @@ public Builder from(CheckFlagsResponseData other) { @JsonSetter(value = "flags", nulls = Nulls.SKIP) public Builder flags(List flags) { this.flags.clear(); - this.flags.addAll(flags); + if (flags != null) { + this.flags.addAll(flags); + } return this; } @@ -91,7 +93,9 @@ public Builder addFlags(CheckFlagResponseData flags) { } public Builder addAllFlags(List flags) { - this.flags.addAll(flags); + if (flags != null) { + this.flags.addAll(flags); + } return this; } diff --git a/src/main/java/com/schematic/api/types/CheckoutDataResponseData.java b/src/main/java/com/schematic/api/types/CheckoutDataResponseData.java index 6608b67..d8b10dd 100644 --- a/src/main/java/com/schematic/api/types/CheckoutDataResponseData.java +++ b/src/main/java/com/schematic/api/types/CheckoutDataResponseData.java @@ -28,10 +28,14 @@ public final class CheckoutDataResponseData { private final List activeUsageBasedEntitlements; + private final List availableCreditBundles; + private final Optional company; private final Optional featureUsage; + private final List selectedCreditBundles; + private final Optional selectedPlan; private final List selectedUsageBasedEntitlements; @@ -44,8 +48,10 @@ private CheckoutDataResponseData( List activeAddOns, Optional activePlan, List activeUsageBasedEntitlements, + List availableCreditBundles, Optional company, Optional featureUsage, + List selectedCreditBundles, Optional selectedPlan, List selectedUsageBasedEntitlements, Optional subscription, @@ -53,8 +59,10 @@ private CheckoutDataResponseData( this.activeAddOns = activeAddOns; this.activePlan = activePlan; this.activeUsageBasedEntitlements = activeUsageBasedEntitlements; + this.availableCreditBundles = availableCreditBundles; this.company = company; this.featureUsage = featureUsage; + this.selectedCreditBundles = selectedCreditBundles; this.selectedPlan = selectedPlan; this.selectedUsageBasedEntitlements = selectedUsageBasedEntitlements; this.subscription = subscription; @@ -76,6 +84,11 @@ public List getActiveUsageBasedEntitlements() return activeUsageBasedEntitlements; } + @JsonProperty("available_credit_bundles") + public List getAvailableCreditBundles() { + return availableCreditBundles; + } + @JsonProperty("company") public Optional getCompany() { return company; @@ -86,6 +99,11 @@ public Optional getFeatureUsage() { return featureUsage; } + @JsonProperty("selected_credit_bundles") + public List getSelectedCreditBundles() { + return selectedCreditBundles; + } + @JsonProperty("selected_plan") public Optional getSelectedPlan() { return selectedPlan; @@ -116,8 +134,10 @@ private boolean equalTo(CheckoutDataResponseData other) { return activeAddOns.equals(other.activeAddOns) && activePlan.equals(other.activePlan) && activeUsageBasedEntitlements.equals(other.activeUsageBasedEntitlements) + && availableCreditBundles.equals(other.availableCreditBundles) && company.equals(other.company) && featureUsage.equals(other.featureUsage) + && selectedCreditBundles.equals(other.selectedCreditBundles) && selectedPlan.equals(other.selectedPlan) && selectedUsageBasedEntitlements.equals(other.selectedUsageBasedEntitlements) && subscription.equals(other.subscription); @@ -129,8 +149,10 @@ public int hashCode() { this.activeAddOns, this.activePlan, this.activeUsageBasedEntitlements, + this.availableCreditBundles, this.company, this.featureUsage, + this.selectedCreditBundles, this.selectedPlan, this.selectedUsageBasedEntitlements, this.subscription); @@ -153,10 +175,14 @@ public static final class Builder { private List activeUsageBasedEntitlements = new ArrayList<>(); + private List availableCreditBundles = new ArrayList<>(); + private Optional company = Optional.empty(); private Optional featureUsage = Optional.empty(); + private List selectedCreditBundles = new ArrayList<>(); + private Optional selectedPlan = Optional.empty(); private List selectedUsageBasedEntitlements = new ArrayList<>(); @@ -172,8 +198,10 @@ public Builder from(CheckoutDataResponseData other) { activeAddOns(other.getActiveAddOns()); activePlan(other.getActivePlan()); activeUsageBasedEntitlements(other.getActiveUsageBasedEntitlements()); + availableCreditBundles(other.getAvailableCreditBundles()); company(other.getCompany()); featureUsage(other.getFeatureUsage()); + selectedCreditBundles(other.getSelectedCreditBundles()); selectedPlan(other.getSelectedPlan()); selectedUsageBasedEntitlements(other.getSelectedUsageBasedEntitlements()); subscription(other.getSubscription()); @@ -183,7 +211,9 @@ public Builder from(CheckoutDataResponseData other) { @JsonSetter(value = "active_add_ons", nulls = Nulls.SKIP) public Builder activeAddOns(List activeAddOns) { this.activeAddOns.clear(); - this.activeAddOns.addAll(activeAddOns); + if (activeAddOns != null) { + this.activeAddOns.addAll(activeAddOns); + } return this; } @@ -193,7 +223,9 @@ public Builder addActiveAddOns(PlanDetailResponseData activeAddOns) { } public Builder addAllActiveAddOns(List activeAddOns) { - this.activeAddOns.addAll(activeAddOns); + if (activeAddOns != null) { + this.activeAddOns.addAll(activeAddOns); + } return this; } @@ -212,7 +244,9 @@ public Builder activePlan(PlanDetailResponseData activePlan) { public Builder activeUsageBasedEntitlements( List activeUsageBasedEntitlements) { this.activeUsageBasedEntitlements.clear(); - this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + if (activeUsageBasedEntitlements != null) { + this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + } return this; } @@ -223,7 +257,30 @@ public Builder addActiveUsageBasedEntitlements(UsageBasedEntitlementResponseData public Builder addAllActiveUsageBasedEntitlements( List activeUsageBasedEntitlements) { - this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + if (activeUsageBasedEntitlements != null) { + this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + } + return this; + } + + @JsonSetter(value = "available_credit_bundles", nulls = Nulls.SKIP) + public Builder availableCreditBundles(List availableCreditBundles) { + this.availableCreditBundles.clear(); + if (availableCreditBundles != null) { + this.availableCreditBundles.addAll(availableCreditBundles); + } + return this; + } + + public Builder addAvailableCreditBundles(BillingCreditBundleResponseData availableCreditBundles) { + this.availableCreditBundles.add(availableCreditBundles); + return this; + } + + public Builder addAllAvailableCreditBundles(List availableCreditBundles) { + if (availableCreditBundles != null) { + this.availableCreditBundles.addAll(availableCreditBundles); + } return this; } @@ -249,6 +306,27 @@ public Builder featureUsage(FeatureUsageDetailResponseData featureUsage) { return this; } + @JsonSetter(value = "selected_credit_bundles", nulls = Nulls.SKIP) + public Builder selectedCreditBundles(List selectedCreditBundles) { + this.selectedCreditBundles.clear(); + if (selectedCreditBundles != null) { + this.selectedCreditBundles.addAll(selectedCreditBundles); + } + return this; + } + + public Builder addSelectedCreditBundles(CreditBundlePurchaseResponseData selectedCreditBundles) { + this.selectedCreditBundles.add(selectedCreditBundles); + return this; + } + + public Builder addAllSelectedCreditBundles(List selectedCreditBundles) { + if (selectedCreditBundles != null) { + this.selectedCreditBundles.addAll(selectedCreditBundles); + } + return this; + } + @JsonSetter(value = "selected_plan", nulls = Nulls.SKIP) public Builder selectedPlan(Optional selectedPlan) { this.selectedPlan = selectedPlan; @@ -264,7 +342,9 @@ public Builder selectedPlan(PlanDetailResponseData selectedPlan) { public Builder selectedUsageBasedEntitlements( List selectedUsageBasedEntitlements) { this.selectedUsageBasedEntitlements.clear(); - this.selectedUsageBasedEntitlements.addAll(selectedUsageBasedEntitlements); + if (selectedUsageBasedEntitlements != null) { + this.selectedUsageBasedEntitlements.addAll(selectedUsageBasedEntitlements); + } return this; } @@ -276,7 +356,9 @@ public Builder addSelectedUsageBasedEntitlements( public Builder addAllSelectedUsageBasedEntitlements( List selectedUsageBasedEntitlements) { - this.selectedUsageBasedEntitlements.addAll(selectedUsageBasedEntitlements); + if (selectedUsageBasedEntitlements != null) { + this.selectedUsageBasedEntitlements.addAll(selectedUsageBasedEntitlements); + } return this; } @@ -296,8 +378,10 @@ public CheckoutDataResponseData build() { activeAddOns, activePlan, activeUsageBasedEntitlements, + availableCreditBundles, company, featureUsage, + selectedCreditBundles, selectedPlan, selectedUsageBasedEntitlements, subscription, diff --git a/src/main/java/com/schematic/api/types/CheckoutSettingsResponseData.java b/src/main/java/com/schematic/api/types/CheckoutSettingsResponseData.java new file mode 100644 index 0000000..f458ec9 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CheckoutSettingsResponseData.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CheckoutSettingsResponseData.Builder.class) +public final class CheckoutSettingsResponseData { + private final boolean collectAddress; + + private final boolean collectEmail; + + private final boolean collectPhone; + + private final Map additionalProperties; + + private CheckoutSettingsResponseData( + boolean collectAddress, + boolean collectEmail, + boolean collectPhone, + Map additionalProperties) { + this.collectAddress = collectAddress; + this.collectEmail = collectEmail; + this.collectPhone = collectPhone; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("collect_address") + public boolean getCollectAddress() { + return collectAddress; + } + + @JsonProperty("collect_email") + public boolean getCollectEmail() { + return collectEmail; + } + + @JsonProperty("collect_phone") + public boolean getCollectPhone() { + return collectPhone; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CheckoutSettingsResponseData && equalTo((CheckoutSettingsResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CheckoutSettingsResponseData other) { + return collectAddress == other.collectAddress + && collectEmail == other.collectEmail + && collectPhone == other.collectPhone; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.collectAddress, this.collectEmail, this.collectPhone); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CollectAddressStage builder() { + return new Builder(); + } + + public interface CollectAddressStage { + CollectEmailStage collectAddress(boolean collectAddress); + + Builder from(CheckoutSettingsResponseData other); + } + + public interface CollectEmailStage { + CollectPhoneStage collectEmail(boolean collectEmail); + } + + public interface CollectPhoneStage { + _FinalStage collectPhone(boolean collectPhone); + } + + public interface _FinalStage { + CheckoutSettingsResponseData build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CollectAddressStage, CollectEmailStage, CollectPhoneStage, _FinalStage { + private boolean collectAddress; + + private boolean collectEmail; + + private boolean collectPhone; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CheckoutSettingsResponseData other) { + collectAddress(other.getCollectAddress()); + collectEmail(other.getCollectEmail()); + collectPhone(other.getCollectPhone()); + return this; + } + + @java.lang.Override + @JsonSetter("collect_address") + public CollectEmailStage collectAddress(boolean collectAddress) { + this.collectAddress = collectAddress; + return this; + } + + @java.lang.Override + @JsonSetter("collect_email") + public CollectPhoneStage collectEmail(boolean collectEmail) { + this.collectEmail = collectEmail; + return this; + } + + @java.lang.Override + @JsonSetter("collect_phone") + public _FinalStage collectPhone(boolean collectPhone) { + this.collectPhone = collectPhone; + return this; + } + + @java.lang.Override + public CheckoutSettingsResponseData build() { + return new CheckoutSettingsResponseData(collectAddress, collectEmail, collectPhone, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CheckoutSubscription.java b/src/main/java/com/schematic/api/types/CheckoutSubscription.java new file mode 100644 index 0000000..ea8916c --- /dev/null +++ b/src/main/java/com/schematic/api/types/CheckoutSubscription.java @@ -0,0 +1,672 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CheckoutSubscription.Builder.class) +public final class CheckoutSubscription { + private final Optional cancelAt; + + private final boolean cancelAtPeriodEnd; + + private final Optional companyId; + + private final Optional confirmPaymentIntentClientSecret; + + private final Optional confirmPaymentIntentId; + + private final OffsetDateTime createdAt; + + private final String currency; + + private final String customerExternalId; + + private final Optional defaultPaymentMethodId; + + private final Optional expiredAt; + + private final String id; + + private final String interval; + + private final Optional> metadata; + + private final int periodEnd; + + private final int periodStart; + + private final String status; + + private final String subscriptionExternalId; + + private final int totalPrice; + + private final Optional trialEnd; + + private final Optional trialEndSetting; + + private final Map additionalProperties; + + private CheckoutSubscription( + Optional cancelAt, + boolean cancelAtPeriodEnd, + Optional companyId, + Optional confirmPaymentIntentClientSecret, + Optional confirmPaymentIntentId, + OffsetDateTime createdAt, + String currency, + String customerExternalId, + Optional defaultPaymentMethodId, + Optional expiredAt, + String id, + String interval, + Optional> metadata, + int periodEnd, + int periodStart, + String status, + String subscriptionExternalId, + int totalPrice, + Optional trialEnd, + Optional trialEndSetting, + Map additionalProperties) { + this.cancelAt = cancelAt; + this.cancelAtPeriodEnd = cancelAtPeriodEnd; + this.companyId = companyId; + this.confirmPaymentIntentClientSecret = confirmPaymentIntentClientSecret; + this.confirmPaymentIntentId = confirmPaymentIntentId; + this.createdAt = createdAt; + this.currency = currency; + this.customerExternalId = customerExternalId; + this.defaultPaymentMethodId = defaultPaymentMethodId; + this.expiredAt = expiredAt; + this.id = id; + this.interval = interval; + this.metadata = metadata; + this.periodEnd = periodEnd; + this.periodStart = periodStart; + this.status = status; + this.subscriptionExternalId = subscriptionExternalId; + this.totalPrice = totalPrice; + this.trialEnd = trialEnd; + this.trialEndSetting = trialEndSetting; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("cancel_at") + public Optional getCancelAt() { + return cancelAt; + } + + @JsonProperty("cancel_at_period_end") + public boolean getCancelAtPeriodEnd() { + return cancelAtPeriodEnd; + } + + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + @JsonProperty("confirm_payment_intent_client_secret") + public Optional getConfirmPaymentIntentClientSecret() { + return confirmPaymentIntentClientSecret; + } + + @JsonProperty("confirm_payment_intent_id") + public Optional getConfirmPaymentIntentId() { + return confirmPaymentIntentId; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("currency") + public String getCurrency() { + return currency; + } + + @JsonProperty("customer_external_id") + public String getCustomerExternalId() { + return customerExternalId; + } + + @JsonProperty("default_payment_method_id") + public Optional getDefaultPaymentMethodId() { + return defaultPaymentMethodId; + } + + @JsonProperty("expired_at") + public Optional getExpiredAt() { + return expiredAt; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("interval") + public String getInterval() { + return interval; + } + + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + @JsonProperty("period_end") + public int getPeriodEnd() { + return periodEnd; + } + + @JsonProperty("period_start") + public int getPeriodStart() { + return periodStart; + } + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @JsonProperty("subscription_external_id") + public String getSubscriptionExternalId() { + return subscriptionExternalId; + } + + @JsonProperty("total_price") + public int getTotalPrice() { + return totalPrice; + } + + @JsonProperty("trial_end") + public Optional getTrialEnd() { + return trialEnd; + } + + @JsonProperty("trial_end_setting") + public Optional getTrialEndSetting() { + return trialEndSetting; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CheckoutSubscription && equalTo((CheckoutSubscription) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CheckoutSubscription other) { + return cancelAt.equals(other.cancelAt) + && cancelAtPeriodEnd == other.cancelAtPeriodEnd + && companyId.equals(other.companyId) + && confirmPaymentIntentClientSecret.equals(other.confirmPaymentIntentClientSecret) + && confirmPaymentIntentId.equals(other.confirmPaymentIntentId) + && createdAt.equals(other.createdAt) + && currency.equals(other.currency) + && customerExternalId.equals(other.customerExternalId) + && defaultPaymentMethodId.equals(other.defaultPaymentMethodId) + && expiredAt.equals(other.expiredAt) + && id.equals(other.id) + && interval.equals(other.interval) + && metadata.equals(other.metadata) + && periodEnd == other.periodEnd + && periodStart == other.periodStart + && status.equals(other.status) + && subscriptionExternalId.equals(other.subscriptionExternalId) + && totalPrice == other.totalPrice + && trialEnd.equals(other.trialEnd) + && trialEndSetting.equals(other.trialEndSetting); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.cancelAt, + this.cancelAtPeriodEnd, + this.companyId, + this.confirmPaymentIntentClientSecret, + this.confirmPaymentIntentId, + this.createdAt, + this.currency, + this.customerExternalId, + this.defaultPaymentMethodId, + this.expiredAt, + this.id, + this.interval, + this.metadata, + this.periodEnd, + this.periodStart, + this.status, + this.subscriptionExternalId, + this.totalPrice, + this.trialEnd, + this.trialEndSetting); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CancelAtPeriodEndStage builder() { + return new Builder(); + } + + public interface CancelAtPeriodEndStage { + CreatedAtStage cancelAtPeriodEnd(boolean cancelAtPeriodEnd); + + Builder from(CheckoutSubscription other); + } + + public interface CreatedAtStage { + CurrencyStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface CurrencyStage { + CustomerExternalIdStage currency(@NotNull String currency); + } + + public interface CustomerExternalIdStage { + IdStage customerExternalId(@NotNull String customerExternalId); + } + + public interface IdStage { + IntervalStage id(@NotNull String id); + } + + public interface IntervalStage { + PeriodEndStage interval(@NotNull String interval); + } + + public interface PeriodEndStage { + PeriodStartStage periodEnd(int periodEnd); + } + + public interface PeriodStartStage { + StatusStage periodStart(int periodStart); + } + + public interface StatusStage { + SubscriptionExternalIdStage status(@NotNull String status); + } + + public interface SubscriptionExternalIdStage { + TotalPriceStage subscriptionExternalId(@NotNull String subscriptionExternalId); + } + + public interface TotalPriceStage { + _FinalStage totalPrice(int totalPrice); + } + + public interface _FinalStage { + CheckoutSubscription build(); + + _FinalStage cancelAt(Optional cancelAt); + + _FinalStage cancelAt(Integer cancelAt); + + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + + _FinalStage confirmPaymentIntentClientSecret(Optional confirmPaymentIntentClientSecret); + + _FinalStage confirmPaymentIntentClientSecret(String confirmPaymentIntentClientSecret); + + _FinalStage confirmPaymentIntentId(Optional confirmPaymentIntentId); + + _FinalStage confirmPaymentIntentId(String confirmPaymentIntentId); + + _FinalStage defaultPaymentMethodId(Optional defaultPaymentMethodId); + + _FinalStage defaultPaymentMethodId(String defaultPaymentMethodId); + + _FinalStage expiredAt(Optional expiredAt); + + _FinalStage expiredAt(OffsetDateTime expiredAt); + + _FinalStage metadata(Optional> metadata); + + _FinalStage metadata(Map metadata); + + _FinalStage trialEnd(Optional trialEnd); + + _FinalStage trialEnd(Integer trialEnd); + + _FinalStage trialEndSetting(Optional trialEndSetting); + + _FinalStage trialEndSetting(String trialEndSetting); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CancelAtPeriodEndStage, + CreatedAtStage, + CurrencyStage, + CustomerExternalIdStage, + IdStage, + IntervalStage, + PeriodEndStage, + PeriodStartStage, + StatusStage, + SubscriptionExternalIdStage, + TotalPriceStage, + _FinalStage { + private boolean cancelAtPeriodEnd; + + private OffsetDateTime createdAt; + + private String currency; + + private String customerExternalId; + + private String id; + + private String interval; + + private int periodEnd; + + private int periodStart; + + private String status; + + private String subscriptionExternalId; + + private int totalPrice; + + private Optional trialEndSetting = Optional.empty(); + + private Optional trialEnd = Optional.empty(); + + private Optional> metadata = Optional.empty(); + + private Optional expiredAt = Optional.empty(); + + private Optional defaultPaymentMethodId = Optional.empty(); + + private Optional confirmPaymentIntentId = Optional.empty(); + + private Optional confirmPaymentIntentClientSecret = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional cancelAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CheckoutSubscription other) { + cancelAt(other.getCancelAt()); + cancelAtPeriodEnd(other.getCancelAtPeriodEnd()); + companyId(other.getCompanyId()); + confirmPaymentIntentClientSecret(other.getConfirmPaymentIntentClientSecret()); + confirmPaymentIntentId(other.getConfirmPaymentIntentId()); + createdAt(other.getCreatedAt()); + currency(other.getCurrency()); + customerExternalId(other.getCustomerExternalId()); + defaultPaymentMethodId(other.getDefaultPaymentMethodId()); + expiredAt(other.getExpiredAt()); + id(other.getId()); + interval(other.getInterval()); + metadata(other.getMetadata()); + periodEnd(other.getPeriodEnd()); + periodStart(other.getPeriodStart()); + status(other.getStatus()); + subscriptionExternalId(other.getSubscriptionExternalId()); + totalPrice(other.getTotalPrice()); + trialEnd(other.getTrialEnd()); + trialEndSetting(other.getTrialEndSetting()); + return this; + } + + @java.lang.Override + @JsonSetter("cancel_at_period_end") + public CreatedAtStage cancelAtPeriodEnd(boolean cancelAtPeriodEnd) { + this.cancelAtPeriodEnd = cancelAtPeriodEnd; + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public CurrencyStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("currency") + public CustomerExternalIdStage currency(@NotNull String currency) { + this.currency = Objects.requireNonNull(currency, "currency must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("customer_external_id") + public IdStage customerExternalId(@NotNull String customerExternalId) { + this.customerExternalId = Objects.requireNonNull(customerExternalId, "customerExternalId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public IntervalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("interval") + public PeriodEndStage interval(@NotNull String interval) { + this.interval = Objects.requireNonNull(interval, "interval must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("period_end") + public PeriodStartStage periodEnd(int periodEnd) { + this.periodEnd = periodEnd; + return this; + } + + @java.lang.Override + @JsonSetter("period_start") + public StatusStage periodStart(int periodStart) { + this.periodStart = periodStart; + return this; + } + + @java.lang.Override + @JsonSetter("status") + public SubscriptionExternalIdStage status(@NotNull String status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("subscription_external_id") + public TotalPriceStage subscriptionExternalId(@NotNull String subscriptionExternalId) { + this.subscriptionExternalId = + Objects.requireNonNull(subscriptionExternalId, "subscriptionExternalId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("total_price") + public _FinalStage totalPrice(int totalPrice) { + this.totalPrice = totalPrice; + return this; + } + + @java.lang.Override + public _FinalStage trialEndSetting(String trialEndSetting) { + this.trialEndSetting = Optional.ofNullable(trialEndSetting); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_end_setting", nulls = Nulls.SKIP) + public _FinalStage trialEndSetting(Optional trialEndSetting) { + this.trialEndSetting = trialEndSetting; + return this; + } + + @java.lang.Override + public _FinalStage trialEnd(Integer trialEnd) { + this.trialEnd = Optional.ofNullable(trialEnd); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_end", nulls = Nulls.SKIP) + public _FinalStage trialEnd(Optional trialEnd) { + this.trialEnd = trialEnd; + return this; + } + + @java.lang.Override + public _FinalStage metadata(Map metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + @java.lang.Override + @JsonSetter(value = "metadata", nulls = Nulls.SKIP) + public _FinalStage metadata(Optional> metadata) { + this.metadata = metadata; + return this; + } + + @java.lang.Override + public _FinalStage expiredAt(OffsetDateTime expiredAt) { + this.expiredAt = Optional.ofNullable(expiredAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expired_at", nulls = Nulls.SKIP) + public _FinalStage expiredAt(Optional expiredAt) { + this.expiredAt = expiredAt; + return this; + } + + @java.lang.Override + public _FinalStage defaultPaymentMethodId(String defaultPaymentMethodId) { + this.defaultPaymentMethodId = Optional.ofNullable(defaultPaymentMethodId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_payment_method_id", nulls = Nulls.SKIP) + public _FinalStage defaultPaymentMethodId(Optional defaultPaymentMethodId) { + this.defaultPaymentMethodId = defaultPaymentMethodId; + return this; + } + + @java.lang.Override + public _FinalStage confirmPaymentIntentId(String confirmPaymentIntentId) { + this.confirmPaymentIntentId = Optional.ofNullable(confirmPaymentIntentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "confirm_payment_intent_id", nulls = Nulls.SKIP) + public _FinalStage confirmPaymentIntentId(Optional confirmPaymentIntentId) { + this.confirmPaymentIntentId = confirmPaymentIntentId; + return this; + } + + @java.lang.Override + public _FinalStage confirmPaymentIntentClientSecret(String confirmPaymentIntentClientSecret) { + this.confirmPaymentIntentClientSecret = Optional.ofNullable(confirmPaymentIntentClientSecret); + return this; + } + + @java.lang.Override + @JsonSetter(value = "confirm_payment_intent_client_secret", nulls = Nulls.SKIP) + public _FinalStage confirmPaymentIntentClientSecret(Optional confirmPaymentIntentClientSecret) { + this.confirmPaymentIntentClientSecret = confirmPaymentIntentClientSecret; + return this; + } + + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + @java.lang.Override + public _FinalStage cancelAt(Integer cancelAt) { + this.cancelAt = Optional.ofNullable(cancelAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "cancel_at", nulls = Nulls.SKIP) + public _FinalStage cancelAt(Optional cancelAt) { + this.cancelAt = cancelAt; + return this; + } + + @java.lang.Override + public CheckoutSubscription build() { + return new CheckoutSubscription( + cancelAt, + cancelAtPeriodEnd, + companyId, + confirmPaymentIntentClientSecret, + confirmPaymentIntentId, + createdAt, + currency, + customerExternalId, + defaultPaymentMethodId, + expiredAt, + id, + interval, + metadata, + periodEnd, + periodStart, + status, + subscriptionExternalId, + totalPrice, + trialEnd, + trialEndSetting, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CompanyCrmDealsResponseData.java b/src/main/java/com/schematic/api/types/CompanyCrmDealsResponseData.java index 31e1c6c..9b72763 100644 --- a/src/main/java/com/schematic/api/types/CompanyCrmDealsResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanyCrmDealsResponseData.java @@ -186,7 +186,9 @@ public _FinalStage dealMrr(@NotNull String dealMrr) { @java.lang.Override public _FinalStage addAllLineItems(List lineItems) { - this.lineItems.addAll(lineItems); + if (lineItems != null) { + this.lineItems.addAll(lineItems); + } return this; } @@ -200,7 +202,9 @@ public _FinalStage addLineItems(CrmDealLineItem lineItems) { @JsonSetter(value = "line_items", nulls = Nulls.SKIP) public _FinalStage lineItems(List lineItems) { this.lineItems.clear(); - this.lineItems.addAll(lineItems); + if (lineItems != null) { + this.lineItems.addAll(lineItems); + } return this; } diff --git a/src/main/java/com/schematic/api/types/CompanyDetailResponseData.java b/src/main/java/com/schematic/api/types/CompanyDetailResponseData.java index 5600a41..128dab8 100644 --- a/src/main/java/com/schematic/api/types/CompanyDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanyDetailResponseData.java @@ -27,12 +27,16 @@ public final class CompanyDetailResponseData { private final List addOns; + private final Optional> billingCreditBalances; + private final Optional billingSubscription; private final List billingSubscriptions; private final OffsetDateTime createdAt; + private final Optional defaultPaymentMethod; + private final List entityTraits; private final String environmentId; @@ -55,6 +59,8 @@ public final class CompanyDetailResponseData { private final List plans; + private final List rules; + private final Optional> traits; private final OffsetDateTime updatedAt; @@ -65,9 +71,11 @@ public final class CompanyDetailResponseData { private CompanyDetailResponseData( List addOns, + Optional> billingCreditBalances, Optional billingSubscription, List billingSubscriptions, OffsetDateTime createdAt, + Optional defaultPaymentMethod, List entityTraits, String environmentId, String id, @@ -79,14 +87,17 @@ private CompanyDetailResponseData( List paymentMethods, Optional plan, List plans, + List rules, Optional> traits, OffsetDateTime updatedAt, int userCount, Map additionalProperties) { this.addOns = addOns; + this.billingCreditBalances = billingCreditBalances; this.billingSubscription = billingSubscription; this.billingSubscriptions = billingSubscriptions; this.createdAt = createdAt; + this.defaultPaymentMethod = defaultPaymentMethod; this.entityTraits = entityTraits; this.environmentId = environmentId; this.id = id; @@ -98,6 +109,7 @@ private CompanyDetailResponseData( this.paymentMethods = paymentMethods; this.plan = plan; this.plans = plans; + this.rules = rules; this.traits = traits; this.updatedAt = updatedAt; this.userCount = userCount; @@ -109,6 +121,11 @@ public List getAddOns() { return addOns; } + @JsonProperty("billing_credit_balances") + public Optional> getBillingCreditBalances() { + return billingCreditBalances; + } + @JsonProperty("billing_subscription") public Optional getBillingSubscription() { return billingSubscription; @@ -124,6 +141,11 @@ public OffsetDateTime getCreatedAt() { return createdAt; } + @JsonProperty("default_payment_method") + public Optional getDefaultPaymentMethod() { + return defaultPaymentMethod; + } + @JsonProperty("entity_traits") public List getEntityTraits() { return entityTraits; @@ -179,6 +201,11 @@ public List getPlans() { return plans; } + @JsonProperty("rules") + public List getRules() { + return rules; + } + /** * @return A map of trait names to trait values */ @@ -210,9 +237,11 @@ public Map getAdditionalProperties() { private boolean equalTo(CompanyDetailResponseData other) { return addOns.equals(other.addOns) + && billingCreditBalances.equals(other.billingCreditBalances) && billingSubscription.equals(other.billingSubscription) && billingSubscriptions.equals(other.billingSubscriptions) && createdAt.equals(other.createdAt) + && defaultPaymentMethod.equals(other.defaultPaymentMethod) && entityTraits.equals(other.entityTraits) && environmentId.equals(other.environmentId) && id.equals(other.id) @@ -224,6 +253,7 @@ private boolean equalTo(CompanyDetailResponseData other) { && paymentMethods.equals(other.paymentMethods) && plan.equals(other.plan) && plans.equals(other.plans) + && rules.equals(other.rules) && traits.equals(other.traits) && updatedAt.equals(other.updatedAt) && userCount == other.userCount; @@ -233,9 +263,11 @@ private boolean equalTo(CompanyDetailResponseData other) { public int hashCode() { return Objects.hash( this.addOns, + this.billingCreditBalances, this.billingSubscription, this.billingSubscriptions, this.createdAt, + this.defaultPaymentMethod, this.entityTraits, this.environmentId, this.id, @@ -247,6 +279,7 @@ public int hashCode() { this.paymentMethods, this.plan, this.plans, + this.rules, this.traits, this.updatedAt, this.userCount); @@ -296,6 +329,10 @@ public interface _FinalStage { _FinalStage addAllAddOns(List addOns); + _FinalStage billingCreditBalances(Optional> billingCreditBalances); + + _FinalStage billingCreditBalances(Map billingCreditBalances); + _FinalStage billingSubscription(Optional billingSubscription); _FinalStage billingSubscription(BillingSubscriptionView billingSubscription); @@ -306,6 +343,10 @@ public interface _FinalStage { _FinalStage addAllBillingSubscriptions(List billingSubscriptions); + _FinalStage defaultPaymentMethod(Optional defaultPaymentMethod); + + _FinalStage defaultPaymentMethod(PaymentMethodResponseData defaultPaymentMethod); + _FinalStage entityTraits(List entityTraits); _FinalStage addEntityTraits(EntityTraitDetailResponseData entityTraits); @@ -348,6 +389,15 @@ public interface _FinalStage { _FinalStage addAllPlans(List plans); + _FinalStage rules(List rules); + + _FinalStage addRules(Rule rules); + + _FinalStage addAllRules(List rules); + + /** + *

A map of trait names to trait values

+ */ _FinalStage traits(Optional> traits); _FinalStage traits(Map traits); @@ -376,6 +426,8 @@ public static final class Builder private Optional> traits = Optional.empty(); + private List rules = new ArrayList<>(); + private List plans = new ArrayList<>(); private Optional plan = Optional.empty(); @@ -392,10 +444,14 @@ public static final class Builder private List entityTraits = new ArrayList<>(); + private Optional defaultPaymentMethod = Optional.empty(); + private List billingSubscriptions = new ArrayList<>(); private Optional billingSubscription = Optional.empty(); + private Optional> billingCreditBalances = Optional.empty(); + private List addOns = new ArrayList<>(); @JsonAnySetter @@ -406,9 +462,11 @@ private Builder() {} @java.lang.Override public Builder from(CompanyDetailResponseData other) { addOns(other.getAddOns()); + billingCreditBalances(other.getBillingCreditBalances()); billingSubscription(other.getBillingSubscription()); billingSubscriptions(other.getBillingSubscriptions()); createdAt(other.getCreatedAt()); + defaultPaymentMethod(other.getDefaultPaymentMethod()); entityTraits(other.getEntityTraits()); environmentId(other.getEnvironmentId()); id(other.getId()); @@ -420,6 +478,7 @@ public Builder from(CompanyDetailResponseData other) { paymentMethods(other.getPaymentMethods()); plan(other.getPlan()); plans(other.getPlans()); + rules(other.getRules()); traits(other.getTraits()); updatedAt(other.getUpdatedAt()); userCount(other.getUserCount()); @@ -478,6 +537,9 @@ public _FinalStage traits(Map traits) { return this; } + /** + *

A map of trait names to trait values

+ */ @java.lang.Override @JsonSetter(value = "traits", nulls = Nulls.SKIP) public _FinalStage traits(Optional> traits) { @@ -485,9 +547,35 @@ public _FinalStage traits(Optional> traits) { return this; } + @java.lang.Override + public _FinalStage addAllRules(List rules) { + if (rules != null) { + this.rules.addAll(rules); + } + return this; + } + + @java.lang.Override + public _FinalStage addRules(Rule rules) { + this.rules.add(rules); + return this; + } + + @java.lang.Override + @JsonSetter(value = "rules", nulls = Nulls.SKIP) + public _FinalStage rules(List rules) { + this.rules.clear(); + if (rules != null) { + this.rules.addAll(rules); + } + return this; + } + @java.lang.Override public _FinalStage addAllPlans(List plans) { - this.plans.addAll(plans); + if (plans != null) { + this.plans.addAll(plans); + } return this; } @@ -501,7 +589,9 @@ public _FinalStage addPlans(GenericPreviewObject plans) { @JsonSetter(value = "plans", nulls = Nulls.SKIP) public _FinalStage plans(List plans) { this.plans.clear(); - this.plans.addAll(plans); + if (plans != null) { + this.plans.addAll(plans); + } return this; } @@ -520,7 +610,9 @@ public _FinalStage plan(Optional plan) { @java.lang.Override public _FinalStage addAllPaymentMethods(List paymentMethods) { - this.paymentMethods.addAll(paymentMethods); + if (paymentMethods != null) { + this.paymentMethods.addAll(paymentMethods); + } return this; } @@ -534,13 +626,17 @@ public _FinalStage addPaymentMethods(PaymentMethodResponseData paymentMethods) { @JsonSetter(value = "payment_methods", nulls = Nulls.SKIP) public _FinalStage paymentMethods(List paymentMethods) { this.paymentMethods.clear(); - this.paymentMethods.addAll(paymentMethods); + if (paymentMethods != null) { + this.paymentMethods.addAll(paymentMethods); + } return this; } @java.lang.Override public _FinalStage addAllMetrics(List metrics) { - this.metrics.addAll(metrics); + if (metrics != null) { + this.metrics.addAll(metrics); + } return this; } @@ -554,7 +650,9 @@ public _FinalStage addMetrics(CompanyEventPeriodMetricsResponseData metrics) { @JsonSetter(value = "metrics", nulls = Nulls.SKIP) public _FinalStage metrics(List metrics) { this.metrics.clear(); - this.metrics.addAll(metrics); + if (metrics != null) { + this.metrics.addAll(metrics); + } return this; } @@ -586,7 +684,9 @@ public _FinalStage lastSeenAt(Optional lastSeenAt) { @java.lang.Override public _FinalStage addAllKeys(List keys) { - this.keys.addAll(keys); + if (keys != null) { + this.keys.addAll(keys); + } return this; } @@ -600,13 +700,17 @@ public _FinalStage addKeys(EntityKeyDetailResponseData keys) { @JsonSetter(value = "keys", nulls = Nulls.SKIP) public _FinalStage keys(List keys) { this.keys.clear(); - this.keys.addAll(keys); + if (keys != null) { + this.keys.addAll(keys); + } return this; } @java.lang.Override public _FinalStage addAllEntityTraits(List entityTraits) { - this.entityTraits.addAll(entityTraits); + if (entityTraits != null) { + this.entityTraits.addAll(entityTraits); + } return this; } @@ -620,13 +724,30 @@ public _FinalStage addEntityTraits(EntityTraitDetailResponseData entityTraits) { @JsonSetter(value = "entity_traits", nulls = Nulls.SKIP) public _FinalStage entityTraits(List entityTraits) { this.entityTraits.clear(); - this.entityTraits.addAll(entityTraits); + if (entityTraits != null) { + this.entityTraits.addAll(entityTraits); + } + return this; + } + + @java.lang.Override + public _FinalStage defaultPaymentMethod(PaymentMethodResponseData defaultPaymentMethod) { + this.defaultPaymentMethod = Optional.ofNullable(defaultPaymentMethod); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_payment_method", nulls = Nulls.SKIP) + public _FinalStage defaultPaymentMethod(Optional defaultPaymentMethod) { + this.defaultPaymentMethod = defaultPaymentMethod; return this; } @java.lang.Override public _FinalStage addAllBillingSubscriptions(List billingSubscriptions) { - this.billingSubscriptions.addAll(billingSubscriptions); + if (billingSubscriptions != null) { + this.billingSubscriptions.addAll(billingSubscriptions); + } return this; } @@ -640,7 +761,9 @@ public _FinalStage addBillingSubscriptions(BillingSubscriptionView billingSubscr @JsonSetter(value = "billing_subscriptions", nulls = Nulls.SKIP) public _FinalStage billingSubscriptions(List billingSubscriptions) { this.billingSubscriptions.clear(); - this.billingSubscriptions.addAll(billingSubscriptions); + if (billingSubscriptions != null) { + this.billingSubscriptions.addAll(billingSubscriptions); + } return this; } @@ -657,9 +780,24 @@ public _FinalStage billingSubscription(Optional billing return this; } + @java.lang.Override + public _FinalStage billingCreditBalances(Map billingCreditBalances) { + this.billingCreditBalances = Optional.ofNullable(billingCreditBalances); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_credit_balances", nulls = Nulls.SKIP) + public _FinalStage billingCreditBalances(Optional> billingCreditBalances) { + this.billingCreditBalances = billingCreditBalances; + return this; + } + @java.lang.Override public _FinalStage addAllAddOns(List addOns) { - this.addOns.addAll(addOns); + if (addOns != null) { + this.addOns.addAll(addOns); + } return this; } @@ -673,7 +811,9 @@ public _FinalStage addAddOns(CompanyPlanWithBillingSubView addOns) { @JsonSetter(value = "add_ons", nulls = Nulls.SKIP) public _FinalStage addOns(List addOns) { this.addOns.clear(); - this.addOns.addAll(addOns); + if (addOns != null) { + this.addOns.addAll(addOns); + } return this; } @@ -681,9 +821,11 @@ public _FinalStage addOns(List addOns) { public CompanyDetailResponseData build() { return new CompanyDetailResponseData( addOns, + billingCreditBalances, billingSubscription, billingSubscriptions, createdAt, + defaultPaymentMethod, entityTraits, environmentId, id, @@ -695,6 +837,7 @@ public CompanyDetailResponseData build() { paymentMethods, plan, plans, + rules, traits, updatedAt, userCount, diff --git a/src/main/java/com/schematic/api/types/CompanyLedgerResponseData.java b/src/main/java/com/schematic/api/types/CompanyLedgerResponseData.java new file mode 100644 index 0000000..f8d1be0 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CompanyLedgerResponseData.java @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CompanyLedgerResponseData.Builder.class) +public final class CompanyLedgerResponseData { + private final String id; + + private final Optional logoUrl; + + private final String name; + + private final Map additionalProperties; + + private CompanyLedgerResponseData( + String id, Optional logoUrl, String name, Map additionalProperties) { + this.id = id; + this.logoUrl = logoUrl; + this.name = name; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("logo_url") + public Optional getLogoUrl() { + return logoUrl; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CompanyLedgerResponseData && equalTo((CompanyLedgerResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CompanyLedgerResponseData other) { + return id.equals(other.id) && logoUrl.equals(other.logoUrl) && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.logoUrl, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(CompanyLedgerResponseData other); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + CompanyLedgerResponseData build(); + + _FinalStage logoUrl(Optional logoUrl); + + _FinalStage logoUrl(String logoUrl); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, _FinalStage { + private String id; + + private String name; + + private Optional logoUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CompanyLedgerResponseData other) { + id(other.getId()); + logoUrl(other.getLogoUrl()); + name(other.getName()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage logoUrl(String logoUrl) { + this.logoUrl = Optional.ofNullable(logoUrl); + return this; + } + + @java.lang.Override + @JsonSetter(value = "logo_url", nulls = Nulls.SKIP) + public _FinalStage logoUrl(Optional logoUrl) { + this.logoUrl = logoUrl; + return this; + } + + @java.lang.Override + public CompanyLedgerResponseData build() { + return new CompanyLedgerResponseData(id, logoUrl, name, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CompanyOverrideNoteResponseData.java b/src/main/java/com/schematic/api/types/CompanyOverrideNoteResponseData.java new file mode 100644 index 0000000..edfb403 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CompanyOverrideNoteResponseData.java @@ -0,0 +1,234 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CompanyOverrideNoteResponseData.Builder.class) +public final class CompanyOverrideNoteResponseData { + private final OffsetDateTime createdAt; + + private final String externalUserId; + + private final String externalUserName; + + private final String id; + + private final String note; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private CompanyOverrideNoteResponseData( + OffsetDateTime createdAt, + String externalUserId, + String externalUserName, + String id, + String note, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.createdAt = createdAt; + this.externalUserId = externalUserId; + this.externalUserName = externalUserName; + this.id = id; + this.note = note; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("external_user_id") + public String getExternalUserId() { + return externalUserId; + } + + @JsonProperty("external_user_name") + public String getExternalUserName() { + return externalUserName; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("note") + public String getNote() { + return note; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CompanyOverrideNoteResponseData && equalTo((CompanyOverrideNoteResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CompanyOverrideNoteResponseData other) { + return createdAt.equals(other.createdAt) + && externalUserId.equals(other.externalUserId) + && externalUserName.equals(other.externalUserName) + && id.equals(other.id) + && note.equals(other.note) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.createdAt, this.externalUserId, this.externalUserName, this.id, this.note, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtStage builder() { + return new Builder(); + } + + public interface CreatedAtStage { + ExternalUserIdStage createdAt(@NotNull OffsetDateTime createdAt); + + Builder from(CompanyOverrideNoteResponseData other); + } + + public interface ExternalUserIdStage { + ExternalUserNameStage externalUserId(@NotNull String externalUserId); + } + + public interface ExternalUserNameStage { + IdStage externalUserName(@NotNull String externalUserName); + } + + public interface IdStage { + NoteStage id(@NotNull String id); + } + + public interface NoteStage { + UpdatedAtStage note(@NotNull String note); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + CompanyOverrideNoteResponseData build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CreatedAtStage, + ExternalUserIdStage, + ExternalUserNameStage, + IdStage, + NoteStage, + UpdatedAtStage, + _FinalStage { + private OffsetDateTime createdAt; + + private String externalUserId; + + private String externalUserName; + + private String id; + + private String note; + + private OffsetDateTime updatedAt; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CompanyOverrideNoteResponseData other) { + createdAt(other.getCreatedAt()); + externalUserId(other.getExternalUserId()); + externalUserName(other.getExternalUserName()); + id(other.getId()); + note(other.getNote()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public ExternalUserIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("external_user_id") + public ExternalUserNameStage externalUserId(@NotNull String externalUserId) { + this.externalUserId = Objects.requireNonNull(externalUserId, "externalUserId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("external_user_name") + public IdStage externalUserName(@NotNull String externalUserName) { + this.externalUserName = Objects.requireNonNull(externalUserName, "externalUserName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NoteStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("note") + public UpdatedAtStage note(@NotNull String note) { + this.note = Objects.requireNonNull(note, "note must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public CompanyOverrideNoteResponseData build() { + return new CompanyOverrideNoteResponseData( + createdAt, externalUserId, externalUserName, id, note, updatedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CompanyOverrideResponseData.java b/src/main/java/com/schematic/api/types/CompanyOverrideResponseData.java index cfedbed..674f7c7 100644 --- a/src/main/java/com/schematic/api/types/CompanyOverrideResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanyOverrideResponseData.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -26,6 +28,8 @@ public final class CompanyOverrideResponseData { private final String companyId; + private final Optional consumptionRate; + private final OffsetDateTime createdAt; private final String environmentId; @@ -42,6 +46,8 @@ public final class CompanyOverrideResponseData { private final Optional metricPeriodMonthReset; + private final List notes; + private final Optional ruleId; private final Optional ruleIdUsageExceeded; @@ -63,6 +69,7 @@ public final class CompanyOverrideResponseData { private CompanyOverrideResponseData( Optional company, String companyId, + Optional consumptionRate, OffsetDateTime createdAt, String environmentId, Optional expirationDate, @@ -71,6 +78,7 @@ private CompanyOverrideResponseData( String id, Optional metricPeriod, Optional metricPeriodMonthReset, + List notes, Optional ruleId, Optional ruleIdUsageExceeded, OffsetDateTime updatedAt, @@ -82,6 +90,7 @@ private CompanyOverrideResponseData( Map additionalProperties) { this.company = company; this.companyId = companyId; + this.consumptionRate = consumptionRate; this.createdAt = createdAt; this.environmentId = environmentId; this.expirationDate = expirationDate; @@ -90,6 +99,7 @@ private CompanyOverrideResponseData( this.id = id; this.metricPeriod = metricPeriod; this.metricPeriodMonthReset = metricPeriodMonthReset; + this.notes = notes; this.ruleId = ruleId; this.ruleIdUsageExceeded = ruleIdUsageExceeded; this.updatedAt = updatedAt; @@ -111,6 +121,11 @@ public String getCompanyId() { return companyId; } + @JsonProperty("consumption_rate") + public Optional getConsumptionRate() { + return consumptionRate; + } + @JsonProperty("created_at") public OffsetDateTime getCreatedAt() { return createdAt; @@ -151,6 +166,11 @@ public Optional getMetricPeriodMonthReset() { return metricPeriodMonthReset; } + @JsonProperty("notes") + public List getNotes() { + return notes; + } + @JsonProperty("rule_id") public Optional getRuleId() { return ruleId; @@ -205,6 +225,7 @@ public Map getAdditionalProperties() { private boolean equalTo(CompanyOverrideResponseData other) { return company.equals(other.company) && companyId.equals(other.companyId) + && consumptionRate.equals(other.consumptionRate) && createdAt.equals(other.createdAt) && environmentId.equals(other.environmentId) && expirationDate.equals(other.expirationDate) @@ -213,6 +234,7 @@ private boolean equalTo(CompanyOverrideResponseData other) { && id.equals(other.id) && metricPeriod.equals(other.metricPeriod) && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) + && notes.equals(other.notes) && ruleId.equals(other.ruleId) && ruleIdUsageExceeded.equals(other.ruleIdUsageExceeded) && updatedAt.equals(other.updatedAt) @@ -228,6 +250,7 @@ public int hashCode() { return Objects.hash( this.company, this.companyId, + this.consumptionRate, this.createdAt, this.environmentId, this.expirationDate, @@ -236,6 +259,7 @@ public int hashCode() { this.id, this.metricPeriod, this.metricPeriodMonthReset, + this.notes, this.ruleId, this.ruleIdUsageExceeded, this.updatedAt, @@ -292,6 +316,10 @@ public interface _FinalStage { _FinalStage company(CompanyDetailResponseData company); + _FinalStage consumptionRate(Optional consumptionRate); + + _FinalStage consumptionRate(Double consumptionRate); + _FinalStage expirationDate(Optional expirationDate); _FinalStage expirationDate(OffsetDateTime expirationDate); @@ -308,6 +336,12 @@ public interface _FinalStage { _FinalStage metricPeriodMonthReset(String metricPeriodMonthReset); + _FinalStage notes(List notes); + + _FinalStage addNotes(CompanyOverrideNoteResponseData notes); + + _FinalStage addAllNotes(List notes); + _FinalStage ruleId(Optional ruleId); _FinalStage ruleId(String ruleId); @@ -369,6 +403,8 @@ public static final class Builder private Optional ruleId = Optional.empty(); + private List notes = new ArrayList<>(); + private Optional metricPeriodMonthReset = Optional.empty(); private Optional metricPeriod = Optional.empty(); @@ -377,6 +413,8 @@ public static final class Builder private Optional expirationDate = Optional.empty(); + private Optional consumptionRate = Optional.empty(); + private Optional company = Optional.empty(); @JsonAnySetter @@ -388,6 +426,7 @@ private Builder() {} public Builder from(CompanyOverrideResponseData other) { company(other.getCompany()); companyId(other.getCompanyId()); + consumptionRate(other.getConsumptionRate()); createdAt(other.getCreatedAt()); environmentId(other.getEnvironmentId()); expirationDate(other.getExpirationDate()); @@ -396,6 +435,7 @@ public Builder from(CompanyOverrideResponseData other) { id(other.getId()); metricPeriod(other.getMetricPeriod()); metricPeriodMonthReset(other.getMetricPeriodMonthReset()); + notes(other.getNotes()); ruleId(other.getRuleId()); ruleIdUsageExceeded(other.getRuleIdUsageExceeded()); updatedAt(other.getUpdatedAt()); @@ -534,6 +574,30 @@ public _FinalStage ruleId(Optional ruleId) { return this; } + @java.lang.Override + public _FinalStage addAllNotes(List notes) { + if (notes != null) { + this.notes.addAll(notes); + } + return this; + } + + @java.lang.Override + public _FinalStage addNotes(CompanyOverrideNoteResponseData notes) { + this.notes.add(notes); + return this; + } + + @java.lang.Override + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public _FinalStage notes(List notes) { + this.notes.clear(); + if (notes != null) { + this.notes.addAll(notes); + } + return this; + } + @java.lang.Override public _FinalStage metricPeriodMonthReset(String metricPeriodMonthReset) { this.metricPeriodMonthReset = Optional.ofNullable(metricPeriodMonthReset); @@ -586,6 +650,19 @@ public _FinalStage expirationDate(Optional expirationDate) { return this; } + @java.lang.Override + public _FinalStage consumptionRate(Double consumptionRate) { + this.consumptionRate = Optional.ofNullable(consumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "consumption_rate", nulls = Nulls.SKIP) + public _FinalStage consumptionRate(Optional consumptionRate) { + this.consumptionRate = consumptionRate; + return this; + } + @java.lang.Override public _FinalStage company(CompanyDetailResponseData company) { this.company = Optional.ofNullable(company); @@ -604,6 +681,7 @@ public CompanyOverrideResponseData build() { return new CompanyOverrideResponseData( company, companyId, + consumptionRate, createdAt, environmentId, expirationDate, @@ -612,6 +690,7 @@ public CompanyOverrideResponseData build() { id, metricPeriod, metricPeriodMonthReset, + notes, ruleId, ruleIdUsageExceeded, updatedAt, diff --git a/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java b/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java index 42b5331..1d355ac 100644 --- a/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanyPlanDetailResponseData.java @@ -28,10 +28,16 @@ public final class CompanyPlanDetailResponseData { private final Optional billingProduct; + private final String chargeType; + private final boolean companyCanTrial; private final int companyCount; + private final List compatiblePlanIds; + + private final String controlledBy; + private final OffsetDateTime createdAt; private final boolean current; @@ -50,6 +56,8 @@ public final class CompanyPlanDetailResponseData { private final String id; + private final List includedCreditGrants; + private final boolean isCustom; private final boolean isDefault; @@ -62,12 +70,16 @@ public final class CompanyPlanDetailResponseData { private final String name; + private final Optional oneTimePrice; + private final String planType; private final Optional trialDays; private final OffsetDateTime updatedAt; + private final List usageViolations; + private final boolean valid; private final Optional yearlyPrice; @@ -77,8 +89,11 @@ public final class CompanyPlanDetailResponseData { private CompanyPlanDetailResponseData( Optional audienceType, Optional billingProduct, + String chargeType, boolean companyCanTrial, int companyCount, + List compatiblePlanIds, + String controlledBy, OffsetDateTime createdAt, boolean current, boolean custom, @@ -88,22 +103,28 @@ private CompanyPlanDetailResponseData( List features, String icon, String id, + List includedCreditGrants, boolean isCustom, boolean isDefault, boolean isFree, boolean isTrialable, Optional monthlyPrice, String name, + Optional oneTimePrice, String planType, Optional trialDays, OffsetDateTime updatedAt, + List usageViolations, boolean valid, Optional yearlyPrice, Map additionalProperties) { this.audienceType = audienceType; this.billingProduct = billingProduct; + this.chargeType = chargeType; this.companyCanTrial = companyCanTrial; this.companyCount = companyCount; + this.compatiblePlanIds = compatiblePlanIds; + this.controlledBy = controlledBy; this.createdAt = createdAt; this.current = current; this.custom = custom; @@ -113,15 +134,18 @@ private CompanyPlanDetailResponseData( this.features = features; this.icon = icon; this.id = id; + this.includedCreditGrants = includedCreditGrants; this.isCustom = isCustom; this.isDefault = isDefault; this.isFree = isFree; this.isTrialable = isTrialable; this.monthlyPrice = monthlyPrice; this.name = name; + this.oneTimePrice = oneTimePrice; this.planType = planType; this.trialDays = trialDays; this.updatedAt = updatedAt; + this.usageViolations = usageViolations; this.valid = valid; this.yearlyPrice = yearlyPrice; this.additionalProperties = additionalProperties; @@ -137,6 +161,11 @@ public Optional getBillingProduct() { return billingProduct; } + @JsonProperty("charge_type") + public String getChargeType() { + return chargeType; + } + @JsonProperty("company_can_trial") public boolean getCompanyCanTrial() { return companyCanTrial; @@ -147,6 +176,16 @@ public int getCompanyCount() { return companyCount; } + @JsonProperty("compatible_plan_ids") + public List getCompatiblePlanIds() { + return compatiblePlanIds; + } + + @JsonProperty("controlled_by") + public String getControlledBy() { + return controlledBy; + } + @JsonProperty("created_at") public OffsetDateTime getCreatedAt() { return createdAt; @@ -192,6 +231,11 @@ public String getId() { return id; } + @JsonProperty("included_credit_grants") + public List getIncludedCreditGrants() { + return includedCreditGrants; + } + @JsonProperty("is_custom") public boolean getIsCustom() { return isCustom; @@ -222,6 +266,11 @@ public String getName() { return name; } + @JsonProperty("one_time_price") + public Optional getOneTimePrice() { + return oneTimePrice; + } + @JsonProperty("plan_type") public String getPlanType() { return planType; @@ -237,6 +286,11 @@ public OffsetDateTime getUpdatedAt() { return updatedAt; } + @JsonProperty("usage_violations") + public List getUsageViolations() { + return usageViolations; + } + @JsonProperty("valid") public boolean getValid() { return valid; @@ -261,8 +315,11 @@ public Map getAdditionalProperties() { private boolean equalTo(CompanyPlanDetailResponseData other) { return audienceType.equals(other.audienceType) && billingProduct.equals(other.billingProduct) + && chargeType.equals(other.chargeType) && companyCanTrial == other.companyCanTrial && companyCount == other.companyCount + && compatiblePlanIds.equals(other.compatiblePlanIds) + && controlledBy.equals(other.controlledBy) && createdAt.equals(other.createdAt) && current == other.current && custom == other.custom @@ -272,15 +329,18 @@ private boolean equalTo(CompanyPlanDetailResponseData other) { && features.equals(other.features) && icon.equals(other.icon) && id.equals(other.id) + && includedCreditGrants.equals(other.includedCreditGrants) && isCustom == other.isCustom && isDefault == other.isDefault && isFree == other.isFree && isTrialable == other.isTrialable && monthlyPrice.equals(other.monthlyPrice) && name.equals(other.name) + && oneTimePrice.equals(other.oneTimePrice) && planType.equals(other.planType) && trialDays.equals(other.trialDays) && updatedAt.equals(other.updatedAt) + && usageViolations.equals(other.usageViolations) && valid == other.valid && yearlyPrice.equals(other.yearlyPrice); } @@ -290,8 +350,11 @@ public int hashCode() { return Objects.hash( this.audienceType, this.billingProduct, + this.chargeType, this.companyCanTrial, this.companyCount, + this.compatiblePlanIds, + this.controlledBy, this.createdAt, this.current, this.custom, @@ -301,15 +364,18 @@ public int hashCode() { this.features, this.icon, this.id, + this.includedCreditGrants, this.isCustom, this.isDefault, this.isFree, this.isTrialable, this.monthlyPrice, this.name, + this.oneTimePrice, this.planType, this.trialDays, this.updatedAt, + this.usageViolations, this.valid, this.yearlyPrice); } @@ -319,18 +385,26 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CompanyCanTrialStage builder() { + public static ChargeTypeStage builder() { return new Builder(); } - public interface CompanyCanTrialStage { - CompanyCountStage companyCanTrial(boolean companyCanTrial); + public interface ChargeTypeStage { + CompanyCanTrialStage chargeType(@NotNull String chargeType); Builder from(CompanyPlanDetailResponseData other); } + public interface CompanyCanTrialStage { + CompanyCountStage companyCanTrial(boolean companyCanTrial); + } + public interface CompanyCountStage { - CreatedAtStage companyCount(int companyCount); + ControlledByStage companyCount(int companyCount); + } + + public interface ControlledByStage { + CreatedAtStage controlledBy(@NotNull String controlledBy); } public interface CreatedAtStage { @@ -400,6 +474,12 @@ public interface _FinalStage { _FinalStage billingProduct(BillingProductDetailResponseData billingProduct); + _FinalStage compatiblePlanIds(List compatiblePlanIds); + + _FinalStage addCompatiblePlanIds(String compatiblePlanIds); + + _FinalStage addAllCompatiblePlanIds(List compatiblePlanIds); + _FinalStage customPlanConfig(Optional customPlanConfig); _FinalStage customPlanConfig(CustomPlanConfig customPlanConfig); @@ -416,14 +496,30 @@ public interface _FinalStage { _FinalStage addAllFeatures(List features); + _FinalStage includedCreditGrants(List includedCreditGrants); + + _FinalStage addIncludedCreditGrants(PlanCreditGrantView includedCreditGrants); + + _FinalStage addAllIncludedCreditGrants(List includedCreditGrants); + _FinalStage monthlyPrice(Optional monthlyPrice); _FinalStage monthlyPrice(BillingPriceResponseData monthlyPrice); + _FinalStage oneTimePrice(Optional oneTimePrice); + + _FinalStage oneTimePrice(BillingPriceResponseData oneTimePrice); + _FinalStage trialDays(Optional trialDays); _FinalStage trialDays(Integer trialDays); + _FinalStage usageViolations(List usageViolations); + + _FinalStage addUsageViolations(FeatureUsageResponseData usageViolations); + + _FinalStage addAllUsageViolations(List usageViolations); + _FinalStage yearlyPrice(Optional yearlyPrice); _FinalStage yearlyPrice(BillingPriceResponseData yearlyPrice); @@ -431,8 +527,10 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CompanyCanTrialStage, + implements ChargeTypeStage, + CompanyCanTrialStage, CompanyCountStage, + ControlledByStage, CreatedAtStage, CurrentStage, CustomStage, @@ -448,10 +546,14 @@ public static final class Builder UpdatedAtStage, ValidStage, _FinalStage { + private String chargeType; + private boolean companyCanTrial; private int companyCount; + private String controlledBy; + private OffsetDateTime createdAt; private boolean current; @@ -482,16 +584,24 @@ public static final class Builder private Optional yearlyPrice = Optional.empty(); + private List usageViolations = new ArrayList<>(); + private Optional trialDays = Optional.empty(); + private Optional oneTimePrice = Optional.empty(); + private Optional monthlyPrice = Optional.empty(); + private List includedCreditGrants = new ArrayList<>(); + private List features = new ArrayList<>(); private List entitlements = new ArrayList<>(); private Optional customPlanConfig = Optional.empty(); + private List compatiblePlanIds = new ArrayList<>(); + private Optional billingProduct = Optional.empty(); private Optional audienceType = Optional.empty(); @@ -505,8 +615,11 @@ private Builder() {} public Builder from(CompanyPlanDetailResponseData other) { audienceType(other.getAudienceType()); billingProduct(other.getBillingProduct()); + chargeType(other.getChargeType()); companyCanTrial(other.getCompanyCanTrial()); companyCount(other.getCompanyCount()); + compatiblePlanIds(other.getCompatiblePlanIds()); + controlledBy(other.getControlledBy()); createdAt(other.getCreatedAt()); current(other.getCurrent()); custom(other.getCustom()); @@ -516,20 +629,30 @@ public Builder from(CompanyPlanDetailResponseData other) { features(other.getFeatures()); icon(other.getIcon()); id(other.getId()); + includedCreditGrants(other.getIncludedCreditGrants()); isCustom(other.getIsCustom()); isDefault(other.getIsDefault()); isFree(other.getIsFree()); isTrialable(other.getIsTrialable()); monthlyPrice(other.getMonthlyPrice()); name(other.getName()); + oneTimePrice(other.getOneTimePrice()); planType(other.getPlanType()); trialDays(other.getTrialDays()); updatedAt(other.getUpdatedAt()); + usageViolations(other.getUsageViolations()); valid(other.getValid()); yearlyPrice(other.getYearlyPrice()); return this; } + @java.lang.Override + @JsonSetter("charge_type") + public CompanyCanTrialStage chargeType(@NotNull String chargeType) { + this.chargeType = Objects.requireNonNull(chargeType, "chargeType must not be null"); + return this; + } + @java.lang.Override @JsonSetter("company_can_trial") public CompanyCountStage companyCanTrial(boolean companyCanTrial) { @@ -539,11 +662,18 @@ public CompanyCountStage companyCanTrial(boolean companyCanTrial) { @java.lang.Override @JsonSetter("company_count") - public CreatedAtStage companyCount(int companyCount) { + public ControlledByStage companyCount(int companyCount) { this.companyCount = companyCount; return this; } + @java.lang.Override + @JsonSetter("controlled_by") + public CreatedAtStage controlledBy(@NotNull String controlledBy) { + this.controlledBy = Objects.requireNonNull(controlledBy, "controlledBy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("created_at") public CurrentStage createdAt(@NotNull OffsetDateTime createdAt) { @@ -655,6 +785,30 @@ public _FinalStage yearlyPrice(Optional yearlyPrice) { return this; } + @java.lang.Override + public _FinalStage addAllUsageViolations(List usageViolations) { + if (usageViolations != null) { + this.usageViolations.addAll(usageViolations); + } + return this; + } + + @java.lang.Override + public _FinalStage addUsageViolations(FeatureUsageResponseData usageViolations) { + this.usageViolations.add(usageViolations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "usage_violations", nulls = Nulls.SKIP) + public _FinalStage usageViolations(List usageViolations) { + this.usageViolations.clear(); + if (usageViolations != null) { + this.usageViolations.addAll(usageViolations); + } + return this; + } + @java.lang.Override public _FinalStage trialDays(Integer trialDays) { this.trialDays = Optional.ofNullable(trialDays); @@ -668,6 +822,19 @@ public _FinalStage trialDays(Optional trialDays) { return this; } + @java.lang.Override + public _FinalStage oneTimePrice(BillingPriceResponseData oneTimePrice) { + this.oneTimePrice = Optional.ofNullable(oneTimePrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "one_time_price", nulls = Nulls.SKIP) + public _FinalStage oneTimePrice(Optional oneTimePrice) { + this.oneTimePrice = oneTimePrice; + return this; + } + @java.lang.Override public _FinalStage monthlyPrice(BillingPriceResponseData monthlyPrice) { this.monthlyPrice = Optional.ofNullable(monthlyPrice); @@ -681,9 +848,35 @@ public _FinalStage monthlyPrice(Optional monthlyPrice) return this; } + @java.lang.Override + public _FinalStage addAllIncludedCreditGrants(List includedCreditGrants) { + if (includedCreditGrants != null) { + this.includedCreditGrants.addAll(includedCreditGrants); + } + return this; + } + + @java.lang.Override + public _FinalStage addIncludedCreditGrants(PlanCreditGrantView includedCreditGrants) { + this.includedCreditGrants.add(includedCreditGrants); + return this; + } + + @java.lang.Override + @JsonSetter(value = "included_credit_grants", nulls = Nulls.SKIP) + public _FinalStage includedCreditGrants(List includedCreditGrants) { + this.includedCreditGrants.clear(); + if (includedCreditGrants != null) { + this.includedCreditGrants.addAll(includedCreditGrants); + } + return this; + } + @java.lang.Override public _FinalStage addAllFeatures(List features) { - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @@ -697,13 +890,17 @@ public _FinalStage addFeatures(FeatureDetailResponseData features) { @JsonSetter(value = "features", nulls = Nulls.SKIP) public _FinalStage features(List features) { this.features.clear(); - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @java.lang.Override public _FinalStage addAllEntitlements(List entitlements) { - this.entitlements.addAll(entitlements); + if (entitlements != null) { + this.entitlements.addAll(entitlements); + } return this; } @@ -717,7 +914,9 @@ public _FinalStage addEntitlements(PlanEntitlementResponseData entitlements) { @JsonSetter(value = "entitlements", nulls = Nulls.SKIP) public _FinalStage entitlements(List entitlements) { this.entitlements.clear(); - this.entitlements.addAll(entitlements); + if (entitlements != null) { + this.entitlements.addAll(entitlements); + } return this; } @@ -734,6 +933,30 @@ public _FinalStage customPlanConfig(Optional customPlanConfig) return this; } + @java.lang.Override + public _FinalStage addAllCompatiblePlanIds(List compatiblePlanIds) { + if (compatiblePlanIds != null) { + this.compatiblePlanIds.addAll(compatiblePlanIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addCompatiblePlanIds(String compatiblePlanIds) { + this.compatiblePlanIds.add(compatiblePlanIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "compatible_plan_ids", nulls = Nulls.SKIP) + public _FinalStage compatiblePlanIds(List compatiblePlanIds) { + this.compatiblePlanIds.clear(); + if (compatiblePlanIds != null) { + this.compatiblePlanIds.addAll(compatiblePlanIds); + } + return this; + } + @java.lang.Override public _FinalStage billingProduct(BillingProductDetailResponseData billingProduct) { this.billingProduct = Optional.ofNullable(billingProduct); @@ -765,8 +988,11 @@ public CompanyPlanDetailResponseData build() { return new CompanyPlanDetailResponseData( audienceType, billingProduct, + chargeType, companyCanTrial, companyCount, + compatiblePlanIds, + controlledBy, createdAt, current, custom, @@ -776,15 +1002,18 @@ public CompanyPlanDetailResponseData build() { features, icon, id, + includedCreditGrants, isCustom, isDefault, isFree, isTrialable, monthlyPrice, name, + oneTimePrice, planType, trialDays, updatedAt, + usageViolations, valid, yearlyPrice, additionalProperties); diff --git a/src/main/java/com/schematic/api/types/CompanyPlanWithBillingSubView.java b/src/main/java/com/schematic/api/types/CompanyPlanWithBillingSubView.java index 748325c..a4dc62d 100644 --- a/src/main/java/com/schematic/api/types/CompanyPlanWithBillingSubView.java +++ b/src/main/java/com/schematic/api/types/CompanyPlanWithBillingSubView.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -21,6 +22,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CompanyPlanWithBillingSubView.Builder.class) public final class CompanyPlanWithBillingSubView { + private final Optional addedOn; + + private final Optional billingProductExternalId; + private final Optional billingProductId; private final Optional description; @@ -38,6 +43,8 @@ public final class CompanyPlanWithBillingSubView { private final Map additionalProperties; private CompanyPlanWithBillingSubView( + Optional addedOn, + Optional billingProductExternalId, Optional billingProductId, Optional description, String id, @@ -46,6 +53,8 @@ private CompanyPlanWithBillingSubView( Optional planPeriod, Optional planPrice, Map additionalProperties) { + this.addedOn = addedOn; + this.billingProductExternalId = billingProductExternalId; this.billingProductId = billingProductId; this.description = description; this.id = id; @@ -56,6 +65,16 @@ private CompanyPlanWithBillingSubView( this.additionalProperties = additionalProperties; } + @JsonProperty("added_on") + public Optional getAddedOn() { + return addedOn; + } + + @JsonProperty("billing_product_external_id") + public Optional getBillingProductExternalId() { + return billingProductExternalId; + } + @JsonProperty("billing_product_id") public Optional getBillingProductId() { return billingProductId; @@ -103,7 +122,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(CompanyPlanWithBillingSubView other) { - return billingProductId.equals(other.billingProductId) + return addedOn.equals(other.addedOn) + && billingProductExternalId.equals(other.billingProductExternalId) + && billingProductId.equals(other.billingProductId) && description.equals(other.description) && id.equals(other.id) && imageUrl.equals(other.imageUrl) @@ -115,6 +136,8 @@ private boolean equalTo(CompanyPlanWithBillingSubView other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.addedOn, + this.billingProductExternalId, this.billingProductId, this.description, this.id, @@ -146,6 +169,14 @@ public interface NameStage { public interface _FinalStage { CompanyPlanWithBillingSubView build(); + _FinalStage addedOn(Optional addedOn); + + _FinalStage addedOn(OffsetDateTime addedOn); + + _FinalStage billingProductExternalId(Optional billingProductExternalId); + + _FinalStage billingProductExternalId(String billingProductExternalId); + _FinalStage billingProductId(Optional billingProductId); _FinalStage billingProductId(String billingProductId); @@ -183,6 +214,10 @@ public static final class Builder implements IdStage, NameStage, _FinalStage { private Optional billingProductId = Optional.empty(); + private Optional billingProductExternalId = Optional.empty(); + + private Optional addedOn = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -190,6 +225,8 @@ private Builder() {} @java.lang.Override public Builder from(CompanyPlanWithBillingSubView other) { + addedOn(other.getAddedOn()); + billingProductExternalId(other.getBillingProductExternalId()); billingProductId(other.getBillingProductId()); description(other.getDescription()); id(other.getId()); @@ -279,10 +316,45 @@ public _FinalStage billingProductId(Optional billingProductId) { return this; } + @java.lang.Override + public _FinalStage billingProductExternalId(String billingProductExternalId) { + this.billingProductExternalId = Optional.ofNullable(billingProductExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_product_external_id", nulls = Nulls.SKIP) + public _FinalStage billingProductExternalId(Optional billingProductExternalId) { + this.billingProductExternalId = billingProductExternalId; + return this; + } + + @java.lang.Override + public _FinalStage addedOn(OffsetDateTime addedOn) { + this.addedOn = Optional.ofNullable(addedOn); + return this; + } + + @java.lang.Override + @JsonSetter(value = "added_on", nulls = Nulls.SKIP) + public _FinalStage addedOn(Optional addedOn) { + this.addedOn = addedOn; + return this; + } + @java.lang.Override public CompanyPlanWithBillingSubView build() { return new CompanyPlanWithBillingSubView( - billingProductId, description, id, imageUrl, name, planPeriod, planPrice, additionalProperties); + addedOn, + billingProductExternalId, + billingProductId, + description, + id, + imageUrl, + name, + planPeriod, + planPrice, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/CompanySubscriptionResponseData.java b/src/main/java/com/schematic/api/types/CompanySubscriptionResponseData.java index dc306c2..90792f8 100644 --- a/src/main/java/com/schematic/api/types/CompanySubscriptionResponseData.java +++ b/src/main/java/com/schematic/api/types/CompanySubscriptionResponseData.java @@ -406,7 +406,9 @@ public _FinalStage trialEnd(Optional trialEnd) { @java.lang.Override public _FinalStage addAllProducts(List products) { - this.products.addAll(products); + if (products != null) { + this.products.addAll(products); + } return this; } @@ -420,7 +422,9 @@ public _FinalStage addProducts(BillingProductForSubscriptionResponseData product @JsonSetter(value = "products", nulls = Nulls.SKIP) public _FinalStage products(List products) { this.products.clear(); - this.products.addAll(products); + if (products != null) { + this.products.addAll(products); + } return this; } @@ -465,7 +469,9 @@ public _FinalStage expiredAt(Optional expiredAt) { @java.lang.Override public _FinalStage addAllDiscounts(List discounts) { - this.discounts.addAll(discounts); + if (discounts != null) { + this.discounts.addAll(discounts); + } return this; } @@ -479,7 +485,9 @@ public _FinalStage addDiscounts(BillingSubscriptionDiscountView discounts) { @JsonSetter(value = "discounts", nulls = Nulls.SKIP) public _FinalStage discounts(List discounts) { this.discounts.clear(); - this.discounts.addAll(discounts); + if (discounts != null) { + this.discounts.addAll(discounts); + } return this; } diff --git a/src/main/java/com/schematic/api/types/CompanyViewWithFeatureUsageResponseData.java b/src/main/java/com/schematic/api/types/CompanyViewWithFeatureUsageResponseData.java new file mode 100644 index 0000000..e703300 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CompanyViewWithFeatureUsageResponseData.java @@ -0,0 +1,893 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CompanyViewWithFeatureUsageResponseData.Builder.class) +public final class CompanyViewWithFeatureUsageResponseData { + private final List addOns; + + private final Optional> billingCreditBalances; + + private final Optional billingSubscription; + + private final List billingSubscriptions; + + private final OffsetDateTime createdAt; + + private final Optional defaultPaymentMethod; + + private final List entityTraits; + + private final String environmentId; + + private final List featureUsage; + + private final String id; + + private final List keys; + + private final Optional lastSeenAt; + + private final Optional logoUrl; + + private final List metrics; + + private final String name; + + private final List paymentMethods; + + private final Optional plan; + + private final List plans; + + private final List rules; + + private final Optional> traits; + + private final OffsetDateTime updatedAt; + + private final int userCount; + + private final Map additionalProperties; + + private CompanyViewWithFeatureUsageResponseData( + List addOns, + Optional> billingCreditBalances, + Optional billingSubscription, + List billingSubscriptions, + OffsetDateTime createdAt, + Optional defaultPaymentMethod, + List entityTraits, + String environmentId, + List featureUsage, + String id, + List keys, + Optional lastSeenAt, + Optional logoUrl, + List metrics, + String name, + List paymentMethods, + Optional plan, + List plans, + List rules, + Optional> traits, + OffsetDateTime updatedAt, + int userCount, + Map additionalProperties) { + this.addOns = addOns; + this.billingCreditBalances = billingCreditBalances; + this.billingSubscription = billingSubscription; + this.billingSubscriptions = billingSubscriptions; + this.createdAt = createdAt; + this.defaultPaymentMethod = defaultPaymentMethod; + this.entityTraits = entityTraits; + this.environmentId = environmentId; + this.featureUsage = featureUsage; + this.id = id; + this.keys = keys; + this.lastSeenAt = lastSeenAt; + this.logoUrl = logoUrl; + this.metrics = metrics; + this.name = name; + this.paymentMethods = paymentMethods; + this.plan = plan; + this.plans = plans; + this.rules = rules; + this.traits = traits; + this.updatedAt = updatedAt; + this.userCount = userCount; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("add_ons") + public List getAddOns() { + return addOns; + } + + @JsonProperty("billing_credit_balances") + public Optional> getBillingCreditBalances() { + return billingCreditBalances; + } + + @JsonProperty("billing_subscription") + public Optional getBillingSubscription() { + return billingSubscription; + } + + @JsonProperty("billing_subscriptions") + public List getBillingSubscriptions() { + return billingSubscriptions; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("default_payment_method") + public Optional getDefaultPaymentMethod() { + return defaultPaymentMethod; + } + + @JsonProperty("entity_traits") + public List getEntityTraits() { + return entityTraits; + } + + @JsonProperty("environment_id") + public String getEnvironmentId() { + return environmentId; + } + + @JsonProperty("feature_usage") + public List getFeatureUsage() { + return featureUsage; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("keys") + public List getKeys() { + return keys; + } + + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + @JsonProperty("logo_url") + public Optional getLogoUrl() { + return logoUrl; + } + + @JsonProperty("metrics") + public List getMetrics() { + return metrics; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("payment_methods") + public List getPaymentMethods() { + return paymentMethods; + } + + @JsonProperty("plan") + public Optional getPlan() { + return plan; + } + + @JsonProperty("plans") + public List getPlans() { + return plans; + } + + @JsonProperty("rules") + public List getRules() { + return rules; + } + + /** + * @return A map of trait names to trait values + */ + @JsonProperty("traits") + public Optional> getTraits() { + return traits; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("user_count") + public int getUserCount() { + return userCount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CompanyViewWithFeatureUsageResponseData + && equalTo((CompanyViewWithFeatureUsageResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CompanyViewWithFeatureUsageResponseData other) { + return addOns.equals(other.addOns) + && billingCreditBalances.equals(other.billingCreditBalances) + && billingSubscription.equals(other.billingSubscription) + && billingSubscriptions.equals(other.billingSubscriptions) + && createdAt.equals(other.createdAt) + && defaultPaymentMethod.equals(other.defaultPaymentMethod) + && entityTraits.equals(other.entityTraits) + && environmentId.equals(other.environmentId) + && featureUsage.equals(other.featureUsage) + && id.equals(other.id) + && keys.equals(other.keys) + && lastSeenAt.equals(other.lastSeenAt) + && logoUrl.equals(other.logoUrl) + && metrics.equals(other.metrics) + && name.equals(other.name) + && paymentMethods.equals(other.paymentMethods) + && plan.equals(other.plan) + && plans.equals(other.plans) + && rules.equals(other.rules) + && traits.equals(other.traits) + && updatedAt.equals(other.updatedAt) + && userCount == other.userCount; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.addOns, + this.billingCreditBalances, + this.billingSubscription, + this.billingSubscriptions, + this.createdAt, + this.defaultPaymentMethod, + this.entityTraits, + this.environmentId, + this.featureUsage, + this.id, + this.keys, + this.lastSeenAt, + this.logoUrl, + this.metrics, + this.name, + this.paymentMethods, + this.plan, + this.plans, + this.rules, + this.traits, + this.updatedAt, + this.userCount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtStage builder() { + return new Builder(); + } + + public interface CreatedAtStage { + EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); + + Builder from(CompanyViewWithFeatureUsageResponseData other); + } + + public interface EnvironmentIdStage { + IdStage environmentId(@NotNull String environmentId); + } + + public interface IdStage { + NameStage id(@NotNull String id); + } + + public interface NameStage { + UpdatedAtStage name(@NotNull String name); + } + + public interface UpdatedAtStage { + UserCountStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface UserCountStage { + _FinalStage userCount(int userCount); + } + + public interface _FinalStage { + CompanyViewWithFeatureUsageResponseData build(); + + _FinalStage addOns(List addOns); + + _FinalStage addAddOns(CompanyPlanWithBillingSubView addOns); + + _FinalStage addAllAddOns(List addOns); + + _FinalStage billingCreditBalances(Optional> billingCreditBalances); + + _FinalStage billingCreditBalances(Map billingCreditBalances); + + _FinalStage billingSubscription(Optional billingSubscription); + + _FinalStage billingSubscription(BillingSubscriptionView billingSubscription); + + _FinalStage billingSubscriptions(List billingSubscriptions); + + _FinalStage addBillingSubscriptions(BillingSubscriptionView billingSubscriptions); + + _FinalStage addAllBillingSubscriptions(List billingSubscriptions); + + _FinalStage defaultPaymentMethod(Optional defaultPaymentMethod); + + _FinalStage defaultPaymentMethod(PaymentMethodResponseData defaultPaymentMethod); + + _FinalStage entityTraits(List entityTraits); + + _FinalStage addEntityTraits(EntityTraitDetailResponseData entityTraits); + + _FinalStage addAllEntityTraits(List entityTraits); + + _FinalStage featureUsage(List featureUsage); + + _FinalStage addFeatureUsage(FeatureUsageDataResponseData featureUsage); + + _FinalStage addAllFeatureUsage(List featureUsage); + + _FinalStage keys(List keys); + + _FinalStage addKeys(EntityKeyDetailResponseData keys); + + _FinalStage addAllKeys(List keys); + + _FinalStage lastSeenAt(Optional lastSeenAt); + + _FinalStage lastSeenAt(OffsetDateTime lastSeenAt); + + _FinalStage logoUrl(Optional logoUrl); + + _FinalStage logoUrl(String logoUrl); + + _FinalStage metrics(List metrics); + + _FinalStage addMetrics(CompanyEventPeriodMetricsResponseData metrics); + + _FinalStage addAllMetrics(List metrics); + + _FinalStage paymentMethods(List paymentMethods); + + _FinalStage addPaymentMethods(PaymentMethodResponseData paymentMethods); + + _FinalStage addAllPaymentMethods(List paymentMethods); + + _FinalStage plan(Optional plan); + + _FinalStage plan(CompanyPlanWithBillingSubView plan); + + _FinalStage plans(List plans); + + _FinalStage addPlans(GenericPreviewObject plans); + + _FinalStage addAllPlans(List plans); + + _FinalStage rules(List rules); + + _FinalStage addRules(Rule rules); + + _FinalStage addAllRules(List rules); + + /** + *

A map of trait names to trait values

+ */ + _FinalStage traits(Optional> traits); + + _FinalStage traits(Map traits); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CreatedAtStage, + EnvironmentIdStage, + IdStage, + NameStage, + UpdatedAtStage, + UserCountStage, + _FinalStage { + private OffsetDateTime createdAt; + + private String environmentId; + + private String id; + + private String name; + + private OffsetDateTime updatedAt; + + private int userCount; + + private Optional> traits = Optional.empty(); + + private List rules = new ArrayList<>(); + + private List plans = new ArrayList<>(); + + private Optional plan = Optional.empty(); + + private List paymentMethods = new ArrayList<>(); + + private List metrics = new ArrayList<>(); + + private Optional logoUrl = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private List keys = new ArrayList<>(); + + private List featureUsage = new ArrayList<>(); + + private List entityTraits = new ArrayList<>(); + + private Optional defaultPaymentMethod = Optional.empty(); + + private List billingSubscriptions = new ArrayList<>(); + + private Optional billingSubscription = Optional.empty(); + + private Optional> billingCreditBalances = Optional.empty(); + + private List addOns = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CompanyViewWithFeatureUsageResponseData other) { + addOns(other.getAddOns()); + billingCreditBalances(other.getBillingCreditBalances()); + billingSubscription(other.getBillingSubscription()); + billingSubscriptions(other.getBillingSubscriptions()); + createdAt(other.getCreatedAt()); + defaultPaymentMethod(other.getDefaultPaymentMethod()); + entityTraits(other.getEntityTraits()); + environmentId(other.getEnvironmentId()); + featureUsage(other.getFeatureUsage()); + id(other.getId()); + keys(other.getKeys()); + lastSeenAt(other.getLastSeenAt()); + logoUrl(other.getLogoUrl()); + metrics(other.getMetrics()); + name(other.getName()); + paymentMethods(other.getPaymentMethods()); + plan(other.getPlan()); + plans(other.getPlans()); + rules(other.getRules()); + traits(other.getTraits()); + updatedAt(other.getUpdatedAt()); + userCount(other.getUserCount()); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("environment_id") + public IdStage environmentId(@NotNull String environmentId) { + this.environmentId = Objects.requireNonNull(environmentId, "environmentId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public UpdatedAtStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public UserCountStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("user_count") + public _FinalStage userCount(int userCount) { + this.userCount = userCount; + return this; + } + + /** + *

A map of trait names to trait values

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage traits(Map traits) { + this.traits = Optional.ofNullable(traits); + return this; + } + + /** + *

A map of trait names to trait values

+ */ + @java.lang.Override + @JsonSetter(value = "traits", nulls = Nulls.SKIP) + public _FinalStage traits(Optional> traits) { + this.traits = traits; + return this; + } + + @java.lang.Override + public _FinalStage addAllRules(List rules) { + if (rules != null) { + this.rules.addAll(rules); + } + return this; + } + + @java.lang.Override + public _FinalStage addRules(Rule rules) { + this.rules.add(rules); + return this; + } + + @java.lang.Override + @JsonSetter(value = "rules", nulls = Nulls.SKIP) + public _FinalStage rules(List rules) { + this.rules.clear(); + if (rules != null) { + this.rules.addAll(rules); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllPlans(List plans) { + if (plans != null) { + this.plans.addAll(plans); + } + return this; + } + + @java.lang.Override + public _FinalStage addPlans(GenericPreviewObject plans) { + this.plans.add(plans); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plans", nulls = Nulls.SKIP) + public _FinalStage plans(List plans) { + this.plans.clear(); + if (plans != null) { + this.plans.addAll(plans); + } + return this; + } + + @java.lang.Override + public _FinalStage plan(CompanyPlanWithBillingSubView plan) { + this.plan = Optional.ofNullable(plan); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan", nulls = Nulls.SKIP) + public _FinalStage plan(Optional plan) { + this.plan = plan; + return this; + } + + @java.lang.Override + public _FinalStage addAllPaymentMethods(List paymentMethods) { + if (paymentMethods != null) { + this.paymentMethods.addAll(paymentMethods); + } + return this; + } + + @java.lang.Override + public _FinalStage addPaymentMethods(PaymentMethodResponseData paymentMethods) { + this.paymentMethods.add(paymentMethods); + return this; + } + + @java.lang.Override + @JsonSetter(value = "payment_methods", nulls = Nulls.SKIP) + public _FinalStage paymentMethods(List paymentMethods) { + this.paymentMethods.clear(); + if (paymentMethods != null) { + this.paymentMethods.addAll(paymentMethods); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllMetrics(List metrics) { + if (metrics != null) { + this.metrics.addAll(metrics); + } + return this; + } + + @java.lang.Override + public _FinalStage addMetrics(CompanyEventPeriodMetricsResponseData metrics) { + this.metrics.add(metrics); + return this; + } + + @java.lang.Override + @JsonSetter(value = "metrics", nulls = Nulls.SKIP) + public _FinalStage metrics(List metrics) { + this.metrics.clear(); + if (metrics != null) { + this.metrics.addAll(metrics); + } + return this; + } + + @java.lang.Override + public _FinalStage logoUrl(String logoUrl) { + this.logoUrl = Optional.ofNullable(logoUrl); + return this; + } + + @java.lang.Override + @JsonSetter(value = "logo_url", nulls = Nulls.SKIP) + public _FinalStage logoUrl(Optional logoUrl) { + this.logoUrl = logoUrl; + return this; + } + + @java.lang.Override + public _FinalStage lastSeenAt(OffsetDateTime lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public _FinalStage lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + @java.lang.Override + public _FinalStage addAllKeys(List keys) { + if (keys != null) { + this.keys.addAll(keys); + } + return this; + } + + @java.lang.Override + public _FinalStage addKeys(EntityKeyDetailResponseData keys) { + this.keys.add(keys); + return this; + } + + @java.lang.Override + @JsonSetter(value = "keys", nulls = Nulls.SKIP) + public _FinalStage keys(List keys) { + this.keys.clear(); + if (keys != null) { + this.keys.addAll(keys); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllFeatureUsage(List featureUsage) { + if (featureUsage != null) { + this.featureUsage.addAll(featureUsage); + } + return this; + } + + @java.lang.Override + public _FinalStage addFeatureUsage(FeatureUsageDataResponseData featureUsage) { + this.featureUsage.add(featureUsage); + return this; + } + + @java.lang.Override + @JsonSetter(value = "feature_usage", nulls = Nulls.SKIP) + public _FinalStage featureUsage(List featureUsage) { + this.featureUsage.clear(); + if (featureUsage != null) { + this.featureUsage.addAll(featureUsage); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllEntityTraits(List entityTraits) { + if (entityTraits != null) { + this.entityTraits.addAll(entityTraits); + } + return this; + } + + @java.lang.Override + public _FinalStage addEntityTraits(EntityTraitDetailResponseData entityTraits) { + this.entityTraits.add(entityTraits); + return this; + } + + @java.lang.Override + @JsonSetter(value = "entity_traits", nulls = Nulls.SKIP) + public _FinalStage entityTraits(List entityTraits) { + this.entityTraits.clear(); + if (entityTraits != null) { + this.entityTraits.addAll(entityTraits); + } + return this; + } + + @java.lang.Override + public _FinalStage defaultPaymentMethod(PaymentMethodResponseData defaultPaymentMethod) { + this.defaultPaymentMethod = Optional.ofNullable(defaultPaymentMethod); + return this; + } + + @java.lang.Override + @JsonSetter(value = "default_payment_method", nulls = Nulls.SKIP) + public _FinalStage defaultPaymentMethod(Optional defaultPaymentMethod) { + this.defaultPaymentMethod = defaultPaymentMethod; + return this; + } + + @java.lang.Override + public _FinalStage addAllBillingSubscriptions(List billingSubscriptions) { + if (billingSubscriptions != null) { + this.billingSubscriptions.addAll(billingSubscriptions); + } + return this; + } + + @java.lang.Override + public _FinalStage addBillingSubscriptions(BillingSubscriptionView billingSubscriptions) { + this.billingSubscriptions.add(billingSubscriptions); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_subscriptions", nulls = Nulls.SKIP) + public _FinalStage billingSubscriptions(List billingSubscriptions) { + this.billingSubscriptions.clear(); + if (billingSubscriptions != null) { + this.billingSubscriptions.addAll(billingSubscriptions); + } + return this; + } + + @java.lang.Override + public _FinalStage billingSubscription(BillingSubscriptionView billingSubscription) { + this.billingSubscription = Optional.ofNullable(billingSubscription); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_subscription", nulls = Nulls.SKIP) + public _FinalStage billingSubscription(Optional billingSubscription) { + this.billingSubscription = billingSubscription; + return this; + } + + @java.lang.Override + public _FinalStage billingCreditBalances(Map billingCreditBalances) { + this.billingCreditBalances = Optional.ofNullable(billingCreditBalances); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_credit_balances", nulls = Nulls.SKIP) + public _FinalStage billingCreditBalances(Optional> billingCreditBalances) { + this.billingCreditBalances = billingCreditBalances; + return this; + } + + @java.lang.Override + public _FinalStage addAllAddOns(List addOns) { + if (addOns != null) { + this.addOns.addAll(addOns); + } + return this; + } + + @java.lang.Override + public _FinalStage addAddOns(CompanyPlanWithBillingSubView addOns) { + this.addOns.add(addOns); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_ons", nulls = Nulls.SKIP) + public _FinalStage addOns(List addOns) { + this.addOns.clear(); + if (addOns != null) { + this.addOns.addAll(addOns); + } + return this; + } + + @java.lang.Override + public CompanyViewWithFeatureUsageResponseData build() { + return new CompanyViewWithFeatureUsageResponseData( + addOns, + billingCreditBalances, + billingSubscription, + billingSubscriptions, + createdAt, + defaultPaymentMethod, + entityTraits, + environmentId, + featureUsage, + id, + keys, + lastSeenAt, + logoUrl, + metrics, + name, + paymentMethods, + plan, + plans, + rules, + traits, + updatedAt, + userCount, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CompatiblePlans.java b/src/main/java/com/schematic/api/types/CompatiblePlans.java new file mode 100644 index 0000000..72c62f3 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CompatiblePlans.java @@ -0,0 +1,147 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CompatiblePlans.Builder.class) +public final class CompatiblePlans { + private final List compatiblePlanIds; + + private final String sourcePlanId; + + private final Map additionalProperties; + + private CompatiblePlans( + List compatiblePlanIds, String sourcePlanId, Map additionalProperties) { + this.compatiblePlanIds = compatiblePlanIds; + this.sourcePlanId = sourcePlanId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("compatible_plan_ids") + public List getCompatiblePlanIds() { + return compatiblePlanIds; + } + + @JsonProperty("source_plan_id") + public String getSourcePlanId() { + return sourcePlanId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CompatiblePlans && equalTo((CompatiblePlans) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CompatiblePlans other) { + return compatiblePlanIds.equals(other.compatiblePlanIds) && sourcePlanId.equals(other.sourcePlanId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.compatiblePlanIds, this.sourcePlanId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourcePlanIdStage builder() { + return new Builder(); + } + + public interface SourcePlanIdStage { + _FinalStage sourcePlanId(@NotNull String sourcePlanId); + + Builder from(CompatiblePlans other); + } + + public interface _FinalStage { + CompatiblePlans build(); + + _FinalStage compatiblePlanIds(List compatiblePlanIds); + + _FinalStage addCompatiblePlanIds(String compatiblePlanIds); + + _FinalStage addAllCompatiblePlanIds(List compatiblePlanIds); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourcePlanIdStage, _FinalStage { + private String sourcePlanId; + + private List compatiblePlanIds = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CompatiblePlans other) { + compatiblePlanIds(other.getCompatiblePlanIds()); + sourcePlanId(other.getSourcePlanId()); + return this; + } + + @java.lang.Override + @JsonSetter("source_plan_id") + public _FinalStage sourcePlanId(@NotNull String sourcePlanId) { + this.sourcePlanId = Objects.requireNonNull(sourcePlanId, "sourcePlanId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllCompatiblePlanIds(List compatiblePlanIds) { + if (compatiblePlanIds != null) { + this.compatiblePlanIds.addAll(compatiblePlanIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addCompatiblePlanIds(String compatiblePlanIds) { + this.compatiblePlanIds.add(compatiblePlanIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "compatible_plan_ids", nulls = Nulls.SKIP) + public _FinalStage compatiblePlanIds(List compatiblePlanIds) { + this.compatiblePlanIds.clear(); + if (compatiblePlanIds != null) { + this.compatiblePlanIds.addAll(compatiblePlanIds); + } + return this; + } + + @java.lang.Override + public CompatiblePlans build() { + return new CompatiblePlans(compatiblePlanIds, sourcePlanId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CompatiblePlansResponseData.java b/src/main/java/com/schematic/api/types/CompatiblePlansResponseData.java new file mode 100644 index 0000000..6dbd2cd --- /dev/null +++ b/src/main/java/com/schematic/api/types/CompatiblePlansResponseData.java @@ -0,0 +1,147 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CompatiblePlansResponseData.Builder.class) +public final class CompatiblePlansResponseData { + private final List compatiblePlanIds; + + private final String sourcePlanId; + + private final Map additionalProperties; + + private CompatiblePlansResponseData( + List compatiblePlanIds, String sourcePlanId, Map additionalProperties) { + this.compatiblePlanIds = compatiblePlanIds; + this.sourcePlanId = sourcePlanId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("compatible_plan_ids") + public List getCompatiblePlanIds() { + return compatiblePlanIds; + } + + @JsonProperty("source_plan_id") + public String getSourcePlanId() { + return sourcePlanId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CompatiblePlansResponseData && equalTo((CompatiblePlansResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CompatiblePlansResponseData other) { + return compatiblePlanIds.equals(other.compatiblePlanIds) && sourcePlanId.equals(other.sourcePlanId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.compatiblePlanIds, this.sourcePlanId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourcePlanIdStage builder() { + return new Builder(); + } + + public interface SourcePlanIdStage { + _FinalStage sourcePlanId(@NotNull String sourcePlanId); + + Builder from(CompatiblePlansResponseData other); + } + + public interface _FinalStage { + CompatiblePlansResponseData build(); + + _FinalStage compatiblePlanIds(List compatiblePlanIds); + + _FinalStage addCompatiblePlanIds(String compatiblePlanIds); + + _FinalStage addAllCompatiblePlanIds(List compatiblePlanIds); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourcePlanIdStage, _FinalStage { + private String sourcePlanId; + + private List compatiblePlanIds = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CompatiblePlansResponseData other) { + compatiblePlanIds(other.getCompatiblePlanIds()); + sourcePlanId(other.getSourcePlanId()); + return this; + } + + @java.lang.Override + @JsonSetter("source_plan_id") + public _FinalStage sourcePlanId(@NotNull String sourcePlanId) { + this.sourcePlanId = Objects.requireNonNull(sourcePlanId, "sourcePlanId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllCompatiblePlanIds(List compatiblePlanIds) { + if (compatiblePlanIds != null) { + this.compatiblePlanIds.addAll(compatiblePlanIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addCompatiblePlanIds(String compatiblePlanIds) { + this.compatiblePlanIds.add(compatiblePlanIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "compatible_plan_ids", nulls = Nulls.SKIP) + public _FinalStage compatiblePlanIds(List compatiblePlanIds) { + this.compatiblePlanIds.clear(); + if (compatiblePlanIds != null) { + this.compatiblePlanIds.addAll(compatiblePlanIds); + } + return this; + } + + @java.lang.Override + public CompatiblePlansResponseData build() { + return new CompatiblePlansResponseData(compatiblePlanIds, sourcePlanId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/ComponentCheckoutSettings.java b/src/main/java/com/schematic/api/types/ComponentCheckoutSettings.java new file mode 100644 index 0000000..e496fe3 --- /dev/null +++ b/src/main/java/com/schematic/api/types/ComponentCheckoutSettings.java @@ -0,0 +1,181 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ComponentCheckoutSettings.Builder.class) +public final class ComponentCheckoutSettings { + private final boolean collectAddress; + + private final boolean collectEmail; + + private final boolean collectPhone; + + private final boolean taxCollectionEnabled; + + private final Map additionalProperties; + + private ComponentCheckoutSettings( + boolean collectAddress, + boolean collectEmail, + boolean collectPhone, + boolean taxCollectionEnabled, + Map additionalProperties) { + this.collectAddress = collectAddress; + this.collectEmail = collectEmail; + this.collectPhone = collectPhone; + this.taxCollectionEnabled = taxCollectionEnabled; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("collect_address") + public boolean getCollectAddress() { + return collectAddress; + } + + @JsonProperty("collect_email") + public boolean getCollectEmail() { + return collectEmail; + } + + @JsonProperty("collect_phone") + public boolean getCollectPhone() { + return collectPhone; + } + + @JsonProperty("tax_collection_enabled") + public boolean getTaxCollectionEnabled() { + return taxCollectionEnabled; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ComponentCheckoutSettings && equalTo((ComponentCheckoutSettings) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ComponentCheckoutSettings other) { + return collectAddress == other.collectAddress + && collectEmail == other.collectEmail + && collectPhone == other.collectPhone + && taxCollectionEnabled == other.taxCollectionEnabled; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.collectAddress, this.collectEmail, this.collectPhone, this.taxCollectionEnabled); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CollectAddressStage builder() { + return new Builder(); + } + + public interface CollectAddressStage { + CollectEmailStage collectAddress(boolean collectAddress); + + Builder from(ComponentCheckoutSettings other); + } + + public interface CollectEmailStage { + CollectPhoneStage collectEmail(boolean collectEmail); + } + + public interface CollectPhoneStage { + TaxCollectionEnabledStage collectPhone(boolean collectPhone); + } + + public interface TaxCollectionEnabledStage { + _FinalStage taxCollectionEnabled(boolean taxCollectionEnabled); + } + + public interface _FinalStage { + ComponentCheckoutSettings build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CollectAddressStage, + CollectEmailStage, + CollectPhoneStage, + TaxCollectionEnabledStage, + _FinalStage { + private boolean collectAddress; + + private boolean collectEmail; + + private boolean collectPhone; + + private boolean taxCollectionEnabled; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ComponentCheckoutSettings other) { + collectAddress(other.getCollectAddress()); + collectEmail(other.getCollectEmail()); + collectPhone(other.getCollectPhone()); + taxCollectionEnabled(other.getTaxCollectionEnabled()); + return this; + } + + @java.lang.Override + @JsonSetter("collect_address") + public CollectEmailStage collectAddress(boolean collectAddress) { + this.collectAddress = collectAddress; + return this; + } + + @java.lang.Override + @JsonSetter("collect_email") + public CollectPhoneStage collectEmail(boolean collectEmail) { + this.collectEmail = collectEmail; + return this; + } + + @java.lang.Override + @JsonSetter("collect_phone") + public TaxCollectionEnabledStage collectPhone(boolean collectPhone) { + this.collectPhone = collectPhone; + return this; + } + + @java.lang.Override + @JsonSetter("tax_collection_enabled") + public _FinalStage taxCollectionEnabled(boolean taxCollectionEnabled) { + this.taxCollectionEnabled = taxCollectionEnabled; + return this; + } + + @java.lang.Override + public ComponentCheckoutSettings build() { + return new ComponentCheckoutSettings( + collectAddress, collectEmail, collectPhone, taxCollectionEnabled, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/ComponentHydrateResponseData.java b/src/main/java/com/schematic/api/types/ComponentHydrateResponseData.java index cb6717e..6a71eb2 100644 --- a/src/main/java/com/schematic/api/types/ComponentHydrateResponseData.java +++ b/src/main/java/com/schematic/api/types/ComponentHydrateResponseData.java @@ -18,6 +18,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ComponentHydrateResponseData.Builder.class) @@ -28,16 +29,32 @@ public final class ComponentHydrateResponseData { private final List activeUsageBasedEntitlements; + private final List addOnCompatibilities; + private final Optional capabilities; + private final ComponentCheckoutSettings checkoutSettings; + private final Optional company; private final Optional component; + private final List creditBundles; + + private final List creditGrants; + private final Optional defaultPlan; private final Optional featureUsage; + private final Optional postTrialPlan; + + private final boolean showCredits; + + private final boolean showPeriodToggle; + + private final boolean showZeroPriceAsFree; + private final Optional stripeEmbed; private final Optional subscription; @@ -52,11 +69,19 @@ private ComponentHydrateResponseData( List activeAddOns, List activePlans, List activeUsageBasedEntitlements, + List addOnCompatibilities, Optional capabilities, + ComponentCheckoutSettings checkoutSettings, Optional company, Optional component, + List creditBundles, + List creditGrants, Optional defaultPlan, Optional featureUsage, + Optional postTrialPlan, + boolean showCredits, + boolean showPeriodToggle, + boolean showZeroPriceAsFree, Optional stripeEmbed, Optional subscription, Optional trialPaymentMethodRequired, @@ -65,11 +90,19 @@ private ComponentHydrateResponseData( this.activeAddOns = activeAddOns; this.activePlans = activePlans; this.activeUsageBasedEntitlements = activeUsageBasedEntitlements; + this.addOnCompatibilities = addOnCompatibilities; this.capabilities = capabilities; + this.checkoutSettings = checkoutSettings; this.company = company; this.component = component; + this.creditBundles = creditBundles; + this.creditGrants = creditGrants; this.defaultPlan = defaultPlan; this.featureUsage = featureUsage; + this.postTrialPlan = postTrialPlan; + this.showCredits = showCredits; + this.showPeriodToggle = showPeriodToggle; + this.showZeroPriceAsFree = showZeroPriceAsFree; this.stripeEmbed = stripeEmbed; this.subscription = subscription; this.trialPaymentMethodRequired = trialPaymentMethodRequired; @@ -92,11 +125,21 @@ public List getActiveUsageBasedEntitlements() return activeUsageBasedEntitlements; } + @JsonProperty("add_on_compatibilities") + public List getAddOnCompatibilities() { + return addOnCompatibilities; + } + @JsonProperty("capabilities") public Optional getCapabilities() { return capabilities; } + @JsonProperty("checkout_settings") + public ComponentCheckoutSettings getCheckoutSettings() { + return checkoutSettings; + } + @JsonProperty("company") public Optional getCompany() { return company; @@ -107,6 +150,16 @@ public Optional getComponent() { return component; } + @JsonProperty("credit_bundles") + public List getCreditBundles() { + return creditBundles; + } + + @JsonProperty("credit_grants") + public List getCreditGrants() { + return creditGrants; + } + @JsonProperty("default_plan") public Optional getDefaultPlan() { return defaultPlan; @@ -117,6 +170,26 @@ public Optional getFeatureUsage() { return featureUsage; } + @JsonProperty("post_trial_plan") + public Optional getPostTrialPlan() { + return postTrialPlan; + } + + @JsonProperty("show_credits") + public boolean getShowCredits() { + return showCredits; + } + + @JsonProperty("show_period_toggle") + public boolean getShowPeriodToggle() { + return showPeriodToggle; + } + + @JsonProperty("show_zero_price_as_free") + public boolean getShowZeroPriceAsFree() { + return showZeroPriceAsFree; + } + @JsonProperty("stripe_embed") public Optional getStripeEmbed() { return stripeEmbed; @@ -152,11 +225,19 @@ private boolean equalTo(ComponentHydrateResponseData other) { return activeAddOns.equals(other.activeAddOns) && activePlans.equals(other.activePlans) && activeUsageBasedEntitlements.equals(other.activeUsageBasedEntitlements) + && addOnCompatibilities.equals(other.addOnCompatibilities) && capabilities.equals(other.capabilities) + && checkoutSettings.equals(other.checkoutSettings) && company.equals(other.company) && component.equals(other.component) + && creditBundles.equals(other.creditBundles) + && creditGrants.equals(other.creditGrants) && defaultPlan.equals(other.defaultPlan) && featureUsage.equals(other.featureUsage) + && postTrialPlan.equals(other.postTrialPlan) + && showCredits == other.showCredits + && showPeriodToggle == other.showPeriodToggle + && showZeroPriceAsFree == other.showZeroPriceAsFree && stripeEmbed.equals(other.stripeEmbed) && subscription.equals(other.subscription) && trialPaymentMethodRequired.equals(other.trialPaymentMethodRequired) @@ -169,11 +250,19 @@ public int hashCode() { this.activeAddOns, this.activePlans, this.activeUsageBasedEntitlements, + this.addOnCompatibilities, this.capabilities, + this.checkoutSettings, this.company, this.component, + this.creditBundles, + this.creditGrants, this.defaultPlan, this.featureUsage, + this.postTrialPlan, + this.showCredits, + this.showPeriodToggle, + this.showZeroPriceAsFree, this.stripeEmbed, this.subscription, this.trialPaymentMethodRequired, @@ -185,50 +274,179 @@ public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static CheckoutSettingsStage builder() { return new Builder(); } + public interface CheckoutSettingsStage { + ShowCreditsStage checkoutSettings(@NotNull ComponentCheckoutSettings checkoutSettings); + + Builder from(ComponentHydrateResponseData other); + } + + public interface ShowCreditsStage { + ShowPeriodToggleStage showCredits(boolean showCredits); + } + + public interface ShowPeriodToggleStage { + ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle); + } + + public interface ShowZeroPriceAsFreeStage { + _FinalStage showZeroPriceAsFree(boolean showZeroPriceAsFree); + } + + public interface _FinalStage { + ComponentHydrateResponseData build(); + + _FinalStage activeAddOns(List activeAddOns); + + _FinalStage addActiveAddOns(CompanyPlanDetailResponseData activeAddOns); + + _FinalStage addAllActiveAddOns(List activeAddOns); + + _FinalStage activePlans(List activePlans); + + _FinalStage addActivePlans(CompanyPlanDetailResponseData activePlans); + + _FinalStage addAllActivePlans(List activePlans); + + _FinalStage activeUsageBasedEntitlements(List activeUsageBasedEntitlements); + + _FinalStage addActiveUsageBasedEntitlements(UsageBasedEntitlementResponseData activeUsageBasedEntitlements); + + _FinalStage addAllActiveUsageBasedEntitlements( + List activeUsageBasedEntitlements); + + _FinalStage addOnCompatibilities(List addOnCompatibilities); + + _FinalStage addAddOnCompatibilities(CompatiblePlans addOnCompatibilities); + + _FinalStage addAllAddOnCompatibilities(List addOnCompatibilities); + + _FinalStage capabilities(Optional capabilities); + + _FinalStage capabilities(ComponentCapabilities capabilities); + + _FinalStage company(Optional company); + + _FinalStage company(CompanyDetailResponseData company); + + _FinalStage component(Optional component); + + _FinalStage component(ComponentResponseData component); + + _FinalStage creditBundles(List creditBundles); + + _FinalStage addCreditBundles(BillingCreditBundleView creditBundles); + + _FinalStage addAllCreditBundles(List creditBundles); + + _FinalStage creditGrants(List creditGrants); + + _FinalStage addCreditGrants(CreditCompanyGrantView creditGrants); + + _FinalStage addAllCreditGrants(List creditGrants); + + _FinalStage defaultPlan(Optional defaultPlan); + + _FinalStage defaultPlan(PlanDetailResponseData defaultPlan); + + _FinalStage featureUsage(Optional featureUsage); + + _FinalStage featureUsage(FeatureUsageDetailResponseData featureUsage); + + _FinalStage postTrialPlan(Optional postTrialPlan); + + _FinalStage postTrialPlan(PlanDetailResponseData postTrialPlan); + + _FinalStage stripeEmbed(Optional stripeEmbed); + + _FinalStage stripeEmbed(StripeEmbedInfo stripeEmbed); + + _FinalStage subscription(Optional subscription); + + _FinalStage subscription(CompanySubscriptionResponseData subscription); + + _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired); + + _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired); + + _FinalStage upcomingInvoice(Optional upcomingInvoice); + + _FinalStage upcomingInvoice(InvoiceResponseData upcomingInvoice); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List activeAddOns = new ArrayList<>(); + public static final class Builder + implements CheckoutSettingsStage, + ShowCreditsStage, + ShowPeriodToggleStage, + ShowZeroPriceAsFreeStage, + _FinalStage { + private ComponentCheckoutSettings checkoutSettings; - private List activePlans = new ArrayList<>(); + private boolean showCredits; - private List activeUsageBasedEntitlements = new ArrayList<>(); + private boolean showPeriodToggle; - private Optional capabilities = Optional.empty(); + private boolean showZeroPriceAsFree; - private Optional company = Optional.empty(); + private Optional upcomingInvoice = Optional.empty(); - private Optional component = Optional.empty(); + private Optional trialPaymentMethodRequired = Optional.empty(); - private Optional defaultPlan = Optional.empty(); + private Optional subscription = Optional.empty(); + + private Optional stripeEmbed = Optional.empty(); + + private Optional postTrialPlan = Optional.empty(); private Optional featureUsage = Optional.empty(); - private Optional stripeEmbed = Optional.empty(); + private Optional defaultPlan = Optional.empty(); - private Optional subscription = Optional.empty(); + private List creditGrants = new ArrayList<>(); - private Optional trialPaymentMethodRequired = Optional.empty(); + private List creditBundles = new ArrayList<>(); - private Optional upcomingInvoice = Optional.empty(); + private Optional component = Optional.empty(); + + private Optional company = Optional.empty(); + + private Optional capabilities = Optional.empty(); + + private List addOnCompatibilities = new ArrayList<>(); + + private List activeUsageBasedEntitlements = new ArrayList<>(); + + private List activePlans = new ArrayList<>(); + + private List activeAddOns = new ArrayList<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} + @java.lang.Override public Builder from(ComponentHydrateResponseData other) { activeAddOns(other.getActiveAddOns()); activePlans(other.getActivePlans()); activeUsageBasedEntitlements(other.getActiveUsageBasedEntitlements()); + addOnCompatibilities(other.getAddOnCompatibilities()); capabilities(other.getCapabilities()); + checkoutSettings(other.getCheckoutSettings()); company(other.getCompany()); component(other.getComponent()); + creditBundles(other.getCreditBundles()); + creditGrants(other.getCreditGrants()); defaultPlan(other.getDefaultPlan()); featureUsage(other.getFeatureUsage()); + postTrialPlan(other.getPostTrialPlan()); + showCredits(other.getShowCredits()); + showPeriodToggle(other.getShowPeriodToggle()); + showZeroPriceAsFree(other.getShowZeroPriceAsFree()); stripeEmbed(other.getStripeEmbed()); subscription(other.getSubscription()); trialPaymentMethodRequired(other.getTrialPaymentMethodRequired()); @@ -236,168 +454,330 @@ public Builder from(ComponentHydrateResponseData other) { return this; } - @JsonSetter(value = "active_add_ons", nulls = Nulls.SKIP) - public Builder activeAddOns(List activeAddOns) { - this.activeAddOns.clear(); - this.activeAddOns.addAll(activeAddOns); + @java.lang.Override + @JsonSetter("checkout_settings") + public ShowCreditsStage checkoutSettings(@NotNull ComponentCheckoutSettings checkoutSettings) { + this.checkoutSettings = Objects.requireNonNull(checkoutSettings, "checkoutSettings must not be null"); return this; } - public Builder addActiveAddOns(CompanyPlanDetailResponseData activeAddOns) { - this.activeAddOns.add(activeAddOns); + @java.lang.Override + @JsonSetter("show_credits") + public ShowPeriodToggleStage showCredits(boolean showCredits) { + this.showCredits = showCredits; return this; } - public Builder addAllActiveAddOns(List activeAddOns) { - this.activeAddOns.addAll(activeAddOns); + @java.lang.Override + @JsonSetter("show_period_toggle") + public ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle) { + this.showPeriodToggle = showPeriodToggle; return this; } - @JsonSetter(value = "active_plans", nulls = Nulls.SKIP) - public Builder activePlans(List activePlans) { - this.activePlans.clear(); - this.activePlans.addAll(activePlans); + @java.lang.Override + @JsonSetter("show_zero_price_as_free") + public _FinalStage showZeroPriceAsFree(boolean showZeroPriceAsFree) { + this.showZeroPriceAsFree = showZeroPriceAsFree; return this; } - public Builder addActivePlans(CompanyPlanDetailResponseData activePlans) { - this.activePlans.add(activePlans); + @java.lang.Override + public _FinalStage upcomingInvoice(InvoiceResponseData upcomingInvoice) { + this.upcomingInvoice = Optional.ofNullable(upcomingInvoice); return this; } - public Builder addAllActivePlans(List activePlans) { - this.activePlans.addAll(activePlans); + @java.lang.Override + @JsonSetter(value = "upcoming_invoice", nulls = Nulls.SKIP) + public _FinalStage upcomingInvoice(Optional upcomingInvoice) { + this.upcomingInvoice = upcomingInvoice; return this; } - @JsonSetter(value = "active_usage_based_entitlements", nulls = Nulls.SKIP) - public Builder activeUsageBasedEntitlements( - List activeUsageBasedEntitlements) { - this.activeUsageBasedEntitlements.clear(); - this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + @java.lang.Override + public _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { + this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); return this; } - public Builder addActiveUsageBasedEntitlements(UsageBasedEntitlementResponseData activeUsageBasedEntitlements) { - this.activeUsageBasedEntitlements.add(activeUsageBasedEntitlements); + @java.lang.Override + @JsonSetter(value = "trial_payment_method_required", nulls = Nulls.SKIP) + public _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired) { + this.trialPaymentMethodRequired = trialPaymentMethodRequired; return this; } - public Builder addAllActiveUsageBasedEntitlements( - List activeUsageBasedEntitlements) { - this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + @java.lang.Override + public _FinalStage subscription(CompanySubscriptionResponseData subscription) { + this.subscription = Optional.ofNullable(subscription); return this; } - @JsonSetter(value = "capabilities", nulls = Nulls.SKIP) - public Builder capabilities(Optional capabilities) { - this.capabilities = capabilities; + @java.lang.Override + @JsonSetter(value = "subscription", nulls = Nulls.SKIP) + public _FinalStage subscription(Optional subscription) { + this.subscription = subscription; return this; } - public Builder capabilities(ComponentCapabilities capabilities) { - this.capabilities = Optional.ofNullable(capabilities); + @java.lang.Override + public _FinalStage stripeEmbed(StripeEmbedInfo stripeEmbed) { + this.stripeEmbed = Optional.ofNullable(stripeEmbed); return this; } - @JsonSetter(value = "company", nulls = Nulls.SKIP) - public Builder company(Optional company) { - this.company = company; + @java.lang.Override + @JsonSetter(value = "stripe_embed", nulls = Nulls.SKIP) + public _FinalStage stripeEmbed(Optional stripeEmbed) { + this.stripeEmbed = stripeEmbed; return this; } - public Builder company(CompanyDetailResponseData company) { - this.company = Optional.ofNullable(company); + @java.lang.Override + public _FinalStage postTrialPlan(PlanDetailResponseData postTrialPlan) { + this.postTrialPlan = Optional.ofNullable(postTrialPlan); return this; } - @JsonSetter(value = "component", nulls = Nulls.SKIP) - public Builder component(Optional component) { - this.component = component; + @java.lang.Override + @JsonSetter(value = "post_trial_plan", nulls = Nulls.SKIP) + public _FinalStage postTrialPlan(Optional postTrialPlan) { + this.postTrialPlan = postTrialPlan; return this; } - public Builder component(ComponentResponseData component) { - this.component = Optional.ofNullable(component); + @java.lang.Override + public _FinalStage featureUsage(FeatureUsageDetailResponseData featureUsage) { + this.featureUsage = Optional.ofNullable(featureUsage); return this; } + @java.lang.Override + @JsonSetter(value = "feature_usage", nulls = Nulls.SKIP) + public _FinalStage featureUsage(Optional featureUsage) { + this.featureUsage = featureUsage; + return this; + } + + @java.lang.Override + public _FinalStage defaultPlan(PlanDetailResponseData defaultPlan) { + this.defaultPlan = Optional.ofNullable(defaultPlan); + return this; + } + + @java.lang.Override @JsonSetter(value = "default_plan", nulls = Nulls.SKIP) - public Builder defaultPlan(Optional defaultPlan) { + public _FinalStage defaultPlan(Optional defaultPlan) { this.defaultPlan = defaultPlan; return this; } - public Builder defaultPlan(PlanDetailResponseData defaultPlan) { - this.defaultPlan = Optional.ofNullable(defaultPlan); + @java.lang.Override + public _FinalStage addAllCreditGrants(List creditGrants) { + if (creditGrants != null) { + this.creditGrants.addAll(creditGrants); + } return this; } - @JsonSetter(value = "feature_usage", nulls = Nulls.SKIP) - public Builder featureUsage(Optional featureUsage) { - this.featureUsage = featureUsage; + @java.lang.Override + public _FinalStage addCreditGrants(CreditCompanyGrantView creditGrants) { + this.creditGrants.add(creditGrants); return this; } - public Builder featureUsage(FeatureUsageDetailResponseData featureUsage) { - this.featureUsage = Optional.ofNullable(featureUsage); + @java.lang.Override + @JsonSetter(value = "credit_grants", nulls = Nulls.SKIP) + public _FinalStage creditGrants(List creditGrants) { + this.creditGrants.clear(); + if (creditGrants != null) { + this.creditGrants.addAll(creditGrants); + } return this; } - @JsonSetter(value = "stripe_embed", nulls = Nulls.SKIP) - public Builder stripeEmbed(Optional stripeEmbed) { - this.stripeEmbed = stripeEmbed; + @java.lang.Override + public _FinalStage addAllCreditBundles(List creditBundles) { + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } return this; } - public Builder stripeEmbed(StripeEmbedInfo stripeEmbed) { - this.stripeEmbed = Optional.ofNullable(stripeEmbed); + @java.lang.Override + public _FinalStage addCreditBundles(BillingCreditBundleView creditBundles) { + this.creditBundles.add(creditBundles); return this; } - @JsonSetter(value = "subscription", nulls = Nulls.SKIP) - public Builder subscription(Optional subscription) { - this.subscription = subscription; + @java.lang.Override + @JsonSetter(value = "credit_bundles", nulls = Nulls.SKIP) + public _FinalStage creditBundles(List creditBundles) { + this.creditBundles.clear(); + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } return this; } - public Builder subscription(CompanySubscriptionResponseData subscription) { - this.subscription = Optional.ofNullable(subscription); + @java.lang.Override + public _FinalStage component(ComponentResponseData component) { + this.component = Optional.ofNullable(component); return this; } - @JsonSetter(value = "trial_payment_method_required", nulls = Nulls.SKIP) - public Builder trialPaymentMethodRequired(Optional trialPaymentMethodRequired) { - this.trialPaymentMethodRequired = trialPaymentMethodRequired; + @java.lang.Override + @JsonSetter(value = "component", nulls = Nulls.SKIP) + public _FinalStage component(Optional component) { + this.component = component; return this; } - public Builder trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { - this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); + @java.lang.Override + public _FinalStage company(CompanyDetailResponseData company) { + this.company = Optional.ofNullable(company); return this; } - @JsonSetter(value = "upcoming_invoice", nulls = Nulls.SKIP) - public Builder upcomingInvoice(Optional upcomingInvoice) { - this.upcomingInvoice = upcomingInvoice; + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Optional company) { + this.company = company; return this; } - public Builder upcomingInvoice(InvoiceResponseData upcomingInvoice) { - this.upcomingInvoice = Optional.ofNullable(upcomingInvoice); + @java.lang.Override + public _FinalStage capabilities(ComponentCapabilities capabilities) { + this.capabilities = Optional.ofNullable(capabilities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "capabilities", nulls = Nulls.SKIP) + public _FinalStage capabilities(Optional capabilities) { + this.capabilities = capabilities; + return this; + } + + @java.lang.Override + public _FinalStage addAllAddOnCompatibilities(List addOnCompatibilities) { + if (addOnCompatibilities != null) { + this.addOnCompatibilities.addAll(addOnCompatibilities); + } + return this; + } + + @java.lang.Override + public _FinalStage addAddOnCompatibilities(CompatiblePlans addOnCompatibilities) { + this.addOnCompatibilities.add(addOnCompatibilities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_on_compatibilities", nulls = Nulls.SKIP) + public _FinalStage addOnCompatibilities(List addOnCompatibilities) { + this.addOnCompatibilities.clear(); + if (addOnCompatibilities != null) { + this.addOnCompatibilities.addAll(addOnCompatibilities); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllActiveUsageBasedEntitlements( + List activeUsageBasedEntitlements) { + if (activeUsageBasedEntitlements != null) { + this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + } + return this; + } + + @java.lang.Override + public _FinalStage addActiveUsageBasedEntitlements( + UsageBasedEntitlementResponseData activeUsageBasedEntitlements) { + this.activeUsageBasedEntitlements.add(activeUsageBasedEntitlements); + return this; + } + + @java.lang.Override + @JsonSetter(value = "active_usage_based_entitlements", nulls = Nulls.SKIP) + public _FinalStage activeUsageBasedEntitlements( + List activeUsageBasedEntitlements) { + this.activeUsageBasedEntitlements.clear(); + if (activeUsageBasedEntitlements != null) { + this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllActivePlans(List activePlans) { + if (activePlans != null) { + this.activePlans.addAll(activePlans); + } + return this; + } + + @java.lang.Override + public _FinalStage addActivePlans(CompanyPlanDetailResponseData activePlans) { + this.activePlans.add(activePlans); + return this; + } + + @java.lang.Override + @JsonSetter(value = "active_plans", nulls = Nulls.SKIP) + public _FinalStage activePlans(List activePlans) { + this.activePlans.clear(); + if (activePlans != null) { + this.activePlans.addAll(activePlans); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllActiveAddOns(List activeAddOns) { + if (activeAddOns != null) { + this.activeAddOns.addAll(activeAddOns); + } + return this; + } + + @java.lang.Override + public _FinalStage addActiveAddOns(CompanyPlanDetailResponseData activeAddOns) { + this.activeAddOns.add(activeAddOns); + return this; + } + + @java.lang.Override + @JsonSetter(value = "active_add_ons", nulls = Nulls.SKIP) + public _FinalStage activeAddOns(List activeAddOns) { + this.activeAddOns.clear(); + if (activeAddOns != null) { + this.activeAddOns.addAll(activeAddOns); + } return this; } + @java.lang.Override public ComponentHydrateResponseData build() { return new ComponentHydrateResponseData( activeAddOns, activePlans, activeUsageBasedEntitlements, + addOnCompatibilities, capabilities, + checkoutSettings, company, component, + creditBundles, + creditGrants, defaultPlan, featureUsage, + postTrialPlan, + showCredits, + showPeriodToggle, + showZeroPriceAsFree, stripeEmbed, subscription, trialPaymentMethodRequired, diff --git a/src/main/java/com/schematic/api/types/ComponentPreviewResponseData.java b/src/main/java/com/schematic/api/types/ComponentPreviewResponseData.java index 60847ad..c6cfeca 100644 --- a/src/main/java/com/schematic/api/types/ComponentPreviewResponseData.java +++ b/src/main/java/com/schematic/api/types/ComponentPreviewResponseData.java @@ -18,6 +18,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ComponentPreviewResponseData.Builder.class) @@ -28,18 +29,34 @@ public final class ComponentPreviewResponseData { private final List activeUsageBasedEntitlements; + private final List addOnCompatibilities; + private final Optional capabilities; + private final ComponentCheckoutSettings checkoutSettings; + private final Optional company; private final Optional component; + private final List creditBundles; + + private final List creditGrants; + private final Optional defaultPlan; private final Optional featureUsage; private final List invoices; + private final Optional postTrialPlan; + + private final boolean showCredits; + + private final boolean showPeriodToggle; + + private final boolean showZeroPriceAsFree; + private final Optional stripeEmbed; private final Optional subscription; @@ -54,12 +71,20 @@ private ComponentPreviewResponseData( List activeAddOns, List activePlans, List activeUsageBasedEntitlements, + List addOnCompatibilities, Optional capabilities, + ComponentCheckoutSettings checkoutSettings, Optional company, Optional component, + List creditBundles, + List creditGrants, Optional defaultPlan, Optional featureUsage, List invoices, + Optional postTrialPlan, + boolean showCredits, + boolean showPeriodToggle, + boolean showZeroPriceAsFree, Optional stripeEmbed, Optional subscription, Optional trialPaymentMethodRequired, @@ -68,12 +93,20 @@ private ComponentPreviewResponseData( this.activeAddOns = activeAddOns; this.activePlans = activePlans; this.activeUsageBasedEntitlements = activeUsageBasedEntitlements; + this.addOnCompatibilities = addOnCompatibilities; this.capabilities = capabilities; + this.checkoutSettings = checkoutSettings; this.company = company; this.component = component; + this.creditBundles = creditBundles; + this.creditGrants = creditGrants; this.defaultPlan = defaultPlan; this.featureUsage = featureUsage; this.invoices = invoices; + this.postTrialPlan = postTrialPlan; + this.showCredits = showCredits; + this.showPeriodToggle = showPeriodToggle; + this.showZeroPriceAsFree = showZeroPriceAsFree; this.stripeEmbed = stripeEmbed; this.subscription = subscription; this.trialPaymentMethodRequired = trialPaymentMethodRequired; @@ -96,11 +129,21 @@ public List getActiveUsageBasedEntitlements() return activeUsageBasedEntitlements; } + @JsonProperty("add_on_compatibilities") + public List getAddOnCompatibilities() { + return addOnCompatibilities; + } + @JsonProperty("capabilities") public Optional getCapabilities() { return capabilities; } + @JsonProperty("checkout_settings") + public ComponentCheckoutSettings getCheckoutSettings() { + return checkoutSettings; + } + @JsonProperty("company") public Optional getCompany() { return company; @@ -111,6 +154,16 @@ public Optional getComponent() { return component; } + @JsonProperty("credit_bundles") + public List getCreditBundles() { + return creditBundles; + } + + @JsonProperty("credit_grants") + public List getCreditGrants() { + return creditGrants; + } + @JsonProperty("default_plan") public Optional getDefaultPlan() { return defaultPlan; @@ -126,6 +179,26 @@ public List getInvoices() { return invoices; } + @JsonProperty("post_trial_plan") + public Optional getPostTrialPlan() { + return postTrialPlan; + } + + @JsonProperty("show_credits") + public boolean getShowCredits() { + return showCredits; + } + + @JsonProperty("show_period_toggle") + public boolean getShowPeriodToggle() { + return showPeriodToggle; + } + + @JsonProperty("show_zero_price_as_free") + public boolean getShowZeroPriceAsFree() { + return showZeroPriceAsFree; + } + @JsonProperty("stripe_embed") public Optional getStripeEmbed() { return stripeEmbed; @@ -161,12 +234,20 @@ private boolean equalTo(ComponentPreviewResponseData other) { return activeAddOns.equals(other.activeAddOns) && activePlans.equals(other.activePlans) && activeUsageBasedEntitlements.equals(other.activeUsageBasedEntitlements) + && addOnCompatibilities.equals(other.addOnCompatibilities) && capabilities.equals(other.capabilities) + && checkoutSettings.equals(other.checkoutSettings) && company.equals(other.company) && component.equals(other.component) + && creditBundles.equals(other.creditBundles) + && creditGrants.equals(other.creditGrants) && defaultPlan.equals(other.defaultPlan) && featureUsage.equals(other.featureUsage) && invoices.equals(other.invoices) + && postTrialPlan.equals(other.postTrialPlan) + && showCredits == other.showCredits + && showPeriodToggle == other.showPeriodToggle + && showZeroPriceAsFree == other.showZeroPriceAsFree && stripeEmbed.equals(other.stripeEmbed) && subscription.equals(other.subscription) && trialPaymentMethodRequired.equals(other.trialPaymentMethodRequired) @@ -179,12 +260,20 @@ public int hashCode() { this.activeAddOns, this.activePlans, this.activeUsageBasedEntitlements, + this.addOnCompatibilities, this.capabilities, + this.checkoutSettings, this.company, this.component, + this.creditBundles, + this.creditGrants, this.defaultPlan, this.featureUsage, this.invoices, + this.postTrialPlan, + this.showCredits, + this.showPeriodToggle, + this.showZeroPriceAsFree, this.stripeEmbed, this.subscription, this.trialPaymentMethodRequired, @@ -196,53 +285,188 @@ public String toString() { return ObjectMappers.stringify(this); } - public static Builder builder() { + public static CheckoutSettingsStage builder() { return new Builder(); } + public interface CheckoutSettingsStage { + ShowCreditsStage checkoutSettings(@NotNull ComponentCheckoutSettings checkoutSettings); + + Builder from(ComponentPreviewResponseData other); + } + + public interface ShowCreditsStage { + ShowPeriodToggleStage showCredits(boolean showCredits); + } + + public interface ShowPeriodToggleStage { + ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle); + } + + public interface ShowZeroPriceAsFreeStage { + _FinalStage showZeroPriceAsFree(boolean showZeroPriceAsFree); + } + + public interface _FinalStage { + ComponentPreviewResponseData build(); + + _FinalStage activeAddOns(List activeAddOns); + + _FinalStage addActiveAddOns(CompanyPlanDetailResponseData activeAddOns); + + _FinalStage addAllActiveAddOns(List activeAddOns); + + _FinalStage activePlans(List activePlans); + + _FinalStage addActivePlans(CompanyPlanDetailResponseData activePlans); + + _FinalStage addAllActivePlans(List activePlans); + + _FinalStage activeUsageBasedEntitlements(List activeUsageBasedEntitlements); + + _FinalStage addActiveUsageBasedEntitlements(UsageBasedEntitlementResponseData activeUsageBasedEntitlements); + + _FinalStage addAllActiveUsageBasedEntitlements( + List activeUsageBasedEntitlements); + + _FinalStage addOnCompatibilities(List addOnCompatibilities); + + _FinalStage addAddOnCompatibilities(CompatiblePlans addOnCompatibilities); + + _FinalStage addAllAddOnCompatibilities(List addOnCompatibilities); + + _FinalStage capabilities(Optional capabilities); + + _FinalStage capabilities(ComponentCapabilities capabilities); + + _FinalStage company(Optional company); + + _FinalStage company(CompanyDetailResponseData company); + + _FinalStage component(Optional component); + + _FinalStage component(ComponentResponseData component); + + _FinalStage creditBundles(List creditBundles); + + _FinalStage addCreditBundles(BillingCreditBundleView creditBundles); + + _FinalStage addAllCreditBundles(List creditBundles); + + _FinalStage creditGrants(List creditGrants); + + _FinalStage addCreditGrants(CreditCompanyGrantView creditGrants); + + _FinalStage addAllCreditGrants(List creditGrants); + + _FinalStage defaultPlan(Optional defaultPlan); + + _FinalStage defaultPlan(PlanDetailResponseData defaultPlan); + + _FinalStage featureUsage(Optional featureUsage); + + _FinalStage featureUsage(FeatureUsageDetailResponseData featureUsage); + + _FinalStage invoices(List invoices); + + _FinalStage addInvoices(InvoiceResponseData invoices); + + _FinalStage addAllInvoices(List invoices); + + _FinalStage postTrialPlan(Optional postTrialPlan); + + _FinalStage postTrialPlan(PlanDetailResponseData postTrialPlan); + + _FinalStage stripeEmbed(Optional stripeEmbed); + + _FinalStage stripeEmbed(StripeEmbedInfo stripeEmbed); + + _FinalStage subscription(Optional subscription); + + _FinalStage subscription(CompanySubscriptionResponseData subscription); + + _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired); + + _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired); + + _FinalStage upcomingInvoice(Optional upcomingInvoice); + + _FinalStage upcomingInvoice(InvoiceResponseData upcomingInvoice); + } + @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List activeAddOns = new ArrayList<>(); + public static final class Builder + implements CheckoutSettingsStage, + ShowCreditsStage, + ShowPeriodToggleStage, + ShowZeroPriceAsFreeStage, + _FinalStage { + private ComponentCheckoutSettings checkoutSettings; - private List activePlans = new ArrayList<>(); + private boolean showCredits; - private List activeUsageBasedEntitlements = new ArrayList<>(); + private boolean showPeriodToggle; - private Optional capabilities = Optional.empty(); + private boolean showZeroPriceAsFree; - private Optional company = Optional.empty(); + private Optional upcomingInvoice = Optional.empty(); - private Optional component = Optional.empty(); + private Optional trialPaymentMethodRequired = Optional.empty(); - private Optional defaultPlan = Optional.empty(); + private Optional subscription = Optional.empty(); - private Optional featureUsage = Optional.empty(); + private Optional stripeEmbed = Optional.empty(); + + private Optional postTrialPlan = Optional.empty(); private List invoices = new ArrayList<>(); - private Optional stripeEmbed = Optional.empty(); + private Optional featureUsage = Optional.empty(); - private Optional subscription = Optional.empty(); + private Optional defaultPlan = Optional.empty(); - private Optional trialPaymentMethodRequired = Optional.empty(); + private List creditGrants = new ArrayList<>(); - private Optional upcomingInvoice = Optional.empty(); + private List creditBundles = new ArrayList<>(); + + private Optional component = Optional.empty(); + + private Optional company = Optional.empty(); + + private Optional capabilities = Optional.empty(); + + private List addOnCompatibilities = new ArrayList<>(); + + private List activeUsageBasedEntitlements = new ArrayList<>(); + + private List activePlans = new ArrayList<>(); + + private List activeAddOns = new ArrayList<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} + @java.lang.Override public Builder from(ComponentPreviewResponseData other) { activeAddOns(other.getActiveAddOns()); activePlans(other.getActivePlans()); activeUsageBasedEntitlements(other.getActiveUsageBasedEntitlements()); + addOnCompatibilities(other.getAddOnCompatibilities()); capabilities(other.getCapabilities()); + checkoutSettings(other.getCheckoutSettings()); company(other.getCompany()); component(other.getComponent()); + creditBundles(other.getCreditBundles()); + creditGrants(other.getCreditGrants()); defaultPlan(other.getDefaultPlan()); featureUsage(other.getFeatureUsage()); invoices(other.getInvoices()); + postTrialPlan(other.getPostTrialPlan()); + showCredits(other.getShowCredits()); + showPeriodToggle(other.getShowPeriodToggle()); + showZeroPriceAsFree(other.getShowZeroPriceAsFree()); stripeEmbed(other.getStripeEmbed()); subscription(other.getSubscription()); trialPaymentMethodRequired(other.getTrialPaymentMethodRequired()); @@ -250,186 +474,355 @@ public Builder from(ComponentPreviewResponseData other) { return this; } - @JsonSetter(value = "active_add_ons", nulls = Nulls.SKIP) - public Builder activeAddOns(List activeAddOns) { - this.activeAddOns.clear(); - this.activeAddOns.addAll(activeAddOns); + @java.lang.Override + @JsonSetter("checkout_settings") + public ShowCreditsStage checkoutSettings(@NotNull ComponentCheckoutSettings checkoutSettings) { + this.checkoutSettings = Objects.requireNonNull(checkoutSettings, "checkoutSettings must not be null"); return this; } - public Builder addActiveAddOns(CompanyPlanDetailResponseData activeAddOns) { - this.activeAddOns.add(activeAddOns); + @java.lang.Override + @JsonSetter("show_credits") + public ShowPeriodToggleStage showCredits(boolean showCredits) { + this.showCredits = showCredits; return this; } - public Builder addAllActiveAddOns(List activeAddOns) { - this.activeAddOns.addAll(activeAddOns); + @java.lang.Override + @JsonSetter("show_period_toggle") + public ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle) { + this.showPeriodToggle = showPeriodToggle; return this; } - @JsonSetter(value = "active_plans", nulls = Nulls.SKIP) - public Builder activePlans(List activePlans) { - this.activePlans.clear(); - this.activePlans.addAll(activePlans); + @java.lang.Override + @JsonSetter("show_zero_price_as_free") + public _FinalStage showZeroPriceAsFree(boolean showZeroPriceAsFree) { + this.showZeroPriceAsFree = showZeroPriceAsFree; return this; } - public Builder addActivePlans(CompanyPlanDetailResponseData activePlans) { - this.activePlans.add(activePlans); + @java.lang.Override + public _FinalStage upcomingInvoice(InvoiceResponseData upcomingInvoice) { + this.upcomingInvoice = Optional.ofNullable(upcomingInvoice); return this; } - public Builder addAllActivePlans(List activePlans) { - this.activePlans.addAll(activePlans); + @java.lang.Override + @JsonSetter(value = "upcoming_invoice", nulls = Nulls.SKIP) + public _FinalStage upcomingInvoice(Optional upcomingInvoice) { + this.upcomingInvoice = upcomingInvoice; return this; } - @JsonSetter(value = "active_usage_based_entitlements", nulls = Nulls.SKIP) - public Builder activeUsageBasedEntitlements( - List activeUsageBasedEntitlements) { - this.activeUsageBasedEntitlements.clear(); - this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + @java.lang.Override + public _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { + this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); return this; } - public Builder addActiveUsageBasedEntitlements(UsageBasedEntitlementResponseData activeUsageBasedEntitlements) { - this.activeUsageBasedEntitlements.add(activeUsageBasedEntitlements); + @java.lang.Override + @JsonSetter(value = "trial_payment_method_required", nulls = Nulls.SKIP) + public _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired) { + this.trialPaymentMethodRequired = trialPaymentMethodRequired; return this; } - public Builder addAllActiveUsageBasedEntitlements( - List activeUsageBasedEntitlements) { - this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + @java.lang.Override + public _FinalStage subscription(CompanySubscriptionResponseData subscription) { + this.subscription = Optional.ofNullable(subscription); return this; } - @JsonSetter(value = "capabilities", nulls = Nulls.SKIP) - public Builder capabilities(Optional capabilities) { - this.capabilities = capabilities; + @java.lang.Override + @JsonSetter(value = "subscription", nulls = Nulls.SKIP) + public _FinalStage subscription(Optional subscription) { + this.subscription = subscription; return this; } - public Builder capabilities(ComponentCapabilities capabilities) { - this.capabilities = Optional.ofNullable(capabilities); + @java.lang.Override + public _FinalStage stripeEmbed(StripeEmbedInfo stripeEmbed) { + this.stripeEmbed = Optional.ofNullable(stripeEmbed); return this; } - @JsonSetter(value = "company", nulls = Nulls.SKIP) - public Builder company(Optional company) { - this.company = company; + @java.lang.Override + @JsonSetter(value = "stripe_embed", nulls = Nulls.SKIP) + public _FinalStage stripeEmbed(Optional stripeEmbed) { + this.stripeEmbed = stripeEmbed; return this; } - public Builder company(CompanyDetailResponseData company) { - this.company = Optional.ofNullable(company); + @java.lang.Override + public _FinalStage postTrialPlan(PlanDetailResponseData postTrialPlan) { + this.postTrialPlan = Optional.ofNullable(postTrialPlan); return this; } - @JsonSetter(value = "component", nulls = Nulls.SKIP) - public Builder component(Optional component) { - this.component = component; + @java.lang.Override + @JsonSetter(value = "post_trial_plan", nulls = Nulls.SKIP) + public _FinalStage postTrialPlan(Optional postTrialPlan) { + this.postTrialPlan = postTrialPlan; return this; } - public Builder component(ComponentResponseData component) { - this.component = Optional.ofNullable(component); + @java.lang.Override + public _FinalStage addAllInvoices(List invoices) { + if (invoices != null) { + this.invoices.addAll(invoices); + } return this; } - @JsonSetter(value = "default_plan", nulls = Nulls.SKIP) - public Builder defaultPlan(Optional defaultPlan) { - this.defaultPlan = defaultPlan; + @java.lang.Override + public _FinalStage addInvoices(InvoiceResponseData invoices) { + this.invoices.add(invoices); return this; } - public Builder defaultPlan(PlanDetailResponseData defaultPlan) { - this.defaultPlan = Optional.ofNullable(defaultPlan); + @java.lang.Override + @JsonSetter(value = "invoices", nulls = Nulls.SKIP) + public _FinalStage invoices(List invoices) { + this.invoices.clear(); + if (invoices != null) { + this.invoices.addAll(invoices); + } + return this; + } + + @java.lang.Override + public _FinalStage featureUsage(FeatureUsageDetailResponseData featureUsage) { + this.featureUsage = Optional.ofNullable(featureUsage); return this; } + @java.lang.Override @JsonSetter(value = "feature_usage", nulls = Nulls.SKIP) - public Builder featureUsage(Optional featureUsage) { + public _FinalStage featureUsage(Optional featureUsage) { this.featureUsage = featureUsage; return this; } - public Builder featureUsage(FeatureUsageDetailResponseData featureUsage) { - this.featureUsage = Optional.ofNullable(featureUsage); + @java.lang.Override + public _FinalStage defaultPlan(PlanDetailResponseData defaultPlan) { + this.defaultPlan = Optional.ofNullable(defaultPlan); return this; } - @JsonSetter(value = "invoices", nulls = Nulls.SKIP) - public Builder invoices(List invoices) { - this.invoices.clear(); - this.invoices.addAll(invoices); + @java.lang.Override + @JsonSetter(value = "default_plan", nulls = Nulls.SKIP) + public _FinalStage defaultPlan(Optional defaultPlan) { + this.defaultPlan = defaultPlan; return this; } - public Builder addInvoices(InvoiceResponseData invoices) { - this.invoices.add(invoices); + @java.lang.Override + public _FinalStage addAllCreditGrants(List creditGrants) { + if (creditGrants != null) { + this.creditGrants.addAll(creditGrants); + } return this; } - public Builder addAllInvoices(List invoices) { - this.invoices.addAll(invoices); + @java.lang.Override + public _FinalStage addCreditGrants(CreditCompanyGrantView creditGrants) { + this.creditGrants.add(creditGrants); return this; } - @JsonSetter(value = "stripe_embed", nulls = Nulls.SKIP) - public Builder stripeEmbed(Optional stripeEmbed) { - this.stripeEmbed = stripeEmbed; + @java.lang.Override + @JsonSetter(value = "credit_grants", nulls = Nulls.SKIP) + public _FinalStage creditGrants(List creditGrants) { + this.creditGrants.clear(); + if (creditGrants != null) { + this.creditGrants.addAll(creditGrants); + } return this; } - public Builder stripeEmbed(StripeEmbedInfo stripeEmbed) { - this.stripeEmbed = Optional.ofNullable(stripeEmbed); + @java.lang.Override + public _FinalStage addAllCreditBundles(List creditBundles) { + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } return this; } - @JsonSetter(value = "subscription", nulls = Nulls.SKIP) - public Builder subscription(Optional subscription) { - this.subscription = subscription; + @java.lang.Override + public _FinalStage addCreditBundles(BillingCreditBundleView creditBundles) { + this.creditBundles.add(creditBundles); return this; } - public Builder subscription(CompanySubscriptionResponseData subscription) { - this.subscription = Optional.ofNullable(subscription); + @java.lang.Override + @JsonSetter(value = "credit_bundles", nulls = Nulls.SKIP) + public _FinalStage creditBundles(List creditBundles) { + this.creditBundles.clear(); + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } return this; } - @JsonSetter(value = "trial_payment_method_required", nulls = Nulls.SKIP) - public Builder trialPaymentMethodRequired(Optional trialPaymentMethodRequired) { - this.trialPaymentMethodRequired = trialPaymentMethodRequired; + @java.lang.Override + public _FinalStage component(ComponentResponseData component) { + this.component = Optional.ofNullable(component); return this; } - public Builder trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { - this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); + @java.lang.Override + @JsonSetter(value = "component", nulls = Nulls.SKIP) + public _FinalStage component(Optional component) { + this.component = component; return this; } - @JsonSetter(value = "upcoming_invoice", nulls = Nulls.SKIP) - public Builder upcomingInvoice(Optional upcomingInvoice) { - this.upcomingInvoice = upcomingInvoice; + @java.lang.Override + public _FinalStage company(CompanyDetailResponseData company) { + this.company = Optional.ofNullable(company); return this; } - public Builder upcomingInvoice(InvoiceResponseData upcomingInvoice) { - this.upcomingInvoice = Optional.ofNullable(upcomingInvoice); + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Optional company) { + this.company = company; + return this; + } + + @java.lang.Override + public _FinalStage capabilities(ComponentCapabilities capabilities) { + this.capabilities = Optional.ofNullable(capabilities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "capabilities", nulls = Nulls.SKIP) + public _FinalStage capabilities(Optional capabilities) { + this.capabilities = capabilities; + return this; + } + + @java.lang.Override + public _FinalStage addAllAddOnCompatibilities(List addOnCompatibilities) { + if (addOnCompatibilities != null) { + this.addOnCompatibilities.addAll(addOnCompatibilities); + } + return this; + } + + @java.lang.Override + public _FinalStage addAddOnCompatibilities(CompatiblePlans addOnCompatibilities) { + this.addOnCompatibilities.add(addOnCompatibilities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_on_compatibilities", nulls = Nulls.SKIP) + public _FinalStage addOnCompatibilities(List addOnCompatibilities) { + this.addOnCompatibilities.clear(); + if (addOnCompatibilities != null) { + this.addOnCompatibilities.addAll(addOnCompatibilities); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllActiveUsageBasedEntitlements( + List activeUsageBasedEntitlements) { + if (activeUsageBasedEntitlements != null) { + this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + } + return this; + } + + @java.lang.Override + public _FinalStage addActiveUsageBasedEntitlements( + UsageBasedEntitlementResponseData activeUsageBasedEntitlements) { + this.activeUsageBasedEntitlements.add(activeUsageBasedEntitlements); + return this; + } + + @java.lang.Override + @JsonSetter(value = "active_usage_based_entitlements", nulls = Nulls.SKIP) + public _FinalStage activeUsageBasedEntitlements( + List activeUsageBasedEntitlements) { + this.activeUsageBasedEntitlements.clear(); + if (activeUsageBasedEntitlements != null) { + this.activeUsageBasedEntitlements.addAll(activeUsageBasedEntitlements); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllActivePlans(List activePlans) { + if (activePlans != null) { + this.activePlans.addAll(activePlans); + } + return this; + } + + @java.lang.Override + public _FinalStage addActivePlans(CompanyPlanDetailResponseData activePlans) { + this.activePlans.add(activePlans); + return this; + } + + @java.lang.Override + @JsonSetter(value = "active_plans", nulls = Nulls.SKIP) + public _FinalStage activePlans(List activePlans) { + this.activePlans.clear(); + if (activePlans != null) { + this.activePlans.addAll(activePlans); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllActiveAddOns(List activeAddOns) { + if (activeAddOns != null) { + this.activeAddOns.addAll(activeAddOns); + } + return this; + } + + @java.lang.Override + public _FinalStage addActiveAddOns(CompanyPlanDetailResponseData activeAddOns) { + this.activeAddOns.add(activeAddOns); + return this; + } + + @java.lang.Override + @JsonSetter(value = "active_add_ons", nulls = Nulls.SKIP) + public _FinalStage activeAddOns(List activeAddOns) { + this.activeAddOns.clear(); + if (activeAddOns != null) { + this.activeAddOns.addAll(activeAddOns); + } return this; } + @java.lang.Override public ComponentPreviewResponseData build() { return new ComponentPreviewResponseData( activeAddOns, activePlans, activeUsageBasedEntitlements, + addOnCompatibilities, capabilities, + checkoutSettings, company, component, + creditBundles, + creditGrants, defaultPlan, featureUsage, invoices, + postTrialPlan, + showCredits, + showPeriodToggle, + showZeroPriceAsFree, stripeEmbed, subscription, trialPaymentMethodRequired, diff --git a/src/main/java/com/schematic/api/types/Condition.java b/src/main/java/com/schematic/api/types/Condition.java new file mode 100644 index 0000000..0e2ce2d --- /dev/null +++ b/src/main/java/com/schematic/api/types/Condition.java @@ -0,0 +1,549 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Condition.Builder.class) +public final class Condition { + private final String accountId; + + private final Optional comparisonTraitDefinition; + + private final String conditionType; + + private final Optional consumptionRate; + + private final Optional creditId; + + private final String environmentId; + + private final Optional eventSubtype; + + private final String id; + + private final Optional metricPeriod; + + private final Optional metricPeriodMonthReset; + + private final Optional metricValue; + + private final String operator; + + private final List resourceIds; + + private final Optional traitDefinition; + + private final String traitValue; + + private final Map additionalProperties; + + private Condition( + String accountId, + Optional comparisonTraitDefinition, + String conditionType, + Optional consumptionRate, + Optional creditId, + String environmentId, + Optional eventSubtype, + String id, + Optional metricPeriod, + Optional metricPeriodMonthReset, + Optional metricValue, + String operator, + List resourceIds, + Optional traitDefinition, + String traitValue, + Map additionalProperties) { + this.accountId = accountId; + this.comparisonTraitDefinition = comparisonTraitDefinition; + this.conditionType = conditionType; + this.consumptionRate = consumptionRate; + this.creditId = creditId; + this.environmentId = environmentId; + this.eventSubtype = eventSubtype; + this.id = id; + this.metricPeriod = metricPeriod; + this.metricPeriodMonthReset = metricPeriodMonthReset; + this.metricValue = metricValue; + this.operator = operator; + this.resourceIds = resourceIds; + this.traitDefinition = traitDefinition; + this.traitValue = traitValue; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("account_id") + public String getAccountId() { + return accountId; + } + + @JsonProperty("comparison_trait_definition") + public Optional getComparisonTraitDefinition() { + return comparisonTraitDefinition; + } + + @JsonProperty("condition_type") + public String getConditionType() { + return conditionType; + } + + @JsonProperty("consumption_rate") + public Optional getConsumptionRate() { + return consumptionRate; + } + + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + + @JsonProperty("environment_id") + public String getEnvironmentId() { + return environmentId; + } + + @JsonProperty("event_subtype") + public Optional getEventSubtype() { + return eventSubtype; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("metric_period") + public Optional getMetricPeriod() { + return metricPeriod; + } + + @JsonProperty("metric_period_month_reset") + public Optional getMetricPeriodMonthReset() { + return metricPeriodMonthReset; + } + + @JsonProperty("metric_value") + public Optional getMetricValue() { + return metricValue; + } + + @JsonProperty("operator") + public String getOperator() { + return operator; + } + + @JsonProperty("resource_ids") + public List getResourceIds() { + return resourceIds; + } + + @JsonProperty("trait_definition") + public Optional getTraitDefinition() { + return traitDefinition; + } + + @JsonProperty("trait_value") + public String getTraitValue() { + return traitValue; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Condition && equalTo((Condition) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Condition other) { + return accountId.equals(other.accountId) + && comparisonTraitDefinition.equals(other.comparisonTraitDefinition) + && conditionType.equals(other.conditionType) + && consumptionRate.equals(other.consumptionRate) + && creditId.equals(other.creditId) + && environmentId.equals(other.environmentId) + && eventSubtype.equals(other.eventSubtype) + && id.equals(other.id) + && metricPeriod.equals(other.metricPeriod) + && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) + && metricValue.equals(other.metricValue) + && operator.equals(other.operator) + && resourceIds.equals(other.resourceIds) + && traitDefinition.equals(other.traitDefinition) + && traitValue.equals(other.traitValue); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.accountId, + this.comparisonTraitDefinition, + this.conditionType, + this.consumptionRate, + this.creditId, + this.environmentId, + this.eventSubtype, + this.id, + this.metricPeriod, + this.metricPeriodMonthReset, + this.metricValue, + this.operator, + this.resourceIds, + this.traitDefinition, + this.traitValue); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AccountIdStage builder() { + return new Builder(); + } + + public interface AccountIdStage { + ConditionTypeStage accountId(@NotNull String accountId); + + Builder from(Condition other); + } + + public interface ConditionTypeStage { + EnvironmentIdStage conditionType(@NotNull String conditionType); + } + + public interface EnvironmentIdStage { + IdStage environmentId(@NotNull String environmentId); + } + + public interface IdStage { + OperatorStage id(@NotNull String id); + } + + public interface OperatorStage { + TraitValueStage operator(@NotNull String operator); + } + + public interface TraitValueStage { + _FinalStage traitValue(@NotNull String traitValue); + } + + public interface _FinalStage { + Condition build(); + + _FinalStage comparisonTraitDefinition(Optional comparisonTraitDefinition); + + _FinalStage comparisonTraitDefinition(TraitDefinition comparisonTraitDefinition); + + _FinalStage consumptionRate(Optional consumptionRate); + + _FinalStage consumptionRate(Double consumptionRate); + + _FinalStage creditId(Optional creditId); + + _FinalStage creditId(String creditId); + + _FinalStage eventSubtype(Optional eventSubtype); + + _FinalStage eventSubtype(String eventSubtype); + + _FinalStage metricPeriod(Optional metricPeriod); + + _FinalStage metricPeriod(String metricPeriod); + + _FinalStage metricPeriodMonthReset(Optional metricPeriodMonthReset); + + _FinalStage metricPeriodMonthReset(String metricPeriodMonthReset); + + _FinalStage metricValue(Optional metricValue); + + _FinalStage metricValue(Integer metricValue); + + _FinalStage resourceIds(List resourceIds); + + _FinalStage addResourceIds(String resourceIds); + + _FinalStage addAllResourceIds(List resourceIds); + + _FinalStage traitDefinition(Optional traitDefinition); + + _FinalStage traitDefinition(TraitDefinition traitDefinition); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AccountIdStage, + ConditionTypeStage, + EnvironmentIdStage, + IdStage, + OperatorStage, + TraitValueStage, + _FinalStage { + private String accountId; + + private String conditionType; + + private String environmentId; + + private String id; + + private String operator; + + private String traitValue; + + private Optional traitDefinition = Optional.empty(); + + private List resourceIds = new ArrayList<>(); + + private Optional metricValue = Optional.empty(); + + private Optional metricPeriodMonthReset = Optional.empty(); + + private Optional metricPeriod = Optional.empty(); + + private Optional eventSubtype = Optional.empty(); + + private Optional creditId = Optional.empty(); + + private Optional consumptionRate = Optional.empty(); + + private Optional comparisonTraitDefinition = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Condition other) { + accountId(other.getAccountId()); + comparisonTraitDefinition(other.getComparisonTraitDefinition()); + conditionType(other.getConditionType()); + consumptionRate(other.getConsumptionRate()); + creditId(other.getCreditId()); + environmentId(other.getEnvironmentId()); + eventSubtype(other.getEventSubtype()); + id(other.getId()); + metricPeriod(other.getMetricPeriod()); + metricPeriodMonthReset(other.getMetricPeriodMonthReset()); + metricValue(other.getMetricValue()); + operator(other.getOperator()); + resourceIds(other.getResourceIds()); + traitDefinition(other.getTraitDefinition()); + traitValue(other.getTraitValue()); + return this; + } + + @java.lang.Override + @JsonSetter("account_id") + public ConditionTypeStage accountId(@NotNull String accountId) { + this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("condition_type") + public EnvironmentIdStage conditionType(@NotNull String conditionType) { + this.conditionType = Objects.requireNonNull(conditionType, "conditionType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("environment_id") + public IdStage environmentId(@NotNull String environmentId) { + this.environmentId = Objects.requireNonNull(environmentId, "environmentId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public OperatorStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("operator") + public TraitValueStage operator(@NotNull String operator) { + this.operator = Objects.requireNonNull(operator, "operator must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_value") + public _FinalStage traitValue(@NotNull String traitValue) { + this.traitValue = Objects.requireNonNull(traitValue, "traitValue must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage traitDefinition(TraitDefinition traitDefinition) { + this.traitDefinition = Optional.ofNullable(traitDefinition); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trait_definition", nulls = Nulls.SKIP) + public _FinalStage traitDefinition(Optional traitDefinition) { + this.traitDefinition = traitDefinition; + return this; + } + + @java.lang.Override + public _FinalStage addAllResourceIds(List resourceIds) { + if (resourceIds != null) { + this.resourceIds.addAll(resourceIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addResourceIds(String resourceIds) { + this.resourceIds.add(resourceIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "resource_ids", nulls = Nulls.SKIP) + public _FinalStage resourceIds(List resourceIds) { + this.resourceIds.clear(); + if (resourceIds != null) { + this.resourceIds.addAll(resourceIds); + } + return this; + } + + @java.lang.Override + public _FinalStage metricValue(Integer metricValue) { + this.metricValue = Optional.ofNullable(metricValue); + return this; + } + + @java.lang.Override + @JsonSetter(value = "metric_value", nulls = Nulls.SKIP) + public _FinalStage metricValue(Optional metricValue) { + this.metricValue = metricValue; + return this; + } + + @java.lang.Override + public _FinalStage metricPeriodMonthReset(String metricPeriodMonthReset) { + this.metricPeriodMonthReset = Optional.ofNullable(metricPeriodMonthReset); + return this; + } + + @java.lang.Override + @JsonSetter(value = "metric_period_month_reset", nulls = Nulls.SKIP) + public _FinalStage metricPeriodMonthReset(Optional metricPeriodMonthReset) { + this.metricPeriodMonthReset = metricPeriodMonthReset; + return this; + } + + @java.lang.Override + public _FinalStage metricPeriod(String metricPeriod) { + this.metricPeriod = Optional.ofNullable(metricPeriod); + return this; + } + + @java.lang.Override + @JsonSetter(value = "metric_period", nulls = Nulls.SKIP) + public _FinalStage metricPeriod(Optional metricPeriod) { + this.metricPeriod = metricPeriod; + return this; + } + + @java.lang.Override + public _FinalStage eventSubtype(String eventSubtype) { + this.eventSubtype = Optional.ofNullable(eventSubtype); + return this; + } + + @java.lang.Override + @JsonSetter(value = "event_subtype", nulls = Nulls.SKIP) + public _FinalStage eventSubtype(Optional eventSubtype) { + this.eventSubtype = eventSubtype; + return this; + } + + @java.lang.Override + public _FinalStage creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public _FinalStage creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + @java.lang.Override + public _FinalStage consumptionRate(Double consumptionRate) { + this.consumptionRate = Optional.ofNullable(consumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "consumption_rate", nulls = Nulls.SKIP) + public _FinalStage consumptionRate(Optional consumptionRate) { + this.consumptionRate = consumptionRate; + return this; + } + + @java.lang.Override + public _FinalStage comparisonTraitDefinition(TraitDefinition comparisonTraitDefinition) { + this.comparisonTraitDefinition = Optional.ofNullable(comparisonTraitDefinition); + return this; + } + + @java.lang.Override + @JsonSetter(value = "comparison_trait_definition", nulls = Nulls.SKIP) + public _FinalStage comparisonTraitDefinition(Optional comparisonTraitDefinition) { + this.comparisonTraitDefinition = comparisonTraitDefinition; + return this; + } + + @java.lang.Override + public Condition build() { + return new Condition( + accountId, + comparisonTraitDefinition, + conditionType, + consumptionRate, + creditId, + environmentId, + eventSubtype, + id, + metricPeriod, + metricPeriodMonthReset, + metricValue, + operator, + resourceIds, + traitDefinition, + traitValue, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/ConditionGroup.java b/src/main/java/com/schematic/api/types/ConditionGroup.java new file mode 100644 index 0000000..97293f2 --- /dev/null +++ b/src/main/java/com/schematic/api/types/ConditionGroup.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ConditionGroup.Builder.class) +public final class ConditionGroup { + private final List conditions; + + private final Map additionalProperties; + + private ConditionGroup(List conditions, Map additionalProperties) { + this.conditions = conditions; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("conditions") + public List getConditions() { + return conditions; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConditionGroup && equalTo((ConditionGroup) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ConditionGroup other) { + return conditions.equals(other.conditions); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conditions); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private List conditions = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ConditionGroup other) { + conditions(other.getConditions()); + return this; + } + + @JsonSetter(value = "conditions", nulls = Nulls.SKIP) + public Builder conditions(List conditions) { + this.conditions.clear(); + if (conditions != null) { + this.conditions.addAll(conditions); + } + return this; + } + + public Builder addConditions(Condition conditions) { + this.conditions.add(conditions); + return this; + } + + public Builder addAllConditions(List conditions) { + if (conditions != null) { + this.conditions.addAll(conditions); + } + return this; + } + + public ConditionGroup build() { + return new ConditionGroup(conditions, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CountResponse.java b/src/main/java/com/schematic/api/types/CountResponse.java index 9f337cd..38df719 100644 --- a/src/main/java/com/schematic/api/types/CountResponse.java +++ b/src/main/java/com/schematic/api/types/CountResponse.java @@ -9,26 +9,31 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CountResponse.Builder.class) public final class CountResponse { - private final int count; + private final Optional count; private final Map additionalProperties; - private CountResponse(int count, Map additionalProperties) { + private CountResponse(Optional count, Map additionalProperties) { this.count = count; this.additionalProperties = additionalProperties; } + /** + * @return The number of resources + */ @JsonProperty("count") - public int getCount() { + public Optional getCount() { return count; } @@ -44,7 +49,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(CountResponse other) { - return count == other.count; + return count.equals(other.count); } @java.lang.Override @@ -57,43 +62,38 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CountStage builder() { + public static Builder builder() { return new Builder(); } - public interface CountStage { - _FinalStage count(int count); - - Builder from(CountResponse other); - } - - public interface _FinalStage { - CountResponse build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements CountStage, _FinalStage { - private int count; + public static final class Builder { + private Optional count = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(CountResponse other) { count(other.getCount()); return this; } - @java.lang.Override - @JsonSetter("count") - public _FinalStage count(int count) { + /** + *

The number of resources

+ */ + @JsonSetter(value = "count", nulls = Nulls.SKIP) + public Builder count(Optional count) { this.count = count; return this; } - @java.lang.Override + public Builder count(Integer count) { + this.count = Optional.ofNullable(count); + return this; + } + public CountResponse build() { return new CountResponse(count, additionalProperties); } diff --git a/src/main/java/com/schematic/api/types/CreateBillingPriceTierRequestBody.java b/src/main/java/com/schematic/api/types/CreateBillingPriceTierRequestBody.java index bd64d0d..acc495b 100644 --- a/src/main/java/com/schematic/api/types/CreateBillingPriceTierRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateBillingPriceTierRequestBody.java @@ -23,6 +23,8 @@ public final class CreateBillingPriceTierRequestBody { private final Optional flatAmount; + private final Optional perUnitDecimal; + private final Optional perUnitPrice; private final String priceExternalId; @@ -33,11 +35,13 @@ public final class CreateBillingPriceTierRequestBody { private CreateBillingPriceTierRequestBody( Optional flatAmount, + Optional perUnitDecimal, Optional perUnitPrice, String priceExternalId, Optional upTo, Map additionalProperties) { this.flatAmount = flatAmount; + this.perUnitDecimal = perUnitDecimal; this.perUnitPrice = perUnitPrice; this.priceExternalId = priceExternalId; this.upTo = upTo; @@ -49,6 +53,11 @@ public Optional getFlatAmount() { return flatAmount; } + @JsonProperty("per_unit_decimal") + public Optional getPerUnitDecimal() { + return perUnitDecimal; + } + @JsonProperty("per_unit_price") public Optional getPerUnitPrice() { return perUnitPrice; @@ -77,6 +86,7 @@ public Map getAdditionalProperties() { private boolean equalTo(CreateBillingPriceTierRequestBody other) { return flatAmount.equals(other.flatAmount) + && perUnitDecimal.equals(other.perUnitDecimal) && perUnitPrice.equals(other.perUnitPrice) && priceExternalId.equals(other.priceExternalId) && upTo.equals(other.upTo); @@ -84,7 +94,7 @@ private boolean equalTo(CreateBillingPriceTierRequestBody other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.flatAmount, this.perUnitPrice, this.priceExternalId, this.upTo); + return Objects.hash(this.flatAmount, this.perUnitDecimal, this.perUnitPrice, this.priceExternalId, this.upTo); } @java.lang.Override @@ -109,6 +119,10 @@ public interface _FinalStage { _FinalStage flatAmount(Integer flatAmount); + _FinalStage perUnitDecimal(Optional perUnitDecimal); + + _FinalStage perUnitDecimal(String perUnitDecimal); + _FinalStage perUnitPrice(Optional perUnitPrice); _FinalStage perUnitPrice(Integer perUnitPrice); @@ -126,6 +140,8 @@ public static final class Builder implements PriceExternalIdStage, _FinalStage { private Optional perUnitPrice = Optional.empty(); + private Optional perUnitDecimal = Optional.empty(); + private Optional flatAmount = Optional.empty(); @JsonAnySetter @@ -136,6 +152,7 @@ private Builder() {} @java.lang.Override public Builder from(CreateBillingPriceTierRequestBody other) { flatAmount(other.getFlatAmount()); + perUnitDecimal(other.getPerUnitDecimal()); perUnitPrice(other.getPerUnitPrice()); priceExternalId(other.getPriceExternalId()); upTo(other.getUpTo()); @@ -175,6 +192,19 @@ public _FinalStage perUnitPrice(Optional perUnitPrice) { return this; } + @java.lang.Override + public _FinalStage perUnitDecimal(String perUnitDecimal) { + this.perUnitDecimal = Optional.ofNullable(perUnitDecimal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "per_unit_decimal", nulls = Nulls.SKIP) + public _FinalStage perUnitDecimal(Optional perUnitDecimal) { + this.perUnitDecimal = perUnitDecimal; + return this; + } + @java.lang.Override public _FinalStage flatAmount(Integer flatAmount) { this.flatAmount = Optional.ofNullable(flatAmount); @@ -191,7 +221,7 @@ public _FinalStage flatAmount(Optional flatAmount) { @java.lang.Override public CreateBillingPriceTierRequestBody build() { return new CreateBillingPriceTierRequestBody( - flatAmount, perUnitPrice, priceExternalId, upTo, additionalProperties); + flatAmount, perUnitDecimal, perUnitPrice, priceExternalId, upTo, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/CreateEntitlementReqCommon.java b/src/main/java/com/schematic/api/types/CreateEntitlementReqCommon.java index 8343cd8..39dd52a 100644 --- a/src/main/java/com/schematic/api/types/CreateEntitlementReqCommon.java +++ b/src/main/java/com/schematic/api/types/CreateEntitlementReqCommon.java @@ -21,6 +21,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreateEntitlementReqCommon.Builder.class) public final class CreateEntitlementReqCommon { + private final Optional creditConsumptionRate; + private final String featureId; private final Optional metricPeriod; @@ -29,6 +31,8 @@ public final class CreateEntitlementReqCommon { private final Optional valueBool; + private final Optional valueCreditId; + private final Optional valueNumeric; private final Optional valueTraitId; @@ -38,24 +42,33 @@ public final class CreateEntitlementReqCommon { private final Map additionalProperties; private CreateEntitlementReqCommon( + Optional creditConsumptionRate, String featureId, Optional metricPeriod, Optional metricPeriodMonthReset, Optional valueBool, + Optional valueCreditId, Optional valueNumeric, Optional valueTraitId, CreateEntitlementReqCommonValueType valueType, Map additionalProperties) { + this.creditConsumptionRate = creditConsumptionRate; this.featureId = featureId; this.metricPeriod = metricPeriod; this.metricPeriodMonthReset = metricPeriodMonthReset; this.valueBool = valueBool; + this.valueCreditId = valueCreditId; this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; this.additionalProperties = additionalProperties; } + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + @JsonProperty("feature_id") public String getFeatureId() { return featureId; @@ -76,6 +89,11 @@ public Optional getValueBool() { return valueBool; } + @JsonProperty("value_credit_id") + public Optional getValueCreditId() { + return valueCreditId; + } + @JsonProperty("value_numeric") public Optional getValueNumeric() { return valueNumeric; @@ -103,10 +121,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateEntitlementReqCommon other) { - return featureId.equals(other.featureId) + return creditConsumptionRate.equals(other.creditConsumptionRate) + && featureId.equals(other.featureId) && metricPeriod.equals(other.metricPeriod) && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) && valueBool.equals(other.valueBool) + && valueCreditId.equals(other.valueCreditId) && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType); @@ -115,10 +135,12 @@ private boolean equalTo(CreateEntitlementReqCommon other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.creditConsumptionRate, this.featureId, this.metricPeriod, this.metricPeriodMonthReset, this.valueBool, + this.valueCreditId, this.valueNumeric, this.valueTraitId, this.valueType); @@ -146,6 +168,10 @@ public interface ValueTypeStage { public interface _FinalStage { CreateEntitlementReqCommon build(); + _FinalStage creditConsumptionRate(Optional creditConsumptionRate); + + _FinalStage creditConsumptionRate(Double creditConsumptionRate); + _FinalStage metricPeriod(Optional metricPeriod); _FinalStage metricPeriod(CreateEntitlementReqCommonMetricPeriod metricPeriod); @@ -159,6 +185,10 @@ _FinalStage metricPeriodMonthReset( _FinalStage valueBool(Boolean valueBool); + _FinalStage valueCreditId(Optional valueCreditId); + + _FinalStage valueCreditId(String valueCreditId); + _FinalStage valueNumeric(Optional valueNumeric); _FinalStage valueNumeric(Integer valueNumeric); @@ -178,12 +208,16 @@ public static final class Builder implements FeatureIdStage, ValueTypeStage, _Fi private Optional valueNumeric = Optional.empty(); + private Optional valueCreditId = Optional.empty(); + private Optional valueBool = Optional.empty(); private Optional metricPeriodMonthReset = Optional.empty(); private Optional metricPeriod = Optional.empty(); + private Optional creditConsumptionRate = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -191,10 +225,12 @@ private Builder() {} @java.lang.Override public Builder from(CreateEntitlementReqCommon other) { + creditConsumptionRate(other.getCreditConsumptionRate()); featureId(other.getFeatureId()); metricPeriod(other.getMetricPeriod()); metricPeriodMonthReset(other.getMetricPeriodMonthReset()); valueBool(other.getValueBool()); + valueCreditId(other.getValueCreditId()); valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); @@ -241,6 +277,19 @@ public _FinalStage valueNumeric(Optional valueNumeric) { return this; } + @java.lang.Override + public _FinalStage valueCreditId(String valueCreditId) { + this.valueCreditId = Optional.ofNullable(valueCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit_id", nulls = Nulls.SKIP) + public _FinalStage valueCreditId(Optional valueCreditId) { + this.valueCreditId = valueCreditId; + return this; + } + @java.lang.Override public _FinalStage valueBool(Boolean valueBool) { this.valueBool = Optional.ofNullable(valueBool); @@ -282,13 +331,28 @@ public _FinalStage metricPeriod(Optional return this; } + @java.lang.Override + public _FinalStage creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public _FinalStage creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + @java.lang.Override public CreateEntitlementReqCommon build() { return new CreateEntitlementReqCommon( + creditConsumptionRate, featureId, metricPeriod, metricPeriodMonthReset, valueBool, + valueCreditId, valueNumeric, valueTraitId, valueType, diff --git a/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonMetricPeriod.java b/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonMetricPeriod.java index 130c46f..532d341 100644 --- a/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonMetricPeriod.java +++ b/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonMetricPeriod.java @@ -3,26 +3,106 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateEntitlementReqCommonMetricPeriod { - ALL_TIME("all_time"), +public final class CreateEntitlementReqCommonMetricPeriod { + public static final CreateEntitlementReqCommonMetricPeriod CURRENT_DAY = + new CreateEntitlementReqCommonMetricPeriod(Value.CURRENT_DAY, "current_day"); - CURRENT_MONTH("current_month"), + public static final CreateEntitlementReqCommonMetricPeriod ALL_TIME = + new CreateEntitlementReqCommonMetricPeriod(Value.ALL_TIME, "all_time"); - CURRENT_WEEK("current_week"), + public static final CreateEntitlementReqCommonMetricPeriod CURRENT_WEEK = + new CreateEntitlementReqCommonMetricPeriod(Value.CURRENT_WEEK, "current_week"); - CURRENT_DAY("current_day"); + public static final CreateEntitlementReqCommonMetricPeriod CURRENT_MONTH = + new CreateEntitlementReqCommonMetricPeriod(Value.CURRENT_MONTH, "current_month"); - private final String value; + private final Value value; - CreateEntitlementReqCommonMetricPeriod(String value) { + private final String string; + + CreateEntitlementReqCommonMetricPeriod(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateEntitlementReqCommonMetricPeriod + && this.string.equals(((CreateEntitlementReqCommonMetricPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CURRENT_DAY: + return visitor.visitCurrentDay(); + case ALL_TIME: + return visitor.visitAllTime(); + case CURRENT_WEEK: + return visitor.visitCurrentWeek(); + case CURRENT_MONTH: + return visitor.visitCurrentMonth(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateEntitlementReqCommonMetricPeriod valueOf(String value) { + switch (value) { + case "current_day": + return CURRENT_DAY; + case "all_time": + return ALL_TIME; + case "current_week": + return CURRENT_WEEK; + case "current_month": + return CURRENT_MONTH; + default: + return new CreateEntitlementReqCommonMetricPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + ALL_TIME, + + CURRENT_MONTH, + + CURRENT_WEEK, + + CURRENT_DAY, + + UNKNOWN + } + + public interface Visitor { + T visitAllTime(); + + T visitCurrentMonth(); + + T visitCurrentWeek(); + + T visitCurrentDay(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonMetricPeriodMonthReset.java b/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonMetricPeriodMonthReset.java index a933855..82ca7ae 100644 --- a/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonMetricPeriodMonthReset.java +++ b/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonMetricPeriodMonthReset.java @@ -3,22 +3,84 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateEntitlementReqCommonMetricPeriodMonthReset { - FIRST_OF_MONTH("first_of_month"), +public final class CreateEntitlementReqCommonMetricPeriodMonthReset { + public static final CreateEntitlementReqCommonMetricPeriodMonthReset FIRST_OF_MONTH = + new CreateEntitlementReqCommonMetricPeriodMonthReset(Value.FIRST_OF_MONTH, "first_of_month"); - BILLING_CYCLE("billing_cycle"); + public static final CreateEntitlementReqCommonMetricPeriodMonthReset BILLING_CYCLE = + new CreateEntitlementReqCommonMetricPeriodMonthReset(Value.BILLING_CYCLE, "billing_cycle"); - private final String value; + private final Value value; - CreateEntitlementReqCommonMetricPeriodMonthReset(String value) { + private final String string; + + CreateEntitlementReqCommonMetricPeriodMonthReset(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateEntitlementReqCommonMetricPeriodMonthReset + && this.string.equals(((CreateEntitlementReqCommonMetricPeriodMonthReset) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FIRST_OF_MONTH: + return visitor.visitFirstOfMonth(); + case BILLING_CYCLE: + return visitor.visitBillingCycle(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateEntitlementReqCommonMetricPeriodMonthReset valueOf(String value) { + switch (value) { + case "first_of_month": + return FIRST_OF_MONTH; + case "billing_cycle": + return BILLING_CYCLE; + default: + return new CreateEntitlementReqCommonMetricPeriodMonthReset(Value.UNKNOWN, value); + } + } + + public enum Value { + FIRST_OF_MONTH, + + BILLING_CYCLE, + + UNKNOWN + } + + public interface Visitor { + T visitFirstOfMonth(); + + T visitBillingCycle(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonValueType.java b/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonValueType.java index 68772d6..9032e84 100644 --- a/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonValueType.java +++ b/src/main/java/com/schematic/api/types/CreateEntitlementReqCommonValueType.java @@ -3,26 +3,117 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateEntitlementReqCommonValueType { - BOOLEAN("boolean"), +public final class CreateEntitlementReqCommonValueType { + public static final CreateEntitlementReqCommonValueType NUMERIC = + new CreateEntitlementReqCommonValueType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final CreateEntitlementReqCommonValueType TRAIT = + new CreateEntitlementReqCommonValueType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final CreateEntitlementReqCommonValueType BOOLEAN = + new CreateEntitlementReqCommonValueType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final CreateEntitlementReqCommonValueType CREDIT = + new CreateEntitlementReqCommonValueType(Value.CREDIT, "credit"); - private final String value; + public static final CreateEntitlementReqCommonValueType UNLIMITED = + new CreateEntitlementReqCommonValueType(Value.UNLIMITED, "unlimited"); - CreateEntitlementReqCommonValueType(String value) { + private final Value value; + + private final String string; + + CreateEntitlementReqCommonValueType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateEntitlementReqCommonValueType + && this.string.equals(((CreateEntitlementReqCommonValueType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case CREDIT: + return visitor.visitCredit(); + case UNLIMITED: + return visitor.visitUnlimited(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateEntitlementReqCommonValueType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "credit": + return CREDIT; + case "unlimited": + return UNLIMITED; + default: + return new CreateEntitlementReqCommonValueType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CREDIT, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCredit(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreateEventRequestBody.java b/src/main/java/com/schematic/api/types/CreateEventRequestBody.java index d73bfd3..513a006 100644 --- a/src/main/java/com/schematic/api/types/CreateEventRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateEventRequestBody.java @@ -92,6 +92,9 @@ public static EventTypeStage builder() { } public interface EventTypeStage { + /** + *

Either 'identify' or 'track'

+ */ _FinalStage eventType(@NotNull CreateEventRequestBodyEventType eventType); Builder from(CreateEventRequestBody other); @@ -104,6 +107,9 @@ public interface _FinalStage { _FinalStage body(EventBody body); + /** + *

Optionally provide a timestamp at which the event was sent to Schematic

+ */ _FinalStage sentAt(Optional sentAt); _FinalStage sentAt(OffsetDateTime sentAt); @@ -131,6 +137,7 @@ public Builder from(CreateEventRequestBody other) { } /** + *

Either 'identify' or 'track'

*

Either 'identify' or 'track'

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -151,6 +158,9 @@ public _FinalStage sentAt(OffsetDateTime sentAt) { return this; } + /** + *

Optionally provide a timestamp at which the event was sent to Schematic

+ */ @java.lang.Override @JsonSetter(value = "sent_at", nulls = Nulls.SKIP) public _FinalStage sentAt(Optional sentAt) { diff --git a/src/main/java/com/schematic/api/types/CreateEventRequestBodyEventType.java b/src/main/java/com/schematic/api/types/CreateEventRequestBodyEventType.java index c79a7c6..8ce4cb7 100644 --- a/src/main/java/com/schematic/api/types/CreateEventRequestBodyEventType.java +++ b/src/main/java/com/schematic/api/types/CreateEventRequestBodyEventType.java @@ -3,24 +3,95 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateEventRequestBodyEventType { - IDENTIFY("identify"), +public final class CreateEventRequestBodyEventType { + public static final CreateEventRequestBodyEventType FLAG_CHECK = + new CreateEventRequestBodyEventType(Value.FLAG_CHECK, "flag_check"); - TRACK("track"), + public static final CreateEventRequestBodyEventType TRACK = + new CreateEventRequestBodyEventType(Value.TRACK, "track"); - FLAG_CHECK("flag_check"); + public static final CreateEventRequestBodyEventType IDENTIFY = + new CreateEventRequestBodyEventType(Value.IDENTIFY, "identify"); - private final String value; + private final Value value; - CreateEventRequestBodyEventType(String value) { + private final String string; + + CreateEventRequestBodyEventType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateEventRequestBodyEventType + && this.string.equals(((CreateEventRequestBodyEventType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FLAG_CHECK: + return visitor.visitFlagCheck(); + case TRACK: + return visitor.visitTrack(); + case IDENTIFY: + return visitor.visitIdentify(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateEventRequestBodyEventType valueOf(String value) { + switch (value) { + case "flag_check": + return FLAG_CHECK; + case "track": + return TRACK; + case "identify": + return IDENTIFY; + default: + return new CreateEventRequestBodyEventType(Value.UNKNOWN, value); + } + } + + public enum Value { + IDENTIFY, + + TRACK, + + FLAG_CHECK, + + UNKNOWN + } + + public interface Visitor { + T visitIdentify(); + + T visitTrack(); + + T visitFlagCheck(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreateFlagRequestBody.java b/src/main/java/com/schematic/api/types/CreateFlagRequestBody.java index 2c3ab1e..eea9a3d 100644 --- a/src/main/java/com/schematic/api/types/CreateFlagRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateFlagRequestBody.java @@ -27,8 +27,6 @@ public final class CreateFlagRequestBody { private final Optional featureId; - private final String flagType; - private final String key; private final Optional maintainerId; @@ -41,7 +39,6 @@ private CreateFlagRequestBody( boolean defaultValue, String description, Optional featureId, - String flagType, String key, Optional maintainerId, String name, @@ -49,7 +46,6 @@ private CreateFlagRequestBody( this.defaultValue = defaultValue; this.description = description; this.featureId = featureId; - this.flagType = flagType; this.key = key; this.maintainerId = maintainerId; this.name = name; @@ -73,7 +69,7 @@ public Optional getFeatureId() { @JsonProperty("flag_type") public String getFlagType() { - return flagType; + return "boolean"; } @JsonProperty("key") @@ -106,7 +102,6 @@ private boolean equalTo(CreateFlagRequestBody other) { return defaultValue == other.defaultValue && description.equals(other.description) && featureId.equals(other.featureId) - && flagType.equals(other.flagType) && key.equals(other.key) && maintainerId.equals(other.maintainerId) && name.equals(other.name); @@ -115,13 +110,7 @@ private boolean equalTo(CreateFlagRequestBody other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.defaultValue, - this.description, - this.featureId, - this.flagType, - this.key, - this.maintainerId, - this.name); + this.defaultValue, this.description, this.featureId, this.key, this.maintainerId, this.name); } @java.lang.Override @@ -140,11 +129,7 @@ public interface DefaultValueStage { } public interface DescriptionStage { - FlagTypeStage description(@NotNull String description); - } - - public interface FlagTypeStage { - KeyStage flagType(@NotNull String flagType); + KeyStage description(@NotNull String description); } public interface KeyStage { @@ -168,14 +153,11 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements DefaultValueStage, DescriptionStage, FlagTypeStage, KeyStage, NameStage, _FinalStage { + public static final class Builder implements DefaultValueStage, DescriptionStage, KeyStage, NameStage, _FinalStage { private boolean defaultValue; private String description; - private String flagType; - private String key; private String name; @@ -194,7 +176,6 @@ public Builder from(CreateFlagRequestBody other) { defaultValue(other.getDefaultValue()); description(other.getDescription()); featureId(other.getFeatureId()); - flagType(other.getFlagType()); key(other.getKey()); maintainerId(other.getMaintainerId()); name(other.getName()); @@ -210,18 +191,11 @@ public DescriptionStage defaultValue(boolean defaultValue) { @java.lang.Override @JsonSetter("description") - public FlagTypeStage description(@NotNull String description) { + public KeyStage description(@NotNull String description) { this.description = Objects.requireNonNull(description, "description must not be null"); return this; } - @java.lang.Override - @JsonSetter("flag_type") - public KeyStage flagType(@NotNull String flagType) { - this.flagType = Objects.requireNonNull(flagType, "flagType must not be null"); - return this; - } - @java.lang.Override @JsonSetter("key") public NameStage key(@NotNull String key) { @@ -265,7 +239,7 @@ public _FinalStage featureId(Optional featureId) { @java.lang.Override public CreateFlagRequestBody build() { return new CreateFlagRequestBody( - defaultValue, description, featureId, flagType, key, maintainerId, name, additionalProperties); + defaultValue, description, featureId, key, maintainerId, name, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionGroupRequestBody.java b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionGroupRequestBody.java index 3aff6f7..7eddfbf 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionGroupRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionGroupRequestBody.java @@ -28,20 +28,16 @@ public final class CreateOrUpdateConditionGroupRequestBody { private final Optional id; - private final Optional planId; - private final Map additionalProperties; private CreateOrUpdateConditionGroupRequestBody( List conditions, Optional flagId, Optional id, - Optional planId, Map additionalProperties) { this.conditions = conditions; this.flagId = flagId; this.id = id; - this.planId = planId; this.additionalProperties = additionalProperties; } @@ -60,11 +56,6 @@ public Optional getId() { return id; } - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,15 +69,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreateOrUpdateConditionGroupRequestBody other) { - return conditions.equals(other.conditions) - && flagId.equals(other.flagId) - && id.equals(other.id) - && planId.equals(other.planId); + return conditions.equals(other.conditions) && flagId.equals(other.flagId) && id.equals(other.id); } @java.lang.Override public int hashCode() { - return Objects.hash(this.conditions, this.flagId, this.id, this.planId); + return Objects.hash(this.conditions, this.flagId, this.id); } @java.lang.Override @@ -106,8 +94,6 @@ public static final class Builder { private Optional id = Optional.empty(); - private Optional planId = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -117,14 +103,15 @@ public Builder from(CreateOrUpdateConditionGroupRequestBody other) { conditions(other.getConditions()); flagId(other.getFlagId()); id(other.getId()); - planId(other.getPlanId()); return this; } @JsonSetter(value = "conditions", nulls = Nulls.SKIP) public Builder conditions(List conditions) { this.conditions.clear(); - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @@ -134,7 +121,9 @@ public Builder addConditions(CreateOrUpdateConditionRequestBody conditions) { } public Builder addAllConditions(List conditions) { - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @@ -160,19 +149,8 @@ public Builder id(String id) { return this; } - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public Builder planId(Optional planId) { - this.planId = planId; - return this; - } - - public Builder planId(String planId) { - this.planId = Optional.ofNullable(planId); - return this; - } - public CreateOrUpdateConditionGroupRequestBody build() { - return new CreateOrUpdateConditionGroupRequestBody(conditions, flagId, id, planId, additionalProperties); + return new CreateOrUpdateConditionGroupRequestBody(conditions, flagId, id, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBody.java b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBody.java index af40b22..b6a270b 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBody.java @@ -27,6 +27,10 @@ public final class CreateOrUpdateConditionRequestBody { private final CreateOrUpdateConditionRequestBodyConditionType conditionType; + private final Optional creditCost; + + private final Optional creditId; + private final Optional eventSubtype; private final Optional id; @@ -50,6 +54,8 @@ public final class CreateOrUpdateConditionRequestBody { private CreateOrUpdateConditionRequestBody( Optional comparisonTraitId, CreateOrUpdateConditionRequestBodyConditionType conditionType, + Optional creditCost, + Optional creditId, Optional eventSubtype, Optional id, Optional metricPeriod, @@ -62,6 +68,8 @@ private CreateOrUpdateConditionRequestBody( Map additionalProperties) { this.comparisonTraitId = comparisonTraitId; this.conditionType = conditionType; + this.creditCost = creditCost; + this.creditId = creditId; this.eventSubtype = eventSubtype; this.id = id; this.metricPeriod = metricPeriod; @@ -87,6 +95,22 @@ public CreateOrUpdateConditionRequestBodyConditionType getConditionType() { return conditionType; } + /** + * @return Cost of credit to use to measure this condition + */ + @JsonProperty("credit_cost") + public Optional getCreditCost() { + return creditCost; + } + + /** + * @return ID of credit to use to measure this condition + */ + @JsonProperty("credit_id") + public Optional getCreditId() { + return creditId; + } + /** * @return Name of track event type used to measure this condition */ @@ -168,6 +192,8 @@ public Map getAdditionalProperties() { private boolean equalTo(CreateOrUpdateConditionRequestBody other) { return comparisonTraitId.equals(other.comparisonTraitId) && conditionType.equals(other.conditionType) + && creditCost.equals(other.creditCost) + && creditId.equals(other.creditId) && eventSubtype.equals(other.eventSubtype) && id.equals(other.id) && metricPeriod.equals(other.metricPeriod) @@ -184,6 +210,8 @@ public int hashCode() { return Objects.hash( this.comparisonTraitId, this.conditionType, + this.creditCost, + this.creditId, this.eventSubtype, this.id, this.metricPeriod, @@ -217,10 +245,30 @@ public interface OperatorStage { public interface _FinalStage { CreateOrUpdateConditionRequestBody build(); + /** + *

Optionally provide a trait ID to compare a metric or trait value against instead of a value

+ */ _FinalStage comparisonTraitId(Optional comparisonTraitId); _FinalStage comparisonTraitId(String comparisonTraitId); + /** + *

Cost of credit to use to measure this condition

+ */ + _FinalStage creditCost(Optional creditCost); + + _FinalStage creditCost(Double creditCost); + + /** + *

ID of credit to use to measure this condition

+ */ + _FinalStage creditId(Optional creditId); + + _FinalStage creditId(String creditId); + + /** + *

Name of track event type used to measure this condition

+ */ _FinalStage eventSubtype(Optional eventSubtype); _FinalStage eventSubtype(String eventSubtype); @@ -229,30 +277,48 @@ public interface _FinalStage { _FinalStage id(String id); + /** + *

Period of time over which to measure the track event metric

+ */ _FinalStage metricPeriod(Optional metricPeriod); _FinalStage metricPeriod(CreateOrUpdateConditionRequestBodyMetricPeriod metricPeriod); + /** + *

When metric_period=current_month, specify whether the month restarts based on the calendar month or the billing period

+ */ _FinalStage metricPeriodMonthReset( Optional metricPeriodMonthReset); _FinalStage metricPeriodMonthReset( CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset metricPeriodMonthReset); + /** + *

Value to compare the track event metric against

+ */ _FinalStage metricValue(Optional metricValue); _FinalStage metricValue(Integer metricValue); + /** + *

List of resource IDs (companies, users, or plans) targeted by this condition

+ */ _FinalStage resourceIds(List resourceIds); _FinalStage addResourceIds(String resourceIds); _FinalStage addAllResourceIds(List resourceIds); + /** + *

ID of trait to use to measure this condition

+ */ _FinalStage traitId(Optional traitId); _FinalStage traitId(String traitId); + /** + *

Value to compare the trait value against

+ */ _FinalStage traitValue(Optional traitValue); _FinalStage traitValue(String traitValue); @@ -281,6 +347,10 @@ public static final class Builder implements ConditionTypeStage, OperatorStage, private Optional eventSubtype = Optional.empty(); + private Optional creditId = Optional.empty(); + + private Optional creditCost = Optional.empty(); + private Optional comparisonTraitId = Optional.empty(); @JsonAnySetter @@ -292,6 +362,8 @@ private Builder() {} public Builder from(CreateOrUpdateConditionRequestBody other) { comparisonTraitId(other.getComparisonTraitId()); conditionType(other.getConditionType()); + creditCost(other.getCreditCost()); + creditId(other.getCreditId()); eventSubtype(other.getEventSubtype()); id(other.getId()); metricPeriod(other.getMetricPeriod()); @@ -328,6 +400,9 @@ public _FinalStage traitValue(String traitValue) { return this; } + /** + *

Value to compare the trait value against

+ */ @java.lang.Override @JsonSetter(value = "trait_value", nulls = Nulls.SKIP) public _FinalStage traitValue(Optional traitValue) { @@ -345,6 +420,9 @@ public _FinalStage traitId(String traitId) { return this; } + /** + *

ID of trait to use to measure this condition

+ */ @java.lang.Override @JsonSetter(value = "trait_id", nulls = Nulls.SKIP) public _FinalStage traitId(Optional traitId) { @@ -358,7 +436,9 @@ public _FinalStage traitId(Optional traitId) { */ @java.lang.Override public _FinalStage addAllResourceIds(List resourceIds) { - this.resourceIds.addAll(resourceIds); + if (resourceIds != null) { + this.resourceIds.addAll(resourceIds); + } return this; } @@ -372,11 +452,16 @@ public _FinalStage addResourceIds(String resourceIds) { return this; } + /** + *

List of resource IDs (companies, users, or plans) targeted by this condition

+ */ @java.lang.Override @JsonSetter(value = "resource_ids", nulls = Nulls.SKIP) public _FinalStage resourceIds(List resourceIds) { this.resourceIds.clear(); - this.resourceIds.addAll(resourceIds); + if (resourceIds != null) { + this.resourceIds.addAll(resourceIds); + } return this; } @@ -390,6 +475,9 @@ public _FinalStage metricValue(Integer metricValue) { return this; } + /** + *

Value to compare the track event metric against

+ */ @java.lang.Override @JsonSetter(value = "metric_value", nulls = Nulls.SKIP) public _FinalStage metricValue(Optional metricValue) { @@ -408,6 +496,9 @@ public _FinalStage metricPeriodMonthReset( return this; } + /** + *

When metric_period=current_month, specify whether the month restarts based on the calendar month or the billing period

+ */ @java.lang.Override @JsonSetter(value = "metric_period_month_reset", nulls = Nulls.SKIP) public _FinalStage metricPeriodMonthReset( @@ -426,6 +517,9 @@ public _FinalStage metricPeriod(CreateOrUpdateConditionRequestBodyMetricPeriod m return this; } + /** + *

Period of time over which to measure the track event metric

+ */ @java.lang.Override @JsonSetter(value = "metric_period", nulls = Nulls.SKIP) public _FinalStage metricPeriod(Optional metricPeriod) { @@ -456,6 +550,9 @@ public _FinalStage eventSubtype(String eventSubtype) { return this; } + /** + *

Name of track event type used to measure this condition

+ */ @java.lang.Override @JsonSetter(value = "event_subtype", nulls = Nulls.SKIP) public _FinalStage eventSubtype(Optional eventSubtype) { @@ -463,6 +560,46 @@ public _FinalStage eventSubtype(Optional eventSubtype) { return this; } + /** + *

ID of credit to use to measure this condition

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creditId(String creditId) { + this.creditId = Optional.ofNullable(creditId); + return this; + } + + /** + *

ID of credit to use to measure this condition

+ */ + @java.lang.Override + @JsonSetter(value = "credit_id", nulls = Nulls.SKIP) + public _FinalStage creditId(Optional creditId) { + this.creditId = creditId; + return this; + } + + /** + *

Cost of credit to use to measure this condition

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creditCost(Double creditCost) { + this.creditCost = Optional.ofNullable(creditCost); + return this; + } + + /** + *

Cost of credit to use to measure this condition

+ */ + @java.lang.Override + @JsonSetter(value = "credit_cost", nulls = Nulls.SKIP) + public _FinalStage creditCost(Optional creditCost) { + this.creditCost = creditCost; + return this; + } + /** *

Optionally provide a trait ID to compare a metric or trait value against instead of a value

* @return Reference to {@code this} so that method calls can be chained together. @@ -473,6 +610,9 @@ public _FinalStage comparisonTraitId(String comparisonTraitId) { return this; } + /** + *

Optionally provide a trait ID to compare a metric or trait value against instead of a value

+ */ @java.lang.Override @JsonSetter(value = "comparison_trait_id", nulls = Nulls.SKIP) public _FinalStage comparisonTraitId(Optional comparisonTraitId) { @@ -485,6 +625,8 @@ public CreateOrUpdateConditionRequestBody build() { return new CreateOrUpdateConditionRequestBody( comparisonTraitId, conditionType, + creditCost, + creditId, eventSubtype, id, metricPeriod, diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyConditionType.java b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyConditionType.java index 30cd230..ab770a0 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyConditionType.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyConditionType.java @@ -3,34 +3,150 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateOrUpdateConditionRequestBodyConditionType { - COMPANY("company"), +public final class CreateOrUpdateConditionRequestBodyConditionType { + public static final CreateOrUpdateConditionRequestBodyConditionType CRM_PRODUCT = + new CreateOrUpdateConditionRequestBodyConditionType(Value.CRM_PRODUCT, "crm_product"); - METRIC("metric"), + public static final CreateOrUpdateConditionRequestBodyConditionType METRIC = + new CreateOrUpdateConditionRequestBodyConditionType(Value.METRIC, "metric"); - TRAIT("trait"), + public static final CreateOrUpdateConditionRequestBodyConditionType BASE_PLAN = + new CreateOrUpdateConditionRequestBodyConditionType(Value.BASE_PLAN, "base_plan"); - USER("user"), + public static final CreateOrUpdateConditionRequestBodyConditionType PLAN = + new CreateOrUpdateConditionRequestBodyConditionType(Value.PLAN, "plan"); - PLAN("plan"), + public static final CreateOrUpdateConditionRequestBodyConditionType TRAIT = + new CreateOrUpdateConditionRequestBodyConditionType(Value.TRAIT, "trait"); - BILLING_PRODUCT("billing_product"), + public static final CreateOrUpdateConditionRequestBodyConditionType BILLING_PRODUCT = + new CreateOrUpdateConditionRequestBodyConditionType(Value.BILLING_PRODUCT, "billing_product"); - CRM_PRODUCT("crm_product"), + public static final CreateOrUpdateConditionRequestBodyConditionType USER = + new CreateOrUpdateConditionRequestBodyConditionType(Value.USER, "user"); - BASE_PLAN("base_plan"); + public static final CreateOrUpdateConditionRequestBodyConditionType COMPANY = + new CreateOrUpdateConditionRequestBodyConditionType(Value.COMPANY, "company"); - private final String value; + private final Value value; - CreateOrUpdateConditionRequestBodyConditionType(String value) { + private final String string; + + CreateOrUpdateConditionRequestBodyConditionType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateOrUpdateConditionRequestBodyConditionType + && this.string.equals(((CreateOrUpdateConditionRequestBodyConditionType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CRM_PRODUCT: + return visitor.visitCrmProduct(); + case METRIC: + return visitor.visitMetric(); + case BASE_PLAN: + return visitor.visitBasePlan(); + case PLAN: + return visitor.visitPlan(); + case TRAIT: + return visitor.visitTrait(); + case BILLING_PRODUCT: + return visitor.visitBillingProduct(); + case USER: + return visitor.visitUser(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateOrUpdateConditionRequestBodyConditionType valueOf(String value) { + switch (value) { + case "crm_product": + return CRM_PRODUCT; + case "metric": + return METRIC; + case "base_plan": + return BASE_PLAN; + case "plan": + return PLAN; + case "trait": + return TRAIT; + case "billing_product": + return BILLING_PRODUCT; + case "user": + return USER; + case "company": + return COMPANY; + default: + return new CreateOrUpdateConditionRequestBodyConditionType(Value.UNKNOWN, value); + } + } + + public enum Value { + COMPANY, + + METRIC, + + TRAIT, + + USER, + + PLAN, + + BILLING_PRODUCT, + + CRM_PRODUCT, + + BASE_PLAN, + + UNKNOWN + } + + public interface Visitor { + T visitCompany(); + + T visitMetric(); + + T visitTrait(); + + T visitUser(); + + T visitPlan(); + + T visitBillingProduct(); + + T visitCrmProduct(); + + T visitBasePlan(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyMetricPeriod.java b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyMetricPeriod.java index 9cef5b5..52dff45 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyMetricPeriod.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyMetricPeriod.java @@ -3,26 +3,106 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateOrUpdateConditionRequestBodyMetricPeriod { - ALL_TIME("all_time"), +public final class CreateOrUpdateConditionRequestBodyMetricPeriod { + public static final CreateOrUpdateConditionRequestBodyMetricPeriod CURRENT_DAY = + new CreateOrUpdateConditionRequestBodyMetricPeriod(Value.CURRENT_DAY, "current_day"); - CURRENT_MONTH("current_month"), + public static final CreateOrUpdateConditionRequestBodyMetricPeriod ALL_TIME = + new CreateOrUpdateConditionRequestBodyMetricPeriod(Value.ALL_TIME, "all_time"); - CURRENT_WEEK("current_week"), + public static final CreateOrUpdateConditionRequestBodyMetricPeriod CURRENT_WEEK = + new CreateOrUpdateConditionRequestBodyMetricPeriod(Value.CURRENT_WEEK, "current_week"); - CURRENT_DAY("current_day"); + public static final CreateOrUpdateConditionRequestBodyMetricPeriod CURRENT_MONTH = + new CreateOrUpdateConditionRequestBodyMetricPeriod(Value.CURRENT_MONTH, "current_month"); - private final String value; + private final Value value; - CreateOrUpdateConditionRequestBodyMetricPeriod(String value) { + private final String string; + + CreateOrUpdateConditionRequestBodyMetricPeriod(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateOrUpdateConditionRequestBodyMetricPeriod + && this.string.equals(((CreateOrUpdateConditionRequestBodyMetricPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CURRENT_DAY: + return visitor.visitCurrentDay(); + case ALL_TIME: + return visitor.visitAllTime(); + case CURRENT_WEEK: + return visitor.visitCurrentWeek(); + case CURRENT_MONTH: + return visitor.visitCurrentMonth(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateOrUpdateConditionRequestBodyMetricPeriod valueOf(String value) { + switch (value) { + case "current_day": + return CURRENT_DAY; + case "all_time": + return ALL_TIME; + case "current_week": + return CURRENT_WEEK; + case "current_month": + return CURRENT_MONTH; + default: + return new CreateOrUpdateConditionRequestBodyMetricPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + ALL_TIME, + + CURRENT_MONTH, + + CURRENT_WEEK, + + CURRENT_DAY, + + UNKNOWN + } + + public interface Visitor { + T visitAllTime(); + + T visitCurrentMonth(); + + T visitCurrentWeek(); + + T visitCurrentDay(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset.java b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset.java index c1fb4ca..e6669fd 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset.java @@ -3,22 +3,85 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset { - FIRST_OF_MONTH("first_of_month"), +public final class CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset { + public static final CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset FIRST_OF_MONTH = + new CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset(Value.FIRST_OF_MONTH, "first_of_month"); - BILLING_CYCLE("billing_cycle"); + public static final CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset BILLING_CYCLE = + new CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset(Value.BILLING_CYCLE, "billing_cycle"); - private final String value; + private final Value value; - CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset(String value) { + private final String string; + + CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset + && this.string.equals( + ((CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FIRST_OF_MONTH: + return visitor.visitFirstOfMonth(); + case BILLING_CYCLE: + return visitor.visitBillingCycle(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset valueOf(String value) { + switch (value) { + case "first_of_month": + return FIRST_OF_MONTH; + case "billing_cycle": + return BILLING_CYCLE; + default: + return new CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset(Value.UNKNOWN, value); + } + } + + public enum Value { + FIRST_OF_MONTH, + + BILLING_CYCLE, + + UNKNOWN + } + + public interface Visitor { + T visitFirstOfMonth(); + + T visitBillingCycle(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyOperator.java b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyOperator.java index abb6645..f14d78a 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyOperator.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateConditionRequestBodyOperator.java @@ -3,34 +3,150 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateOrUpdateConditionRequestBodyOperator { - EQ("eq"), +public final class CreateOrUpdateConditionRequestBodyOperator { + public static final CreateOrUpdateConditionRequestBodyOperator GTE = + new CreateOrUpdateConditionRequestBodyOperator(Value.GTE, "gte"); - NE("ne"), + public static final CreateOrUpdateConditionRequestBodyOperator LT = + new CreateOrUpdateConditionRequestBodyOperator(Value.LT, "lt"); - GT("gt"), + public static final CreateOrUpdateConditionRequestBodyOperator GT = + new CreateOrUpdateConditionRequestBodyOperator(Value.GT, "gt"); - GTE("gte"), + public static final CreateOrUpdateConditionRequestBodyOperator NOT_EMPTY = + new CreateOrUpdateConditionRequestBodyOperator(Value.NOT_EMPTY, "not_empty"); - LT("lt"), + public static final CreateOrUpdateConditionRequestBodyOperator EQ = + new CreateOrUpdateConditionRequestBodyOperator(Value.EQ, "eq"); - LTE("lte"), + public static final CreateOrUpdateConditionRequestBodyOperator NE = + new CreateOrUpdateConditionRequestBodyOperator(Value.NE, "ne"); - IS_EMPTY("is_empty"), + public static final CreateOrUpdateConditionRequestBodyOperator LTE = + new CreateOrUpdateConditionRequestBodyOperator(Value.LTE, "lte"); - NOT_EMPTY("not_empty"); + public static final CreateOrUpdateConditionRequestBodyOperator IS_EMPTY = + new CreateOrUpdateConditionRequestBodyOperator(Value.IS_EMPTY, "is_empty"); - private final String value; + private final Value value; - CreateOrUpdateConditionRequestBodyOperator(String value) { + private final String string; + + CreateOrUpdateConditionRequestBodyOperator(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateOrUpdateConditionRequestBodyOperator + && this.string.equals(((CreateOrUpdateConditionRequestBodyOperator) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case GTE: + return visitor.visitGte(); + case LT: + return visitor.visitLt(); + case GT: + return visitor.visitGt(); + case NOT_EMPTY: + return visitor.visitNotEmpty(); + case EQ: + return visitor.visitEq(); + case NE: + return visitor.visitNe(); + case LTE: + return visitor.visitLte(); + case IS_EMPTY: + return visitor.visitIsEmpty(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateOrUpdateConditionRequestBodyOperator valueOf(String value) { + switch (value) { + case "gte": + return GTE; + case "lt": + return LT; + case "gt": + return GT; + case "not_empty": + return NOT_EMPTY; + case "eq": + return EQ; + case "ne": + return NE; + case "lte": + return LTE; + case "is_empty": + return IS_EMPTY; + default: + return new CreateOrUpdateConditionRequestBodyOperator(Value.UNKNOWN, value); + } + } + + public enum Value { + EQ, + + NE, + + GT, + + GTE, + + LT, + + LTE, + + IS_EMPTY, + + NOT_EMPTY, + + UNKNOWN + } + + public interface Visitor { + T visitEq(); + + T visitNe(); + + T visitGt(); + + T visitGte(); + + T visitLt(); + + T visitLte(); + + T visitIsEmpty(); + + T visitNotEmpty(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateFlagRequestBody.java b/src/main/java/com/schematic/api/types/CreateOrUpdateFlagRequestBody.java index 28c4904..ef9517e 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateFlagRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateFlagRequestBody.java @@ -27,8 +27,6 @@ public final class CreateOrUpdateFlagRequestBody { private final Optional featureId; - private final String flagType; - private final Optional id; private final String key; @@ -43,7 +41,6 @@ private CreateOrUpdateFlagRequestBody( boolean defaultValue, String description, Optional featureId, - String flagType, Optional id, String key, Optional maintainerId, @@ -52,7 +49,6 @@ private CreateOrUpdateFlagRequestBody( this.defaultValue = defaultValue; this.description = description; this.featureId = featureId; - this.flagType = flagType; this.id = id; this.key = key; this.maintainerId = maintainerId; @@ -77,7 +73,7 @@ public Optional getFeatureId() { @JsonProperty("flag_type") public String getFlagType() { - return flagType; + return "boolean"; } @JsonProperty("id") @@ -115,7 +111,6 @@ private boolean equalTo(CreateOrUpdateFlagRequestBody other) { return defaultValue == other.defaultValue && description.equals(other.description) && featureId.equals(other.featureId) - && flagType.equals(other.flagType) && id.equals(other.id) && key.equals(other.key) && maintainerId.equals(other.maintainerId) @@ -125,14 +120,7 @@ private boolean equalTo(CreateOrUpdateFlagRequestBody other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.defaultValue, - this.description, - this.featureId, - this.flagType, - this.id, - this.key, - this.maintainerId, - this.name); + this.defaultValue, this.description, this.featureId, this.id, this.key, this.maintainerId, this.name); } @java.lang.Override @@ -151,11 +139,7 @@ public interface DefaultValueStage { } public interface DescriptionStage { - FlagTypeStage description(@NotNull String description); - } - - public interface FlagTypeStage { - KeyStage flagType(@NotNull String flagType); + KeyStage description(@NotNull String description); } public interface KeyStage { @@ -183,14 +167,11 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements DefaultValueStage, DescriptionStage, FlagTypeStage, KeyStage, NameStage, _FinalStage { + public static final class Builder implements DefaultValueStage, DescriptionStage, KeyStage, NameStage, _FinalStage { private boolean defaultValue; private String description; - private String flagType; - private String key; private String name; @@ -211,7 +192,6 @@ public Builder from(CreateOrUpdateFlagRequestBody other) { defaultValue(other.getDefaultValue()); description(other.getDescription()); featureId(other.getFeatureId()); - flagType(other.getFlagType()); id(other.getId()); key(other.getKey()); maintainerId(other.getMaintainerId()); @@ -228,18 +208,11 @@ public DescriptionStage defaultValue(boolean defaultValue) { @java.lang.Override @JsonSetter("description") - public FlagTypeStage description(@NotNull String description) { + public KeyStage description(@NotNull String description) { this.description = Objects.requireNonNull(description, "description must not be null"); return this; } - @java.lang.Override - @JsonSetter("flag_type") - public KeyStage flagType(@NotNull String flagType) { - this.flagType = Objects.requireNonNull(flagType, "flagType must not be null"); - return this; - } - @java.lang.Override @JsonSetter("key") public NameStage key(@NotNull String key) { @@ -296,7 +269,7 @@ public _FinalStage featureId(Optional featureId) { @java.lang.Override public CreateOrUpdateFlagRequestBody build() { return new CreateOrUpdateFlagRequestBody( - defaultValue, description, featureId, flagType, id, key, maintainerId, name, additionalProperties); + defaultValue, description, featureId, id, key, maintainerId, name, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateRuleRequestBody.java b/src/main/java/com/schematic/api/types/CreateOrUpdateRuleRequestBody.java index 357ddc6..8d91ab3 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateRuleRequestBody.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateRuleRequestBody.java @@ -249,7 +249,9 @@ public _FinalStage id(Optional id) { @java.lang.Override public _FinalStage addAllConditions(List conditions) { - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @@ -263,13 +265,17 @@ public _FinalStage addConditions(CreateOrUpdateConditionRequestBody conditions) @JsonSetter(value = "conditions", nulls = Nulls.SKIP) public _FinalStage conditions(List conditions) { this.conditions.clear(); - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @java.lang.Override public _FinalStage addAllConditionGroups(List conditionGroups) { - this.conditionGroups.addAll(conditionGroups); + if (conditionGroups != null) { + this.conditionGroups.addAll(conditionGroups); + } return this; } @@ -283,7 +289,9 @@ public _FinalStage addConditionGroups(CreateOrUpdateConditionGroupRequestBody co @JsonSetter(value = "condition_groups", nulls = Nulls.SKIP) public _FinalStage conditionGroups(List conditionGroups) { this.conditionGroups.clear(); - this.conditionGroups.addAll(conditionGroups); + if (conditionGroups != null) { + this.conditionGroups.addAll(conditionGroups); + } return this; } diff --git a/src/main/java/com/schematic/api/types/CreateOrUpdateRuleRequestBodyRuleType.java b/src/main/java/com/schematic/api/types/CreateOrUpdateRuleRequestBodyRuleType.java index c2b6f0c..3926e9a 100644 --- a/src/main/java/com/schematic/api/types/CreateOrUpdateRuleRequestBodyRuleType.java +++ b/src/main/java/com/schematic/api/types/CreateOrUpdateRuleRequestBodyRuleType.java @@ -3,30 +3,117 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum CreateOrUpdateRuleRequestBodyRuleType { - GLOBAL_OVERRIDE("global_override"), +public final class CreateOrUpdateRuleRequestBodyRuleType { + public static final CreateOrUpdateRuleRequestBodyRuleType GLOBAL_OVERRIDE = + new CreateOrUpdateRuleRequestBodyRuleType(Value.GLOBAL_OVERRIDE, "global_override"); - COMPANY_OVERRIDE("company_override"), + public static final CreateOrUpdateRuleRequestBodyRuleType COMPANY_OVERRIDE = + new CreateOrUpdateRuleRequestBodyRuleType(Value.COMPANY_OVERRIDE, "company_override"); - PLAN_ENTITLEMENT("plan_entitlement"), + public static final CreateOrUpdateRuleRequestBodyRuleType STANDARD = + new CreateOrUpdateRuleRequestBodyRuleType(Value.STANDARD, "standard"); - STANDARD("standard"), + public static final CreateOrUpdateRuleRequestBodyRuleType PLAN_ENTITLEMENT = + new CreateOrUpdateRuleRequestBodyRuleType(Value.PLAN_ENTITLEMENT, "plan_entitlement"); - DEFAULT("default"), + public static final CreateOrUpdateRuleRequestBodyRuleType DEFAULT = + new CreateOrUpdateRuleRequestBodyRuleType(Value.DEFAULT, "default"); - PLAN_AUDIENCE("plan_audience"); + private final Value value; - private final String value; + private final String string; - CreateOrUpdateRuleRequestBodyRuleType(String value) { + CreateOrUpdateRuleRequestBodyRuleType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreateOrUpdateRuleRequestBodyRuleType + && this.string.equals(((CreateOrUpdateRuleRequestBodyRuleType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case GLOBAL_OVERRIDE: + return visitor.visitGlobalOverride(); + case COMPANY_OVERRIDE: + return visitor.visitCompanyOverride(); + case STANDARD: + return visitor.visitStandard(); + case PLAN_ENTITLEMENT: + return visitor.visitPlanEntitlement(); + case DEFAULT: + return visitor.visitDefault(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreateOrUpdateRuleRequestBodyRuleType valueOf(String value) { + switch (value) { + case "global_override": + return GLOBAL_OVERRIDE; + case "company_override": + return COMPANY_OVERRIDE; + case "standard": + return STANDARD; + case "plan_entitlement": + return PLAN_ENTITLEMENT; + case "default": + return DEFAULT; + default: + return new CreateOrUpdateRuleRequestBodyRuleType(Value.UNKNOWN, value); + } + } + + public enum Value { + GLOBAL_OVERRIDE, + + COMPANY_OVERRIDE, + + PLAN_ENTITLEMENT, + + STANDARD, + + DEFAULT, + + UNKNOWN + } + + public interface Visitor { + T visitGlobalOverride(); + + T visitCompanyOverride(); + + T visitPlanEntitlement(); + + T visitStandard(); + + T visitDefault(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/CreatePriceTierRequestBody.java b/src/main/java/com/schematic/api/types/CreatePriceTierRequestBody.java new file mode 100644 index 0000000..95f054a --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreatePriceTierRequestBody.java @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreatePriceTierRequestBody.Builder.class) +public final class CreatePriceTierRequestBody { + private final Optional flatAmount; + + private final Optional perUnitPrice; + + private final Optional perUnitPriceDecimal; + + private final Optional upTo; + + private final Map additionalProperties; + + private CreatePriceTierRequestBody( + Optional flatAmount, + Optional perUnitPrice, + Optional perUnitPriceDecimal, + Optional upTo, + Map additionalProperties) { + this.flatAmount = flatAmount; + this.perUnitPrice = perUnitPrice; + this.perUnitPriceDecimal = perUnitPriceDecimal; + this.upTo = upTo; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("flat_amount") + public Optional getFlatAmount() { + return flatAmount; + } + + @JsonProperty("per_unit_price") + public Optional getPerUnitPrice() { + return perUnitPrice; + } + + @JsonProperty("per_unit_price_decimal") + public Optional getPerUnitPriceDecimal() { + return perUnitPriceDecimal; + } + + @JsonProperty("up_to") + public Optional getUpTo() { + return upTo; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreatePriceTierRequestBody && equalTo((CreatePriceTierRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreatePriceTierRequestBody other) { + return flatAmount.equals(other.flatAmount) + && perUnitPrice.equals(other.perUnitPrice) + && perUnitPriceDecimal.equals(other.perUnitPriceDecimal) + && upTo.equals(other.upTo); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.flatAmount, this.perUnitPrice, this.perUnitPriceDecimal, this.upTo); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional flatAmount = Optional.empty(); + + private Optional perUnitPrice = Optional.empty(); + + private Optional perUnitPriceDecimal = Optional.empty(); + + private Optional upTo = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CreatePriceTierRequestBody other) { + flatAmount(other.getFlatAmount()); + perUnitPrice(other.getPerUnitPrice()); + perUnitPriceDecimal(other.getPerUnitPriceDecimal()); + upTo(other.getUpTo()); + return this; + } + + @JsonSetter(value = "flat_amount", nulls = Nulls.SKIP) + public Builder flatAmount(Optional flatAmount) { + this.flatAmount = flatAmount; + return this; + } + + public Builder flatAmount(Integer flatAmount) { + this.flatAmount = Optional.ofNullable(flatAmount); + return this; + } + + @JsonSetter(value = "per_unit_price", nulls = Nulls.SKIP) + public Builder perUnitPrice(Optional perUnitPrice) { + this.perUnitPrice = perUnitPrice; + return this; + } + + public Builder perUnitPrice(Integer perUnitPrice) { + this.perUnitPrice = Optional.ofNullable(perUnitPrice); + return this; + } + + @JsonSetter(value = "per_unit_price_decimal", nulls = Nulls.SKIP) + public Builder perUnitPriceDecimal(Optional perUnitPriceDecimal) { + this.perUnitPriceDecimal = perUnitPriceDecimal; + return this; + } + + public Builder perUnitPriceDecimal(String perUnitPriceDecimal) { + this.perUnitPriceDecimal = Optional.ofNullable(perUnitPriceDecimal); + return this; + } + + @JsonSetter(value = "up_to", nulls = Nulls.SKIP) + public Builder upTo(Optional upTo) { + this.upTo = upTo; + return this; + } + + public Builder upTo(Integer upTo) { + this.upTo = Optional.ofNullable(upTo); + return this; + } + + public CreatePriceTierRequestBody build() { + return new CreatePriceTierRequestBody( + flatAmount, perUnitPrice, perUnitPriceDecimal, upTo, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CreditBundlePurchaseResponseData.java b/src/main/java/com/schematic/api/types/CreditBundlePurchaseResponseData.java new file mode 100644 index 0000000..2776f74 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditBundlePurchaseResponseData.java @@ -0,0 +1,157 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreditBundlePurchaseResponseData.Builder.class) +public final class CreditBundlePurchaseResponseData { + private final Optional bundle; + + private final int quantity; + + private final int total; + + private final Map additionalProperties; + + private CreditBundlePurchaseResponseData( + Optional bundle, + int quantity, + int total, + Map additionalProperties) { + this.bundle = bundle; + this.quantity = quantity; + this.total = total; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("bundle") + public Optional getBundle() { + return bundle; + } + + @JsonProperty("quantity") + public int getQuantity() { + return quantity; + } + + @JsonProperty("total") + public int getTotal() { + return total; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditBundlePurchaseResponseData && equalTo((CreditBundlePurchaseResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditBundlePurchaseResponseData other) { + return bundle.equals(other.bundle) && quantity == other.quantity && total == other.total; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.bundle, this.quantity, this.total); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static QuantityStage builder() { + return new Builder(); + } + + public interface QuantityStage { + TotalStage quantity(int quantity); + + Builder from(CreditBundlePurchaseResponseData other); + } + + public interface TotalStage { + _FinalStage total(int total); + } + + public interface _FinalStage { + CreditBundlePurchaseResponseData build(); + + _FinalStage bundle(Optional bundle); + + _FinalStage bundle(BillingCreditBundleResponseData bundle); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements QuantityStage, TotalStage, _FinalStage { + private int quantity; + + private int total; + + private Optional bundle = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreditBundlePurchaseResponseData other) { + bundle(other.getBundle()); + quantity(other.getQuantity()); + total(other.getTotal()); + return this; + } + + @java.lang.Override + @JsonSetter("quantity") + public TotalStage quantity(int quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + @JsonSetter("total") + public _FinalStage total(int total) { + this.total = total; + return this; + } + + @java.lang.Override + public _FinalStage bundle(BillingCreditBundleResponseData bundle) { + this.bundle = Optional.ofNullable(bundle); + return this; + } + + @java.lang.Override + @JsonSetter(value = "bundle", nulls = Nulls.SKIP) + public _FinalStage bundle(Optional bundle) { + this.bundle = bundle; + return this; + } + + @java.lang.Override + public CreditBundlePurchaseResponseData build() { + return new CreditBundlePurchaseResponseData(bundle, quantity, total, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CreditCompanyGrantView.java b/src/main/java/com/schematic/api/types/CreditCompanyGrantView.java new file mode 100644 index 0000000..4cf2a27 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditCompanyGrantView.java @@ -0,0 +1,884 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreditCompanyGrantView.Builder.class) +public final class CreditCompanyGrantView { + private final Optional billingCreditBundleId; + + private final String billingCreditId; + + private final String companyId; + + private final String companyName; + + private final OffsetDateTime createdAt; + + private final String creditDescription; + + private final Optional creditIcon; + + private final String creditName; + + private final Optional expiresAt; + + private final Optional expiryType; + + private final Optional expiryUnit; + + private final Optional expiryUnitCount; + + private final String grantReason; + + private final String id; + + private final Optional planId; + + private final Optional planName; + + private final Optional pluralName; + + private final Optional price; + + private final int quantity; + + private final double quantityRemaining; + + private final double quantityUsed; + + private final Optional singularName; + + private final String sourceLabel; + + private final OffsetDateTime updatedAt; + + private final Optional validFrom; + + private final Optional zeroedOutDate; + + private final Optional zeroedOutReason; + + private final Map additionalProperties; + + private CreditCompanyGrantView( + Optional billingCreditBundleId, + String billingCreditId, + String companyId, + String companyName, + OffsetDateTime createdAt, + String creditDescription, + Optional creditIcon, + String creditName, + Optional expiresAt, + Optional expiryType, + Optional expiryUnit, + Optional expiryUnitCount, + String grantReason, + String id, + Optional planId, + Optional planName, + Optional pluralName, + Optional price, + int quantity, + double quantityRemaining, + double quantityUsed, + Optional singularName, + String sourceLabel, + OffsetDateTime updatedAt, + Optional validFrom, + Optional zeroedOutDate, + Optional zeroedOutReason, + Map additionalProperties) { + this.billingCreditBundleId = billingCreditBundleId; + this.billingCreditId = billingCreditId; + this.companyId = companyId; + this.companyName = companyName; + this.createdAt = createdAt; + this.creditDescription = creditDescription; + this.creditIcon = creditIcon; + this.creditName = creditName; + this.expiresAt = expiresAt; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.grantReason = grantReason; + this.id = id; + this.planId = planId; + this.planName = planName; + this.pluralName = pluralName; + this.price = price; + this.quantity = quantity; + this.quantityRemaining = quantityRemaining; + this.quantityUsed = quantityUsed; + this.singularName = singularName; + this.sourceLabel = sourceLabel; + this.updatedAt = updatedAt; + this.validFrom = validFrom; + this.zeroedOutDate = zeroedOutDate; + this.zeroedOutReason = zeroedOutReason; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_credit_bundle_id") + public Optional getBillingCreditBundleId() { + return billingCreditBundleId; + } + + @JsonProperty("billing_credit_id") + public String getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("company_name") + public String getCompanyName() { + return companyName; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("credit_description") + public String getCreditDescription() { + return creditDescription; + } + + @JsonProperty("credit_icon") + public Optional getCreditIcon() { + return creditIcon; + } + + @JsonProperty("credit_name") + public String getCreditName() { + return creditName; + } + + @JsonProperty("expires_at") + public Optional getExpiresAt() { + return expiresAt; + } + + @JsonProperty("expiry_type") + public Optional getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public Optional getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("grant_reason") + public String getGrantReason() { + return grantReason; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("plan_id") + public Optional getPlanId() { + return planId; + } + + @JsonProperty("plan_name") + public Optional getPlanName() { + return planName; + } + + @JsonProperty("plural_name") + public Optional getPluralName() { + return pluralName; + } + + @JsonProperty("price") + public Optional getPrice() { + return price; + } + + @JsonProperty("quantity") + public int getQuantity() { + return quantity; + } + + @JsonProperty("quantity_remaining") + public double getQuantityRemaining() { + return quantityRemaining; + } + + @JsonProperty("quantity_used") + public double getQuantityUsed() { + return quantityUsed; + } + + @JsonProperty("singular_name") + public Optional getSingularName() { + return singularName; + } + + @JsonProperty("source_label") + public String getSourceLabel() { + return sourceLabel; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("valid_from") + public Optional getValidFrom() { + return validFrom; + } + + @JsonProperty("zeroed_out_date") + public Optional getZeroedOutDate() { + return zeroedOutDate; + } + + @JsonProperty("zeroed_out_reason") + public Optional getZeroedOutReason() { + return zeroedOutReason; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditCompanyGrantView && equalTo((CreditCompanyGrantView) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditCompanyGrantView other) { + return billingCreditBundleId.equals(other.billingCreditBundleId) + && billingCreditId.equals(other.billingCreditId) + && companyId.equals(other.companyId) + && companyName.equals(other.companyName) + && createdAt.equals(other.createdAt) + && creditDescription.equals(other.creditDescription) + && creditIcon.equals(other.creditIcon) + && creditName.equals(other.creditName) + && expiresAt.equals(other.expiresAt) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && grantReason.equals(other.grantReason) + && id.equals(other.id) + && planId.equals(other.planId) + && planName.equals(other.planName) + && pluralName.equals(other.pluralName) + && price.equals(other.price) + && quantity == other.quantity + && quantityRemaining == other.quantityRemaining + && quantityUsed == other.quantityUsed + && singularName.equals(other.singularName) + && sourceLabel.equals(other.sourceLabel) + && updatedAt.equals(other.updatedAt) + && validFrom.equals(other.validFrom) + && zeroedOutDate.equals(other.zeroedOutDate) + && zeroedOutReason.equals(other.zeroedOutReason); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingCreditBundleId, + this.billingCreditId, + this.companyId, + this.companyName, + this.createdAt, + this.creditDescription, + this.creditIcon, + this.creditName, + this.expiresAt, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.grantReason, + this.id, + this.planId, + this.planName, + this.pluralName, + this.price, + this.quantity, + this.quantityRemaining, + this.quantityUsed, + this.singularName, + this.sourceLabel, + this.updatedAt, + this.validFrom, + this.zeroedOutDate, + this.zeroedOutReason); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BillingCreditIdStage builder() { + return new Builder(); + } + + public interface BillingCreditIdStage { + CompanyIdStage billingCreditId(@NotNull String billingCreditId); + + Builder from(CreditCompanyGrantView other); + } + + public interface CompanyIdStage { + CompanyNameStage companyId(@NotNull String companyId); + } + + public interface CompanyNameStage { + CreatedAtStage companyName(@NotNull String companyName); + } + + public interface CreatedAtStage { + CreditDescriptionStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface CreditDescriptionStage { + CreditNameStage creditDescription(@NotNull String creditDescription); + } + + public interface CreditNameStage { + GrantReasonStage creditName(@NotNull String creditName); + } + + public interface GrantReasonStage { + IdStage grantReason(@NotNull String grantReason); + } + + public interface IdStage { + QuantityStage id(@NotNull String id); + } + + public interface QuantityStage { + QuantityRemainingStage quantity(int quantity); + } + + public interface QuantityRemainingStage { + QuantityUsedStage quantityRemaining(double quantityRemaining); + } + + public interface QuantityUsedStage { + SourceLabelStage quantityUsed(double quantityUsed); + } + + public interface SourceLabelStage { + UpdatedAtStage sourceLabel(@NotNull String sourceLabel); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + CreditCompanyGrantView build(); + + _FinalStage billingCreditBundleId(Optional billingCreditBundleId); + + _FinalStage billingCreditBundleId(String billingCreditBundleId); + + _FinalStage creditIcon(Optional creditIcon); + + _FinalStage creditIcon(String creditIcon); + + _FinalStage expiresAt(Optional expiresAt); + + _FinalStage expiresAt(OffsetDateTime expiresAt); + + _FinalStage expiryType(Optional expiryType); + + _FinalStage expiryType(String expiryType); + + _FinalStage expiryUnit(Optional expiryUnit); + + _FinalStage expiryUnit(String expiryUnit); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + + _FinalStage planId(Optional planId); + + _FinalStage planId(String planId); + + _FinalStage planName(Optional planName); + + _FinalStage planName(String planName); + + _FinalStage pluralName(Optional pluralName); + + _FinalStage pluralName(String pluralName); + + _FinalStage price(Optional price); + + _FinalStage price(BillingProductPriceResponseData price); + + _FinalStage singularName(Optional singularName); + + _FinalStage singularName(String singularName); + + _FinalStage validFrom(Optional validFrom); + + _FinalStage validFrom(OffsetDateTime validFrom); + + _FinalStage zeroedOutDate(Optional zeroedOutDate); + + _FinalStage zeroedOutDate(OffsetDateTime zeroedOutDate); + + _FinalStage zeroedOutReason(Optional zeroedOutReason); + + _FinalStage zeroedOutReason(String zeroedOutReason); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements BillingCreditIdStage, + CompanyIdStage, + CompanyNameStage, + CreatedAtStage, + CreditDescriptionStage, + CreditNameStage, + GrantReasonStage, + IdStage, + QuantityStage, + QuantityRemainingStage, + QuantityUsedStage, + SourceLabelStage, + UpdatedAtStage, + _FinalStage { + private String billingCreditId; + + private String companyId; + + private String companyName; + + private OffsetDateTime createdAt; + + private String creditDescription; + + private String creditName; + + private String grantReason; + + private String id; + + private int quantity; + + private double quantityRemaining; + + private double quantityUsed; + + private String sourceLabel; + + private OffsetDateTime updatedAt; + + private Optional zeroedOutReason = Optional.empty(); + + private Optional zeroedOutDate = Optional.empty(); + + private Optional validFrom = Optional.empty(); + + private Optional singularName = Optional.empty(); + + private Optional price = Optional.empty(); + + private Optional pluralName = Optional.empty(); + + private Optional planName = Optional.empty(); + + private Optional planId = Optional.empty(); + + private Optional expiryUnitCount = Optional.empty(); + + private Optional expiryUnit = Optional.empty(); + + private Optional expiryType = Optional.empty(); + + private Optional expiresAt = Optional.empty(); + + private Optional creditIcon = Optional.empty(); + + private Optional billingCreditBundleId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreditCompanyGrantView other) { + billingCreditBundleId(other.getBillingCreditBundleId()); + billingCreditId(other.getBillingCreditId()); + companyId(other.getCompanyId()); + companyName(other.getCompanyName()); + createdAt(other.getCreatedAt()); + creditDescription(other.getCreditDescription()); + creditIcon(other.getCreditIcon()); + creditName(other.getCreditName()); + expiresAt(other.getExpiresAt()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + grantReason(other.getGrantReason()); + id(other.getId()); + planId(other.getPlanId()); + planName(other.getPlanName()); + pluralName(other.getPluralName()); + price(other.getPrice()); + quantity(other.getQuantity()); + quantityRemaining(other.getQuantityRemaining()); + quantityUsed(other.getQuantityUsed()); + singularName(other.getSingularName()); + sourceLabel(other.getSourceLabel()); + updatedAt(other.getUpdatedAt()); + validFrom(other.getValidFrom()); + zeroedOutDate(other.getZeroedOutDate()); + zeroedOutReason(other.getZeroedOutReason()); + return this; + } + + @java.lang.Override + @JsonSetter("billing_credit_id") + public CompanyIdStage billingCreditId(@NotNull String billingCreditId) { + this.billingCreditId = Objects.requireNonNull(billingCreditId, "billingCreditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public CompanyNameStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("company_name") + public CreatedAtStage companyName(@NotNull String companyName) { + this.companyName = Objects.requireNonNull(companyName, "companyName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public CreditDescriptionStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_description") + public CreditNameStage creditDescription(@NotNull String creditDescription) { + this.creditDescription = Objects.requireNonNull(creditDescription, "creditDescription must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_name") + public GrantReasonStage creditName(@NotNull String creditName) { + this.creditName = Objects.requireNonNull(creditName, "creditName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("grant_reason") + public IdStage grantReason(@NotNull String grantReason) { + this.grantReason = Objects.requireNonNull(grantReason, "grantReason must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public QuantityStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("quantity") + public QuantityRemainingStage quantity(int quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + @JsonSetter("quantity_remaining") + public QuantityUsedStage quantityRemaining(double quantityRemaining) { + this.quantityRemaining = quantityRemaining; + return this; + } + + @java.lang.Override + @JsonSetter("quantity_used") + public SourceLabelStage quantityUsed(double quantityUsed) { + this.quantityUsed = quantityUsed; + return this; + } + + @java.lang.Override + @JsonSetter("source_label") + public UpdatedAtStage sourceLabel(@NotNull String sourceLabel) { + this.sourceLabel = Objects.requireNonNull(sourceLabel, "sourceLabel must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage zeroedOutReason(String zeroedOutReason) { + this.zeroedOutReason = Optional.ofNullable(zeroedOutReason); + return this; + } + + @java.lang.Override + @JsonSetter(value = "zeroed_out_reason", nulls = Nulls.SKIP) + public _FinalStage zeroedOutReason(Optional zeroedOutReason) { + this.zeroedOutReason = zeroedOutReason; + return this; + } + + @java.lang.Override + public _FinalStage zeroedOutDate(OffsetDateTime zeroedOutDate) { + this.zeroedOutDate = Optional.ofNullable(zeroedOutDate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "zeroed_out_date", nulls = Nulls.SKIP) + public _FinalStage zeroedOutDate(Optional zeroedOutDate) { + this.zeroedOutDate = zeroedOutDate; + return this; + } + + @java.lang.Override + public _FinalStage validFrom(OffsetDateTime validFrom) { + this.validFrom = Optional.ofNullable(validFrom); + return this; + } + + @java.lang.Override + @JsonSetter(value = "valid_from", nulls = Nulls.SKIP) + public _FinalStage validFrom(Optional validFrom) { + this.validFrom = validFrom; + return this; + } + + @java.lang.Override + public _FinalStage singularName(String singularName) { + this.singularName = Optional.ofNullable(singularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "singular_name", nulls = Nulls.SKIP) + public _FinalStage singularName(Optional singularName) { + this.singularName = singularName; + return this; + } + + @java.lang.Override + public _FinalStage price(BillingProductPriceResponseData price) { + this.price = Optional.ofNullable(price); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price", nulls = Nulls.SKIP) + public _FinalStage price(Optional price) { + this.price = price; + return this; + } + + @java.lang.Override + public _FinalStage pluralName(String pluralName) { + this.pluralName = Optional.ofNullable(pluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plural_name", nulls = Nulls.SKIP) + public _FinalStage pluralName(Optional pluralName) { + this.pluralName = pluralName; + return this; + } + + @java.lang.Override + public _FinalStage planName(String planName) { + this.planName = Optional.ofNullable(planName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan_name", nulls = Nulls.SKIP) + public _FinalStage planName(Optional planName) { + this.planName = planName; + return this; + } + + @java.lang.Override + public _FinalStage planId(String planId) { + this.planId = Optional.ofNullable(planId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) + public _FinalStage planId(Optional planId) { + this.planId = planId; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnit(String expiryUnit) { + this.expiryUnit = Optional.ofNullable(expiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit", nulls = Nulls.SKIP) + public _FinalStage expiryUnit(Optional expiryUnit) { + this.expiryUnit = expiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage expiryType(String expiryType) { + this.expiryType = Optional.ofNullable(expiryType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_type", nulls = Nulls.SKIP) + public _FinalStage expiryType(Optional expiryType) { + this.expiryType = expiryType; + return this; + } + + @java.lang.Override + public _FinalStage expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = Optional.ofNullable(expiresAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) + public _FinalStage expiresAt(Optional expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + @java.lang.Override + public _FinalStage creditIcon(String creditIcon) { + this.creditIcon = Optional.ofNullable(creditIcon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_icon", nulls = Nulls.SKIP) + public _FinalStage creditIcon(Optional creditIcon) { + this.creditIcon = creditIcon; + return this; + } + + @java.lang.Override + public _FinalStage billingCreditBundleId(String billingCreditBundleId) { + this.billingCreditBundleId = Optional.ofNullable(billingCreditBundleId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_credit_bundle_id", nulls = Nulls.SKIP) + public _FinalStage billingCreditBundleId(Optional billingCreditBundleId) { + this.billingCreditBundleId = billingCreditBundleId; + return this; + } + + @java.lang.Override + public CreditCompanyGrantView build() { + return new CreditCompanyGrantView( + billingCreditBundleId, + billingCreditId, + companyId, + companyName, + createdAt, + creditDescription, + creditIcon, + creditName, + expiresAt, + expiryType, + expiryUnit, + expiryUnitCount, + grantReason, + id, + planId, + planName, + pluralName, + price, + quantity, + quantityRemaining, + quantityUsed, + singularName, + sourceLabel, + updatedAt, + validFrom, + zeroedOutDate, + zeroedOutReason, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CreditGrantDetail.java b/src/main/java/com/schematic/api/types/CreditGrantDetail.java new file mode 100644 index 0000000..e9d2a46 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditGrantDetail.java @@ -0,0 +1,191 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreditGrantDetail.Builder.class) +public final class CreditGrantDetail { + private final Optional creditTypeIcon; + + private final Optional expiresAt; + + private final CreditGrantDetailGrantReason grantReason; + + private final double quantity; + + private final Map additionalProperties; + + private CreditGrantDetail( + Optional creditTypeIcon, + Optional expiresAt, + CreditGrantDetailGrantReason grantReason, + double quantity, + Map additionalProperties) { + this.creditTypeIcon = creditTypeIcon; + this.expiresAt = expiresAt; + this.grantReason = grantReason; + this.quantity = quantity; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_type_icon") + public Optional getCreditTypeIcon() { + return creditTypeIcon; + } + + @JsonProperty("expires_at") + public Optional getExpiresAt() { + return expiresAt; + } + + @JsonProperty("grant_reason") + public CreditGrantDetailGrantReason getGrantReason() { + return grantReason; + } + + @JsonProperty("quantity") + public double getQuantity() { + return quantity; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditGrantDetail && equalTo((CreditGrantDetail) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditGrantDetail other) { + return creditTypeIcon.equals(other.creditTypeIcon) + && expiresAt.equals(other.expiresAt) + && grantReason.equals(other.grantReason) + && quantity == other.quantity; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.creditTypeIcon, this.expiresAt, this.grantReason, this.quantity); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static GrantReasonStage builder() { + return new Builder(); + } + + public interface GrantReasonStage { + QuantityStage grantReason(@NotNull CreditGrantDetailGrantReason grantReason); + + Builder from(CreditGrantDetail other); + } + + public interface QuantityStage { + _FinalStage quantity(double quantity); + } + + public interface _FinalStage { + CreditGrantDetail build(); + + _FinalStage creditTypeIcon(Optional creditTypeIcon); + + _FinalStage creditTypeIcon(String creditTypeIcon); + + _FinalStage expiresAt(Optional expiresAt); + + _FinalStage expiresAt(OffsetDateTime expiresAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements GrantReasonStage, QuantityStage, _FinalStage { + private CreditGrantDetailGrantReason grantReason; + + private double quantity; + + private Optional expiresAt = Optional.empty(); + + private Optional creditTypeIcon = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreditGrantDetail other) { + creditTypeIcon(other.getCreditTypeIcon()); + expiresAt(other.getExpiresAt()); + grantReason(other.getGrantReason()); + quantity(other.getQuantity()); + return this; + } + + @java.lang.Override + @JsonSetter("grant_reason") + public QuantityStage grantReason(@NotNull CreditGrantDetailGrantReason grantReason) { + this.grantReason = Objects.requireNonNull(grantReason, "grantReason must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("quantity") + public _FinalStage quantity(double quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + public _FinalStage expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = Optional.ofNullable(expiresAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) + public _FinalStage expiresAt(Optional expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + @java.lang.Override + public _FinalStage creditTypeIcon(String creditTypeIcon) { + this.creditTypeIcon = Optional.ofNullable(creditTypeIcon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_type_icon", nulls = Nulls.SKIP) + public _FinalStage creditTypeIcon(Optional creditTypeIcon) { + this.creditTypeIcon = creditTypeIcon; + return this; + } + + @java.lang.Override + public CreditGrantDetail build() { + return new CreditGrantDetail(creditTypeIcon, expiresAt, grantReason, quantity, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CreditGrantDetailGrantReason.java b/src/main/java/com/schematic/api/types/CreditGrantDetailGrantReason.java new file mode 100644 index 0000000..11c9906 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditGrantDetailGrantReason.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class CreditGrantDetailGrantReason { + public static final CreditGrantDetailGrantReason PURCHASED = + new CreditGrantDetailGrantReason(Value.PURCHASED, "purchased"); + + public static final CreditGrantDetailGrantReason PLAN = new CreditGrantDetailGrantReason(Value.PLAN, "plan"); + + public static final CreditGrantDetailGrantReason FREE = new CreditGrantDetailGrantReason(Value.FREE, "free"); + + private final Value value; + + private final String string; + + CreditGrantDetailGrantReason(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof CreditGrantDetailGrantReason + && this.string.equals(((CreditGrantDetailGrantReason) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PURCHASED: + return visitor.visitPurchased(); + case PLAN: + return visitor.visitPlan(); + case FREE: + return visitor.visitFree(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CreditGrantDetailGrantReason valueOf(String value) { + switch (value) { + case "purchased": + return PURCHASED; + case "plan": + return PLAN; + case "free": + return FREE; + default: + return new CreditGrantDetailGrantReason(Value.UNKNOWN, value); + } + } + + public enum Value { + FREE, + + PLAN, + + PURCHASED, + + UNKNOWN + } + + public interface Visitor { + T visitFree(); + + T visitPlan(); + + T visitPurchased(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/CreditLedgerEnrichedEntryResponseData.java b/src/main/java/com/schematic/api/types/CreditLedgerEnrichedEntryResponseData.java new file mode 100644 index 0000000..30a7d3a --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditLedgerEnrichedEntryResponseData.java @@ -0,0 +1,673 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreditLedgerEnrichedEntryResponseData.Builder.class) +public final class CreditLedgerEnrichedEntryResponseData { + private final String billingCreditId; + + private final Optional company; + + private final String companyId; + + private final Optional credit; + + private final int expiredGrantCount; + + private final Optional feature; + + private final Optional featureId; + + private final OffsetDateTime firstTransactionAt; + + private final int freeGrantCount; + + private final int grantCount; + + private final OffsetDateTime lastTransactionAt; + + private final int manuallyZeroedCount; + + private final double netChange; + + private final int planGrantCount; + + private final int purchasedGrantCount; + + private final OffsetDateTime timeBucket; + + private final double totalConsumed; + + private final double totalGranted; + + private final int transactionCount; + + private final int usageCount; + + private final int zeroedOutCount; + + private final Map additionalProperties; + + private CreditLedgerEnrichedEntryResponseData( + String billingCreditId, + Optional company, + String companyId, + Optional credit, + int expiredGrantCount, + Optional feature, + Optional featureId, + OffsetDateTime firstTransactionAt, + int freeGrantCount, + int grantCount, + OffsetDateTime lastTransactionAt, + int manuallyZeroedCount, + double netChange, + int planGrantCount, + int purchasedGrantCount, + OffsetDateTime timeBucket, + double totalConsumed, + double totalGranted, + int transactionCount, + int usageCount, + int zeroedOutCount, + Map additionalProperties) { + this.billingCreditId = billingCreditId; + this.company = company; + this.companyId = companyId; + this.credit = credit; + this.expiredGrantCount = expiredGrantCount; + this.feature = feature; + this.featureId = featureId; + this.firstTransactionAt = firstTransactionAt; + this.freeGrantCount = freeGrantCount; + this.grantCount = grantCount; + this.lastTransactionAt = lastTransactionAt; + this.manuallyZeroedCount = manuallyZeroedCount; + this.netChange = netChange; + this.planGrantCount = planGrantCount; + this.purchasedGrantCount = purchasedGrantCount; + this.timeBucket = timeBucket; + this.totalConsumed = totalConsumed; + this.totalGranted = totalGranted; + this.transactionCount = transactionCount; + this.usageCount = usageCount; + this.zeroedOutCount = zeroedOutCount; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("billing_credit_id") + public String getBillingCreditId() { + return billingCreditId; + } + + @JsonProperty("company") + public Optional getCompany() { + return company; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("credit") + public Optional getCredit() { + return credit; + } + + @JsonProperty("expired_grant_count") + public int getExpiredGrantCount() { + return expiredGrantCount; + } + + @JsonProperty("feature") + public Optional getFeature() { + return feature; + } + + @JsonProperty("feature_id") + public Optional getFeatureId() { + return featureId; + } + + @JsonProperty("first_transaction_at") + public OffsetDateTime getFirstTransactionAt() { + return firstTransactionAt; + } + + @JsonProperty("free_grant_count") + public int getFreeGrantCount() { + return freeGrantCount; + } + + @JsonProperty("grant_count") + public int getGrantCount() { + return grantCount; + } + + @JsonProperty("last_transaction_at") + public OffsetDateTime getLastTransactionAt() { + return lastTransactionAt; + } + + @JsonProperty("manually_zeroed_count") + public int getManuallyZeroedCount() { + return manuallyZeroedCount; + } + + @JsonProperty("net_change") + public double getNetChange() { + return netChange; + } + + @JsonProperty("plan_grant_count") + public int getPlanGrantCount() { + return planGrantCount; + } + + @JsonProperty("purchased_grant_count") + public int getPurchasedGrantCount() { + return purchasedGrantCount; + } + + @JsonProperty("time_bucket") + public OffsetDateTime getTimeBucket() { + return timeBucket; + } + + @JsonProperty("total_consumed") + public double getTotalConsumed() { + return totalConsumed; + } + + @JsonProperty("total_granted") + public double getTotalGranted() { + return totalGranted; + } + + @JsonProperty("transaction_count") + public int getTransactionCount() { + return transactionCount; + } + + @JsonProperty("usage_count") + public int getUsageCount() { + return usageCount; + } + + @JsonProperty("zeroed_out_count") + public int getZeroedOutCount() { + return zeroedOutCount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditLedgerEnrichedEntryResponseData + && equalTo((CreditLedgerEnrichedEntryResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditLedgerEnrichedEntryResponseData other) { + return billingCreditId.equals(other.billingCreditId) + && company.equals(other.company) + && companyId.equals(other.companyId) + && credit.equals(other.credit) + && expiredGrantCount == other.expiredGrantCount + && feature.equals(other.feature) + && featureId.equals(other.featureId) + && firstTransactionAt.equals(other.firstTransactionAt) + && freeGrantCount == other.freeGrantCount + && grantCount == other.grantCount + && lastTransactionAt.equals(other.lastTransactionAt) + && manuallyZeroedCount == other.manuallyZeroedCount + && netChange == other.netChange + && planGrantCount == other.planGrantCount + && purchasedGrantCount == other.purchasedGrantCount + && timeBucket.equals(other.timeBucket) + && totalConsumed == other.totalConsumed + && totalGranted == other.totalGranted + && transactionCount == other.transactionCount + && usageCount == other.usageCount + && zeroedOutCount == other.zeroedOutCount; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.billingCreditId, + this.company, + this.companyId, + this.credit, + this.expiredGrantCount, + this.feature, + this.featureId, + this.firstTransactionAt, + this.freeGrantCount, + this.grantCount, + this.lastTransactionAt, + this.manuallyZeroedCount, + this.netChange, + this.planGrantCount, + this.purchasedGrantCount, + this.timeBucket, + this.totalConsumed, + this.totalGranted, + this.transactionCount, + this.usageCount, + this.zeroedOutCount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BillingCreditIdStage builder() { + return new Builder(); + } + + public interface BillingCreditIdStage { + CompanyIdStage billingCreditId(@NotNull String billingCreditId); + + Builder from(CreditLedgerEnrichedEntryResponseData other); + } + + public interface CompanyIdStage { + ExpiredGrantCountStage companyId(@NotNull String companyId); + } + + public interface ExpiredGrantCountStage { + FirstTransactionAtStage expiredGrantCount(int expiredGrantCount); + } + + public interface FirstTransactionAtStage { + FreeGrantCountStage firstTransactionAt(@NotNull OffsetDateTime firstTransactionAt); + } + + public interface FreeGrantCountStage { + GrantCountStage freeGrantCount(int freeGrantCount); + } + + public interface GrantCountStage { + LastTransactionAtStage grantCount(int grantCount); + } + + public interface LastTransactionAtStage { + ManuallyZeroedCountStage lastTransactionAt(@NotNull OffsetDateTime lastTransactionAt); + } + + public interface ManuallyZeroedCountStage { + NetChangeStage manuallyZeroedCount(int manuallyZeroedCount); + } + + public interface NetChangeStage { + PlanGrantCountStage netChange(double netChange); + } + + public interface PlanGrantCountStage { + PurchasedGrantCountStage planGrantCount(int planGrantCount); + } + + public interface PurchasedGrantCountStage { + TimeBucketStage purchasedGrantCount(int purchasedGrantCount); + } + + public interface TimeBucketStage { + TotalConsumedStage timeBucket(@NotNull OffsetDateTime timeBucket); + } + + public interface TotalConsumedStage { + TotalGrantedStage totalConsumed(double totalConsumed); + } + + public interface TotalGrantedStage { + TransactionCountStage totalGranted(double totalGranted); + } + + public interface TransactionCountStage { + UsageCountStage transactionCount(int transactionCount); + } + + public interface UsageCountStage { + ZeroedOutCountStage usageCount(int usageCount); + } + + public interface ZeroedOutCountStage { + _FinalStage zeroedOutCount(int zeroedOutCount); + } + + public interface _FinalStage { + CreditLedgerEnrichedEntryResponseData build(); + + _FinalStage company(Optional company); + + _FinalStage company(CompanyLedgerResponseData company); + + _FinalStage credit(Optional credit); + + _FinalStage credit(BillingCreditLedgerResponseData credit); + + _FinalStage feature(Optional feature); + + _FinalStage feature(FeatureLedgerResponseData feature); + + _FinalStage featureId(Optional featureId); + + _FinalStage featureId(String featureId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements BillingCreditIdStage, + CompanyIdStage, + ExpiredGrantCountStage, + FirstTransactionAtStage, + FreeGrantCountStage, + GrantCountStage, + LastTransactionAtStage, + ManuallyZeroedCountStage, + NetChangeStage, + PlanGrantCountStage, + PurchasedGrantCountStage, + TimeBucketStage, + TotalConsumedStage, + TotalGrantedStage, + TransactionCountStage, + UsageCountStage, + ZeroedOutCountStage, + _FinalStage { + private String billingCreditId; + + private String companyId; + + private int expiredGrantCount; + + private OffsetDateTime firstTransactionAt; + + private int freeGrantCount; + + private int grantCount; + + private OffsetDateTime lastTransactionAt; + + private int manuallyZeroedCount; + + private double netChange; + + private int planGrantCount; + + private int purchasedGrantCount; + + private OffsetDateTime timeBucket; + + private double totalConsumed; + + private double totalGranted; + + private int transactionCount; + + private int usageCount; + + private int zeroedOutCount; + + private Optional featureId = Optional.empty(); + + private Optional feature = Optional.empty(); + + private Optional credit = Optional.empty(); + + private Optional company = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreditLedgerEnrichedEntryResponseData other) { + billingCreditId(other.getBillingCreditId()); + company(other.getCompany()); + companyId(other.getCompanyId()); + credit(other.getCredit()); + expiredGrantCount(other.getExpiredGrantCount()); + feature(other.getFeature()); + featureId(other.getFeatureId()); + firstTransactionAt(other.getFirstTransactionAt()); + freeGrantCount(other.getFreeGrantCount()); + grantCount(other.getGrantCount()); + lastTransactionAt(other.getLastTransactionAt()); + manuallyZeroedCount(other.getManuallyZeroedCount()); + netChange(other.getNetChange()); + planGrantCount(other.getPlanGrantCount()); + purchasedGrantCount(other.getPurchasedGrantCount()); + timeBucket(other.getTimeBucket()); + totalConsumed(other.getTotalConsumed()); + totalGranted(other.getTotalGranted()); + transactionCount(other.getTransactionCount()); + usageCount(other.getUsageCount()); + zeroedOutCount(other.getZeroedOutCount()); + return this; + } + + @java.lang.Override + @JsonSetter("billing_credit_id") + public CompanyIdStage billingCreditId(@NotNull String billingCreditId) { + this.billingCreditId = Objects.requireNonNull(billingCreditId, "billingCreditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public ExpiredGrantCountStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("expired_grant_count") + public FirstTransactionAtStage expiredGrantCount(int expiredGrantCount) { + this.expiredGrantCount = expiredGrantCount; + return this; + } + + @java.lang.Override + @JsonSetter("first_transaction_at") + public FreeGrantCountStage firstTransactionAt(@NotNull OffsetDateTime firstTransactionAt) { + this.firstTransactionAt = Objects.requireNonNull(firstTransactionAt, "firstTransactionAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("free_grant_count") + public GrantCountStage freeGrantCount(int freeGrantCount) { + this.freeGrantCount = freeGrantCount; + return this; + } + + @java.lang.Override + @JsonSetter("grant_count") + public LastTransactionAtStage grantCount(int grantCount) { + this.grantCount = grantCount; + return this; + } + + @java.lang.Override + @JsonSetter("last_transaction_at") + public ManuallyZeroedCountStage lastTransactionAt(@NotNull OffsetDateTime lastTransactionAt) { + this.lastTransactionAt = Objects.requireNonNull(lastTransactionAt, "lastTransactionAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("manually_zeroed_count") + public NetChangeStage manuallyZeroedCount(int manuallyZeroedCount) { + this.manuallyZeroedCount = manuallyZeroedCount; + return this; + } + + @java.lang.Override + @JsonSetter("net_change") + public PlanGrantCountStage netChange(double netChange) { + this.netChange = netChange; + return this; + } + + @java.lang.Override + @JsonSetter("plan_grant_count") + public PurchasedGrantCountStage planGrantCount(int planGrantCount) { + this.planGrantCount = planGrantCount; + return this; + } + + @java.lang.Override + @JsonSetter("purchased_grant_count") + public TimeBucketStage purchasedGrantCount(int purchasedGrantCount) { + this.purchasedGrantCount = purchasedGrantCount; + return this; + } + + @java.lang.Override + @JsonSetter("time_bucket") + public TotalConsumedStage timeBucket(@NotNull OffsetDateTime timeBucket) { + this.timeBucket = Objects.requireNonNull(timeBucket, "timeBucket must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("total_consumed") + public TotalGrantedStage totalConsumed(double totalConsumed) { + this.totalConsumed = totalConsumed; + return this; + } + + @java.lang.Override + @JsonSetter("total_granted") + public TransactionCountStage totalGranted(double totalGranted) { + this.totalGranted = totalGranted; + return this; + } + + @java.lang.Override + @JsonSetter("transaction_count") + public UsageCountStage transactionCount(int transactionCount) { + this.transactionCount = transactionCount; + return this; + } + + @java.lang.Override + @JsonSetter("usage_count") + public ZeroedOutCountStage usageCount(int usageCount) { + this.usageCount = usageCount; + return this; + } + + @java.lang.Override + @JsonSetter("zeroed_out_count") + public _FinalStage zeroedOutCount(int zeroedOutCount) { + this.zeroedOutCount = zeroedOutCount; + return this; + } + + @java.lang.Override + public _FinalStage featureId(String featureId) { + this.featureId = Optional.ofNullable(featureId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "feature_id", nulls = Nulls.SKIP) + public _FinalStage featureId(Optional featureId) { + this.featureId = featureId; + return this; + } + + @java.lang.Override + public _FinalStage feature(FeatureLedgerResponseData feature) { + this.feature = Optional.ofNullable(feature); + return this; + } + + @java.lang.Override + @JsonSetter(value = "feature", nulls = Nulls.SKIP) + public _FinalStage feature(Optional feature) { + this.feature = feature; + return this; + } + + @java.lang.Override + public _FinalStage credit(BillingCreditLedgerResponseData credit) { + this.credit = Optional.ofNullable(credit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit", nulls = Nulls.SKIP) + public _FinalStage credit(Optional credit) { + this.credit = credit; + return this; + } + + @java.lang.Override + public _FinalStage company(CompanyLedgerResponseData company) { + this.company = Optional.ofNullable(company); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Optional company) { + this.company = company; + return this; + } + + @java.lang.Override + public CreditLedgerEnrichedEntryResponseData build() { + return new CreditLedgerEnrichedEntryResponseData( + billingCreditId, + company, + companyId, + credit, + expiredGrantCount, + feature, + featureId, + firstTransactionAt, + freeGrantCount, + grantCount, + lastTransactionAt, + manuallyZeroedCount, + netChange, + planGrantCount, + purchasedGrantCount, + timeBucket, + totalConsumed, + totalGranted, + transactionCount, + usageCount, + zeroedOutCount, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CreditTriggerConfig.java b/src/main/java/com/schematic/api/types/CreditTriggerConfig.java new file mode 100644 index 0000000..c62d75d --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditTriggerConfig.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreditTriggerConfig.Builder.class) +public final class CreditTriggerConfig { + private final String creditId; + + private final Map additionalProperties; + + private CreditTriggerConfig(String creditId, Map additionalProperties) { + this.creditId = creditId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditTriggerConfig && equalTo((CreditTriggerConfig) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditTriggerConfig other) { + return creditId.equals(other.creditId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.creditId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreditIdStage builder() { + return new Builder(); + } + + public interface CreditIdStage { + _FinalStage creditId(@NotNull String creditId); + + Builder from(CreditTriggerConfig other); + } + + public interface _FinalStage { + CreditTriggerConfig build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CreditIdStage, _FinalStage { + private String creditId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreditTriggerConfig other) { + creditId(other.getCreditId()); + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public _FinalStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + public CreditTriggerConfig build() { + return new CreditTriggerConfig(creditId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CreditUsage.java b/src/main/java/com/schematic/api/types/CreditUsage.java new file mode 100644 index 0000000..15fa81e --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditUsage.java @@ -0,0 +1,283 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreditUsage.Builder.class) +public final class CreditUsage { + private final Optional creditConsumptionRate; + + private final Optional> creditGrantCounts; + + private final Optional> creditGrantDetails; + + private final Optional creditRemaining; + + private final Optional creditTotal; + + private final Optional creditTypeIcon; + + private final Optional creditTypeName; + + private final Optional creditUsed; + + private final Map additionalProperties; + + private CreditUsage( + Optional creditConsumptionRate, + Optional> creditGrantCounts, + Optional> creditGrantDetails, + Optional creditRemaining, + Optional creditTotal, + Optional creditTypeIcon, + Optional creditTypeName, + Optional creditUsed, + Map additionalProperties) { + this.creditConsumptionRate = creditConsumptionRate; + this.creditGrantCounts = creditGrantCounts; + this.creditGrantDetails = creditGrantDetails; + this.creditRemaining = creditRemaining; + this.creditTotal = creditTotal; + this.creditTypeIcon = creditTypeIcon; + this.creditTypeName = creditTypeName; + this.creditUsed = creditUsed; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + + @JsonProperty("credit_grant_counts") + public Optional> getCreditGrantCounts() { + return creditGrantCounts; + } + + @JsonProperty("credit_grant_details") + public Optional> getCreditGrantDetails() { + return creditGrantDetails; + } + + @JsonProperty("credit_remaining") + public Optional getCreditRemaining() { + return creditRemaining; + } + + @JsonProperty("credit_total") + public Optional getCreditTotal() { + return creditTotal; + } + + @JsonProperty("credit_type_icon") + public Optional getCreditTypeIcon() { + return creditTypeIcon; + } + + @JsonProperty("credit_type_name") + public Optional getCreditTypeName() { + return creditTypeName; + } + + @JsonProperty("credit_used") + public Optional getCreditUsed() { + return creditUsed; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditUsage && equalTo((CreditUsage) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditUsage other) { + return creditConsumptionRate.equals(other.creditConsumptionRate) + && creditGrantCounts.equals(other.creditGrantCounts) + && creditGrantDetails.equals(other.creditGrantDetails) + && creditRemaining.equals(other.creditRemaining) + && creditTotal.equals(other.creditTotal) + && creditTypeIcon.equals(other.creditTypeIcon) + && creditTypeName.equals(other.creditTypeName) + && creditUsed.equals(other.creditUsed); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.creditConsumptionRate, + this.creditGrantCounts, + this.creditGrantDetails, + this.creditRemaining, + this.creditTotal, + this.creditTypeIcon, + this.creditTypeName, + this.creditUsed); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional creditConsumptionRate = Optional.empty(); + + private Optional> creditGrantCounts = Optional.empty(); + + private Optional> creditGrantDetails = Optional.empty(); + + private Optional creditRemaining = Optional.empty(); + + private Optional creditTotal = Optional.empty(); + + private Optional creditTypeIcon = Optional.empty(); + + private Optional creditTypeName = Optional.empty(); + + private Optional creditUsed = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CreditUsage other) { + creditConsumptionRate(other.getCreditConsumptionRate()); + creditGrantCounts(other.getCreditGrantCounts()); + creditGrantDetails(other.getCreditGrantDetails()); + creditRemaining(other.getCreditRemaining()); + creditTotal(other.getCreditTotal()); + creditTypeIcon(other.getCreditTypeIcon()); + creditTypeName(other.getCreditTypeName()); + creditUsed(other.getCreditUsed()); + return this; + } + + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public Builder creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + + public Builder creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + @JsonSetter(value = "credit_grant_counts", nulls = Nulls.SKIP) + public Builder creditGrantCounts(Optional> creditGrantCounts) { + this.creditGrantCounts = creditGrantCounts; + return this; + } + + public Builder creditGrantCounts(Map creditGrantCounts) { + this.creditGrantCounts = Optional.ofNullable(creditGrantCounts); + return this; + } + + @JsonSetter(value = "credit_grant_details", nulls = Nulls.SKIP) + public Builder creditGrantDetails(Optional> creditGrantDetails) { + this.creditGrantDetails = creditGrantDetails; + return this; + } + + public Builder creditGrantDetails(List creditGrantDetails) { + this.creditGrantDetails = Optional.ofNullable(creditGrantDetails); + return this; + } + + @JsonSetter(value = "credit_remaining", nulls = Nulls.SKIP) + public Builder creditRemaining(Optional creditRemaining) { + this.creditRemaining = creditRemaining; + return this; + } + + public Builder creditRemaining(Double creditRemaining) { + this.creditRemaining = Optional.ofNullable(creditRemaining); + return this; + } + + @JsonSetter(value = "credit_total", nulls = Nulls.SKIP) + public Builder creditTotal(Optional creditTotal) { + this.creditTotal = creditTotal; + return this; + } + + public Builder creditTotal(Double creditTotal) { + this.creditTotal = Optional.ofNullable(creditTotal); + return this; + } + + @JsonSetter(value = "credit_type_icon", nulls = Nulls.SKIP) + public Builder creditTypeIcon(Optional creditTypeIcon) { + this.creditTypeIcon = creditTypeIcon; + return this; + } + + public Builder creditTypeIcon(String creditTypeIcon) { + this.creditTypeIcon = Optional.ofNullable(creditTypeIcon); + return this; + } + + @JsonSetter(value = "credit_type_name", nulls = Nulls.SKIP) + public Builder creditTypeName(Optional creditTypeName) { + this.creditTypeName = creditTypeName; + return this; + } + + public Builder creditTypeName(String creditTypeName) { + this.creditTypeName = Optional.ofNullable(creditTypeName); + return this; + } + + @JsonSetter(value = "credit_used", nulls = Nulls.SKIP) + public Builder creditUsed(Optional creditUsed) { + this.creditUsed = creditUsed; + return this; + } + + public Builder creditUsed(Double creditUsed) { + this.creditUsed = Optional.ofNullable(creditUsed); + return this; + } + + public CreditUsage build() { + return new CreditUsage( + creditConsumptionRate, + creditGrantCounts, + creditGrantDetails, + creditRemaining, + creditTotal, + creditTypeIcon, + creditTypeName, + creditUsed, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/CreditUsageResponseData.java b/src/main/java/com/schematic/api/types/CreditUsageResponseData.java new file mode 100644 index 0000000..1e9bbd5 --- /dev/null +++ b/src/main/java/com/schematic/api/types/CreditUsageResponseData.java @@ -0,0 +1,294 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreditUsageResponseData.Builder.class) +public final class CreditUsageResponseData { + private final Optional creditConsumptionRate; + + private final Optional> creditGrantCounts; + + private final List creditGrantDetails; + + private final Optional creditRemaining; + + private final Optional creditTotal; + + private final Optional creditTypeIcon; + + private final Optional creditTypeName; + + private final Optional creditUsed; + + private final Map additionalProperties; + + private CreditUsageResponseData( + Optional creditConsumptionRate, + Optional> creditGrantCounts, + List creditGrantDetails, + Optional creditRemaining, + Optional creditTotal, + Optional creditTypeIcon, + Optional creditTypeName, + Optional creditUsed, + Map additionalProperties) { + this.creditConsumptionRate = creditConsumptionRate; + this.creditGrantCounts = creditGrantCounts; + this.creditGrantDetails = creditGrantDetails; + this.creditRemaining = creditRemaining; + this.creditTotal = creditTotal; + this.creditTypeIcon = creditTypeIcon; + this.creditTypeName = creditTypeName; + this.creditUsed = creditUsed; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + + @JsonProperty("credit_grant_counts") + public Optional> getCreditGrantCounts() { + return creditGrantCounts; + } + + @JsonProperty("credit_grant_details") + public List getCreditGrantDetails() { + return creditGrantDetails; + } + + @JsonProperty("credit_remaining") + public Optional getCreditRemaining() { + return creditRemaining; + } + + @JsonProperty("credit_total") + public Optional getCreditTotal() { + return creditTotal; + } + + @JsonProperty("credit_type_icon") + public Optional getCreditTypeIcon() { + return creditTypeIcon; + } + + @JsonProperty("credit_type_name") + public Optional getCreditTypeName() { + return creditTypeName; + } + + @JsonProperty("credit_used") + public Optional getCreditUsed() { + return creditUsed; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreditUsageResponseData && equalTo((CreditUsageResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreditUsageResponseData other) { + return creditConsumptionRate.equals(other.creditConsumptionRate) + && creditGrantCounts.equals(other.creditGrantCounts) + && creditGrantDetails.equals(other.creditGrantDetails) + && creditRemaining.equals(other.creditRemaining) + && creditTotal.equals(other.creditTotal) + && creditTypeIcon.equals(other.creditTypeIcon) + && creditTypeName.equals(other.creditTypeName) + && creditUsed.equals(other.creditUsed); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.creditConsumptionRate, + this.creditGrantCounts, + this.creditGrantDetails, + this.creditRemaining, + this.creditTotal, + this.creditTypeIcon, + this.creditTypeName, + this.creditUsed); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional creditConsumptionRate = Optional.empty(); + + private Optional> creditGrantCounts = Optional.empty(); + + private List creditGrantDetails = new ArrayList<>(); + + private Optional creditRemaining = Optional.empty(); + + private Optional creditTotal = Optional.empty(); + + private Optional creditTypeIcon = Optional.empty(); + + private Optional creditTypeName = Optional.empty(); + + private Optional creditUsed = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CreditUsageResponseData other) { + creditConsumptionRate(other.getCreditConsumptionRate()); + creditGrantCounts(other.getCreditGrantCounts()); + creditGrantDetails(other.getCreditGrantDetails()); + creditRemaining(other.getCreditRemaining()); + creditTotal(other.getCreditTotal()); + creditTypeIcon(other.getCreditTypeIcon()); + creditTypeName(other.getCreditTypeName()); + creditUsed(other.getCreditUsed()); + return this; + } + + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public Builder creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + + public Builder creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + @JsonSetter(value = "credit_grant_counts", nulls = Nulls.SKIP) + public Builder creditGrantCounts(Optional> creditGrantCounts) { + this.creditGrantCounts = creditGrantCounts; + return this; + } + + public Builder creditGrantCounts(Map creditGrantCounts) { + this.creditGrantCounts = Optional.ofNullable(creditGrantCounts); + return this; + } + + @JsonSetter(value = "credit_grant_details", nulls = Nulls.SKIP) + public Builder creditGrantDetails(List creditGrantDetails) { + this.creditGrantDetails.clear(); + if (creditGrantDetails != null) { + this.creditGrantDetails.addAll(creditGrantDetails); + } + return this; + } + + public Builder addCreditGrantDetails(CreditGrantDetail creditGrantDetails) { + this.creditGrantDetails.add(creditGrantDetails); + return this; + } + + public Builder addAllCreditGrantDetails(List creditGrantDetails) { + if (creditGrantDetails != null) { + this.creditGrantDetails.addAll(creditGrantDetails); + } + return this; + } + + @JsonSetter(value = "credit_remaining", nulls = Nulls.SKIP) + public Builder creditRemaining(Optional creditRemaining) { + this.creditRemaining = creditRemaining; + return this; + } + + public Builder creditRemaining(Double creditRemaining) { + this.creditRemaining = Optional.ofNullable(creditRemaining); + return this; + } + + @JsonSetter(value = "credit_total", nulls = Nulls.SKIP) + public Builder creditTotal(Optional creditTotal) { + this.creditTotal = creditTotal; + return this; + } + + public Builder creditTotal(Double creditTotal) { + this.creditTotal = Optional.ofNullable(creditTotal); + return this; + } + + @JsonSetter(value = "credit_type_icon", nulls = Nulls.SKIP) + public Builder creditTypeIcon(Optional creditTypeIcon) { + this.creditTypeIcon = creditTypeIcon; + return this; + } + + public Builder creditTypeIcon(String creditTypeIcon) { + this.creditTypeIcon = Optional.ofNullable(creditTypeIcon); + return this; + } + + @JsonSetter(value = "credit_type_name", nulls = Nulls.SKIP) + public Builder creditTypeName(Optional creditTypeName) { + this.creditTypeName = creditTypeName; + return this; + } + + public Builder creditTypeName(String creditTypeName) { + this.creditTypeName = Optional.ofNullable(creditTypeName); + return this; + } + + @JsonSetter(value = "credit_used", nulls = Nulls.SKIP) + public Builder creditUsed(Optional creditUsed) { + this.creditUsed = creditUsed; + return this; + } + + public Builder creditUsed(Double creditUsed) { + this.creditUsed = Optional.ofNullable(creditUsed); + return this; + } + + public CreditUsageResponseData build() { + return new CreditUsageResponseData( + creditConsumptionRate, + creditGrantCounts, + creditGrantDetails, + creditRemaining, + creditTotal, + creditTypeIcon, + creditTypeName, + creditUsed, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/DataExportResponseData.java b/src/main/java/com/schematic/api/types/DataExportResponseData.java new file mode 100644 index 0000000..f043bed --- /dev/null +++ b/src/main/java/com/schematic/api/types/DataExportResponseData.java @@ -0,0 +1,326 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DataExportResponseData.Builder.class) +public final class DataExportResponseData { + private final String accountId; + + private final OffsetDateTime createdAt; + + private final String environmentId; + + private final String exportType; + + private final String id; + + private final String metadata; + + private final String outputFileType; + + private final String status; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private DataExportResponseData( + String accountId, + OffsetDateTime createdAt, + String environmentId, + String exportType, + String id, + String metadata, + String outputFileType, + String status, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.accountId = accountId; + this.createdAt = createdAt; + this.environmentId = environmentId; + this.exportType = exportType; + this.id = id; + this.metadata = metadata; + this.outputFileType = outputFileType; + this.status = status; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("account_id") + public String getAccountId() { + return accountId; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("environment_id") + public String getEnvironmentId() { + return environmentId; + } + + @JsonProperty("export_type") + public String getExportType() { + return exportType; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("metadata") + public String getMetadata() { + return metadata; + } + + @JsonProperty("output_file_type") + public String getOutputFileType() { + return outputFileType; + } + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataExportResponseData && equalTo((DataExportResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataExportResponseData other) { + return accountId.equals(other.accountId) + && createdAt.equals(other.createdAt) + && environmentId.equals(other.environmentId) + && exportType.equals(other.exportType) + && id.equals(other.id) + && metadata.equals(other.metadata) + && outputFileType.equals(other.outputFileType) + && status.equals(other.status) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.accountId, + this.createdAt, + this.environmentId, + this.exportType, + this.id, + this.metadata, + this.outputFileType, + this.status, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AccountIdStage builder() { + return new Builder(); + } + + public interface AccountIdStage { + CreatedAtStage accountId(@NotNull String accountId); + + Builder from(DataExportResponseData other); + } + + public interface CreatedAtStage { + EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface EnvironmentIdStage { + ExportTypeStage environmentId(@NotNull String environmentId); + } + + public interface ExportTypeStage { + IdStage exportType(@NotNull String exportType); + } + + public interface IdStage { + MetadataStage id(@NotNull String id); + } + + public interface MetadataStage { + OutputFileTypeStage metadata(@NotNull String metadata); + } + + public interface OutputFileTypeStage { + StatusStage outputFileType(@NotNull String outputFileType); + } + + public interface StatusStage { + UpdatedAtStage status(@NotNull String status); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + DataExportResponseData build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AccountIdStage, + CreatedAtStage, + EnvironmentIdStage, + ExportTypeStage, + IdStage, + MetadataStage, + OutputFileTypeStage, + StatusStage, + UpdatedAtStage, + _FinalStage { + private String accountId; + + private OffsetDateTime createdAt; + + private String environmentId; + + private String exportType; + + private String id; + + private String metadata; + + private String outputFileType; + + private String status; + + private OffsetDateTime updatedAt; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DataExportResponseData other) { + accountId(other.getAccountId()); + createdAt(other.getCreatedAt()); + environmentId(other.getEnvironmentId()); + exportType(other.getExportType()); + id(other.getId()); + metadata(other.getMetadata()); + outputFileType(other.getOutputFileType()); + status(other.getStatus()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("account_id") + public CreatedAtStage accountId(@NotNull String accountId) { + this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("environment_id") + public ExportTypeStage environmentId(@NotNull String environmentId) { + this.environmentId = Objects.requireNonNull(environmentId, "environmentId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("export_type") + public IdStage exportType(@NotNull String exportType) { + this.exportType = Objects.requireNonNull(exportType, "exportType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public MetadataStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("metadata") + public OutputFileTypeStage metadata(@NotNull String metadata) { + this.metadata = Objects.requireNonNull(metadata, "metadata must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("output_file_type") + public StatusStage outputFileType(@NotNull String outputFileType) { + this.outputFileType = Objects.requireNonNull(outputFileType, "outputFileType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("status") + public UpdatedAtStage status(@NotNull String status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public DataExportResponseData build() { + return new DataExportResponseData( + accountId, + createdAt, + environmentId, + exportType, + id, + metadata, + outputFileType, + status, + updatedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/DeleteResponse.java b/src/main/java/com/schematic/api/types/DeleteResponse.java index 1970414..94308eb 100644 --- a/src/main/java/com/schematic/api/types/DeleteResponse.java +++ b/src/main/java/com/schematic/api/types/DeleteResponse.java @@ -80,6 +80,9 @@ public Builder from(DeleteResponse other) { return this; } + /** + *

Whether the delete was successful

+ */ @JsonSetter(value = "deleted", nulls = Nulls.SKIP) public Builder deleted(Optional deleted) { this.deleted = deleted; diff --git a/src/main/java/com/schematic/api/types/EntitlementTriggerConfig.java b/src/main/java/com/schematic/api/types/EntitlementTriggerConfig.java new file mode 100644 index 0000000..19f5934 --- /dev/null +++ b/src/main/java/com/schematic/api/types/EntitlementTriggerConfig.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = EntitlementTriggerConfig.Builder.class) +public final class EntitlementTriggerConfig { + private final String featureId; + + private final Map additionalProperties; + + private EntitlementTriggerConfig(String featureId, Map additionalProperties) { + this.featureId = featureId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("feature_id") + public String getFeatureId() { + return featureId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EntitlementTriggerConfig && equalTo((EntitlementTriggerConfig) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EntitlementTriggerConfig other) { + return featureId.equals(other.featureId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.featureId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static FeatureIdStage builder() { + return new Builder(); + } + + public interface FeatureIdStage { + _FinalStage featureId(@NotNull String featureId); + + Builder from(EntitlementTriggerConfig other); + } + + public interface _FinalStage { + EntitlementTriggerConfig build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements FeatureIdStage, _FinalStage { + private String featureId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(EntitlementTriggerConfig other) { + featureId(other.getFeatureId()); + return this; + } + + @java.lang.Override + @JsonSetter("feature_id") + public _FinalStage featureId(@NotNull String featureId) { + this.featureId = Objects.requireNonNull(featureId, "featureId must not be null"); + return this; + } + + @java.lang.Override + public EntitlementTriggerConfig build() { + return new EntitlementTriggerConfig(featureId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/EntityTraitDefinitionResponseData.java b/src/main/java/com/schematic/api/types/EntityTraitDefinitionResponseData.java index 43e19c9..c397434 100644 --- a/src/main/java/com/schematic/api/types/EntityTraitDefinitionResponseData.java +++ b/src/main/java/com/schematic/api/types/EntityTraitDefinitionResponseData.java @@ -255,7 +255,9 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { @java.lang.Override public _FinalStage addAllHierarchy(List hierarchy) { - this.hierarchy.addAll(hierarchy); + if (hierarchy != null) { + this.hierarchy.addAll(hierarchy); + } return this; } @@ -269,7 +271,9 @@ public _FinalStage addHierarchy(String hierarchy) { @JsonSetter(value = "hierarchy", nulls = Nulls.SKIP) public _FinalStage hierarchy(List hierarchy) { this.hierarchy.clear(); - this.hierarchy.addAll(hierarchy); + if (hierarchy != null) { + this.hierarchy.addAll(hierarchy); + } return this; } diff --git a/src/main/java/com/schematic/api/types/EnvironmentDetailResponseData.java b/src/main/java/com/schematic/api/types/EnvironmentDetailResponseData.java index 0d8ca0a..c8fb78f 100644 --- a/src/main/java/com/schematic/api/types/EnvironmentDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/EnvironmentDetailResponseData.java @@ -218,7 +218,9 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { @java.lang.Override public _FinalStage addAllApiKeys(List apiKeys) { - this.apiKeys.addAll(apiKeys); + if (apiKeys != null) { + this.apiKeys.addAll(apiKeys); + } return this; } @@ -232,7 +234,9 @@ public _FinalStage addApiKeys(ApiKeyResponseData apiKeys) { @JsonSetter(value = "api_keys", nulls = Nulls.SKIP) public _FinalStage apiKeys(List apiKeys) { this.apiKeys.clear(); - this.apiKeys.addAll(apiKeys); + if (apiKeys != null) { + this.apiKeys.addAll(apiKeys); + } return this; } diff --git a/src/main/java/com/schematic/api/types/EventBody.java b/src/main/java/com/schematic/api/types/EventBody.java index 0dc881f..9f05eb4 100644 --- a/src/main/java/com/schematic/api/types/EventBody.java +++ b/src/main/java/com/schematic/api/types/EventBody.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((EventBodyTrack) this.value); @@ -90,15 +91,15 @@ public EventBody deserialize(JsonParser p, DeserializationContext context) throw Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventBodyTrack.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventBodyFlagCheck.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventBodyIdentify.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } throw new JsonParseException(p, "Failed to deserialize"); } diff --git a/src/main/java/com/schematic/api/types/EventBodyFlagCheck.java b/src/main/java/com/schematic/api/types/EventBodyFlagCheck.java index 80e3118..951a3a3 100644 --- a/src/main/java/com/schematic/api/types/EventBodyFlagCheck.java +++ b/src/main/java/com/schematic/api/types/EventBodyFlagCheck.java @@ -197,46 +197,76 @@ public static FlagKeyStage builder() { } public interface FlagKeyStage { + /** + *

The key of the flag being checked

+ */ ReasonStage flagKey(@NotNull String flagKey); Builder from(EventBodyFlagCheck other); } public interface ReasonStage { + /** + *

The reason why the value was returned

+ */ ValueStage reason(@NotNull String reason); } public interface ValueStage { + /** + *

The value of the flag for the given company and/or user

+ */ _FinalStage value(boolean value); } public interface _FinalStage { EventBodyFlagCheck build(); + /** + *

Schematic company ID (starting with 'comp_') of the company evaluated, if any

+ */ _FinalStage companyId(Optional companyId); _FinalStage companyId(String companyId); + /** + *

Report an error that occurred during the flag check

+ */ _FinalStage error(Optional error); _FinalStage error(String error); + /** + *

Schematic flag ID (starting with 'flag_') for the flag matching the key, if any

+ */ _FinalStage flagId(Optional flagId); _FinalStage flagId(String flagId); + /** + *

Key-value pairs used to to identify company for which the flag was checked

+ */ _FinalStage reqCompany(Optional> reqCompany); _FinalStage reqCompany(Map reqCompany); + /** + *

Key-value pairs used to to identify user for which the flag was checked

+ */ _FinalStage reqUser(Optional> reqUser); _FinalStage reqUser(Map reqUser); + /** + *

Schematic rule ID (starting with 'rule_') of the rule that matched for the flag, if any

+ */ _FinalStage ruleId(Optional ruleId); _FinalStage ruleId(String ruleId); + /** + *

Schematic user ID (starting with 'user_') of the user evaluated, if any

+ */ _FinalStage userId(Optional userId); _FinalStage userId(String userId); @@ -285,6 +315,7 @@ public Builder from(EventBodyFlagCheck other) { } /** + *

The key of the flag being checked

*

The key of the flag being checked

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -296,6 +327,7 @@ public ReasonStage flagKey(@NotNull String flagKey) { } /** + *

The reason why the value was returned

*

The reason why the value was returned

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -307,6 +339,7 @@ public ValueStage reason(@NotNull String reason) { } /** + *

The value of the flag for the given company and/or user

*

The value of the flag for the given company and/or user

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -327,6 +360,9 @@ public _FinalStage userId(String userId) { return this; } + /** + *

Schematic user ID (starting with 'user_') of the user evaluated, if any

+ */ @java.lang.Override @JsonSetter(value = "user_id", nulls = Nulls.SKIP) public _FinalStage userId(Optional userId) { @@ -344,6 +380,9 @@ public _FinalStage ruleId(String ruleId) { return this; } + /** + *

Schematic rule ID (starting with 'rule_') of the rule that matched for the flag, if any

+ */ @java.lang.Override @JsonSetter(value = "rule_id", nulls = Nulls.SKIP) public _FinalStage ruleId(Optional ruleId) { @@ -361,6 +400,9 @@ public _FinalStage reqUser(Map reqUser) { return this; } + /** + *

Key-value pairs used to to identify user for which the flag was checked

+ */ @java.lang.Override @JsonSetter(value = "req_user", nulls = Nulls.SKIP) public _FinalStage reqUser(Optional> reqUser) { @@ -378,6 +420,9 @@ public _FinalStage reqCompany(Map reqCompany) { return this; } + /** + *

Key-value pairs used to to identify company for which the flag was checked

+ */ @java.lang.Override @JsonSetter(value = "req_company", nulls = Nulls.SKIP) public _FinalStage reqCompany(Optional> reqCompany) { @@ -395,6 +440,9 @@ public _FinalStage flagId(String flagId) { return this; } + /** + *

Schematic flag ID (starting with 'flag_') for the flag matching the key, if any

+ */ @java.lang.Override @JsonSetter(value = "flag_id", nulls = Nulls.SKIP) public _FinalStage flagId(Optional flagId) { @@ -412,6 +460,9 @@ public _FinalStage error(String error) { return this; } + /** + *

Report an error that occurred during the flag check

+ */ @java.lang.Override @JsonSetter(value = "error", nulls = Nulls.SKIP) public _FinalStage error(Optional error) { @@ -429,6 +480,9 @@ public _FinalStage companyId(String companyId) { return this; } + /** + *

Schematic company ID (starting with 'comp_') of the company evaluated, if any

+ */ @java.lang.Override @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public _FinalStage companyId(Optional companyId) { diff --git a/src/main/java/com/schematic/api/types/EventBodyIdentify.java b/src/main/java/com/schematic/api/types/EventBodyIdentify.java index f173366..4fa0403 100644 --- a/src/main/java/com/schematic/api/types/EventBodyIdentify.java +++ b/src/main/java/com/schematic/api/types/EventBodyIdentify.java @@ -132,6 +132,9 @@ public Builder from(EventBodyIdentify other) { return this; } + /** + *

Information about the company associated with the user; required only if it is a new user

+ */ @JsonSetter(value = "company", nulls = Nulls.SKIP) public Builder company(Optional company) { this.company = company; @@ -143,15 +146,22 @@ public Builder company(EventBodyIdentifyCompany company) { return this; } + /** + *

Key-value pairs to identify the user

+ */ @JsonSetter(value = "keys", nulls = Nulls.SKIP) public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } @@ -160,6 +170,9 @@ public Builder keys(String key, String value) { return this; } + /** + *

The display name of the user being identified; required only if it is a new user

+ */ @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -171,6 +184,9 @@ public Builder name(String name) { return this; } + /** + *

A map of trait names to trait values

+ */ @JsonSetter(value = "traits", nulls = Nulls.SKIP) public Builder traits(Optional> traits) { this.traits = traits; diff --git a/src/main/java/com/schematic/api/types/EventBodyIdentifyCompany.java b/src/main/java/com/schematic/api/types/EventBodyIdentifyCompany.java index 40ac5c3..3d8a1dd 100644 --- a/src/main/java/com/schematic/api/types/EventBodyIdentifyCompany.java +++ b/src/main/java/com/schematic/api/types/EventBodyIdentifyCompany.java @@ -114,15 +114,22 @@ public Builder from(EventBodyIdentifyCompany other) { return this; } + /** + *

Key-value pairs to identify the company

+ */ @JsonSetter(value = "keys", nulls = Nulls.SKIP) public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } @@ -131,6 +138,9 @@ public Builder keys(String key, String value) { return this; } + /** + *

The display name of the company; required only if it is a new company

+ */ @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -142,6 +152,9 @@ public Builder name(String name) { return this; } + /** + *

A map of trait names to trait values

+ */ @JsonSetter(value = "traits", nulls = Nulls.SKIP) public Builder traits(Optional> traits) { this.traits = traits; diff --git a/src/main/java/com/schematic/api/types/EventBodyTrack.java b/src/main/java/com/schematic/api/types/EventBodyTrack.java index b1ccba8..b33576d 100644 --- a/src/main/java/com/schematic/api/types/EventBodyTrack.java +++ b/src/main/java/com/schematic/api/types/EventBodyTrack.java @@ -123,6 +123,9 @@ public static EventStage builder() { } public interface EventStage { + /** + *

The name of the type of track event

+ */ _FinalStage event(@NotNull String event); Builder from(EventBodyTrack other); @@ -131,18 +134,30 @@ public interface EventStage { public interface _FinalStage { EventBodyTrack build(); + /** + *

Key-value pairs to identify company associated with track event

+ */ _FinalStage company(Optional> company); _FinalStage company(Map company); + /** + *

Optionally specify the quantity of the event

+ */ _FinalStage quantity(Optional quantity); _FinalStage quantity(Integer quantity); + /** + *

A map of trait names to trait values

+ */ _FinalStage traits(Optional> traits); _FinalStage traits(Map traits); + /** + *

Key-value pairs to identify user associated with track event

+ */ _FinalStage user(Optional> user); _FinalStage user(Map user); @@ -176,6 +191,7 @@ public Builder from(EventBodyTrack other) { } /** + *

The name of the type of track event

*

The name of the type of track event

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -196,6 +212,9 @@ public _FinalStage user(Map user) { return this; } + /** + *

Key-value pairs to identify user associated with track event

+ */ @java.lang.Override @JsonSetter(value = "user", nulls = Nulls.SKIP) public _FinalStage user(Optional> user) { @@ -213,6 +232,9 @@ public _FinalStage traits(Map traits) { return this; } + /** + *

A map of trait names to trait values

+ */ @java.lang.Override @JsonSetter(value = "traits", nulls = Nulls.SKIP) public _FinalStage traits(Optional> traits) { @@ -230,6 +252,9 @@ public _FinalStage quantity(Integer quantity) { return this; } + /** + *

Optionally specify the quantity of the event

+ */ @java.lang.Override @JsonSetter(value = "quantity", nulls = Nulls.SKIP) public _FinalStage quantity(Optional quantity) { @@ -247,6 +272,9 @@ public _FinalStage company(Map company) { return this; } + /** + *

Key-value pairs to identify company associated with track event

+ */ @java.lang.Override @JsonSetter(value = "company", nulls = Nulls.SKIP) public _FinalStage company(Optional> company) { diff --git a/src/main/java/com/schematic/api/types/EventDetailResponseData.java b/src/main/java/com/schematic/api/types/EventDetailResponseData.java index 9cc34c1..e02e5a8 100644 --- a/src/main/java/com/schematic/api/types/EventDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/EventDetailResponseData.java @@ -618,7 +618,9 @@ public _FinalStage loadedAt(Optional loadedAt) { @java.lang.Override public _FinalStage addAllFeatures(List features) { - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @@ -632,13 +634,17 @@ public _FinalStage addFeatures(PreviewObject features) { @JsonSetter(value = "features", nulls = Nulls.SKIP) public _FinalStage features(List features) { this.features.clear(); - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @java.lang.Override public _FinalStage addAllFeatureIds(List featureIds) { - this.featureIds.addAll(featureIds); + if (featureIds != null) { + this.featureIds.addAll(featureIds); + } return this; } @@ -652,7 +658,9 @@ public _FinalStage addFeatureIds(String featureIds) { @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) public _FinalStage featureIds(List featureIds) { this.featureIds.clear(); - this.featureIds.addAll(featureIds); + if (featureIds != null) { + this.featureIds.addAll(featureIds); + } return this; } @@ -729,7 +737,9 @@ public _FinalStage body(String key, JsonNode value) { @java.lang.Override public _FinalStage putAllBody(Map body) { - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } @@ -737,7 +747,9 @@ public _FinalStage putAllBody(Map body) { @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Map body) { this.body.clear(); - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } diff --git a/src/main/java/com/schematic/api/types/EventResponseData.java b/src/main/java/com/schematic/api/types/EventResponseData.java index 23a4f8a..cdbf66d 100644 --- a/src/main/java/com/schematic/api/types/EventResponseData.java +++ b/src/main/java/com/schematic/api/types/EventResponseData.java @@ -549,7 +549,9 @@ public _FinalStage loadedAt(Optional loadedAt) { @java.lang.Override public _FinalStage addAllFeatureIds(List featureIds) { - this.featureIds.addAll(featureIds); + if (featureIds != null) { + this.featureIds.addAll(featureIds); + } return this; } @@ -563,7 +565,9 @@ public _FinalStage addFeatureIds(String featureIds) { @JsonSetter(value = "feature_ids", nulls = Nulls.SKIP) public _FinalStage featureIds(List featureIds) { this.featureIds.clear(); - this.featureIds.addAll(featureIds); + if (featureIds != null) { + this.featureIds.addAll(featureIds); + } return this; } @@ -627,7 +631,9 @@ public _FinalStage body(String key, JsonNode value) { @java.lang.Override public _FinalStage putAllBody(Map body) { - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } @@ -635,7 +641,9 @@ public _FinalStage putAllBody(Map body) { @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Map body) { this.body.clear(); - this.body.putAll(body); + if (body != null) { + this.body.putAll(body); + } return this; } diff --git a/src/main/java/com/schematic/api/types/FeatureCompanyResponseData.java b/src/main/java/com/schematic/api/types/FeatureCompanyResponseData.java index 2dba20c..3aaa7a6 100644 --- a/src/main/java/com/schematic/api/types/FeatureCompanyResponseData.java +++ b/src/main/java/com/schematic/api/types/FeatureCompanyResponseData.java @@ -14,6 +14,7 @@ import com.schematic.api.core.ObjectMappers; import java.time.OffsetDateTime; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -30,24 +31,68 @@ public final class FeatureCompanyResponseData { private final Optional company; + private final Optional companyOverride; + + private final Optional creditConsumptionRate; + + private final Optional> creditGrantCounts; + + private final Optional> creditGrantDetails; + + private final Optional creditGrantReason; + + private final Optional creditRemaining; + + private final Optional creditTotal; + + private final Optional creditTypeIcon; + + private final Optional creditUsage; + + private final Optional creditUsed; + + private final Optional effectiveLimit; + + private final Optional effectivePrice; + private final Optional entitlementExpirationDate; private final String entitlementId; + private final Optional entitlementSource; + private final String entitlementType; private final Optional feature; + private final Optional hasValidAllocation; + + private final Optional isUnlimited; + private final Optional metricResetAt; private final Optional monthReset; + private final Optional monthlyUsageBasedPrice; + + private final Optional overuse; + + private final Optional percentUsed; + private final Optional period; private final Optional plan; + private final Optional planEntitlement; + + private final Optional priceBehavior; + + private final Optional softLimit; + private final Optional usage; + private final Optional yearlyUsageBasedPrice; + private final Map additionalProperties; private FeatureCompanyResponseData( @@ -55,29 +100,73 @@ private FeatureCompanyResponseData( Optional allocation, FeatureCompanyResponseDataAllocationType allocationType, Optional company, + Optional companyOverride, + Optional creditConsumptionRate, + Optional> creditGrantCounts, + Optional> creditGrantDetails, + Optional creditGrantReason, + Optional creditRemaining, + Optional creditTotal, + Optional creditTypeIcon, + Optional creditUsage, + Optional creditUsed, + Optional effectiveLimit, + Optional effectivePrice, Optional entitlementExpirationDate, String entitlementId, + Optional entitlementSource, String entitlementType, Optional feature, + Optional hasValidAllocation, + Optional isUnlimited, Optional metricResetAt, Optional monthReset, + Optional monthlyUsageBasedPrice, + Optional overuse, + Optional percentUsed, Optional period, Optional plan, + Optional planEntitlement, + Optional priceBehavior, + Optional softLimit, Optional usage, + Optional yearlyUsageBasedPrice, Map additionalProperties) { this.access = access; this.allocation = allocation; this.allocationType = allocationType; this.company = company; + this.companyOverride = companyOverride; + this.creditConsumptionRate = creditConsumptionRate; + this.creditGrantCounts = creditGrantCounts; + this.creditGrantDetails = creditGrantDetails; + this.creditGrantReason = creditGrantReason; + this.creditRemaining = creditRemaining; + this.creditTotal = creditTotal; + this.creditTypeIcon = creditTypeIcon; + this.creditUsage = creditUsage; + this.creditUsed = creditUsed; + this.effectiveLimit = effectiveLimit; + this.effectivePrice = effectivePrice; this.entitlementExpirationDate = entitlementExpirationDate; this.entitlementId = entitlementId; + this.entitlementSource = entitlementSource; this.entitlementType = entitlementType; this.feature = feature; + this.hasValidAllocation = hasValidAllocation; + this.isUnlimited = isUnlimited; this.metricResetAt = metricResetAt; this.monthReset = monthReset; + this.monthlyUsageBasedPrice = monthlyUsageBasedPrice; + this.overuse = overuse; + this.percentUsed = percentUsed; this.period = period; this.plan = plan; + this.planEntitlement = planEntitlement; + this.priceBehavior = priceBehavior; + this.softLimit = softLimit; this.usage = usage; + this.yearlyUsageBasedPrice = yearlyUsageBasedPrice; this.additionalProperties = additionalProperties; } @@ -110,6 +199,81 @@ public Optional getCompany() { return company; } + @JsonProperty("company_override") + public Optional getCompanyOverride() { + return companyOverride; + } + + /** + * @return The rate at which credits are consumed per unit of usage + */ + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + + @JsonProperty("credit_grant_counts") + public Optional> getCreditGrantCounts() { + return creditGrantCounts; + } + + @JsonProperty("credit_grant_details") + public Optional> getCreditGrantDetails() { + return creditGrantDetails; + } + + /** + * @return Reason for the credit grant + */ + @JsonProperty("credit_grant_reason") + public Optional getCreditGrantReason() { + return creditGrantReason; + } + + @JsonProperty("credit_remaining") + public Optional getCreditRemaining() { + return creditRemaining; + } + + @JsonProperty("credit_total") + public Optional getCreditTotal() { + return creditTotal; + } + + /** + * @return Icon identifier for the credit type + */ + @JsonProperty("credit_type_icon") + public Optional getCreditTypeIcon() { + return creditTypeIcon; + } + + @JsonProperty("credit_usage") + public Optional getCreditUsage() { + return creditUsage; + } + + @JsonProperty("credit_used") + public Optional getCreditUsed() { + return creditUsed; + } + + /** + * @return Effective limit for usage calculations. For overage pricing, this is the soft limit where overage charges begin. For tiered pricing, this is the first tier boundary. For other pricing models, this is the base allocation. Used to calculate usage percentages and determine access thresholds. + */ + @JsonProperty("effective_limit") + public Optional getEffectiveLimit() { + return effectiveLimit; + } + + /** + * @return Per-unit price for current usage scenario + */ + @JsonProperty("effective_price") + public Optional getEffectivePrice() { + return effectivePrice; + } + @JsonProperty("entitlement_expiration_date") public Optional getEntitlementExpirationDate() { return entitlementExpirationDate; @@ -120,6 +284,14 @@ public String getEntitlementId() { return entitlementId; } + /** + * @return Source of the entitlement (plan or company_override) + */ + @JsonProperty("entitlement_source") + public Optional getEntitlementSource() { + return entitlementSource; + } + @JsonProperty("entitlement_type") public String getEntitlementType() { return entitlementType; @@ -131,7 +303,23 @@ public Optional getFeature() { } /** - * @return The time at which the metric will resets. + * @return Whether a valid allocation exists + */ + @JsonProperty("has_valid_allocation") + public Optional getHasValidAllocation() { + return hasValidAllocation; + } + + /** + * @return Whether this is an unlimited allocation + */ + @JsonProperty("is_unlimited") + public Optional getIsUnlimited() { + return isUnlimited; + } + + /** + * @return The time at which the metric will reset. */ @JsonProperty("metric_reset_at") public Optional getMetricResetAt() { @@ -146,6 +334,27 @@ public Optional getMonthReset() { return monthReset; } + @JsonProperty("monthly_usage_based_price") + public Optional getMonthlyUsageBasedPrice() { + return monthlyUsageBasedPrice; + } + + /** + * @return Amount of usage exceeding soft limit (overage pricing only) + */ + @JsonProperty("overuse") + public Optional getOveruse() { + return overuse; + } + + /** + * @return Percentage of allocation consumed (0-100+) + */ + @JsonProperty("percent_used") + public Optional getPercentUsed() { + return percentUsed; + } + /** * @return The period over which usage is measured. */ @@ -159,6 +368,24 @@ public Optional getPlan() { return plan; } + @JsonProperty("plan_entitlement") + public Optional getPlanEntitlement() { + return planEntitlement; + } + + @JsonProperty("price_behavior") + public Optional getPriceBehavior() { + return priceBehavior; + } + + /** + * @return The soft limit for the feature usage. Available only for overage price behavior + */ + @JsonProperty("soft_limit") + public Optional getSoftLimit() { + return softLimit; + } + /** * @return The amount of usage that has been consumed; a null value indicates that usage is not being measured. */ @@ -167,6 +394,11 @@ public Optional getUsage() { return usage; } + @JsonProperty("yearly_usage_based_price") + public Optional getYearlyUsageBasedPrice() { + return yearlyUsageBasedPrice; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -183,15 +415,37 @@ private boolean equalTo(FeatureCompanyResponseData other) { && allocation.equals(other.allocation) && allocationType.equals(other.allocationType) && company.equals(other.company) + && companyOverride.equals(other.companyOverride) + && creditConsumptionRate.equals(other.creditConsumptionRate) + && creditGrantCounts.equals(other.creditGrantCounts) + && creditGrantDetails.equals(other.creditGrantDetails) + && creditGrantReason.equals(other.creditGrantReason) + && creditRemaining.equals(other.creditRemaining) + && creditTotal.equals(other.creditTotal) + && creditTypeIcon.equals(other.creditTypeIcon) + && creditUsage.equals(other.creditUsage) + && creditUsed.equals(other.creditUsed) + && effectiveLimit.equals(other.effectiveLimit) + && effectivePrice.equals(other.effectivePrice) && entitlementExpirationDate.equals(other.entitlementExpirationDate) && entitlementId.equals(other.entitlementId) + && entitlementSource.equals(other.entitlementSource) && entitlementType.equals(other.entitlementType) && feature.equals(other.feature) + && hasValidAllocation.equals(other.hasValidAllocation) + && isUnlimited.equals(other.isUnlimited) && metricResetAt.equals(other.metricResetAt) && monthReset.equals(other.monthReset) + && monthlyUsageBasedPrice.equals(other.monthlyUsageBasedPrice) + && overuse.equals(other.overuse) + && percentUsed.equals(other.percentUsed) && period.equals(other.period) && plan.equals(other.plan) - && usage.equals(other.usage); + && planEntitlement.equals(other.planEntitlement) + && priceBehavior.equals(other.priceBehavior) + && softLimit.equals(other.softLimit) + && usage.equals(other.usage) + && yearlyUsageBasedPrice.equals(other.yearlyUsageBasedPrice); } @java.lang.Override @@ -201,15 +455,37 @@ public int hashCode() { this.allocation, this.allocationType, this.company, + this.companyOverride, + this.creditConsumptionRate, + this.creditGrantCounts, + this.creditGrantDetails, + this.creditGrantReason, + this.creditRemaining, + this.creditTotal, + this.creditTypeIcon, + this.creditUsage, + this.creditUsed, + this.effectiveLimit, + this.effectivePrice, this.entitlementExpirationDate, this.entitlementId, + this.entitlementSource, this.entitlementType, this.feature, + this.hasValidAllocation, + this.isUnlimited, this.metricResetAt, this.monthReset, + this.monthlyUsageBasedPrice, + this.overuse, + this.percentUsed, this.period, this.plan, - this.usage); + this.planEntitlement, + this.priceBehavior, + this.softLimit, + this.usage, + this.yearlyUsageBasedPrice); } @java.lang.Override @@ -222,12 +498,18 @@ public static AccessStage builder() { } public interface AccessStage { + /** + *

Whether further usage is permitted.

+ */ AllocationTypeStage access(boolean access); Builder from(FeatureCompanyResponseData other); } public interface AllocationTypeStage { + /** + *

The type of allocation that is being used.

+ */ EntitlementIdStage allocationType(@NotNull FeatureCompanyResponseDataAllocationType allocationType); } @@ -242,6 +524,9 @@ public interface EntitlementTypeStage { public interface _FinalStage { FeatureCompanyResponseData build(); + /** + *

The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted.

+ */ _FinalStage allocation(Optional allocation); _FinalStage allocation(Integer allocation); @@ -250,22 +535,133 @@ public interface _FinalStage { _FinalStage company(CompanyDetailResponseData company); + _FinalStage companyOverride(Optional companyOverride); + + _FinalStage companyOverride(CompanyOverrideResponseData companyOverride); + + /** + *

The rate at which credits are consumed per unit of usage

+ */ + _FinalStage creditConsumptionRate(Optional creditConsumptionRate); + + _FinalStage creditConsumptionRate(Double creditConsumptionRate); + + _FinalStage creditGrantCounts(Optional> creditGrantCounts); + + _FinalStage creditGrantCounts(Map creditGrantCounts); + + _FinalStage creditGrantDetails(Optional> creditGrantDetails); + + _FinalStage creditGrantDetails(List creditGrantDetails); + + /** + *

Reason for the credit grant

+ */ + _FinalStage creditGrantReason(Optional creditGrantReason); + + _FinalStage creditGrantReason(FeatureCompanyResponseDataCreditGrantReason creditGrantReason); + + _FinalStage creditRemaining(Optional creditRemaining); + + _FinalStage creditRemaining(Double creditRemaining); + + _FinalStage creditTotal(Optional creditTotal); + + _FinalStage creditTotal(Double creditTotal); + + /** + *

Icon identifier for the credit type

+ */ + _FinalStage creditTypeIcon(Optional creditTypeIcon); + + _FinalStage creditTypeIcon(String creditTypeIcon); + + _FinalStage creditUsage(Optional creditUsage); + + _FinalStage creditUsage(CreditUsage creditUsage); + + _FinalStage creditUsed(Optional creditUsed); + + _FinalStage creditUsed(Double creditUsed); + + /** + *

Effective limit for usage calculations. For overage pricing, this is the soft limit where overage charges begin. For tiered pricing, this is the first tier boundary. For other pricing models, this is the base allocation. Used to calculate usage percentages and determine access thresholds.

+ */ + _FinalStage effectiveLimit(Optional effectiveLimit); + + _FinalStage effectiveLimit(Integer effectiveLimit); + + /** + *

Per-unit price for current usage scenario

+ */ + _FinalStage effectivePrice(Optional effectivePrice); + + _FinalStage effectivePrice(Double effectivePrice); + _FinalStage entitlementExpirationDate(Optional entitlementExpirationDate); _FinalStage entitlementExpirationDate(OffsetDateTime entitlementExpirationDate); + /** + *

Source of the entitlement (plan or company_override)

+ */ + _FinalStage entitlementSource(Optional entitlementSource); + + _FinalStage entitlementSource(String entitlementSource); + _FinalStage feature(Optional feature); _FinalStage feature(FeatureDetailResponseData feature); + /** + *

Whether a valid allocation exists

+ */ + _FinalStage hasValidAllocation(Optional hasValidAllocation); + + _FinalStage hasValidAllocation(Boolean hasValidAllocation); + + /** + *

Whether this is an unlimited allocation

+ */ + _FinalStage isUnlimited(Optional isUnlimited); + + _FinalStage isUnlimited(Boolean isUnlimited); + + /** + *

The time at which the metric will reset.

+ */ _FinalStage metricResetAt(Optional metricResetAt); _FinalStage metricResetAt(OffsetDateTime metricResetAt); + /** + *

If the period is current_month, when the month resets.

+ */ _FinalStage monthReset(Optional monthReset); _FinalStage monthReset(String monthReset); + _FinalStage monthlyUsageBasedPrice(Optional monthlyUsageBasedPrice); + + _FinalStage monthlyUsageBasedPrice(BillingPriceView monthlyUsageBasedPrice); + + /** + *

Amount of usage exceeding soft limit (overage pricing only)

+ */ + _FinalStage overuse(Optional overuse); + + _FinalStage overuse(Integer overuse); + + /** + *

Percentage of allocation consumed (0-100+)

+ */ + _FinalStage percentUsed(Optional percentUsed); + + _FinalStage percentUsed(Double percentUsed); + + /** + *

The period over which usage is measured.

+ */ _FinalStage period(Optional period); _FinalStage period(String period); @@ -274,9 +670,31 @@ public interface _FinalStage { _FinalStage plan(PlanResponseData plan); + _FinalStage planEntitlement(Optional planEntitlement); + + _FinalStage planEntitlement(PlanEntitlementResponseData planEntitlement); + + _FinalStage priceBehavior(Optional priceBehavior); + + _FinalStage priceBehavior(String priceBehavior); + + /** + *

The soft limit for the feature usage. Available only for overage price behavior

+ */ + _FinalStage softLimit(Optional softLimit); + + _FinalStage softLimit(Integer softLimit); + + /** + *

The amount of usage that has been consumed; a null value indicates that usage is not being measured.

+ */ _FinalStage usage(Optional usage); _FinalStage usage(Integer usage); + + _FinalStage yearlyUsageBasedPrice(Optional yearlyUsageBasedPrice); + + _FinalStage yearlyUsageBasedPrice(BillingPriceView yearlyUsageBasedPrice); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -290,20 +708,64 @@ public static final class Builder private String entitlementType; + private Optional yearlyUsageBasedPrice = Optional.empty(); + private Optional usage = Optional.empty(); + private Optional softLimit = Optional.empty(); + + private Optional priceBehavior = Optional.empty(); + + private Optional planEntitlement = Optional.empty(); + private Optional plan = Optional.empty(); private Optional period = Optional.empty(); + private Optional percentUsed = Optional.empty(); + + private Optional overuse = Optional.empty(); + + private Optional monthlyUsageBasedPrice = Optional.empty(); + private Optional monthReset = Optional.empty(); private Optional metricResetAt = Optional.empty(); + private Optional isUnlimited = Optional.empty(); + + private Optional hasValidAllocation = Optional.empty(); + private Optional feature = Optional.empty(); + private Optional entitlementSource = Optional.empty(); + private Optional entitlementExpirationDate = Optional.empty(); + private Optional effectivePrice = Optional.empty(); + + private Optional effectiveLimit = Optional.empty(); + + private Optional creditUsed = Optional.empty(); + + private Optional creditUsage = Optional.empty(); + + private Optional creditTypeIcon = Optional.empty(); + + private Optional creditTotal = Optional.empty(); + + private Optional creditRemaining = Optional.empty(); + + private Optional creditGrantReason = Optional.empty(); + + private Optional> creditGrantDetails = Optional.empty(); + + private Optional> creditGrantCounts = Optional.empty(); + + private Optional creditConsumptionRate = Optional.empty(); + + private Optional companyOverride = Optional.empty(); + private Optional company = Optional.empty(); private Optional allocation = Optional.empty(); @@ -319,19 +781,42 @@ public Builder from(FeatureCompanyResponseData other) { allocation(other.getAllocation()); allocationType(other.getAllocationType()); company(other.getCompany()); + companyOverride(other.getCompanyOverride()); + creditConsumptionRate(other.getCreditConsumptionRate()); + creditGrantCounts(other.getCreditGrantCounts()); + creditGrantDetails(other.getCreditGrantDetails()); + creditGrantReason(other.getCreditGrantReason()); + creditRemaining(other.getCreditRemaining()); + creditTotal(other.getCreditTotal()); + creditTypeIcon(other.getCreditTypeIcon()); + creditUsage(other.getCreditUsage()); + creditUsed(other.getCreditUsed()); + effectiveLimit(other.getEffectiveLimit()); + effectivePrice(other.getEffectivePrice()); entitlementExpirationDate(other.getEntitlementExpirationDate()); entitlementId(other.getEntitlementId()); + entitlementSource(other.getEntitlementSource()); entitlementType(other.getEntitlementType()); feature(other.getFeature()); + hasValidAllocation(other.getHasValidAllocation()); + isUnlimited(other.getIsUnlimited()); metricResetAt(other.getMetricResetAt()); monthReset(other.getMonthReset()); + monthlyUsageBasedPrice(other.getMonthlyUsageBasedPrice()); + overuse(other.getOveruse()); + percentUsed(other.getPercentUsed()); period(other.getPeriod()); plan(other.getPlan()); + planEntitlement(other.getPlanEntitlement()); + priceBehavior(other.getPriceBehavior()); + softLimit(other.getSoftLimit()); usage(other.getUsage()); + yearlyUsageBasedPrice(other.getYearlyUsageBasedPrice()); return this; } /** + *

Whether further usage is permitted.

*

Whether further usage is permitted.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -343,6 +828,7 @@ public AllocationTypeStage access(boolean access) { } /** + *

The type of allocation that is being used.

*

The type of allocation that is being used.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -367,6 +853,19 @@ public _FinalStage entitlementType(@NotNull String entitlementType) { return this; } + @java.lang.Override + public _FinalStage yearlyUsageBasedPrice(BillingPriceView yearlyUsageBasedPrice) { + this.yearlyUsageBasedPrice = Optional.ofNullable(yearlyUsageBasedPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_usage_based_price", nulls = Nulls.SKIP) + public _FinalStage yearlyUsageBasedPrice(Optional yearlyUsageBasedPrice) { + this.yearlyUsageBasedPrice = yearlyUsageBasedPrice; + return this; + } + /** *

The amount of usage that has been consumed; a null value indicates that usage is not being measured.

* @return Reference to {@code this} so that method calls can be chained together. @@ -377,6 +876,9 @@ public _FinalStage usage(Integer usage) { return this; } + /** + *

The amount of usage that has been consumed; a null value indicates that usage is not being measured.

+ */ @java.lang.Override @JsonSetter(value = "usage", nulls = Nulls.SKIP) public _FinalStage usage(Optional usage) { @@ -384,6 +886,52 @@ public _FinalStage usage(Optional usage) { return this; } + /** + *

The soft limit for the feature usage. Available only for overage price behavior

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage softLimit(Integer softLimit) { + this.softLimit = Optional.ofNullable(softLimit); + return this; + } + + /** + *

The soft limit for the feature usage. Available only for overage price behavior

+ */ + @java.lang.Override + @JsonSetter(value = "soft_limit", nulls = Nulls.SKIP) + public _FinalStage softLimit(Optional softLimit) { + this.softLimit = softLimit; + return this; + } + + @java.lang.Override + public _FinalStage priceBehavior(String priceBehavior) { + this.priceBehavior = Optional.ofNullable(priceBehavior); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_behavior", nulls = Nulls.SKIP) + public _FinalStage priceBehavior(Optional priceBehavior) { + this.priceBehavior = priceBehavior; + return this; + } + + @java.lang.Override + public _FinalStage planEntitlement(PlanEntitlementResponseData planEntitlement) { + this.planEntitlement = Optional.ofNullable(planEntitlement); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan_entitlement", nulls = Nulls.SKIP) + public _FinalStage planEntitlement(Optional planEntitlement) { + this.planEntitlement = planEntitlement; + return this; + } + @java.lang.Override public _FinalStage plan(PlanResponseData plan) { this.plan = Optional.ofNullable(plan); @@ -407,6 +955,9 @@ public _FinalStage period(String period) { return this; } + /** + *

The period over which usage is measured.

+ */ @java.lang.Override @JsonSetter(value = "period", nulls = Nulls.SKIP) public _FinalStage period(Optional period) { @@ -414,6 +965,59 @@ public _FinalStage period(Optional period) { return this; } + /** + *

Percentage of allocation consumed (0-100+)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage percentUsed(Double percentUsed) { + this.percentUsed = Optional.ofNullable(percentUsed); + return this; + } + + /** + *

Percentage of allocation consumed (0-100+)

+ */ + @java.lang.Override + @JsonSetter(value = "percent_used", nulls = Nulls.SKIP) + public _FinalStage percentUsed(Optional percentUsed) { + this.percentUsed = percentUsed; + return this; + } + + /** + *

Amount of usage exceeding soft limit (overage pricing only)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage overuse(Integer overuse) { + this.overuse = Optional.ofNullable(overuse); + return this; + } + + /** + *

Amount of usage exceeding soft limit (overage pricing only)

+ */ + @java.lang.Override + @JsonSetter(value = "overuse", nulls = Nulls.SKIP) + public _FinalStage overuse(Optional overuse) { + this.overuse = overuse; + return this; + } + + @java.lang.Override + public _FinalStage monthlyUsageBasedPrice(BillingPriceView monthlyUsageBasedPrice) { + this.monthlyUsageBasedPrice = Optional.ofNullable(monthlyUsageBasedPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_usage_based_price", nulls = Nulls.SKIP) + public _FinalStage monthlyUsageBasedPrice(Optional monthlyUsageBasedPrice) { + this.monthlyUsageBasedPrice = monthlyUsageBasedPrice; + return this; + } + /** *

If the period is current_month, when the month resets.

* @return Reference to {@code this} so that method calls can be chained together. @@ -424,6 +1028,9 @@ public _FinalStage monthReset(String monthReset) { return this; } + /** + *

If the period is current_month, when the month resets.

+ */ @java.lang.Override @JsonSetter(value = "month_reset", nulls = Nulls.SKIP) public _FinalStage monthReset(Optional monthReset) { @@ -432,7 +1039,7 @@ public _FinalStage monthReset(Optional monthReset) { } /** - *

The time at which the metric will resets.

+ *

The time at which the metric will reset.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -441,6 +1048,9 @@ public _FinalStage metricResetAt(OffsetDateTime metricResetAt) { return this; } + /** + *

The time at which the metric will reset.

+ */ @java.lang.Override @JsonSetter(value = "metric_reset_at", nulls = Nulls.SKIP) public _FinalStage metricResetAt(Optional metricResetAt) { @@ -448,6 +1058,46 @@ public _FinalStage metricResetAt(Optional metricResetAt) { return this; } + /** + *

Whether this is an unlimited allocation

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage isUnlimited(Boolean isUnlimited) { + this.isUnlimited = Optional.ofNullable(isUnlimited); + return this; + } + + /** + *

Whether this is an unlimited allocation

+ */ + @java.lang.Override + @JsonSetter(value = "is_unlimited", nulls = Nulls.SKIP) + public _FinalStage isUnlimited(Optional isUnlimited) { + this.isUnlimited = isUnlimited; + return this; + } + + /** + *

Whether a valid allocation exists

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage hasValidAllocation(Boolean hasValidAllocation) { + this.hasValidAllocation = Optional.ofNullable(hasValidAllocation); + return this; + } + + /** + *

Whether a valid allocation exists

+ */ + @java.lang.Override + @JsonSetter(value = "has_valid_allocation", nulls = Nulls.SKIP) + public _FinalStage hasValidAllocation(Optional hasValidAllocation) { + this.hasValidAllocation = hasValidAllocation; + return this; + } + @java.lang.Override public _FinalStage feature(FeatureDetailResponseData feature) { this.feature = Optional.ofNullable(feature); @@ -461,6 +1111,26 @@ public _FinalStage feature(Optional feature) { return this; } + /** + *

Source of the entitlement (plan or company_override)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage entitlementSource(String entitlementSource) { + this.entitlementSource = Optional.ofNullable(entitlementSource); + return this; + } + + /** + *

Source of the entitlement (plan or company_override)

+ */ + @java.lang.Override + @JsonSetter(value = "entitlement_source", nulls = Nulls.SKIP) + public _FinalStage entitlementSource(Optional entitlementSource) { + this.entitlementSource = entitlementSource; + return this; + } + @java.lang.Override public _FinalStage entitlementExpirationDate(OffsetDateTime entitlementExpirationDate) { this.entitlementExpirationDate = Optional.ofNullable(entitlementExpirationDate); @@ -474,6 +1144,197 @@ public _FinalStage entitlementExpirationDate(Optional entitlemen return this; } + /** + *

Per-unit price for current usage scenario

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage effectivePrice(Double effectivePrice) { + this.effectivePrice = Optional.ofNullable(effectivePrice); + return this; + } + + /** + *

Per-unit price for current usage scenario

+ */ + @java.lang.Override + @JsonSetter(value = "effective_price", nulls = Nulls.SKIP) + public _FinalStage effectivePrice(Optional effectivePrice) { + this.effectivePrice = effectivePrice; + return this; + } + + /** + *

Effective limit for usage calculations. For overage pricing, this is the soft limit where overage charges begin. For tiered pricing, this is the first tier boundary. For other pricing models, this is the base allocation. Used to calculate usage percentages and determine access thresholds.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage effectiveLimit(Integer effectiveLimit) { + this.effectiveLimit = Optional.ofNullable(effectiveLimit); + return this; + } + + /** + *

Effective limit for usage calculations. For overage pricing, this is the soft limit where overage charges begin. For tiered pricing, this is the first tier boundary. For other pricing models, this is the base allocation. Used to calculate usage percentages and determine access thresholds.

+ */ + @java.lang.Override + @JsonSetter(value = "effective_limit", nulls = Nulls.SKIP) + public _FinalStage effectiveLimit(Optional effectiveLimit) { + this.effectiveLimit = effectiveLimit; + return this; + } + + @java.lang.Override + public _FinalStage creditUsed(Double creditUsed) { + this.creditUsed = Optional.ofNullable(creditUsed); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_used", nulls = Nulls.SKIP) + public _FinalStage creditUsed(Optional creditUsed) { + this.creditUsed = creditUsed; + return this; + } + + @java.lang.Override + public _FinalStage creditUsage(CreditUsage creditUsage) { + this.creditUsage = Optional.ofNullable(creditUsage); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_usage", nulls = Nulls.SKIP) + public _FinalStage creditUsage(Optional creditUsage) { + this.creditUsage = creditUsage; + return this; + } + + /** + *

Icon identifier for the credit type

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creditTypeIcon(String creditTypeIcon) { + this.creditTypeIcon = Optional.ofNullable(creditTypeIcon); + return this; + } + + /** + *

Icon identifier for the credit type

+ */ + @java.lang.Override + @JsonSetter(value = "credit_type_icon", nulls = Nulls.SKIP) + public _FinalStage creditTypeIcon(Optional creditTypeIcon) { + this.creditTypeIcon = creditTypeIcon; + return this; + } + + @java.lang.Override + public _FinalStage creditTotal(Double creditTotal) { + this.creditTotal = Optional.ofNullable(creditTotal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_total", nulls = Nulls.SKIP) + public _FinalStage creditTotal(Optional creditTotal) { + this.creditTotal = creditTotal; + return this; + } + + @java.lang.Override + public _FinalStage creditRemaining(Double creditRemaining) { + this.creditRemaining = Optional.ofNullable(creditRemaining); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_remaining", nulls = Nulls.SKIP) + public _FinalStage creditRemaining(Optional creditRemaining) { + this.creditRemaining = creditRemaining; + return this; + } + + /** + *

Reason for the credit grant

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creditGrantReason(FeatureCompanyResponseDataCreditGrantReason creditGrantReason) { + this.creditGrantReason = Optional.ofNullable(creditGrantReason); + return this; + } + + /** + *

Reason for the credit grant

+ */ + @java.lang.Override + @JsonSetter(value = "credit_grant_reason", nulls = Nulls.SKIP) + public _FinalStage creditGrantReason(Optional creditGrantReason) { + this.creditGrantReason = creditGrantReason; + return this; + } + + @java.lang.Override + public _FinalStage creditGrantDetails(List creditGrantDetails) { + this.creditGrantDetails = Optional.ofNullable(creditGrantDetails); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_grant_details", nulls = Nulls.SKIP) + public _FinalStage creditGrantDetails(Optional> creditGrantDetails) { + this.creditGrantDetails = creditGrantDetails; + return this; + } + + @java.lang.Override + public _FinalStage creditGrantCounts(Map creditGrantCounts) { + this.creditGrantCounts = Optional.ofNullable(creditGrantCounts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_grant_counts", nulls = Nulls.SKIP) + public _FinalStage creditGrantCounts(Optional> creditGrantCounts) { + this.creditGrantCounts = creditGrantCounts; + return this; + } + + /** + *

The rate at which credits are consumed per unit of usage

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + /** + *

The rate at which credits are consumed per unit of usage

+ */ + @java.lang.Override + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public _FinalStage creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + + @java.lang.Override + public _FinalStage companyOverride(CompanyOverrideResponseData companyOverride) { + this.companyOverride = Optional.ofNullable(companyOverride); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_override", nulls = Nulls.SKIP) + public _FinalStage companyOverride(Optional companyOverride) { + this.companyOverride = companyOverride; + return this; + } + @java.lang.Override public _FinalStage company(CompanyDetailResponseData company) { this.company = Optional.ofNullable(company); @@ -497,6 +1358,9 @@ public _FinalStage allocation(Integer allocation) { return this; } + /** + *

The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted.

+ */ @java.lang.Override @JsonSetter(value = "allocation", nulls = Nulls.SKIP) public _FinalStage allocation(Optional allocation) { @@ -511,15 +1375,37 @@ public FeatureCompanyResponseData build() { allocation, allocationType, company, + companyOverride, + creditConsumptionRate, + creditGrantCounts, + creditGrantDetails, + creditGrantReason, + creditRemaining, + creditTotal, + creditTypeIcon, + creditUsage, + creditUsed, + effectiveLimit, + effectivePrice, entitlementExpirationDate, entitlementId, + entitlementSource, entitlementType, feature, + hasValidAllocation, + isUnlimited, metricResetAt, monthReset, + monthlyUsageBasedPrice, + overuse, + percentUsed, period, plan, + planEntitlement, + priceBehavior, + softLimit, usage, + yearlyUsageBasedPrice, additionalProperties); } } diff --git a/src/main/java/com/schematic/api/types/FeatureCompanyResponseDataAllocationType.java b/src/main/java/com/schematic/api/types/FeatureCompanyResponseDataAllocationType.java index 159fa9f..33511cc 100644 --- a/src/main/java/com/schematic/api/types/FeatureCompanyResponseDataAllocationType.java +++ b/src/main/java/com/schematic/api/types/FeatureCompanyResponseDataAllocationType.java @@ -3,26 +3,106 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum FeatureCompanyResponseDataAllocationType { - BOOLEAN("boolean"), +public final class FeatureCompanyResponseDataAllocationType { + public static final FeatureCompanyResponseDataAllocationType NUMERIC = + new FeatureCompanyResponseDataAllocationType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final FeatureCompanyResponseDataAllocationType TRAIT = + new FeatureCompanyResponseDataAllocationType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final FeatureCompanyResponseDataAllocationType BOOLEAN = + new FeatureCompanyResponseDataAllocationType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final FeatureCompanyResponseDataAllocationType UNLIMITED = + new FeatureCompanyResponseDataAllocationType(Value.UNLIMITED, "unlimited"); - private final String value; + private final Value value; - FeatureCompanyResponseDataAllocationType(String value) { + private final String string; + + FeatureCompanyResponseDataAllocationType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof FeatureCompanyResponseDataAllocationType + && this.string.equals(((FeatureCompanyResponseDataAllocationType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case UNLIMITED: + return visitor.visitUnlimited(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static FeatureCompanyResponseDataAllocationType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "unlimited": + return UNLIMITED; + default: + return new FeatureCompanyResponseDataAllocationType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/FeatureCompanyResponseDataCreditGrantReason.java b/src/main/java/com/schematic/api/types/FeatureCompanyResponseDataCreditGrantReason.java new file mode 100644 index 0000000..8482230 --- /dev/null +++ b/src/main/java/com/schematic/api/types/FeatureCompanyResponseDataCreditGrantReason.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class FeatureCompanyResponseDataCreditGrantReason { + public static final FeatureCompanyResponseDataCreditGrantReason PURCHASED = + new FeatureCompanyResponseDataCreditGrantReason(Value.PURCHASED, "purchased"); + + public static final FeatureCompanyResponseDataCreditGrantReason PLAN = + new FeatureCompanyResponseDataCreditGrantReason(Value.PLAN, "plan"); + + public static final FeatureCompanyResponseDataCreditGrantReason FREE = + new FeatureCompanyResponseDataCreditGrantReason(Value.FREE, "free"); + + private final Value value; + + private final String string; + + FeatureCompanyResponseDataCreditGrantReason(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof FeatureCompanyResponseDataCreditGrantReason + && this.string.equals(((FeatureCompanyResponseDataCreditGrantReason) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PURCHASED: + return visitor.visitPurchased(); + case PLAN: + return visitor.visitPlan(); + case FREE: + return visitor.visitFree(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static FeatureCompanyResponseDataCreditGrantReason valueOf(String value) { + switch (value) { + case "purchased": + return PURCHASED; + case "plan": + return PLAN; + case "free": + return FREE; + default: + return new FeatureCompanyResponseDataCreditGrantReason(Value.UNKNOWN, value); + } + } + + public enum Value { + FREE, + + PLAN, + + PURCHASED, + + UNKNOWN + } + + public interface Visitor { + T visitFree(); + + T visitPlan(); + + T visitPurchased(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseData.java b/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseData.java index b6fd381..4935055 100644 --- a/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseData.java +++ b/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseData.java @@ -222,12 +222,18 @@ public static AccessStage builder() { } public interface AccessStage { + /** + *

Whether further usage is permitted.

+ */ AllocationTypeStage access(boolean access); Builder from(FeatureCompanyUserResponseData other); } public interface AllocationTypeStage { + /** + *

The type of allocation that is being used.

+ */ EntitlementIdStage allocationType(@NotNull FeatureCompanyUserResponseDataAllocationType allocationType); } @@ -242,6 +248,9 @@ public interface EntitlementTypeStage { public interface _FinalStage { FeatureCompanyUserResponseData build(); + /** + *

The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted.

+ */ _FinalStage allocation(Optional allocation); _FinalStage allocation(Integer allocation); @@ -254,14 +263,23 @@ public interface _FinalStage { _FinalStage feature(FeatureDetailResponseData feature); + /** + *

The time at which the metric will resets.

+ */ _FinalStage metricResetAt(Optional metricResetAt); _FinalStage metricResetAt(OffsetDateTime metricResetAt); + /** + *

If the period is current_month, when the month resets.

+ */ _FinalStage monthReset(Optional monthReset); _FinalStage monthReset(String monthReset); + /** + *

The period over which usage is measured.

+ */ _FinalStage period(Optional period); _FinalStage period(String period); @@ -270,6 +288,9 @@ public interface _FinalStage { _FinalStage plan(PlanResponseData plan); + /** + *

The amount of usage that has been consumed; a null value indicates that usage is not being measured.

+ */ _FinalStage usage(Optional usage); _FinalStage usage(Integer usage); @@ -332,6 +353,7 @@ public Builder from(FeatureCompanyUserResponseData other) { } /** + *

Whether further usage is permitted.

*

Whether further usage is permitted.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -343,6 +365,7 @@ public AllocationTypeStage access(boolean access) { } /** + *

The type of allocation that is being used.

*

The type of allocation that is being used.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -390,6 +413,9 @@ public _FinalStage usage(Integer usage) { return this; } + /** + *

The amount of usage that has been consumed; a null value indicates that usage is not being measured.

+ */ @java.lang.Override @JsonSetter(value = "usage", nulls = Nulls.SKIP) public _FinalStage usage(Optional usage) { @@ -420,6 +446,9 @@ public _FinalStage period(String period) { return this; } + /** + *

The period over which usage is measured.

+ */ @java.lang.Override @JsonSetter(value = "period", nulls = Nulls.SKIP) public _FinalStage period(Optional period) { @@ -437,6 +466,9 @@ public _FinalStage monthReset(String monthReset) { return this; } + /** + *

If the period is current_month, when the month resets.

+ */ @java.lang.Override @JsonSetter(value = "month_reset", nulls = Nulls.SKIP) public _FinalStage monthReset(Optional monthReset) { @@ -454,6 +486,9 @@ public _FinalStage metricResetAt(OffsetDateTime metricResetAt) { return this; } + /** + *

The time at which the metric will resets.

+ */ @java.lang.Override @JsonSetter(value = "metric_reset_at", nulls = Nulls.SKIP) public _FinalStage metricResetAt(Optional metricResetAt) { @@ -497,6 +532,9 @@ public _FinalStage allocation(Integer allocation) { return this; } + /** + *

The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted.

+ */ @java.lang.Override @JsonSetter(value = "allocation", nulls = Nulls.SKIP) public _FinalStage allocation(Optional allocation) { diff --git a/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseDataAllocationType.java b/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseDataAllocationType.java index 5722889..557643f 100644 --- a/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseDataAllocationType.java +++ b/src/main/java/com/schematic/api/types/FeatureCompanyUserResponseDataAllocationType.java @@ -3,26 +3,117 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum FeatureCompanyUserResponseDataAllocationType { - BOOLEAN("boolean"), +public final class FeatureCompanyUserResponseDataAllocationType { + public static final FeatureCompanyUserResponseDataAllocationType NUMERIC = + new FeatureCompanyUserResponseDataAllocationType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final FeatureCompanyUserResponseDataAllocationType TRAIT = + new FeatureCompanyUserResponseDataAllocationType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final FeatureCompanyUserResponseDataAllocationType BOOLEAN = + new FeatureCompanyUserResponseDataAllocationType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final FeatureCompanyUserResponseDataAllocationType UNKNOWN = + new FeatureCompanyUserResponseDataAllocationType(Value.UNKNOWN, "unknown"); - private final String value; + public static final FeatureCompanyUserResponseDataAllocationType UNLIMITED = + new FeatureCompanyUserResponseDataAllocationType(Value.UNLIMITED, "unlimited"); - FeatureCompanyUserResponseDataAllocationType(String value) { + private final Value value; + + private final String string; + + FeatureCompanyUserResponseDataAllocationType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof FeatureCompanyUserResponseDataAllocationType + && this.string.equals(((FeatureCompanyUserResponseDataAllocationType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case UNKNOWN: + return visitor.visitUnknown(); + case UNLIMITED: + return visitor.visitUnlimited(); + case _UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static FeatureCompanyUserResponseDataAllocationType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "unknown": + return UNKNOWN; + case "unlimited": + return UNLIMITED; + default: + return new FeatureCompanyUserResponseDataAllocationType(Value._UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN, + + _UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/FeatureDetailResponseData.java b/src/main/java/com/schematic/api/types/FeatureDetailResponseData.java index 2ad5116..0127ee2 100644 --- a/src/main/java/com/schematic/api/types/FeatureDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/FeatureDetailResponseData.java @@ -498,7 +498,9 @@ public _FinalStage pluralName(Optional pluralName) { @java.lang.Override public _FinalStage addAllPlans(List plans) { - this.plans.addAll(plans); + if (plans != null) { + this.plans.addAll(plans); + } return this; } @@ -512,7 +514,9 @@ public _FinalStage addPlans(PreviewObject plans) { @JsonSetter(value = "plans", nulls = Nulls.SKIP) public _FinalStage plans(List plans) { this.plans.clear(); - this.plans.addAll(plans); + if (plans != null) { + this.plans.addAll(plans); + } return this; } @@ -544,7 +548,9 @@ public _FinalStage lifecyclePhase(Optional lifecyclePhase) { @java.lang.Override public _FinalStage addAllFlags(List flags) { - this.flags.addAll(flags); + if (flags != null) { + this.flags.addAll(flags); + } return this; } @@ -558,7 +564,9 @@ public _FinalStage addFlags(FlagDetailResponseData flags) { @JsonSetter(value = "flags", nulls = Nulls.SKIP) public _FinalStage flags(List flags) { this.flags.clear(); - this.flags.addAll(flags); + if (flags != null) { + this.flags.addAll(flags); + } return this; } diff --git a/src/main/java/com/schematic/api/types/FeatureLedgerResponseData.java b/src/main/java/com/schematic/api/types/FeatureLedgerResponseData.java new file mode 100644 index 0000000..4faddbc --- /dev/null +++ b/src/main/java/com/schematic/api/types/FeatureLedgerResponseData.java @@ -0,0 +1,190 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = FeatureLedgerResponseData.Builder.class) +public final class FeatureLedgerResponseData { + private final Optional description; + + private final Optional icon; + + private final String id; + + private final String name; + + private final Map additionalProperties; + + private FeatureLedgerResponseData( + Optional description, + Optional icon, + String id, + String name, + Map additionalProperties) { + this.description = description; + this.icon = icon; + this.id = id; + this.name = name; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FeatureLedgerResponseData && equalTo((FeatureLedgerResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FeatureLedgerResponseData other) { + return description.equals(other.description) + && icon.equals(other.icon) + && id.equals(other.id) + && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.description, this.icon, this.id, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + NameStage id(@NotNull String id); + + Builder from(FeatureLedgerResponseData other); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + FeatureLedgerResponseData build(); + + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage icon(Optional icon); + + _FinalStage icon(String icon); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, NameStage, _FinalStage { + private String id; + + private String name; + + private Optional icon = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FeatureLedgerResponseData other) { + description(other.getDescription()); + icon(other.getIcon()); + id(other.getId()); + name(other.getName()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public _FinalStage icon(Optional icon) { + this.icon = icon; + return this; + } + + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public FeatureLedgerResponseData build() { + return new FeatureLedgerResponseData(description, icon, id, name, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/FeatureUsageDataResponseData.java b/src/main/java/com/schematic/api/types/FeatureUsageDataResponseData.java new file mode 100644 index 0000000..a3bf021 --- /dev/null +++ b/src/main/java/com/schematic/api/types/FeatureUsageDataResponseData.java @@ -0,0 +1,553 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = FeatureUsageDataResponseData.Builder.class) +public final class FeatureUsageDataResponseData { + private final Optional creditTypeId; + + private final Optional creditUsage; + + private final String entitlementSource; + + private final String entitlementValueType; + + private final String featureId; + + private final String featureName; + + private final String featureType; + + private final String hardLimit; + + private final boolean hasAccess; + + private final Optional metricResetAt; + + private final Optional monthlyUsageBasedPrice; + + private final Optional priceBehavior; + + private final String softLimit; + + private final String usage; + + private final Optional valueNumeric; + + private final Optional yearlyUsageBasedPrice; + + private final Map additionalProperties; + + private FeatureUsageDataResponseData( + Optional creditTypeId, + Optional creditUsage, + String entitlementSource, + String entitlementValueType, + String featureId, + String featureName, + String featureType, + String hardLimit, + boolean hasAccess, + Optional metricResetAt, + Optional monthlyUsageBasedPrice, + Optional priceBehavior, + String softLimit, + String usage, + Optional valueNumeric, + Optional yearlyUsageBasedPrice, + Map additionalProperties) { + this.creditTypeId = creditTypeId; + this.creditUsage = creditUsage; + this.entitlementSource = entitlementSource; + this.entitlementValueType = entitlementValueType; + this.featureId = featureId; + this.featureName = featureName; + this.featureType = featureType; + this.hardLimit = hardLimit; + this.hasAccess = hasAccess; + this.metricResetAt = metricResetAt; + this.monthlyUsageBasedPrice = monthlyUsageBasedPrice; + this.priceBehavior = priceBehavior; + this.softLimit = softLimit; + this.usage = usage; + this.valueNumeric = valueNumeric; + this.yearlyUsageBasedPrice = yearlyUsageBasedPrice; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("credit_type_id") + public Optional getCreditTypeId() { + return creditTypeId; + } + + @JsonProperty("credit_usage") + public Optional getCreditUsage() { + return creditUsage; + } + + @JsonProperty("entitlement_source") + public String getEntitlementSource() { + return entitlementSource; + } + + @JsonProperty("entitlement_value_type") + public String getEntitlementValueType() { + return entitlementValueType; + } + + @JsonProperty("feature_id") + public String getFeatureId() { + return featureId; + } + + @JsonProperty("feature_name") + public String getFeatureName() { + return featureName; + } + + @JsonProperty("feature_type") + public String getFeatureType() { + return featureType; + } + + @JsonProperty("hard_limit") + public String getHardLimit() { + return hardLimit; + } + + @JsonProperty("has_access") + public boolean getHasAccess() { + return hasAccess; + } + + @JsonProperty("metric_reset_at") + public Optional getMetricResetAt() { + return metricResetAt; + } + + @JsonProperty("monthly_usage_based_price") + public Optional getMonthlyUsageBasedPrice() { + return monthlyUsageBasedPrice; + } + + @JsonProperty("price_behavior") + public Optional getPriceBehavior() { + return priceBehavior; + } + + @JsonProperty("soft_limit") + public String getSoftLimit() { + return softLimit; + } + + @JsonProperty("usage") + public String getUsage() { + return usage; + } + + @JsonProperty("value_numeric") + public Optional getValueNumeric() { + return valueNumeric; + } + + @JsonProperty("yearly_usage_based_price") + public Optional getYearlyUsageBasedPrice() { + return yearlyUsageBasedPrice; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FeatureUsageDataResponseData && equalTo((FeatureUsageDataResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FeatureUsageDataResponseData other) { + return creditTypeId.equals(other.creditTypeId) + && creditUsage.equals(other.creditUsage) + && entitlementSource.equals(other.entitlementSource) + && entitlementValueType.equals(other.entitlementValueType) + && featureId.equals(other.featureId) + && featureName.equals(other.featureName) + && featureType.equals(other.featureType) + && hardLimit.equals(other.hardLimit) + && hasAccess == other.hasAccess + && metricResetAt.equals(other.metricResetAt) + && monthlyUsageBasedPrice.equals(other.monthlyUsageBasedPrice) + && priceBehavior.equals(other.priceBehavior) + && softLimit.equals(other.softLimit) + && usage.equals(other.usage) + && valueNumeric.equals(other.valueNumeric) + && yearlyUsageBasedPrice.equals(other.yearlyUsageBasedPrice); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.creditTypeId, + this.creditUsage, + this.entitlementSource, + this.entitlementValueType, + this.featureId, + this.featureName, + this.featureType, + this.hardLimit, + this.hasAccess, + this.metricResetAt, + this.monthlyUsageBasedPrice, + this.priceBehavior, + this.softLimit, + this.usage, + this.valueNumeric, + this.yearlyUsageBasedPrice); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EntitlementSourceStage builder() { + return new Builder(); + } + + public interface EntitlementSourceStage { + EntitlementValueTypeStage entitlementSource(@NotNull String entitlementSource); + + Builder from(FeatureUsageDataResponseData other); + } + + public interface EntitlementValueTypeStage { + FeatureIdStage entitlementValueType(@NotNull String entitlementValueType); + } + + public interface FeatureIdStage { + FeatureNameStage featureId(@NotNull String featureId); + } + + public interface FeatureNameStage { + FeatureTypeStage featureName(@NotNull String featureName); + } + + public interface FeatureTypeStage { + HardLimitStage featureType(@NotNull String featureType); + } + + public interface HardLimitStage { + HasAccessStage hardLimit(@NotNull String hardLimit); + } + + public interface HasAccessStage { + SoftLimitStage hasAccess(boolean hasAccess); + } + + public interface SoftLimitStage { + UsageStage softLimit(@NotNull String softLimit); + } + + public interface UsageStage { + _FinalStage usage(@NotNull String usage); + } + + public interface _FinalStage { + FeatureUsageDataResponseData build(); + + _FinalStage creditTypeId(Optional creditTypeId); + + _FinalStage creditTypeId(String creditTypeId); + + _FinalStage creditUsage(Optional creditUsage); + + _FinalStage creditUsage(CreditUsageResponseData creditUsage); + + _FinalStage metricResetAt(Optional metricResetAt); + + _FinalStage metricResetAt(OffsetDateTime metricResetAt); + + _FinalStage monthlyUsageBasedPrice(Optional monthlyUsageBasedPrice); + + _FinalStage monthlyUsageBasedPrice(BillingPriceView monthlyUsageBasedPrice); + + _FinalStage priceBehavior(Optional priceBehavior); + + _FinalStage priceBehavior(String priceBehavior); + + _FinalStage valueNumeric(Optional valueNumeric); + + _FinalStage valueNumeric(Integer valueNumeric); + + _FinalStage yearlyUsageBasedPrice(Optional yearlyUsageBasedPrice); + + _FinalStage yearlyUsageBasedPrice(BillingPriceView yearlyUsageBasedPrice); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements EntitlementSourceStage, + EntitlementValueTypeStage, + FeatureIdStage, + FeatureNameStage, + FeatureTypeStage, + HardLimitStage, + HasAccessStage, + SoftLimitStage, + UsageStage, + _FinalStage { + private String entitlementSource; + + private String entitlementValueType; + + private String featureId; + + private String featureName; + + private String featureType; + + private String hardLimit; + + private boolean hasAccess; + + private String softLimit; + + private String usage; + + private Optional yearlyUsageBasedPrice = Optional.empty(); + + private Optional valueNumeric = Optional.empty(); + + private Optional priceBehavior = Optional.empty(); + + private Optional monthlyUsageBasedPrice = Optional.empty(); + + private Optional metricResetAt = Optional.empty(); + + private Optional creditUsage = Optional.empty(); + + private Optional creditTypeId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FeatureUsageDataResponseData other) { + creditTypeId(other.getCreditTypeId()); + creditUsage(other.getCreditUsage()); + entitlementSource(other.getEntitlementSource()); + entitlementValueType(other.getEntitlementValueType()); + featureId(other.getFeatureId()); + featureName(other.getFeatureName()); + featureType(other.getFeatureType()); + hardLimit(other.getHardLimit()); + hasAccess(other.getHasAccess()); + metricResetAt(other.getMetricResetAt()); + monthlyUsageBasedPrice(other.getMonthlyUsageBasedPrice()); + priceBehavior(other.getPriceBehavior()); + softLimit(other.getSoftLimit()); + usage(other.getUsage()); + valueNumeric(other.getValueNumeric()); + yearlyUsageBasedPrice(other.getYearlyUsageBasedPrice()); + return this; + } + + @java.lang.Override + @JsonSetter("entitlement_source") + public EntitlementValueTypeStage entitlementSource(@NotNull String entitlementSource) { + this.entitlementSource = Objects.requireNonNull(entitlementSource, "entitlementSource must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("entitlement_value_type") + public FeatureIdStage entitlementValueType(@NotNull String entitlementValueType) { + this.entitlementValueType = + Objects.requireNonNull(entitlementValueType, "entitlementValueType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("feature_id") + public FeatureNameStage featureId(@NotNull String featureId) { + this.featureId = Objects.requireNonNull(featureId, "featureId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("feature_name") + public FeatureTypeStage featureName(@NotNull String featureName) { + this.featureName = Objects.requireNonNull(featureName, "featureName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("feature_type") + public HardLimitStage featureType(@NotNull String featureType) { + this.featureType = Objects.requireNonNull(featureType, "featureType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("hard_limit") + public HasAccessStage hardLimit(@NotNull String hardLimit) { + this.hardLimit = Objects.requireNonNull(hardLimit, "hardLimit must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("has_access") + public SoftLimitStage hasAccess(boolean hasAccess) { + this.hasAccess = hasAccess; + return this; + } + + @java.lang.Override + @JsonSetter("soft_limit") + public UsageStage softLimit(@NotNull String softLimit) { + this.softLimit = Objects.requireNonNull(softLimit, "softLimit must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("usage") + public _FinalStage usage(@NotNull String usage) { + this.usage = Objects.requireNonNull(usage, "usage must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage yearlyUsageBasedPrice(BillingPriceView yearlyUsageBasedPrice) { + this.yearlyUsageBasedPrice = Optional.ofNullable(yearlyUsageBasedPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "yearly_usage_based_price", nulls = Nulls.SKIP) + public _FinalStage yearlyUsageBasedPrice(Optional yearlyUsageBasedPrice) { + this.yearlyUsageBasedPrice = yearlyUsageBasedPrice; + return this; + } + + @java.lang.Override + public _FinalStage valueNumeric(Integer valueNumeric) { + this.valueNumeric = Optional.ofNullable(valueNumeric); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_numeric", nulls = Nulls.SKIP) + public _FinalStage valueNumeric(Optional valueNumeric) { + this.valueNumeric = valueNumeric; + return this; + } + + @java.lang.Override + public _FinalStage priceBehavior(String priceBehavior) { + this.priceBehavior = Optional.ofNullable(priceBehavior); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_behavior", nulls = Nulls.SKIP) + public _FinalStage priceBehavior(Optional priceBehavior) { + this.priceBehavior = priceBehavior; + return this; + } + + @java.lang.Override + public _FinalStage monthlyUsageBasedPrice(BillingPriceView monthlyUsageBasedPrice) { + this.monthlyUsageBasedPrice = Optional.ofNullable(monthlyUsageBasedPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "monthly_usage_based_price", nulls = Nulls.SKIP) + public _FinalStage monthlyUsageBasedPrice(Optional monthlyUsageBasedPrice) { + this.monthlyUsageBasedPrice = monthlyUsageBasedPrice; + return this; + } + + @java.lang.Override + public _FinalStage metricResetAt(OffsetDateTime metricResetAt) { + this.metricResetAt = Optional.ofNullable(metricResetAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "metric_reset_at", nulls = Nulls.SKIP) + public _FinalStage metricResetAt(Optional metricResetAt) { + this.metricResetAt = metricResetAt; + return this; + } + + @java.lang.Override + public _FinalStage creditUsage(CreditUsageResponseData creditUsage) { + this.creditUsage = Optional.ofNullable(creditUsage); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_usage", nulls = Nulls.SKIP) + public _FinalStage creditUsage(Optional creditUsage) { + this.creditUsage = creditUsage; + return this; + } + + @java.lang.Override + public _FinalStage creditTypeId(String creditTypeId) { + this.creditTypeId = Optional.ofNullable(creditTypeId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_type_id", nulls = Nulls.SKIP) + public _FinalStage creditTypeId(Optional creditTypeId) { + this.creditTypeId = creditTypeId; + return this; + } + + @java.lang.Override + public FeatureUsageDataResponseData build() { + return new FeatureUsageDataResponseData( + creditTypeId, + creditUsage, + entitlementSource, + entitlementValueType, + featureId, + featureName, + featureType, + hardLimit, + hasAccess, + metricResetAt, + monthlyUsageBasedPrice, + priceBehavior, + softLimit, + usage, + valueNumeric, + yearlyUsageBasedPrice, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/FeatureUsageDetailResponseData.java b/src/main/java/com/schematic/api/types/FeatureUsageDetailResponseData.java index 5375a7c..90a7a36 100644 --- a/src/main/java/com/schematic/api/types/FeatureUsageDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/FeatureUsageDetailResponseData.java @@ -82,7 +82,9 @@ public Builder from(FeatureUsageDetailResponseData other) { @JsonSetter(value = "features", nulls = Nulls.SKIP) public Builder features(List features) { this.features.clear(); - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @@ -92,7 +94,9 @@ public Builder addFeatures(FeatureUsageResponseData features) { } public Builder addAllFeatures(List features) { - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } diff --git a/src/main/java/com/schematic/api/types/FeatureUsageResponseData.java b/src/main/java/com/schematic/api/types/FeatureUsageResponseData.java index 086926c..3c32ae7 100644 --- a/src/main/java/com/schematic/api/types/FeatureUsageResponseData.java +++ b/src/main/java/com/schematic/api/types/FeatureUsageResponseData.java @@ -14,6 +14,7 @@ import com.schematic.api.core.ObjectMappers; import java.time.OffsetDateTime; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -28,24 +29,58 @@ public final class FeatureUsageResponseData { private final FeatureUsageResponseDataAllocationType allocationType; + private final Optional companyOverride; + + private final Optional creditConsumptionRate; + + private final Optional> creditGrantCounts; + + private final Optional> creditGrantDetails; + + private final Optional creditGrantReason; + + private final Optional creditRemaining; + + private final Optional creditTotal; + + private final Optional creditTypeIcon; + + private final Optional creditUsed; + + private final Optional effectiveLimit; + + private final Optional effectivePrice; + private final Optional entitlementExpirationDate; private final String entitlementId; + private final Optional entitlementSource; + private final String entitlementType; private final Optional feature; + private final Optional hasValidAllocation; + + private final Optional isUnlimited; + private final Optional metricResetAt; private final Optional monthReset; private final Optional monthlyUsageBasedPrice; + private final Optional overuse; + + private final Optional percentUsed; + private final Optional period; private final Optional plan; + private final Optional planEntitlement; + private final Optional priceBehavior; private final Optional softLimit; @@ -60,15 +95,32 @@ private FeatureUsageResponseData( boolean access, Optional allocation, FeatureUsageResponseDataAllocationType allocationType, + Optional companyOverride, + Optional creditConsumptionRate, + Optional> creditGrantCounts, + Optional> creditGrantDetails, + Optional creditGrantReason, + Optional creditRemaining, + Optional creditTotal, + Optional creditTypeIcon, + Optional creditUsed, + Optional effectiveLimit, + Optional effectivePrice, Optional entitlementExpirationDate, String entitlementId, + Optional entitlementSource, String entitlementType, Optional feature, + Optional hasValidAllocation, + Optional isUnlimited, Optional metricResetAt, Optional monthReset, Optional monthlyUsageBasedPrice, + Optional overuse, + Optional percentUsed, Optional period, Optional plan, + Optional planEntitlement, Optional priceBehavior, Optional softLimit, Optional usage, @@ -77,15 +129,32 @@ private FeatureUsageResponseData( this.access = access; this.allocation = allocation; this.allocationType = allocationType; + this.companyOverride = companyOverride; + this.creditConsumptionRate = creditConsumptionRate; + this.creditGrantCounts = creditGrantCounts; + this.creditGrantDetails = creditGrantDetails; + this.creditGrantReason = creditGrantReason; + this.creditRemaining = creditRemaining; + this.creditTotal = creditTotal; + this.creditTypeIcon = creditTypeIcon; + this.creditUsed = creditUsed; + this.effectiveLimit = effectiveLimit; + this.effectivePrice = effectivePrice; this.entitlementExpirationDate = entitlementExpirationDate; this.entitlementId = entitlementId; + this.entitlementSource = entitlementSource; this.entitlementType = entitlementType; this.feature = feature; + this.hasValidAllocation = hasValidAllocation; + this.isUnlimited = isUnlimited; this.metricResetAt = metricResetAt; this.monthReset = monthReset; this.monthlyUsageBasedPrice = monthlyUsageBasedPrice; + this.overuse = overuse; + this.percentUsed = percentUsed; this.period = period; this.plan = plan; + this.planEntitlement = planEntitlement; this.priceBehavior = priceBehavior; this.softLimit = softLimit; this.usage = usage; @@ -117,6 +186,76 @@ public FeatureUsageResponseDataAllocationType getAllocationType() { return allocationType; } + @JsonProperty("company_override") + public Optional getCompanyOverride() { + return companyOverride; + } + + /** + * @return The rate at which credits are consumed per unit of usage + */ + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + + @JsonProperty("credit_grant_counts") + public Optional> getCreditGrantCounts() { + return creditGrantCounts; + } + + @JsonProperty("credit_grant_details") + public Optional> getCreditGrantDetails() { + return creditGrantDetails; + } + + /** + * @return Reason for the credit grant + */ + @JsonProperty("credit_grant_reason") + public Optional getCreditGrantReason() { + return creditGrantReason; + } + + @JsonProperty("credit_remaining") + public Optional getCreditRemaining() { + return creditRemaining; + } + + @JsonProperty("credit_total") + public Optional getCreditTotal() { + return creditTotal; + } + + /** + * @return Icon identifier for the credit type + */ + @JsonProperty("credit_type_icon") + public Optional getCreditTypeIcon() { + return creditTypeIcon; + } + + @JsonProperty("credit_used") + public Optional getCreditUsed() { + return creditUsed; + } + + /** + * @return Effective limit for usage calculations. For overage pricing, this is the soft limit where overage charges begin. For tiered pricing, this is the first tier boundary. For other pricing models, this is the base allocation. Used to calculate usage percentages and determine access thresholds. + */ + @JsonProperty("effective_limit") + public Optional getEffectiveLimit() { + return effectiveLimit; + } + + /** + * @return Per-unit price for current usage scenario + */ + @JsonProperty("effective_price") + public Optional getEffectivePrice() { + return effectivePrice; + } + @JsonProperty("entitlement_expiration_date") public Optional getEntitlementExpirationDate() { return entitlementExpirationDate; @@ -127,6 +266,14 @@ public String getEntitlementId() { return entitlementId; } + /** + * @return Source of the entitlement (plan or company_override) + */ + @JsonProperty("entitlement_source") + public Optional getEntitlementSource() { + return entitlementSource; + } + @JsonProperty("entitlement_type") public String getEntitlementType() { return entitlementType; @@ -137,6 +284,22 @@ public Optional getFeature() { return feature; } + /** + * @return Whether a valid allocation exists + */ + @JsonProperty("has_valid_allocation") + public Optional getHasValidAllocation() { + return hasValidAllocation; + } + + /** + * @return Whether this is an unlimited allocation + */ + @JsonProperty("is_unlimited") + public Optional getIsUnlimited() { + return isUnlimited; + } + /** * @return The time at which the metric will reset. */ @@ -158,6 +321,22 @@ public Optional getMonthlyUsageBasedPrice() { return monthlyUsageBasedPrice; } + /** + * @return Amount of usage exceeding soft limit (overage pricing only) + */ + @JsonProperty("overuse") + public Optional getOveruse() { + return overuse; + } + + /** + * @return Percentage of allocation consumed (0-100+) + */ + @JsonProperty("percent_used") + public Optional getPercentUsed() { + return percentUsed; + } + /** * @return The period over which usage is measured. */ @@ -171,6 +350,11 @@ public Optional getPlan() { return plan; } + @JsonProperty("plan_entitlement") + public Optional getPlanEntitlement() { + return planEntitlement; + } + @JsonProperty("price_behavior") public Optional getPriceBehavior() { return priceBehavior; @@ -212,15 +396,32 @@ private boolean equalTo(FeatureUsageResponseData other) { return access == other.access && allocation.equals(other.allocation) && allocationType.equals(other.allocationType) + && companyOverride.equals(other.companyOverride) + && creditConsumptionRate.equals(other.creditConsumptionRate) + && creditGrantCounts.equals(other.creditGrantCounts) + && creditGrantDetails.equals(other.creditGrantDetails) + && creditGrantReason.equals(other.creditGrantReason) + && creditRemaining.equals(other.creditRemaining) + && creditTotal.equals(other.creditTotal) + && creditTypeIcon.equals(other.creditTypeIcon) + && creditUsed.equals(other.creditUsed) + && effectiveLimit.equals(other.effectiveLimit) + && effectivePrice.equals(other.effectivePrice) && entitlementExpirationDate.equals(other.entitlementExpirationDate) && entitlementId.equals(other.entitlementId) + && entitlementSource.equals(other.entitlementSource) && entitlementType.equals(other.entitlementType) && feature.equals(other.feature) + && hasValidAllocation.equals(other.hasValidAllocation) + && isUnlimited.equals(other.isUnlimited) && metricResetAt.equals(other.metricResetAt) && monthReset.equals(other.monthReset) && monthlyUsageBasedPrice.equals(other.monthlyUsageBasedPrice) + && overuse.equals(other.overuse) + && percentUsed.equals(other.percentUsed) && period.equals(other.period) && plan.equals(other.plan) + && planEntitlement.equals(other.planEntitlement) && priceBehavior.equals(other.priceBehavior) && softLimit.equals(other.softLimit) && usage.equals(other.usage) @@ -233,15 +434,32 @@ public int hashCode() { this.access, this.allocation, this.allocationType, + this.companyOverride, + this.creditConsumptionRate, + this.creditGrantCounts, + this.creditGrantDetails, + this.creditGrantReason, + this.creditRemaining, + this.creditTotal, + this.creditTypeIcon, + this.creditUsed, + this.effectiveLimit, + this.effectivePrice, this.entitlementExpirationDate, this.entitlementId, + this.entitlementSource, this.entitlementType, this.feature, + this.hasValidAllocation, + this.isUnlimited, this.metricResetAt, this.monthReset, this.monthlyUsageBasedPrice, + this.overuse, + this.percentUsed, this.period, this.plan, + this.planEntitlement, this.priceBehavior, this.softLimit, this.usage, @@ -258,12 +476,18 @@ public static AccessStage builder() { } public interface AccessStage { + /** + *

Whether further usage is permitted.

+ */ AllocationTypeStage access(boolean access); Builder from(FeatureUsageResponseData other); } public interface AllocationTypeStage { + /** + *

The type of allocation that is being used.

+ */ EntitlementIdStage allocationType(@NotNull FeatureUsageResponseDataAllocationType allocationType); } @@ -278,22 +502,111 @@ public interface EntitlementTypeStage { public interface _FinalStage { FeatureUsageResponseData build(); + /** + *

The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted.

+ */ _FinalStage allocation(Optional allocation); _FinalStage allocation(Integer allocation); + _FinalStage companyOverride(Optional companyOverride); + + _FinalStage companyOverride(CompanyOverrideResponseData companyOverride); + + /** + *

The rate at which credits are consumed per unit of usage

+ */ + _FinalStage creditConsumptionRate(Optional creditConsumptionRate); + + _FinalStage creditConsumptionRate(Double creditConsumptionRate); + + _FinalStage creditGrantCounts(Optional> creditGrantCounts); + + _FinalStage creditGrantCounts(Map creditGrantCounts); + + _FinalStage creditGrantDetails(Optional> creditGrantDetails); + + _FinalStage creditGrantDetails(List creditGrantDetails); + + /** + *

Reason for the credit grant

+ */ + _FinalStage creditGrantReason(Optional creditGrantReason); + + _FinalStage creditGrantReason(FeatureUsageResponseDataCreditGrantReason creditGrantReason); + + _FinalStage creditRemaining(Optional creditRemaining); + + _FinalStage creditRemaining(Double creditRemaining); + + _FinalStage creditTotal(Optional creditTotal); + + _FinalStage creditTotal(Double creditTotal); + + /** + *

Icon identifier for the credit type

+ */ + _FinalStage creditTypeIcon(Optional creditTypeIcon); + + _FinalStage creditTypeIcon(String creditTypeIcon); + + _FinalStage creditUsed(Optional creditUsed); + + _FinalStage creditUsed(Double creditUsed); + + /** + *

Effective limit for usage calculations. For overage pricing, this is the soft limit where overage charges begin. For tiered pricing, this is the first tier boundary. For other pricing models, this is the base allocation. Used to calculate usage percentages and determine access thresholds.

+ */ + _FinalStage effectiveLimit(Optional effectiveLimit); + + _FinalStage effectiveLimit(Integer effectiveLimit); + + /** + *

Per-unit price for current usage scenario

+ */ + _FinalStage effectivePrice(Optional effectivePrice); + + _FinalStage effectivePrice(Double effectivePrice); + _FinalStage entitlementExpirationDate(Optional entitlementExpirationDate); _FinalStage entitlementExpirationDate(OffsetDateTime entitlementExpirationDate); + /** + *

Source of the entitlement (plan or company_override)

+ */ + _FinalStage entitlementSource(Optional entitlementSource); + + _FinalStage entitlementSource(String entitlementSource); + _FinalStage feature(Optional feature); _FinalStage feature(FeatureDetailResponseData feature); + /** + *

Whether a valid allocation exists

+ */ + _FinalStage hasValidAllocation(Optional hasValidAllocation); + + _FinalStage hasValidAllocation(Boolean hasValidAllocation); + + /** + *

Whether this is an unlimited allocation

+ */ + _FinalStage isUnlimited(Optional isUnlimited); + + _FinalStage isUnlimited(Boolean isUnlimited); + + /** + *

The time at which the metric will reset.

+ */ _FinalStage metricResetAt(Optional metricResetAt); _FinalStage metricResetAt(OffsetDateTime metricResetAt); + /** + *

If the period is current_month, when the month resets.

+ */ _FinalStage monthReset(Optional monthReset); _FinalStage monthReset(String monthReset); @@ -302,6 +615,23 @@ public interface _FinalStage { _FinalStage monthlyUsageBasedPrice(BillingPriceView monthlyUsageBasedPrice); + /** + *

Amount of usage exceeding soft limit (overage pricing only)

+ */ + _FinalStage overuse(Optional overuse); + + _FinalStage overuse(Integer overuse); + + /** + *

Percentage of allocation consumed (0-100+)

+ */ + _FinalStage percentUsed(Optional percentUsed); + + _FinalStage percentUsed(Double percentUsed); + + /** + *

The period over which usage is measured.

+ */ _FinalStage period(Optional period); _FinalStage period(String period); @@ -310,14 +640,24 @@ public interface _FinalStage { _FinalStage plan(PlanResponseData plan); + _FinalStage planEntitlement(Optional planEntitlement); + + _FinalStage planEntitlement(PlanEntitlementResponseData planEntitlement); + _FinalStage priceBehavior(Optional priceBehavior); _FinalStage priceBehavior(String priceBehavior); + /** + *

The soft limit for the feature usage. Available only for overage price behavior

+ */ _FinalStage softLimit(Optional softLimit); _FinalStage softLimit(Integer softLimit); + /** + *

The amount of usage that has been consumed; a null value indicates that usage is not being measured.

+ */ _FinalStage usage(Optional usage); _FinalStage usage(Integer usage); @@ -346,20 +686,54 @@ public static final class Builder private Optional priceBehavior = Optional.empty(); + private Optional planEntitlement = Optional.empty(); + private Optional plan = Optional.empty(); private Optional period = Optional.empty(); + private Optional percentUsed = Optional.empty(); + + private Optional overuse = Optional.empty(); + private Optional monthlyUsageBasedPrice = Optional.empty(); private Optional monthReset = Optional.empty(); private Optional metricResetAt = Optional.empty(); + private Optional isUnlimited = Optional.empty(); + + private Optional hasValidAllocation = Optional.empty(); + private Optional feature = Optional.empty(); + private Optional entitlementSource = Optional.empty(); + private Optional entitlementExpirationDate = Optional.empty(); + private Optional effectivePrice = Optional.empty(); + + private Optional effectiveLimit = Optional.empty(); + + private Optional creditUsed = Optional.empty(); + + private Optional creditTypeIcon = Optional.empty(); + + private Optional creditTotal = Optional.empty(); + + private Optional creditRemaining = Optional.empty(); + + private Optional creditGrantReason = Optional.empty(); + + private Optional> creditGrantDetails = Optional.empty(); + + private Optional> creditGrantCounts = Optional.empty(); + + private Optional creditConsumptionRate = Optional.empty(); + + private Optional companyOverride = Optional.empty(); + private Optional allocation = Optional.empty(); @JsonAnySetter @@ -372,15 +746,32 @@ public Builder from(FeatureUsageResponseData other) { access(other.getAccess()); allocation(other.getAllocation()); allocationType(other.getAllocationType()); + companyOverride(other.getCompanyOverride()); + creditConsumptionRate(other.getCreditConsumptionRate()); + creditGrantCounts(other.getCreditGrantCounts()); + creditGrantDetails(other.getCreditGrantDetails()); + creditGrantReason(other.getCreditGrantReason()); + creditRemaining(other.getCreditRemaining()); + creditTotal(other.getCreditTotal()); + creditTypeIcon(other.getCreditTypeIcon()); + creditUsed(other.getCreditUsed()); + effectiveLimit(other.getEffectiveLimit()); + effectivePrice(other.getEffectivePrice()); entitlementExpirationDate(other.getEntitlementExpirationDate()); entitlementId(other.getEntitlementId()); + entitlementSource(other.getEntitlementSource()); entitlementType(other.getEntitlementType()); feature(other.getFeature()); + hasValidAllocation(other.getHasValidAllocation()); + isUnlimited(other.getIsUnlimited()); metricResetAt(other.getMetricResetAt()); monthReset(other.getMonthReset()); monthlyUsageBasedPrice(other.getMonthlyUsageBasedPrice()); + overuse(other.getOveruse()); + percentUsed(other.getPercentUsed()); period(other.getPeriod()); plan(other.getPlan()); + planEntitlement(other.getPlanEntitlement()); priceBehavior(other.getPriceBehavior()); softLimit(other.getSoftLimit()); usage(other.getUsage()); @@ -389,6 +780,7 @@ public Builder from(FeatureUsageResponseData other) { } /** + *

Whether further usage is permitted.

*

Whether further usage is permitted.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -400,6 +792,7 @@ public AllocationTypeStage access(boolean access) { } /** + *

The type of allocation that is being used.

*

The type of allocation that is being used.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -447,6 +840,9 @@ public _FinalStage usage(Integer usage) { return this; } + /** + *

The amount of usage that has been consumed; a null value indicates that usage is not being measured.

+ */ @java.lang.Override @JsonSetter(value = "usage", nulls = Nulls.SKIP) public _FinalStage usage(Optional usage) { @@ -464,6 +860,9 @@ public _FinalStage softLimit(Integer softLimit) { return this; } + /** + *

The soft limit for the feature usage. Available only for overage price behavior

+ */ @java.lang.Override @JsonSetter(value = "soft_limit", nulls = Nulls.SKIP) public _FinalStage softLimit(Optional softLimit) { @@ -484,6 +883,19 @@ public _FinalStage priceBehavior(Optional priceBehavior) { return this; } + @java.lang.Override + public _FinalStage planEntitlement(PlanEntitlementResponseData planEntitlement) { + this.planEntitlement = Optional.ofNullable(planEntitlement); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plan_entitlement", nulls = Nulls.SKIP) + public _FinalStage planEntitlement(Optional planEntitlement) { + this.planEntitlement = planEntitlement; + return this; + } + @java.lang.Override public _FinalStage plan(PlanResponseData plan) { this.plan = Optional.ofNullable(plan); @@ -507,6 +919,9 @@ public _FinalStage period(String period) { return this; } + /** + *

The period over which usage is measured.

+ */ @java.lang.Override @JsonSetter(value = "period", nulls = Nulls.SKIP) public _FinalStage period(Optional period) { @@ -514,6 +929,46 @@ public _FinalStage period(Optional period) { return this; } + /** + *

Percentage of allocation consumed (0-100+)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage percentUsed(Double percentUsed) { + this.percentUsed = Optional.ofNullable(percentUsed); + return this; + } + + /** + *

Percentage of allocation consumed (0-100+)

+ */ + @java.lang.Override + @JsonSetter(value = "percent_used", nulls = Nulls.SKIP) + public _FinalStage percentUsed(Optional percentUsed) { + this.percentUsed = percentUsed; + return this; + } + + /** + *

Amount of usage exceeding soft limit (overage pricing only)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage overuse(Integer overuse) { + this.overuse = Optional.ofNullable(overuse); + return this; + } + + /** + *

Amount of usage exceeding soft limit (overage pricing only)

+ */ + @java.lang.Override + @JsonSetter(value = "overuse", nulls = Nulls.SKIP) + public _FinalStage overuse(Optional overuse) { + this.overuse = overuse; + return this; + } + @java.lang.Override public _FinalStage monthlyUsageBasedPrice(BillingPriceView monthlyUsageBasedPrice) { this.monthlyUsageBasedPrice = Optional.ofNullable(monthlyUsageBasedPrice); @@ -537,6 +992,9 @@ public _FinalStage monthReset(String monthReset) { return this; } + /** + *

If the period is current_month, when the month resets.

+ */ @java.lang.Override @JsonSetter(value = "month_reset", nulls = Nulls.SKIP) public _FinalStage monthReset(Optional monthReset) { @@ -554,6 +1012,9 @@ public _FinalStage metricResetAt(OffsetDateTime metricResetAt) { return this; } + /** + *

The time at which the metric will reset.

+ */ @java.lang.Override @JsonSetter(value = "metric_reset_at", nulls = Nulls.SKIP) public _FinalStage metricResetAt(Optional metricResetAt) { @@ -561,6 +1022,46 @@ public _FinalStage metricResetAt(Optional metricResetAt) { return this; } + /** + *

Whether this is an unlimited allocation

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage isUnlimited(Boolean isUnlimited) { + this.isUnlimited = Optional.ofNullable(isUnlimited); + return this; + } + + /** + *

Whether this is an unlimited allocation

+ */ + @java.lang.Override + @JsonSetter(value = "is_unlimited", nulls = Nulls.SKIP) + public _FinalStage isUnlimited(Optional isUnlimited) { + this.isUnlimited = isUnlimited; + return this; + } + + /** + *

Whether a valid allocation exists

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage hasValidAllocation(Boolean hasValidAllocation) { + this.hasValidAllocation = Optional.ofNullable(hasValidAllocation); + return this; + } + + /** + *

Whether a valid allocation exists

+ */ + @java.lang.Override + @JsonSetter(value = "has_valid_allocation", nulls = Nulls.SKIP) + public _FinalStage hasValidAllocation(Optional hasValidAllocation) { + this.hasValidAllocation = hasValidAllocation; + return this; + } + @java.lang.Override public _FinalStage feature(FeatureDetailResponseData feature) { this.feature = Optional.ofNullable(feature); @@ -574,6 +1075,26 @@ public _FinalStage feature(Optional feature) { return this; } + /** + *

Source of the entitlement (plan or company_override)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage entitlementSource(String entitlementSource) { + this.entitlementSource = Optional.ofNullable(entitlementSource); + return this; + } + + /** + *

Source of the entitlement (plan or company_override)

+ */ + @java.lang.Override + @JsonSetter(value = "entitlement_source", nulls = Nulls.SKIP) + public _FinalStage entitlementSource(Optional entitlementSource) { + this.entitlementSource = entitlementSource; + return this; + } + @java.lang.Override public _FinalStage entitlementExpirationDate(OffsetDateTime entitlementExpirationDate) { this.entitlementExpirationDate = Optional.ofNullable(entitlementExpirationDate); @@ -587,6 +1108,184 @@ public _FinalStage entitlementExpirationDate(Optional entitlemen return this; } + /** + *

Per-unit price for current usage scenario

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage effectivePrice(Double effectivePrice) { + this.effectivePrice = Optional.ofNullable(effectivePrice); + return this; + } + + /** + *

Per-unit price for current usage scenario

+ */ + @java.lang.Override + @JsonSetter(value = "effective_price", nulls = Nulls.SKIP) + public _FinalStage effectivePrice(Optional effectivePrice) { + this.effectivePrice = effectivePrice; + return this; + } + + /** + *

Effective limit for usage calculations. For overage pricing, this is the soft limit where overage charges begin. For tiered pricing, this is the first tier boundary. For other pricing models, this is the base allocation. Used to calculate usage percentages and determine access thresholds.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage effectiveLimit(Integer effectiveLimit) { + this.effectiveLimit = Optional.ofNullable(effectiveLimit); + return this; + } + + /** + *

Effective limit for usage calculations. For overage pricing, this is the soft limit where overage charges begin. For tiered pricing, this is the first tier boundary. For other pricing models, this is the base allocation. Used to calculate usage percentages and determine access thresholds.

+ */ + @java.lang.Override + @JsonSetter(value = "effective_limit", nulls = Nulls.SKIP) + public _FinalStage effectiveLimit(Optional effectiveLimit) { + this.effectiveLimit = effectiveLimit; + return this; + } + + @java.lang.Override + public _FinalStage creditUsed(Double creditUsed) { + this.creditUsed = Optional.ofNullable(creditUsed); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_used", nulls = Nulls.SKIP) + public _FinalStage creditUsed(Optional creditUsed) { + this.creditUsed = creditUsed; + return this; + } + + /** + *

Icon identifier for the credit type

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creditTypeIcon(String creditTypeIcon) { + this.creditTypeIcon = Optional.ofNullable(creditTypeIcon); + return this; + } + + /** + *

Icon identifier for the credit type

+ */ + @java.lang.Override + @JsonSetter(value = "credit_type_icon", nulls = Nulls.SKIP) + public _FinalStage creditTypeIcon(Optional creditTypeIcon) { + this.creditTypeIcon = creditTypeIcon; + return this; + } + + @java.lang.Override + public _FinalStage creditTotal(Double creditTotal) { + this.creditTotal = Optional.ofNullable(creditTotal); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_total", nulls = Nulls.SKIP) + public _FinalStage creditTotal(Optional creditTotal) { + this.creditTotal = creditTotal; + return this; + } + + @java.lang.Override + public _FinalStage creditRemaining(Double creditRemaining) { + this.creditRemaining = Optional.ofNullable(creditRemaining); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_remaining", nulls = Nulls.SKIP) + public _FinalStage creditRemaining(Optional creditRemaining) { + this.creditRemaining = creditRemaining; + return this; + } + + /** + *

Reason for the credit grant

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creditGrantReason(FeatureUsageResponseDataCreditGrantReason creditGrantReason) { + this.creditGrantReason = Optional.ofNullable(creditGrantReason); + return this; + } + + /** + *

Reason for the credit grant

+ */ + @java.lang.Override + @JsonSetter(value = "credit_grant_reason", nulls = Nulls.SKIP) + public _FinalStage creditGrantReason(Optional creditGrantReason) { + this.creditGrantReason = creditGrantReason; + return this; + } + + @java.lang.Override + public _FinalStage creditGrantDetails(List creditGrantDetails) { + this.creditGrantDetails = Optional.ofNullable(creditGrantDetails); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_grant_details", nulls = Nulls.SKIP) + public _FinalStage creditGrantDetails(Optional> creditGrantDetails) { + this.creditGrantDetails = creditGrantDetails; + return this; + } + + @java.lang.Override + public _FinalStage creditGrantCounts(Map creditGrantCounts) { + this.creditGrantCounts = Optional.ofNullable(creditGrantCounts); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_grant_counts", nulls = Nulls.SKIP) + public _FinalStage creditGrantCounts(Optional> creditGrantCounts) { + this.creditGrantCounts = creditGrantCounts; + return this; + } + + /** + *

The rate at which credits are consumed per unit of usage

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + /** + *

The rate at which credits are consumed per unit of usage

+ */ + @java.lang.Override + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public _FinalStage creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + + @java.lang.Override + public _FinalStage companyOverride(CompanyOverrideResponseData companyOverride) { + this.companyOverride = Optional.ofNullable(companyOverride); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company_override", nulls = Nulls.SKIP) + public _FinalStage companyOverride(Optional companyOverride) { + this.companyOverride = companyOverride; + return this; + } + /** *

The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted.

* @return Reference to {@code this} so that method calls can be chained together. @@ -597,6 +1296,9 @@ public _FinalStage allocation(Integer allocation) { return this; } + /** + *

The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted.

+ */ @java.lang.Override @JsonSetter(value = "allocation", nulls = Nulls.SKIP) public _FinalStage allocation(Optional allocation) { @@ -610,15 +1312,32 @@ public FeatureUsageResponseData build() { access, allocation, allocationType, + companyOverride, + creditConsumptionRate, + creditGrantCounts, + creditGrantDetails, + creditGrantReason, + creditRemaining, + creditTotal, + creditTypeIcon, + creditUsed, + effectiveLimit, + effectivePrice, entitlementExpirationDate, entitlementId, + entitlementSource, entitlementType, feature, + hasValidAllocation, + isUnlimited, metricResetAt, monthReset, monthlyUsageBasedPrice, + overuse, + percentUsed, period, plan, + planEntitlement, priceBehavior, softLimit, usage, diff --git a/src/main/java/com/schematic/api/types/FeatureUsageResponseDataAllocationType.java b/src/main/java/com/schematic/api/types/FeatureUsageResponseDataAllocationType.java index 26779a1..33f1b2d 100644 --- a/src/main/java/com/schematic/api/types/FeatureUsageResponseDataAllocationType.java +++ b/src/main/java/com/schematic/api/types/FeatureUsageResponseDataAllocationType.java @@ -3,26 +3,106 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum FeatureUsageResponseDataAllocationType { - BOOLEAN("boolean"), +public final class FeatureUsageResponseDataAllocationType { + public static final FeatureUsageResponseDataAllocationType NUMERIC = + new FeatureUsageResponseDataAllocationType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final FeatureUsageResponseDataAllocationType TRAIT = + new FeatureUsageResponseDataAllocationType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final FeatureUsageResponseDataAllocationType BOOLEAN = + new FeatureUsageResponseDataAllocationType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final FeatureUsageResponseDataAllocationType UNLIMITED = + new FeatureUsageResponseDataAllocationType(Value.UNLIMITED, "unlimited"); - private final String value; + private final Value value; - FeatureUsageResponseDataAllocationType(String value) { + private final String string; + + FeatureUsageResponseDataAllocationType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof FeatureUsageResponseDataAllocationType + && this.string.equals(((FeatureUsageResponseDataAllocationType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case UNLIMITED: + return visitor.visitUnlimited(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static FeatureUsageResponseDataAllocationType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "unlimited": + return UNLIMITED; + default: + return new FeatureUsageResponseDataAllocationType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/FeatureUsageResponseDataCreditGrantReason.java b/src/main/java/com/schematic/api/types/FeatureUsageResponseDataCreditGrantReason.java new file mode 100644 index 0000000..c12e8d6 --- /dev/null +++ b/src/main/java/com/schematic/api/types/FeatureUsageResponseDataCreditGrantReason.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class FeatureUsageResponseDataCreditGrantReason { + public static final FeatureUsageResponseDataCreditGrantReason PURCHASED = + new FeatureUsageResponseDataCreditGrantReason(Value.PURCHASED, "purchased"); + + public static final FeatureUsageResponseDataCreditGrantReason PLAN = + new FeatureUsageResponseDataCreditGrantReason(Value.PLAN, "plan"); + + public static final FeatureUsageResponseDataCreditGrantReason FREE = + new FeatureUsageResponseDataCreditGrantReason(Value.FREE, "free"); + + private final Value value; + + private final String string; + + FeatureUsageResponseDataCreditGrantReason(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof FeatureUsageResponseDataCreditGrantReason + && this.string.equals(((FeatureUsageResponseDataCreditGrantReason) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PURCHASED: + return visitor.visitPurchased(); + case PLAN: + return visitor.visitPlan(); + case FREE: + return visitor.visitFree(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static FeatureUsageResponseDataCreditGrantReason valueOf(String value) { + switch (value) { + case "purchased": + return PURCHASED; + case "plan": + return PLAN; + case "free": + return FREE; + default: + return new FeatureUsageResponseDataCreditGrantReason(Value.UNKNOWN, value); + } + } + + public enum Value { + FREE, + + PLAN, + + PURCHASED, + + UNKNOWN + } + + public interface Visitor { + T visitFree(); + + T visitPlan(); + + T visitPurchased(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/FlagDetailResponseData.java b/src/main/java/com/schematic/api/types/FlagDetailResponseData.java index 95dece4..f882038 100644 --- a/src/main/java/com/schematic/api/types/FlagDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/FlagDetailResponseData.java @@ -380,7 +380,9 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { @java.lang.Override public _FinalStage addAllRules(List rules) { - this.rules.addAll(rules); + if (rules != null) { + this.rules.addAll(rules); + } return this; } @@ -394,7 +396,9 @@ public _FinalStage addRules(RuleDetailResponseData rules) { @JsonSetter(value = "rules", nulls = Nulls.SKIP) public _FinalStage rules(List rules) { this.rules.clear(); - this.rules.addAll(rules); + if (rules != null) { + this.rules.addAll(rules); + } return this; } diff --git a/src/main/java/com/schematic/api/types/KeysRequestBody.java b/src/main/java/com/schematic/api/types/KeysRequestBody.java index 174d391..c79c8a8 100644 --- a/src/main/java/com/schematic/api/types/KeysRequestBody.java +++ b/src/main/java/com/schematic/api/types/KeysRequestBody.java @@ -80,12 +80,16 @@ public Builder from(KeysRequestBody other) { @JsonSetter(value = "keys", nulls = Nulls.SKIP) public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } diff --git a/src/main/java/com/schematic/api/types/ManagePlanPreviewResponseResponseData.java b/src/main/java/com/schematic/api/types/ManagePlanPreviewResponseResponseData.java new file mode 100644 index 0000000..89db780 --- /dev/null +++ b/src/main/java/com/schematic/api/types/ManagePlanPreviewResponseResponseData.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ManagePlanPreviewResponseResponseData.Builder.class) +public final class ManagePlanPreviewResponseResponseData { + private final Optional subscriptionChangePreview; + + private final Map additionalProperties; + + private ManagePlanPreviewResponseResponseData( + Optional subscriptionChangePreview, + Map additionalProperties) { + this.subscriptionChangePreview = subscriptionChangePreview; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("subscription_change_preview") + public Optional getSubscriptionChangePreview() { + return subscriptionChangePreview; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ManagePlanPreviewResponseResponseData + && equalTo((ManagePlanPreviewResponseResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ManagePlanPreviewResponseResponseData other) { + return subscriptionChangePreview.equals(other.subscriptionChangePreview); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.subscriptionChangePreview); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional subscriptionChangePreview = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ManagePlanPreviewResponseResponseData other) { + subscriptionChangePreview(other.getSubscriptionChangePreview()); + return this; + } + + @JsonSetter(value = "subscription_change_preview", nulls = Nulls.SKIP) + public Builder subscriptionChangePreview( + Optional subscriptionChangePreview) { + this.subscriptionChangePreview = subscriptionChangePreview; + return this; + } + + public Builder subscriptionChangePreview(PreviewSubscriptionChangeResponseData subscriptionChangePreview) { + this.subscriptionChangePreview = Optional.ofNullable(subscriptionChangePreview); + return this; + } + + public ManagePlanPreviewResponseResponseData build() { + return new ManagePlanPreviewResponseResponseData(subscriptionChangePreview, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/ManagePlanRequest.java b/src/main/java/com/schematic/api/types/ManagePlanRequest.java new file mode 100644 index 0000000..731ae45 --- /dev/null +++ b/src/main/java/com/schematic/api/types/ManagePlanRequest.java @@ -0,0 +1,407 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ManagePlanRequest.Builder.class) +public final class ManagePlanRequest { + private final List addOnSelections; + + private final Optional basePlanId; + + private final Optional basePlanPriceId; + + private final String companyId; + + private final Optional couponExternalId; + + private final List creditBundles; + + private final List payInAdvanceEntitlements; + + private final Optional paymentMethodExternalId; + + private final Optional promoCode; + + private final Map additionalProperties; + + private ManagePlanRequest( + List addOnSelections, + Optional basePlanId, + Optional basePlanPriceId, + String companyId, + Optional couponExternalId, + List creditBundles, + List payInAdvanceEntitlements, + Optional paymentMethodExternalId, + Optional promoCode, + Map additionalProperties) { + this.addOnSelections = addOnSelections; + this.basePlanId = basePlanId; + this.basePlanPriceId = basePlanPriceId; + this.companyId = companyId; + this.couponExternalId = couponExternalId; + this.creditBundles = creditBundles; + this.payInAdvanceEntitlements = payInAdvanceEntitlements; + this.paymentMethodExternalId = paymentMethodExternalId; + this.promoCode = promoCode; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("add_on_selections") + public List getAddOnSelections() { + return addOnSelections; + } + + @JsonProperty("base_plan_id") + public Optional getBasePlanId() { + return basePlanId; + } + + @JsonProperty("base_plan_price_id") + public Optional getBasePlanPriceId() { + return basePlanPriceId; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("coupon_external_id") + public Optional getCouponExternalId() { + return couponExternalId; + } + + @JsonProperty("credit_bundles") + public List getCreditBundles() { + return creditBundles; + } + + @JsonProperty("pay_in_advance_entitlements") + public List getPayInAdvanceEntitlements() { + return payInAdvanceEntitlements; + } + + @JsonProperty("payment_method_external_id") + public Optional getPaymentMethodExternalId() { + return paymentMethodExternalId; + } + + @JsonProperty("promo_code") + public Optional getPromoCode() { + return promoCode; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ManagePlanRequest && equalTo((ManagePlanRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ManagePlanRequest other) { + return addOnSelections.equals(other.addOnSelections) + && basePlanId.equals(other.basePlanId) + && basePlanPriceId.equals(other.basePlanPriceId) + && companyId.equals(other.companyId) + && couponExternalId.equals(other.couponExternalId) + && creditBundles.equals(other.creditBundles) + && payInAdvanceEntitlements.equals(other.payInAdvanceEntitlements) + && paymentMethodExternalId.equals(other.paymentMethodExternalId) + && promoCode.equals(other.promoCode); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.addOnSelections, + this.basePlanId, + this.basePlanPriceId, + this.companyId, + this.couponExternalId, + this.creditBundles, + this.payInAdvanceEntitlements, + this.paymentMethodExternalId, + this.promoCode); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CompanyIdStage builder() { + return new Builder(); + } + + public interface CompanyIdStage { + _FinalStage companyId(@NotNull String companyId); + + Builder from(ManagePlanRequest other); + } + + public interface _FinalStage { + ManagePlanRequest build(); + + _FinalStage addOnSelections(List addOnSelections); + + _FinalStage addAddOnSelections(PlanSelection addOnSelections); + + _FinalStage addAllAddOnSelections(List addOnSelections); + + _FinalStage basePlanId(Optional basePlanId); + + _FinalStage basePlanId(String basePlanId); + + _FinalStage basePlanPriceId(Optional basePlanPriceId); + + _FinalStage basePlanPriceId(String basePlanPriceId); + + _FinalStage couponExternalId(Optional couponExternalId); + + _FinalStage couponExternalId(String couponExternalId); + + _FinalStage creditBundles(List creditBundles); + + _FinalStage addCreditBundles(UpdateCreditBundleRequestBody creditBundles); + + _FinalStage addAllCreditBundles(List creditBundles); + + _FinalStage payInAdvanceEntitlements(List payInAdvanceEntitlements); + + _FinalStage addPayInAdvanceEntitlements(UpdatePayInAdvanceRequestBody payInAdvanceEntitlements); + + _FinalStage addAllPayInAdvanceEntitlements(List payInAdvanceEntitlements); + + _FinalStage paymentMethodExternalId(Optional paymentMethodExternalId); + + _FinalStage paymentMethodExternalId(String paymentMethodExternalId); + + _FinalStage promoCode(Optional promoCode); + + _FinalStage promoCode(String promoCode); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CompanyIdStage, _FinalStage { + private String companyId; + + private Optional promoCode = Optional.empty(); + + private Optional paymentMethodExternalId = Optional.empty(); + + private List payInAdvanceEntitlements = new ArrayList<>(); + + private List creditBundles = new ArrayList<>(); + + private Optional couponExternalId = Optional.empty(); + + private Optional basePlanPriceId = Optional.empty(); + + private Optional basePlanId = Optional.empty(); + + private List addOnSelections = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ManagePlanRequest other) { + addOnSelections(other.getAddOnSelections()); + basePlanId(other.getBasePlanId()); + basePlanPriceId(other.getBasePlanPriceId()); + companyId(other.getCompanyId()); + couponExternalId(other.getCouponExternalId()); + creditBundles(other.getCreditBundles()); + payInAdvanceEntitlements(other.getPayInAdvanceEntitlements()); + paymentMethodExternalId(other.getPaymentMethodExternalId()); + promoCode(other.getPromoCode()); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage promoCode(String promoCode) { + this.promoCode = Optional.ofNullable(promoCode); + return this; + } + + @java.lang.Override + @JsonSetter(value = "promo_code", nulls = Nulls.SKIP) + public _FinalStage promoCode(Optional promoCode) { + this.promoCode = promoCode; + return this; + } + + @java.lang.Override + public _FinalStage paymentMethodExternalId(String paymentMethodExternalId) { + this.paymentMethodExternalId = Optional.ofNullable(paymentMethodExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "payment_method_external_id", nulls = Nulls.SKIP) + public _FinalStage paymentMethodExternalId(Optional paymentMethodExternalId) { + this.paymentMethodExternalId = paymentMethodExternalId; + return this; + } + + @java.lang.Override + public _FinalStage addAllPayInAdvanceEntitlements( + List payInAdvanceEntitlements) { + if (payInAdvanceEntitlements != null) { + this.payInAdvanceEntitlements.addAll(payInAdvanceEntitlements); + } + return this; + } + + @java.lang.Override + public _FinalStage addPayInAdvanceEntitlements(UpdatePayInAdvanceRequestBody payInAdvanceEntitlements) { + this.payInAdvanceEntitlements.add(payInAdvanceEntitlements); + return this; + } + + @java.lang.Override + @JsonSetter(value = "pay_in_advance_entitlements", nulls = Nulls.SKIP) + public _FinalStage payInAdvanceEntitlements(List payInAdvanceEntitlements) { + this.payInAdvanceEntitlements.clear(); + if (payInAdvanceEntitlements != null) { + this.payInAdvanceEntitlements.addAll(payInAdvanceEntitlements); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllCreditBundles(List creditBundles) { + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } + return this; + } + + @java.lang.Override + public _FinalStage addCreditBundles(UpdateCreditBundleRequestBody creditBundles) { + this.creditBundles.add(creditBundles); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_bundles", nulls = Nulls.SKIP) + public _FinalStage creditBundles(List creditBundles) { + this.creditBundles.clear(); + if (creditBundles != null) { + this.creditBundles.addAll(creditBundles); + } + return this; + } + + @java.lang.Override + public _FinalStage couponExternalId(String couponExternalId) { + this.couponExternalId = Optional.ofNullable(couponExternalId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "coupon_external_id", nulls = Nulls.SKIP) + public _FinalStage couponExternalId(Optional couponExternalId) { + this.couponExternalId = couponExternalId; + return this; + } + + @java.lang.Override + public _FinalStage basePlanPriceId(String basePlanPriceId) { + this.basePlanPriceId = Optional.ofNullable(basePlanPriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "base_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage basePlanPriceId(Optional basePlanPriceId) { + this.basePlanPriceId = basePlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage basePlanId(String basePlanId) { + this.basePlanId = Optional.ofNullable(basePlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "base_plan_id", nulls = Nulls.SKIP) + public _FinalStage basePlanId(Optional basePlanId) { + this.basePlanId = basePlanId; + return this; + } + + @java.lang.Override + public _FinalStage addAllAddOnSelections(List addOnSelections) { + if (addOnSelections != null) { + this.addOnSelections.addAll(addOnSelections); + } + return this; + } + + @java.lang.Override + public _FinalStage addAddOnSelections(PlanSelection addOnSelections) { + this.addOnSelections.add(addOnSelections); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_on_selections", nulls = Nulls.SKIP) + public _FinalStage addOnSelections(List addOnSelections) { + this.addOnSelections.clear(); + if (addOnSelections != null) { + this.addOnSelections.addAll(addOnSelections); + } + return this; + } + + @java.lang.Override + public ManagePlanRequest build() { + return new ManagePlanRequest( + addOnSelections, + basePlanId, + basePlanPriceId, + companyId, + couponExternalId, + creditBundles, + payInAdvanceEntitlements, + paymentMethodExternalId, + promoCode, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/ManagePlanResponseResponseData.java b/src/main/java/com/schematic/api/types/ManagePlanResponseResponseData.java new file mode 100644 index 0000000..ed45ea2 --- /dev/null +++ b/src/main/java/com/schematic/api/types/ManagePlanResponseResponseData.java @@ -0,0 +1,132 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ManagePlanResponseResponseData.Builder.class) +public final class ManagePlanResponseResponseData { + private final Optional company; + + private final boolean success; + + private final Map additionalProperties; + + private ManagePlanResponseResponseData( + Optional company, boolean success, Map additionalProperties) { + this.company = company; + this.success = success; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("company") + public Optional getCompany() { + return company; + } + + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ManagePlanResponseResponseData && equalTo((ManagePlanResponseResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ManagePlanResponseResponseData other) { + return company.equals(other.company) && success == other.success; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.company, this.success); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + _FinalStage success(boolean success); + + Builder from(ManagePlanResponseResponseData other); + } + + public interface _FinalStage { + ManagePlanResponseResponseData build(); + + _FinalStage company(Optional company); + + _FinalStage company(CompanyDetailResponseData company); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, _FinalStage { + private boolean success; + + private Optional company = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ManagePlanResponseResponseData other) { + company(other.getCompany()); + success(other.getSuccess()); + return this; + } + + @java.lang.Override + @JsonSetter("success") + public _FinalStage success(boolean success) { + this.success = success; + return this; + } + + @java.lang.Override + public _FinalStage company(CompanyDetailResponseData company) { + this.company = Optional.ofNullable(company); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Optional company) { + this.company = company; + return this; + } + + @java.lang.Override + public ManagePlanResponseResponseData build() { + return new ManagePlanResponseResponseData(company, success, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PlanAudienceDetailResponseData.java b/src/main/java/com/schematic/api/types/PlanAudienceDetailResponseData.java deleted file mode 100644 index c52729f..0000000 --- a/src/main/java/com/schematic/api/types/PlanAudienceDetailResponseData.java +++ /dev/null @@ -1,449 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.schematic.api.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.schematic.api.core.ObjectMappers; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = PlanAudienceDetailResponseData.Builder.class) -public final class PlanAudienceDetailResponseData { - private final List conditionGroups; - - private final List conditions; - - private final OffsetDateTime createdAt; - - private final String environmentId; - - private final Optional flagId; - - private final String id; - - private final String name; - - private final Optional planId; - - private final int priority; - - private final String ruleType; - - private final OffsetDateTime updatedAt; - - private final boolean value; - - private final Map additionalProperties; - - private PlanAudienceDetailResponseData( - List conditionGroups, - List conditions, - OffsetDateTime createdAt, - String environmentId, - Optional flagId, - String id, - String name, - Optional planId, - int priority, - String ruleType, - OffsetDateTime updatedAt, - boolean value, - Map additionalProperties) { - this.conditionGroups = conditionGroups; - this.conditions = conditions; - this.createdAt = createdAt; - this.environmentId = environmentId; - this.flagId = flagId; - this.id = id; - this.name = name; - this.planId = planId; - this.priority = priority; - this.ruleType = ruleType; - this.updatedAt = updatedAt; - this.value = value; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("condition_groups") - public List getConditionGroups() { - return conditionGroups; - } - - @JsonProperty("conditions") - public List getConditions() { - return conditions; - } - - @JsonProperty("created_at") - public OffsetDateTime getCreatedAt() { - return createdAt; - } - - @JsonProperty("environment_id") - public String getEnvironmentId() { - return environmentId; - } - - @JsonProperty("flag_id") - public Optional getFlagId() { - return flagId; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - - @JsonProperty("priority") - public int getPriority() { - return priority; - } - - @JsonProperty("rule_type") - public String getRuleType() { - return ruleType; - } - - @JsonProperty("updated_at") - public OffsetDateTime getUpdatedAt() { - return updatedAt; - } - - @JsonProperty("value") - public boolean getValue() { - return value; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PlanAudienceDetailResponseData && equalTo((PlanAudienceDetailResponseData) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(PlanAudienceDetailResponseData other) { - return conditionGroups.equals(other.conditionGroups) - && conditions.equals(other.conditions) - && createdAt.equals(other.createdAt) - && environmentId.equals(other.environmentId) - && flagId.equals(other.flagId) - && id.equals(other.id) - && name.equals(other.name) - && planId.equals(other.planId) - && priority == other.priority - && ruleType.equals(other.ruleType) - && updatedAt.equals(other.updatedAt) - && value == other.value; - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.conditionGroups, - this.conditions, - this.createdAt, - this.environmentId, - this.flagId, - this.id, - this.name, - this.planId, - this.priority, - this.ruleType, - this.updatedAt, - this.value); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static CreatedAtStage builder() { - return new Builder(); - } - - public interface CreatedAtStage { - EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); - - Builder from(PlanAudienceDetailResponseData other); - } - - public interface EnvironmentIdStage { - IdStage environmentId(@NotNull String environmentId); - } - - public interface IdStage { - NameStage id(@NotNull String id); - } - - public interface NameStage { - PriorityStage name(@NotNull String name); - } - - public interface PriorityStage { - RuleTypeStage priority(int priority); - } - - public interface RuleTypeStage { - UpdatedAtStage ruleType(@NotNull String ruleType); - } - - public interface UpdatedAtStage { - ValueStage updatedAt(@NotNull OffsetDateTime updatedAt); - } - - public interface ValueStage { - _FinalStage value(boolean value); - } - - public interface _FinalStage { - PlanAudienceDetailResponseData build(); - - _FinalStage conditionGroups(List conditionGroups); - - _FinalStage addConditionGroups(RuleConditionGroupDetailResponseData conditionGroups); - - _FinalStage addAllConditionGroups(List conditionGroups); - - _FinalStage conditions(List conditions); - - _FinalStage addConditions(RuleConditionDetailResponseData conditions); - - _FinalStage addAllConditions(List conditions); - - _FinalStage flagId(Optional flagId); - - _FinalStage flagId(String flagId); - - _FinalStage planId(Optional planId); - - _FinalStage planId(String planId); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements CreatedAtStage, - EnvironmentIdStage, - IdStage, - NameStage, - PriorityStage, - RuleTypeStage, - UpdatedAtStage, - ValueStage, - _FinalStage { - private OffsetDateTime createdAt; - - private String environmentId; - - private String id; - - private String name; - - private int priority; - - private String ruleType; - - private OffsetDateTime updatedAt; - - private boolean value; - - private Optional planId = Optional.empty(); - - private Optional flagId = Optional.empty(); - - private List conditions = new ArrayList<>(); - - private List conditionGroups = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(PlanAudienceDetailResponseData other) { - conditionGroups(other.getConditionGroups()); - conditions(other.getConditions()); - createdAt(other.getCreatedAt()); - environmentId(other.getEnvironmentId()); - flagId(other.getFlagId()); - id(other.getId()); - name(other.getName()); - planId(other.getPlanId()); - priority(other.getPriority()); - ruleType(other.getRuleType()); - updatedAt(other.getUpdatedAt()); - value(other.getValue()); - return this; - } - - @java.lang.Override - @JsonSetter("created_at") - public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { - this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("environment_id") - public IdStage environmentId(@NotNull String environmentId) { - this.environmentId = Objects.requireNonNull(environmentId, "environmentId must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public NameStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("name") - public PriorityStage name(@NotNull String name) { - this.name = Objects.requireNonNull(name, "name must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("priority") - public RuleTypeStage priority(int priority) { - this.priority = priority; - return this; - } - - @java.lang.Override - @JsonSetter("rule_type") - public UpdatedAtStage ruleType(@NotNull String ruleType) { - this.ruleType = Objects.requireNonNull(ruleType, "ruleType must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("updated_at") - public ValueStage updatedAt(@NotNull OffsetDateTime updatedAt) { - this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("value") - public _FinalStage value(boolean value) { - this.value = value; - return this; - } - - @java.lang.Override - public _FinalStage planId(String planId) { - this.planId = Optional.ofNullable(planId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public _FinalStage planId(Optional planId) { - this.planId = planId; - return this; - } - - @java.lang.Override - public _FinalStage flagId(String flagId) { - this.flagId = Optional.ofNullable(flagId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "flag_id", nulls = Nulls.SKIP) - public _FinalStage flagId(Optional flagId) { - this.flagId = flagId; - return this; - } - - @java.lang.Override - public _FinalStage addAllConditions(List conditions) { - this.conditions.addAll(conditions); - return this; - } - - @java.lang.Override - public _FinalStage addConditions(RuleConditionDetailResponseData conditions) { - this.conditions.add(conditions); - return this; - } - - @java.lang.Override - @JsonSetter(value = "conditions", nulls = Nulls.SKIP) - public _FinalStage conditions(List conditions) { - this.conditions.clear(); - this.conditions.addAll(conditions); - return this; - } - - @java.lang.Override - public _FinalStage addAllConditionGroups(List conditionGroups) { - this.conditionGroups.addAll(conditionGroups); - return this; - } - - @java.lang.Override - public _FinalStage addConditionGroups(RuleConditionGroupDetailResponseData conditionGroups) { - this.conditionGroups.add(conditionGroups); - return this; - } - - @java.lang.Override - @JsonSetter(value = "condition_groups", nulls = Nulls.SKIP) - public _FinalStage conditionGroups(List conditionGroups) { - this.conditionGroups.clear(); - this.conditionGroups.addAll(conditionGroups); - return this; - } - - @java.lang.Override - public PlanAudienceDetailResponseData build() { - return new PlanAudienceDetailResponseData( - conditionGroups, - conditions, - createdAt, - environmentId, - flagId, - id, - name, - planId, - priority, - ruleType, - updatedAt, - value, - additionalProperties); - } - } -} diff --git a/src/main/java/com/schematic/api/types/PlanChangeResponseData.java b/src/main/java/com/schematic/api/types/PlanChangeResponseData.java new file mode 100644 index 0000000..0713dac --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanChangeResponseData.java @@ -0,0 +1,777 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PlanChangeResponseData.Builder.class) +public final class PlanChangeResponseData { + private final PlanChangeResponseDataAction action; + + private final PlanChangeResponseDataActorType actorType; + + private final List addOnsAdded; + + private final List addOnsRemoved; + + private final Optional apiKey; + + private final Optional apiKeyRequest; + + private final Optional basePlan; + + private final Optional basePlanAction; + + private final Optional company; + + private final String companyId; + + private final OffsetDateTime createdAt; + + private final String environmentId; + + private final String id; + + private final Optional previousBasePlan; + + private final Optional requestId; + + private final Optional subscriptionChangeAction; + + private final List traitsUpdated; + + private final OffsetDateTime updatedAt; + + private final Optional userId; + + private final Optional userName; + + private final Map additionalProperties; + + private PlanChangeResponseData( + PlanChangeResponseDataAction action, + PlanChangeResponseDataActorType actorType, + List addOnsAdded, + List addOnsRemoved, + Optional apiKey, + Optional apiKeyRequest, + Optional basePlan, + Optional basePlanAction, + Optional company, + String companyId, + OffsetDateTime createdAt, + String environmentId, + String id, + Optional previousBasePlan, + Optional requestId, + Optional subscriptionChangeAction, + List traitsUpdated, + OffsetDateTime updatedAt, + Optional userId, + Optional userName, + Map additionalProperties) { + this.action = action; + this.actorType = actorType; + this.addOnsAdded = addOnsAdded; + this.addOnsRemoved = addOnsRemoved; + this.apiKey = apiKey; + this.apiKeyRequest = apiKeyRequest; + this.basePlan = basePlan; + this.basePlanAction = basePlanAction; + this.company = company; + this.companyId = companyId; + this.createdAt = createdAt; + this.environmentId = environmentId; + this.id = id; + this.previousBasePlan = previousBasePlan; + this.requestId = requestId; + this.subscriptionChangeAction = subscriptionChangeAction; + this.traitsUpdated = traitsUpdated; + this.updatedAt = updatedAt; + this.userId = userId; + this.userName = userName; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("action") + public PlanChangeResponseDataAction getAction() { + return action; + } + + @JsonProperty("actor_type") + public PlanChangeResponseDataActorType getActorType() { + return actorType; + } + + @JsonProperty("add_ons_added") + public List getAddOnsAdded() { + return addOnsAdded; + } + + @JsonProperty("add_ons_removed") + public List getAddOnsRemoved() { + return addOnsRemoved; + } + + @JsonProperty("api_key") + public Optional getApiKey() { + return apiKey; + } + + @JsonProperty("api_key_request") + public Optional getApiKeyRequest() { + return apiKeyRequest; + } + + @JsonProperty("base_plan") + public Optional getBasePlan() { + return basePlan; + } + + /** + * @return Any special behavior that affected the assignment of the base plan during this change. + */ + @JsonProperty("base_plan_action") + public Optional getBasePlanAction() { + return basePlanAction; + } + + @JsonProperty("company") + public Optional getCompany() { + return company; + } + + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("environment_id") + public String getEnvironmentId() { + return environmentId; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("previous_base_plan") + public Optional getPreviousBasePlan() { + return previousBasePlan; + } + + @JsonProperty("request_id") + public Optional getRequestId() { + return requestId; + } + + /** + * @return If a subscription was changed as a part of this plan change, indicates the type of change that was made. + */ + @JsonProperty("subscription_change_action") + public Optional getSubscriptionChangeAction() { + return subscriptionChangeAction; + } + + /** + * @return Any traits were updated as part of this plan change (via pay-in-advance entitlements). + */ + @JsonProperty("traits_updated") + public List getTraitsUpdated() { + return traitsUpdated; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + @JsonProperty("user_name") + public Optional getUserName() { + return userName; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PlanChangeResponseData && equalTo((PlanChangeResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PlanChangeResponseData other) { + return action.equals(other.action) + && actorType.equals(other.actorType) + && addOnsAdded.equals(other.addOnsAdded) + && addOnsRemoved.equals(other.addOnsRemoved) + && apiKey.equals(other.apiKey) + && apiKeyRequest.equals(other.apiKeyRequest) + && basePlan.equals(other.basePlan) + && basePlanAction.equals(other.basePlanAction) + && company.equals(other.company) + && companyId.equals(other.companyId) + && createdAt.equals(other.createdAt) + && environmentId.equals(other.environmentId) + && id.equals(other.id) + && previousBasePlan.equals(other.previousBasePlan) + && requestId.equals(other.requestId) + && subscriptionChangeAction.equals(other.subscriptionChangeAction) + && traitsUpdated.equals(other.traitsUpdated) + && updatedAt.equals(other.updatedAt) + && userId.equals(other.userId) + && userName.equals(other.userName); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.action, + this.actorType, + this.addOnsAdded, + this.addOnsRemoved, + this.apiKey, + this.apiKeyRequest, + this.basePlan, + this.basePlanAction, + this.company, + this.companyId, + this.createdAt, + this.environmentId, + this.id, + this.previousBasePlan, + this.requestId, + this.subscriptionChangeAction, + this.traitsUpdated, + this.updatedAt, + this.userId, + this.userName); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ActionStage builder() { + return new Builder(); + } + + public interface ActionStage { + ActorTypeStage action(@NotNull PlanChangeResponseDataAction action); + + Builder from(PlanChangeResponseData other); + } + + public interface ActorTypeStage { + CompanyIdStage actorType(@NotNull PlanChangeResponseDataActorType actorType); + } + + public interface CompanyIdStage { + CreatedAtStage companyId(@NotNull String companyId); + } + + public interface CreatedAtStage { + EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface EnvironmentIdStage { + IdStage environmentId(@NotNull String environmentId); + } + + public interface IdStage { + UpdatedAtStage id(@NotNull String id); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + PlanChangeResponseData build(); + + _FinalStage addOnsAdded(List addOnsAdded); + + _FinalStage addAddOnsAdded(PlanSnapshotView addOnsAdded); + + _FinalStage addAllAddOnsAdded(List addOnsAdded); + + _FinalStage addOnsRemoved(List addOnsRemoved); + + _FinalStage addAddOnsRemoved(PlanSnapshotView addOnsRemoved); + + _FinalStage addAllAddOnsRemoved(List addOnsRemoved); + + _FinalStage apiKey(Optional apiKey); + + _FinalStage apiKey(ApiKeyResponseData apiKey); + + _FinalStage apiKeyRequest(Optional apiKeyRequest); + + _FinalStage apiKeyRequest(ApiKeyRequestListResponseData apiKeyRequest); + + _FinalStage basePlan(Optional basePlan); + + _FinalStage basePlan(PlanSnapshotView basePlan); + + /** + *

Any special behavior that affected the assignment of the base plan during this change.

+ */ + _FinalStage basePlanAction(Optional basePlanAction); + + _FinalStage basePlanAction(PlanChangeResponseDataBasePlanAction basePlanAction); + + _FinalStage company(Optional company); + + _FinalStage company(CompanyResponseData company); + + _FinalStage previousBasePlan(Optional previousBasePlan); + + _FinalStage previousBasePlan(PlanSnapshotView previousBasePlan); + + _FinalStage requestId(Optional requestId); + + _FinalStage requestId(String requestId); + + /** + *

If a subscription was changed as a part of this plan change, indicates the type of change that was made.

+ */ + _FinalStage subscriptionChangeAction( + Optional subscriptionChangeAction); + + _FinalStage subscriptionChangeAction(PlanChangeResponseDataSubscriptionChangeAction subscriptionChangeAction); + + /** + *

Any traits were updated as part of this plan change (via pay-in-advance entitlements).

+ */ + _FinalStage traitsUpdated(List traitsUpdated); + + _FinalStage addTraitsUpdated(SubscriptionTraitUpdate traitsUpdated); + + _FinalStage addAllTraitsUpdated(List traitsUpdated); + + _FinalStage userId(Optional userId); + + _FinalStage userId(String userId); + + _FinalStage userName(Optional userName); + + _FinalStage userName(String userName); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements ActionStage, + ActorTypeStage, + CompanyIdStage, + CreatedAtStage, + EnvironmentIdStage, + IdStage, + UpdatedAtStage, + _FinalStage { + private PlanChangeResponseDataAction action; + + private PlanChangeResponseDataActorType actorType; + + private String companyId; + + private OffsetDateTime createdAt; + + private String environmentId; + + private String id; + + private OffsetDateTime updatedAt; + + private Optional userName = Optional.empty(); + + private Optional userId = Optional.empty(); + + private List traitsUpdated = new ArrayList<>(); + + private Optional subscriptionChangeAction = Optional.empty(); + + private Optional requestId = Optional.empty(); + + private Optional previousBasePlan = Optional.empty(); + + private Optional company = Optional.empty(); + + private Optional basePlanAction = Optional.empty(); + + private Optional basePlan = Optional.empty(); + + private Optional apiKeyRequest = Optional.empty(); + + private Optional apiKey = Optional.empty(); + + private List addOnsRemoved = new ArrayList<>(); + + private List addOnsAdded = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PlanChangeResponseData other) { + action(other.getAction()); + actorType(other.getActorType()); + addOnsAdded(other.getAddOnsAdded()); + addOnsRemoved(other.getAddOnsRemoved()); + apiKey(other.getApiKey()); + apiKeyRequest(other.getApiKeyRequest()); + basePlan(other.getBasePlan()); + basePlanAction(other.getBasePlanAction()); + company(other.getCompany()); + companyId(other.getCompanyId()); + createdAt(other.getCreatedAt()); + environmentId(other.getEnvironmentId()); + id(other.getId()); + previousBasePlan(other.getPreviousBasePlan()); + requestId(other.getRequestId()); + subscriptionChangeAction(other.getSubscriptionChangeAction()); + traitsUpdated(other.getTraitsUpdated()); + updatedAt(other.getUpdatedAt()); + userId(other.getUserId()); + userName(other.getUserName()); + return this; + } + + @java.lang.Override + @JsonSetter("action") + public ActorTypeStage action(@NotNull PlanChangeResponseDataAction action) { + this.action = Objects.requireNonNull(action, "action must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("actor_type") + public CompanyIdStage actorType(@NotNull PlanChangeResponseDataActorType actorType) { + this.actorType = Objects.requireNonNull(actorType, "actorType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("company_id") + public CreatedAtStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("environment_id") + public IdStage environmentId(@NotNull String environmentId) { + this.environmentId = Objects.requireNonNull(environmentId, "environmentId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public UpdatedAtStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage userName(String userName) { + this.userName = Optional.ofNullable(userName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_name", nulls = Nulls.SKIP) + public _FinalStage userName(Optional userName) { + this.userName = userName; + return this; + } + + @java.lang.Override + public _FinalStage userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public _FinalStage userId(Optional userId) { + this.userId = userId; + return this; + } + + /** + *

Any traits were updated as part of this plan change (via pay-in-advance entitlements).

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllTraitsUpdated(List traitsUpdated) { + if (traitsUpdated != null) { + this.traitsUpdated.addAll(traitsUpdated); + } + return this; + } + + /** + *

Any traits were updated as part of this plan change (via pay-in-advance entitlements).

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addTraitsUpdated(SubscriptionTraitUpdate traitsUpdated) { + this.traitsUpdated.add(traitsUpdated); + return this; + } + + /** + *

Any traits were updated as part of this plan change (via pay-in-advance entitlements).

+ */ + @java.lang.Override + @JsonSetter(value = "traits_updated", nulls = Nulls.SKIP) + public _FinalStage traitsUpdated(List traitsUpdated) { + this.traitsUpdated.clear(); + if (traitsUpdated != null) { + this.traitsUpdated.addAll(traitsUpdated); + } + return this; + } + + /** + *

If a subscription was changed as a part of this plan change, indicates the type of change that was made.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage subscriptionChangeAction( + PlanChangeResponseDataSubscriptionChangeAction subscriptionChangeAction) { + this.subscriptionChangeAction = Optional.ofNullable(subscriptionChangeAction); + return this; + } + + /** + *

If a subscription was changed as a part of this plan change, indicates the type of change that was made.

+ */ + @java.lang.Override + @JsonSetter(value = "subscription_change_action", nulls = Nulls.SKIP) + public _FinalStage subscriptionChangeAction( + Optional subscriptionChangeAction) { + this.subscriptionChangeAction = subscriptionChangeAction; + return this; + } + + @java.lang.Override + public _FinalStage requestId(String requestId) { + this.requestId = Optional.ofNullable(requestId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "request_id", nulls = Nulls.SKIP) + public _FinalStage requestId(Optional requestId) { + this.requestId = requestId; + return this; + } + + @java.lang.Override + public _FinalStage previousBasePlan(PlanSnapshotView previousBasePlan) { + this.previousBasePlan = Optional.ofNullable(previousBasePlan); + return this; + } + + @java.lang.Override + @JsonSetter(value = "previous_base_plan", nulls = Nulls.SKIP) + public _FinalStage previousBasePlan(Optional previousBasePlan) { + this.previousBasePlan = previousBasePlan; + return this; + } + + @java.lang.Override + public _FinalStage company(CompanyResponseData company) { + this.company = Optional.ofNullable(company); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Optional company) { + this.company = company; + return this; + } + + /** + *

Any special behavior that affected the assignment of the base plan during this change.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage basePlanAction(PlanChangeResponseDataBasePlanAction basePlanAction) { + this.basePlanAction = Optional.ofNullable(basePlanAction); + return this; + } + + /** + *

Any special behavior that affected the assignment of the base plan during this change.

+ */ + @java.lang.Override + @JsonSetter(value = "base_plan_action", nulls = Nulls.SKIP) + public _FinalStage basePlanAction(Optional basePlanAction) { + this.basePlanAction = basePlanAction; + return this; + } + + @java.lang.Override + public _FinalStage basePlan(PlanSnapshotView basePlan) { + this.basePlan = Optional.ofNullable(basePlan); + return this; + } + + @java.lang.Override + @JsonSetter(value = "base_plan", nulls = Nulls.SKIP) + public _FinalStage basePlan(Optional basePlan) { + this.basePlan = basePlan; + return this; + } + + @java.lang.Override + public _FinalStage apiKeyRequest(ApiKeyRequestListResponseData apiKeyRequest) { + this.apiKeyRequest = Optional.ofNullable(apiKeyRequest); + return this; + } + + @java.lang.Override + @JsonSetter(value = "api_key_request", nulls = Nulls.SKIP) + public _FinalStage apiKeyRequest(Optional apiKeyRequest) { + this.apiKeyRequest = apiKeyRequest; + return this; + } + + @java.lang.Override + public _FinalStage apiKey(ApiKeyResponseData apiKey) { + this.apiKey = Optional.ofNullable(apiKey); + return this; + } + + @java.lang.Override + @JsonSetter(value = "api_key", nulls = Nulls.SKIP) + public _FinalStage apiKey(Optional apiKey) { + this.apiKey = apiKey; + return this; + } + + @java.lang.Override + public _FinalStage addAllAddOnsRemoved(List addOnsRemoved) { + if (addOnsRemoved != null) { + this.addOnsRemoved.addAll(addOnsRemoved); + } + return this; + } + + @java.lang.Override + public _FinalStage addAddOnsRemoved(PlanSnapshotView addOnsRemoved) { + this.addOnsRemoved.add(addOnsRemoved); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_ons_removed", nulls = Nulls.SKIP) + public _FinalStage addOnsRemoved(List addOnsRemoved) { + this.addOnsRemoved.clear(); + if (addOnsRemoved != null) { + this.addOnsRemoved.addAll(addOnsRemoved); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllAddOnsAdded(List addOnsAdded) { + if (addOnsAdded != null) { + this.addOnsAdded.addAll(addOnsAdded); + } + return this; + } + + @java.lang.Override + public _FinalStage addAddOnsAdded(PlanSnapshotView addOnsAdded) { + this.addOnsAdded.add(addOnsAdded); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_ons_added", nulls = Nulls.SKIP) + public _FinalStage addOnsAdded(List addOnsAdded) { + this.addOnsAdded.clear(); + if (addOnsAdded != null) { + this.addOnsAdded.addAll(addOnsAdded); + } + return this; + } + + @java.lang.Override + public PlanChangeResponseData build() { + return new PlanChangeResponseData( + action, + actorType, + addOnsAdded, + addOnsRemoved, + apiKey, + apiKeyRequest, + basePlan, + basePlanAction, + company, + companyId, + createdAt, + environmentId, + id, + previousBasePlan, + requestId, + subscriptionChangeAction, + traitsUpdated, + updatedAt, + userId, + userName, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PlanChangeResponseDataAction.java b/src/main/java/com/schematic/api/types/PlanChangeResponseDataAction.java new file mode 100644 index 0000000..060f114 --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanChangeResponseDataAction.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class PlanChangeResponseDataAction { + public static final PlanChangeResponseDataAction CHECKOUT = + new PlanChangeResponseDataAction(Value.CHECKOUT, "checkout"); + + public static final PlanChangeResponseDataAction COMPANY_UPSERT = + new PlanChangeResponseDataAction(Value.COMPANY_UPSERT, "company_upsert"); + + public static final PlanChangeResponseDataAction PLAN_BILLING_PRODUCT_CHANGED = + new PlanChangeResponseDataAction(Value.PLAN_BILLING_PRODUCT_CHANGED, "plan_billing_product_changed"); + + public static final PlanChangeResponseDataAction FALLBACK_PLAN = + new PlanChangeResponseDataAction(Value.FALLBACK_PLAN, "fallback_plan"); + + public static final PlanChangeResponseDataAction SUBSCRIPTION_CHANGE = + new PlanChangeResponseDataAction(Value.SUBSCRIPTION_CHANGE, "subscription_change"); + + public static final PlanChangeResponseDataAction PLAN_DELETED = + new PlanChangeResponseDataAction(Value.PLAN_DELETED, "plan_deleted"); + + public static final PlanChangeResponseDataAction QUICKSTART = + new PlanChangeResponseDataAction(Value.QUICKSTART, "quickstart"); + + public static final PlanChangeResponseDataAction MANAGE_PLAN = + new PlanChangeResponseDataAction(Value.MANAGE_PLAN, "manage_plan"); + + private final Value value; + + private final String string; + + PlanChangeResponseDataAction(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof PlanChangeResponseDataAction + && this.string.equals(((PlanChangeResponseDataAction) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CHECKOUT: + return visitor.visitCheckout(); + case COMPANY_UPSERT: + return visitor.visitCompanyUpsert(); + case PLAN_BILLING_PRODUCT_CHANGED: + return visitor.visitPlanBillingProductChanged(); + case FALLBACK_PLAN: + return visitor.visitFallbackPlan(); + case SUBSCRIPTION_CHANGE: + return visitor.visitSubscriptionChange(); + case PLAN_DELETED: + return visitor.visitPlanDeleted(); + case QUICKSTART: + return visitor.visitQuickstart(); + case MANAGE_PLAN: + return visitor.visitManagePlan(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static PlanChangeResponseDataAction valueOf(String value) { + switch (value) { + case "checkout": + return CHECKOUT; + case "company_upsert": + return COMPANY_UPSERT; + case "plan_billing_product_changed": + return PLAN_BILLING_PRODUCT_CHANGED; + case "fallback_plan": + return FALLBACK_PLAN; + case "subscription_change": + return SUBSCRIPTION_CHANGE; + case "plan_deleted": + return PLAN_DELETED; + case "quickstart": + return QUICKSTART; + case "manage_plan": + return MANAGE_PLAN; + default: + return new PlanChangeResponseDataAction(Value.UNKNOWN, value); + } + } + + public enum Value { + CHECKOUT, + + COMPANY_UPSERT, + + FALLBACK_PLAN, + + MANAGE_PLAN, + + PLAN_BILLING_PRODUCT_CHANGED, + + PLAN_DELETED, + + QUICKSTART, + + SUBSCRIPTION_CHANGE, + + UNKNOWN + } + + public interface Visitor { + T visitCheckout(); + + T visitCompanyUpsert(); + + T visitFallbackPlan(); + + T visitManagePlan(); + + T visitPlanBillingProductChanged(); + + T visitPlanDeleted(); + + T visitQuickstart(); + + T visitSubscriptionChange(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/PlanChangeResponseDataActorType.java b/src/main/java/com/schematic/api/types/PlanChangeResponseDataActorType.java new file mode 100644 index 0000000..dea36b1 --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanChangeResponseDataActorType.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class PlanChangeResponseDataActorType { + public static final PlanChangeResponseDataActorType TEMPORARY_ACCESS_TOKEN = + new PlanChangeResponseDataActorType(Value.TEMPORARY_ACCESS_TOKEN, "temporary_access_token"); + + public static final PlanChangeResponseDataActorType APP_USER = + new PlanChangeResponseDataActorType(Value.APP_USER, "app_user"); + + public static final PlanChangeResponseDataActorType API_KEY = + new PlanChangeResponseDataActorType(Value.API_KEY, "api_key"); + + public static final PlanChangeResponseDataActorType SYSTEM = + new PlanChangeResponseDataActorType(Value.SYSTEM, "system"); + + private final Value value; + + private final String string; + + PlanChangeResponseDataActorType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof PlanChangeResponseDataActorType + && this.string.equals(((PlanChangeResponseDataActorType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case TEMPORARY_ACCESS_TOKEN: + return visitor.visitTemporaryAccessToken(); + case APP_USER: + return visitor.visitAppUser(); + case API_KEY: + return visitor.visitApiKey(); + case SYSTEM: + return visitor.visitSystem(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static PlanChangeResponseDataActorType valueOf(String value) { + switch (value) { + case "temporary_access_token": + return TEMPORARY_ACCESS_TOKEN; + case "app_user": + return APP_USER; + case "api_key": + return API_KEY; + case "system": + return SYSTEM; + default: + return new PlanChangeResponseDataActorType(Value.UNKNOWN, value); + } + } + + public enum Value { + APP_USER, + + API_KEY, + + SYSTEM, + + TEMPORARY_ACCESS_TOKEN, + + UNKNOWN + } + + public interface Visitor { + T visitAppUser(); + + T visitApiKey(); + + T visitSystem(); + + T visitTemporaryAccessToken(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/PlanChangeResponseDataBasePlanAction.java b/src/main/java/com/schematic/api/types/PlanChangeResponseDataBasePlanAction.java new file mode 100644 index 0000000..e619d36 --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanChangeResponseDataBasePlanAction.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class PlanChangeResponseDataBasePlanAction { + public static final PlanChangeResponseDataBasePlanAction FALLBACK = + new PlanChangeResponseDataBasePlanAction(Value.FALLBACK, "fallback"); + + public static final PlanChangeResponseDataBasePlanAction INITIAL = + new PlanChangeResponseDataBasePlanAction(Value.INITIAL, "initial"); + + public static final PlanChangeResponseDataBasePlanAction TRAIT = + new PlanChangeResponseDataBasePlanAction(Value.TRAIT, "trait"); + + public static final PlanChangeResponseDataBasePlanAction TRIAL_EXPIRY = + new PlanChangeResponseDataBasePlanAction(Value.TRIAL_EXPIRY, "trial_expiry"); + + private final Value value; + + private final String string; + + PlanChangeResponseDataBasePlanAction(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof PlanChangeResponseDataBasePlanAction + && this.string.equals(((PlanChangeResponseDataBasePlanAction) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FALLBACK: + return visitor.visitFallback(); + case INITIAL: + return visitor.visitInitial(); + case TRAIT: + return visitor.visitTrait(); + case TRIAL_EXPIRY: + return visitor.visitTrialExpiry(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static PlanChangeResponseDataBasePlanAction valueOf(String value) { + switch (value) { + case "fallback": + return FALLBACK; + case "initial": + return INITIAL; + case "trait": + return TRAIT; + case "trial_expiry": + return TRIAL_EXPIRY; + default: + return new PlanChangeResponseDataBasePlanAction(Value.UNKNOWN, value); + } + } + + public enum Value { + FALLBACK, + + INITIAL, + + TRAIT, + + TRIAL_EXPIRY, + + UNKNOWN + } + + public interface Visitor { + T visitFallback(); + + T visitInitial(); + + T visitTrait(); + + T visitTrialExpiry(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/PlanChangeResponseDataSubscriptionChangeAction.java b/src/main/java/com/schematic/api/types/PlanChangeResponseDataSubscriptionChangeAction.java new file mode 100644 index 0000000..f9fa09c --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanChangeResponseDataSubscriptionChangeAction.java @@ -0,0 +1,130 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class PlanChangeResponseDataSubscriptionChangeAction { + public static final PlanChangeResponseDataSubscriptionChangeAction DOWNGRADE = + new PlanChangeResponseDataSubscriptionChangeAction(Value.DOWNGRADE, "downgrade"); + + public static final PlanChangeResponseDataSubscriptionChangeAction INVALID = + new PlanChangeResponseDataSubscriptionChangeAction(Value.INVALID, "invalid"); + + public static final PlanChangeResponseDataSubscriptionChangeAction UNSUBSCRIBE = + new PlanChangeResponseDataSubscriptionChangeAction(Value.UNSUBSCRIBE, "unsubscribe"); + + public static final PlanChangeResponseDataSubscriptionChangeAction SUBSCRIBE = + new PlanChangeResponseDataSubscriptionChangeAction(Value.SUBSCRIBE, "subscribe"); + + public static final PlanChangeResponseDataSubscriptionChangeAction UPGRADE_TRIAL = + new PlanChangeResponseDataSubscriptionChangeAction(Value.UPGRADE_TRIAL, "upgrade_trial"); + + public static final PlanChangeResponseDataSubscriptionChangeAction UPGRADE = + new PlanChangeResponseDataSubscriptionChangeAction(Value.UPGRADE, "upgrade"); + + private final Value value; + + private final String string; + + PlanChangeResponseDataSubscriptionChangeAction(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof PlanChangeResponseDataSubscriptionChangeAction + && this.string.equals(((PlanChangeResponseDataSubscriptionChangeAction) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DOWNGRADE: + return visitor.visitDowngrade(); + case INVALID: + return visitor.visitInvalid(); + case UNSUBSCRIBE: + return visitor.visitUnsubscribe(); + case SUBSCRIBE: + return visitor.visitSubscribe(); + case UPGRADE_TRIAL: + return visitor.visitUpgradeTrial(); + case UPGRADE: + return visitor.visitUpgrade(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static PlanChangeResponseDataSubscriptionChangeAction valueOf(String value) { + switch (value) { + case "downgrade": + return DOWNGRADE; + case "invalid": + return INVALID; + case "unsubscribe": + return UNSUBSCRIBE; + case "subscribe": + return SUBSCRIBE; + case "upgrade_trial": + return UPGRADE_TRIAL; + case "upgrade": + return UPGRADE; + default: + return new PlanChangeResponseDataSubscriptionChangeAction(Value.UNKNOWN, value); + } + } + + public enum Value { + DOWNGRADE, + + INVALID, + + SUBSCRIBE, + + UNSUBSCRIBE, + + UPGRADE, + + UPGRADE_TRIAL, + + UNKNOWN + } + + public interface Visitor { + T visitDowngrade(); + + T visitInvalid(); + + T visitSubscribe(); + + T visitUnsubscribe(); + + T visitUpgrade(); + + T visitUpgradeTrial(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/PlanCreditGrantView.java b/src/main/java/com/schematic/api/types/PlanCreditGrantView.java new file mode 100644 index 0000000..c274702 --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanCreditGrantView.java @@ -0,0 +1,601 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PlanCreditGrantView.Builder.class) +public final class PlanCreditGrantView { + private final OffsetDateTime createdAt; + + private final int creditAmount; + + private final String creditDescription; + + private final Optional creditIcon; + + private final String creditId; + + private final String creditName; + + private final Optional expiryType; + + private final Optional expiryUnit; + + private final Optional expiryUnitCount; + + private final String id; + + private final String planId; + + private final String planName; + + private final Optional pluralName; + + private final String resetCadence; + + private final String resetStart; + + private final String resetType; + + private final Optional singularName; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private PlanCreditGrantView( + OffsetDateTime createdAt, + int creditAmount, + String creditDescription, + Optional creditIcon, + String creditId, + String creditName, + Optional expiryType, + Optional expiryUnit, + Optional expiryUnitCount, + String id, + String planId, + String planName, + Optional pluralName, + String resetCadence, + String resetStart, + String resetType, + Optional singularName, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.createdAt = createdAt; + this.creditAmount = creditAmount; + this.creditDescription = creditDescription; + this.creditIcon = creditIcon; + this.creditId = creditId; + this.creditName = creditName; + this.expiryType = expiryType; + this.expiryUnit = expiryUnit; + this.expiryUnitCount = expiryUnitCount; + this.id = id; + this.planId = planId; + this.planName = planName; + this.pluralName = pluralName; + this.resetCadence = resetCadence; + this.resetStart = resetStart; + this.resetType = resetType; + this.singularName = singularName; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("credit_amount") + public int getCreditAmount() { + return creditAmount; + } + + @JsonProperty("credit_description") + public String getCreditDescription() { + return creditDescription; + } + + @JsonProperty("credit_icon") + public Optional getCreditIcon() { + return creditIcon; + } + + @JsonProperty("credit_id") + public String getCreditId() { + return creditId; + } + + @JsonProperty("credit_name") + public String getCreditName() { + return creditName; + } + + @JsonProperty("expiry_type") + public Optional getExpiryType() { + return expiryType; + } + + @JsonProperty("expiry_unit") + public Optional getExpiryUnit() { + return expiryUnit; + } + + @JsonProperty("expiry_unit_count") + public Optional getExpiryUnitCount() { + return expiryUnitCount; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @JsonProperty("plan_name") + public String getPlanName() { + return planName; + } + + @JsonProperty("plural_name") + public Optional getPluralName() { + return pluralName; + } + + @JsonProperty("reset_cadence") + public String getResetCadence() { + return resetCadence; + } + + @JsonProperty("reset_start") + public String getResetStart() { + return resetStart; + } + + @JsonProperty("reset_type") + public String getResetType() { + return resetType; + } + + @JsonProperty("singular_name") + public Optional getSingularName() { + return singularName; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PlanCreditGrantView && equalTo((PlanCreditGrantView) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PlanCreditGrantView other) { + return createdAt.equals(other.createdAt) + && creditAmount == other.creditAmount + && creditDescription.equals(other.creditDescription) + && creditIcon.equals(other.creditIcon) + && creditId.equals(other.creditId) + && creditName.equals(other.creditName) + && expiryType.equals(other.expiryType) + && expiryUnit.equals(other.expiryUnit) + && expiryUnitCount.equals(other.expiryUnitCount) + && id.equals(other.id) + && planId.equals(other.planId) + && planName.equals(other.planName) + && pluralName.equals(other.pluralName) + && resetCadence.equals(other.resetCadence) + && resetStart.equals(other.resetStart) + && resetType.equals(other.resetType) + && singularName.equals(other.singularName) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.createdAt, + this.creditAmount, + this.creditDescription, + this.creditIcon, + this.creditId, + this.creditName, + this.expiryType, + this.expiryUnit, + this.expiryUnitCount, + this.id, + this.planId, + this.planName, + this.pluralName, + this.resetCadence, + this.resetStart, + this.resetType, + this.singularName, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtStage builder() { + return new Builder(); + } + + public interface CreatedAtStage { + CreditAmountStage createdAt(@NotNull OffsetDateTime createdAt); + + Builder from(PlanCreditGrantView other); + } + + public interface CreditAmountStage { + CreditDescriptionStage creditAmount(int creditAmount); + } + + public interface CreditDescriptionStage { + CreditIdStage creditDescription(@NotNull String creditDescription); + } + + public interface CreditIdStage { + CreditNameStage creditId(@NotNull String creditId); + } + + public interface CreditNameStage { + IdStage creditName(@NotNull String creditName); + } + + public interface IdStage { + PlanIdStage id(@NotNull String id); + } + + public interface PlanIdStage { + PlanNameStage planId(@NotNull String planId); + } + + public interface PlanNameStage { + ResetCadenceStage planName(@NotNull String planName); + } + + public interface ResetCadenceStage { + ResetStartStage resetCadence(@NotNull String resetCadence); + } + + public interface ResetStartStage { + ResetTypeStage resetStart(@NotNull String resetStart); + } + + public interface ResetTypeStage { + UpdatedAtStage resetType(@NotNull String resetType); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + PlanCreditGrantView build(); + + _FinalStage creditIcon(Optional creditIcon); + + _FinalStage creditIcon(String creditIcon); + + _FinalStage expiryType(Optional expiryType); + + _FinalStage expiryType(String expiryType); + + _FinalStage expiryUnit(Optional expiryUnit); + + _FinalStage expiryUnit(String expiryUnit); + + _FinalStage expiryUnitCount(Optional expiryUnitCount); + + _FinalStage expiryUnitCount(Integer expiryUnitCount); + + _FinalStage pluralName(Optional pluralName); + + _FinalStage pluralName(String pluralName); + + _FinalStage singularName(Optional singularName); + + _FinalStage singularName(String singularName); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CreatedAtStage, + CreditAmountStage, + CreditDescriptionStage, + CreditIdStage, + CreditNameStage, + IdStage, + PlanIdStage, + PlanNameStage, + ResetCadenceStage, + ResetStartStage, + ResetTypeStage, + UpdatedAtStage, + _FinalStage { + private OffsetDateTime createdAt; + + private int creditAmount; + + private String creditDescription; + + private String creditId; + + private String creditName; + + private String id; + + private String planId; + + private String planName; + + private String resetCadence; + + private String resetStart; + + private String resetType; + + private OffsetDateTime updatedAt; + + private Optional singularName = Optional.empty(); + + private Optional pluralName = Optional.empty(); + + private Optional expiryUnitCount = Optional.empty(); + + private Optional expiryUnit = Optional.empty(); + + private Optional expiryType = Optional.empty(); + + private Optional creditIcon = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PlanCreditGrantView other) { + createdAt(other.getCreatedAt()); + creditAmount(other.getCreditAmount()); + creditDescription(other.getCreditDescription()); + creditIcon(other.getCreditIcon()); + creditId(other.getCreditId()); + creditName(other.getCreditName()); + expiryType(other.getExpiryType()); + expiryUnit(other.getExpiryUnit()); + expiryUnitCount(other.getExpiryUnitCount()); + id(other.getId()); + planId(other.getPlanId()); + planName(other.getPlanName()); + pluralName(other.getPluralName()); + resetCadence(other.getResetCadence()); + resetStart(other.getResetStart()); + resetType(other.getResetType()); + singularName(other.getSingularName()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public CreditAmountStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_amount") + public CreditDescriptionStage creditAmount(int creditAmount) { + this.creditAmount = creditAmount; + return this; + } + + @java.lang.Override + @JsonSetter("credit_description") + public CreditIdStage creditDescription(@NotNull String creditDescription) { + this.creditDescription = Objects.requireNonNull(creditDescription, "creditDescription must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_id") + public CreditNameStage creditId(@NotNull String creditId) { + this.creditId = Objects.requireNonNull(creditId, "creditId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("credit_name") + public IdStage creditName(@NotNull String creditName) { + this.creditName = Objects.requireNonNull(creditName, "creditName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public PlanIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public PlanNameStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("plan_name") + public ResetCadenceStage planName(@NotNull String planName) { + this.planName = Objects.requireNonNull(planName, "planName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("reset_cadence") + public ResetStartStage resetCadence(@NotNull String resetCadence) { + this.resetCadence = Objects.requireNonNull(resetCadence, "resetCadence must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("reset_start") + public ResetTypeStage resetStart(@NotNull String resetStart) { + this.resetStart = Objects.requireNonNull(resetStart, "resetStart must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("reset_type") + public UpdatedAtStage resetType(@NotNull String resetType) { + this.resetType = Objects.requireNonNull(resetType, "resetType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage singularName(String singularName) { + this.singularName = Optional.ofNullable(singularName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "singular_name", nulls = Nulls.SKIP) + public _FinalStage singularName(Optional singularName) { + this.singularName = singularName; + return this; + } + + @java.lang.Override + public _FinalStage pluralName(String pluralName) { + this.pluralName = Optional.ofNullable(pluralName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "plural_name", nulls = Nulls.SKIP) + public _FinalStage pluralName(Optional pluralName) { + this.pluralName = pluralName; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnitCount(Integer expiryUnitCount) { + this.expiryUnitCount = Optional.ofNullable(expiryUnitCount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit_count", nulls = Nulls.SKIP) + public _FinalStage expiryUnitCount(Optional expiryUnitCount) { + this.expiryUnitCount = expiryUnitCount; + return this; + } + + @java.lang.Override + public _FinalStage expiryUnit(String expiryUnit) { + this.expiryUnit = Optional.ofNullable(expiryUnit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_unit", nulls = Nulls.SKIP) + public _FinalStage expiryUnit(Optional expiryUnit) { + this.expiryUnit = expiryUnit; + return this; + } + + @java.lang.Override + public _FinalStage expiryType(String expiryType) { + this.expiryType = Optional.ofNullable(expiryType); + return this; + } + + @java.lang.Override + @JsonSetter(value = "expiry_type", nulls = Nulls.SKIP) + public _FinalStage expiryType(Optional expiryType) { + this.expiryType = expiryType; + return this; + } + + @java.lang.Override + public _FinalStage creditIcon(String creditIcon) { + this.creditIcon = Optional.ofNullable(creditIcon); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_icon", nulls = Nulls.SKIP) + public _FinalStage creditIcon(Optional creditIcon) { + this.creditIcon = creditIcon; + return this; + } + + @java.lang.Override + public PlanCreditGrantView build() { + return new PlanCreditGrantView( + createdAt, + creditAmount, + creditDescription, + creditIcon, + creditId, + creditName, + expiryType, + expiryUnit, + expiryUnitCount, + id, + planId, + planName, + pluralName, + resetCadence, + resetStart, + resetType, + singularName, + updatedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PlanDetailResponseData.java b/src/main/java/com/schematic/api/types/PlanDetailResponseData.java index dee8b8f..873a4a1 100644 --- a/src/main/java/com/schematic/api/types/PlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanDetailResponseData.java @@ -28,8 +28,12 @@ public final class PlanDetailResponseData { private final Optional billingProduct; + private final String chargeType; + private final int companyCount; + private final String controlledBy; + private final OffsetDateTime createdAt; private final String description; @@ -40,6 +44,8 @@ public final class PlanDetailResponseData { private final String id; + private final Optional> includedCreditGrants; + private final boolean isDefault; private final boolean isFree; @@ -50,6 +56,8 @@ public final class PlanDetailResponseData { private final String name; + private final Optional oneTimePrice; + private final String planType; private final Optional trialDays; @@ -63,17 +71,21 @@ public final class PlanDetailResponseData { private PlanDetailResponseData( Optional audienceType, Optional billingProduct, + String chargeType, int companyCount, + String controlledBy, OffsetDateTime createdAt, String description, List features, String icon, String id, + Optional> includedCreditGrants, boolean isDefault, boolean isFree, boolean isTrialable, Optional monthlyPrice, String name, + Optional oneTimePrice, String planType, Optional trialDays, OffsetDateTime updatedAt, @@ -81,17 +93,21 @@ private PlanDetailResponseData( Map additionalProperties) { this.audienceType = audienceType; this.billingProduct = billingProduct; + this.chargeType = chargeType; this.companyCount = companyCount; + this.controlledBy = controlledBy; this.createdAt = createdAt; this.description = description; this.features = features; this.icon = icon; this.id = id; + this.includedCreditGrants = includedCreditGrants; this.isDefault = isDefault; this.isFree = isFree; this.isTrialable = isTrialable; this.monthlyPrice = monthlyPrice; this.name = name; + this.oneTimePrice = oneTimePrice; this.planType = planType; this.trialDays = trialDays; this.updatedAt = updatedAt; @@ -109,11 +125,21 @@ public Optional getBillingProduct() { return billingProduct; } + @JsonProperty("charge_type") + public String getChargeType() { + return chargeType; + } + @JsonProperty("company_count") public int getCompanyCount() { return companyCount; } + @JsonProperty("controlled_by") + public String getControlledBy() { + return controlledBy; + } + @JsonProperty("created_at") public OffsetDateTime getCreatedAt() { return createdAt; @@ -139,6 +165,11 @@ public String getId() { return id; } + @JsonProperty("included_credit_grants") + public Optional> getIncludedCreditGrants() { + return includedCreditGrants; + } + @JsonProperty("is_default") public boolean getIsDefault() { return isDefault; @@ -164,6 +195,11 @@ public String getName() { return name; } + @JsonProperty("one_time_price") + public Optional getOneTimePrice() { + return oneTimePrice; + } + @JsonProperty("plan_type") public String getPlanType() { return planType; @@ -198,17 +234,21 @@ public Map getAdditionalProperties() { private boolean equalTo(PlanDetailResponseData other) { return audienceType.equals(other.audienceType) && billingProduct.equals(other.billingProduct) + && chargeType.equals(other.chargeType) && companyCount == other.companyCount + && controlledBy.equals(other.controlledBy) && createdAt.equals(other.createdAt) && description.equals(other.description) && features.equals(other.features) && icon.equals(other.icon) && id.equals(other.id) + && includedCreditGrants.equals(other.includedCreditGrants) && isDefault == other.isDefault && isFree == other.isFree && isTrialable == other.isTrialable && monthlyPrice.equals(other.monthlyPrice) && name.equals(other.name) + && oneTimePrice.equals(other.oneTimePrice) && planType.equals(other.planType) && trialDays.equals(other.trialDays) && updatedAt.equals(other.updatedAt) @@ -220,17 +260,21 @@ public int hashCode() { return Objects.hash( this.audienceType, this.billingProduct, + this.chargeType, this.companyCount, + this.controlledBy, this.createdAt, this.description, this.features, this.icon, this.id, + this.includedCreditGrants, this.isDefault, this.isFree, this.isTrialable, this.monthlyPrice, this.name, + this.oneTimePrice, this.planType, this.trialDays, this.updatedAt, @@ -242,16 +286,24 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CompanyCountStage builder() { + public static ChargeTypeStage builder() { return new Builder(); } - public interface CompanyCountStage { - CreatedAtStage companyCount(int companyCount); + public interface ChargeTypeStage { + CompanyCountStage chargeType(@NotNull String chargeType); Builder from(PlanDetailResponseData other); } + public interface CompanyCountStage { + ControlledByStage companyCount(int companyCount); + } + + public interface ControlledByStage { + CreatedAtStage controlledBy(@NotNull String controlledBy); + } + public interface CreatedAtStage { DescriptionStage createdAt(@NotNull OffsetDateTime createdAt); } @@ -309,10 +361,18 @@ public interface _FinalStage { _FinalStage addAllFeatures(List features); + _FinalStage includedCreditGrants(Optional> includedCreditGrants); + + _FinalStage includedCreditGrants(List includedCreditGrants); + _FinalStage monthlyPrice(Optional monthlyPrice); _FinalStage monthlyPrice(BillingPriceResponseData monthlyPrice); + _FinalStage oneTimePrice(Optional oneTimePrice); + + _FinalStage oneTimePrice(BillingPriceResponseData oneTimePrice); + _FinalStage trialDays(Optional trialDays); _FinalStage trialDays(Integer trialDays); @@ -324,7 +384,9 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CompanyCountStage, + implements ChargeTypeStage, + CompanyCountStage, + ControlledByStage, CreatedAtStage, DescriptionStage, IconStage, @@ -336,8 +398,12 @@ public static final class Builder PlanTypeStage, UpdatedAtStage, _FinalStage { + private String chargeType; + private int companyCount; + private String controlledBy; + private OffsetDateTime createdAt; private String description; @@ -362,8 +428,12 @@ public static final class Builder private Optional trialDays = Optional.empty(); + private Optional oneTimePrice = Optional.empty(); + private Optional monthlyPrice = Optional.empty(); + private Optional> includedCreditGrants = Optional.empty(); + private List features = new ArrayList<>(); private Optional billingProduct = Optional.empty(); @@ -379,17 +449,21 @@ private Builder() {} public Builder from(PlanDetailResponseData other) { audienceType(other.getAudienceType()); billingProduct(other.getBillingProduct()); + chargeType(other.getChargeType()); companyCount(other.getCompanyCount()); + controlledBy(other.getControlledBy()); createdAt(other.getCreatedAt()); description(other.getDescription()); features(other.getFeatures()); icon(other.getIcon()); id(other.getId()); + includedCreditGrants(other.getIncludedCreditGrants()); isDefault(other.getIsDefault()); isFree(other.getIsFree()); isTrialable(other.getIsTrialable()); monthlyPrice(other.getMonthlyPrice()); name(other.getName()); + oneTimePrice(other.getOneTimePrice()); planType(other.getPlanType()); trialDays(other.getTrialDays()); updatedAt(other.getUpdatedAt()); @@ -397,13 +471,27 @@ public Builder from(PlanDetailResponseData other) { return this; } + @java.lang.Override + @JsonSetter("charge_type") + public CompanyCountStage chargeType(@NotNull String chargeType) { + this.chargeType = Objects.requireNonNull(chargeType, "chargeType must not be null"); + return this; + } + @java.lang.Override @JsonSetter("company_count") - public CreatedAtStage companyCount(int companyCount) { + public ControlledByStage companyCount(int companyCount) { this.companyCount = companyCount; return this; } + @java.lang.Override + @JsonSetter("controlled_by") + public CreatedAtStage controlledBy(@NotNull String controlledBy) { + this.controlledBy = Objects.requireNonNull(controlledBy, "controlledBy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("created_at") public DescriptionStage createdAt(@NotNull OffsetDateTime createdAt) { @@ -500,6 +588,19 @@ public _FinalStage trialDays(Optional trialDays) { return this; } + @java.lang.Override + public _FinalStage oneTimePrice(BillingPriceResponseData oneTimePrice) { + this.oneTimePrice = Optional.ofNullable(oneTimePrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "one_time_price", nulls = Nulls.SKIP) + public _FinalStage oneTimePrice(Optional oneTimePrice) { + this.oneTimePrice = oneTimePrice; + return this; + } + @java.lang.Override public _FinalStage monthlyPrice(BillingPriceResponseData monthlyPrice) { this.monthlyPrice = Optional.ofNullable(monthlyPrice); @@ -513,9 +614,25 @@ public _FinalStage monthlyPrice(Optional monthlyPrice) return this; } + @java.lang.Override + public _FinalStage includedCreditGrants(List includedCreditGrants) { + this.includedCreditGrants = Optional.ofNullable(includedCreditGrants); + return this; + } + + @java.lang.Override + @JsonSetter(value = "included_credit_grants", nulls = Nulls.SKIP) + public _FinalStage includedCreditGrants( + Optional> includedCreditGrants) { + this.includedCreditGrants = includedCreditGrants; + return this; + } + @java.lang.Override public _FinalStage addAllFeatures(List features) { - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @@ -529,7 +646,9 @@ public _FinalStage addFeatures(FeatureDetailResponseData features) { @JsonSetter(value = "features", nulls = Nulls.SKIP) public _FinalStage features(List features) { this.features.clear(); - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @@ -564,17 +683,21 @@ public PlanDetailResponseData build() { return new PlanDetailResponseData( audienceType, billingProduct, + chargeType, companyCount, + controlledBy, createdAt, description, features, icon, id, + includedCreditGrants, isDefault, isFree, isTrialable, monthlyPrice, name, + oneTimePrice, planType, trialDays, updatedAt, diff --git a/src/main/java/com/schematic/api/types/PlanEntitlementResponseData.java b/src/main/java/com/schematic/api/types/PlanEntitlementResponseData.java index 5a8dfde..f5757a5 100644 --- a/src/main/java/com/schematic/api/types/PlanEntitlementResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanEntitlementResponseData.java @@ -22,6 +22,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PlanEntitlementResponseData.Builder.class) public final class PlanEntitlementResponseData { + private final Optional billingThreshold; + + private final Optional consumptionRate; + private final OffsetDateTime createdAt; private final String environmentId; @@ -54,8 +58,12 @@ public final class PlanEntitlementResponseData { private final OffsetDateTime updatedAt; + private final Optional usageBasedProduct; + private final Optional valueBool; + private final Optional valueCredit; + private final Optional valueNumeric; private final Optional valueTrait; @@ -67,6 +75,8 @@ public final class PlanEntitlementResponseData { private final Map additionalProperties; private PlanEntitlementResponseData( + Optional billingThreshold, + Optional consumptionRate, OffsetDateTime createdAt, String environmentId, Optional feature, @@ -83,12 +93,16 @@ private PlanEntitlementResponseData( Optional ruleIdUsageExceeded, Optional softLimit, OffsetDateTime updatedAt, + Optional usageBasedProduct, Optional valueBool, + Optional valueCredit, Optional valueNumeric, Optional valueTrait, Optional valueTraitId, String valueType, Map additionalProperties) { + this.billingThreshold = billingThreshold; + this.consumptionRate = consumptionRate; this.createdAt = createdAt; this.environmentId = environmentId; this.feature = feature; @@ -105,7 +119,9 @@ private PlanEntitlementResponseData( this.ruleIdUsageExceeded = ruleIdUsageExceeded; this.softLimit = softLimit; this.updatedAt = updatedAt; + this.usageBasedProduct = usageBasedProduct; this.valueBool = valueBool; + this.valueCredit = valueCredit; this.valueNumeric = valueNumeric; this.valueTrait = valueTrait; this.valueTraitId = valueTraitId; @@ -113,6 +129,16 @@ private PlanEntitlementResponseData( this.additionalProperties = additionalProperties; } + @JsonProperty("billing_threshold") + public Optional getBillingThreshold() { + return billingThreshold; + } + + @JsonProperty("consumption_rate") + public Optional getConsumptionRate() { + return consumptionRate; + } + @JsonProperty("created_at") public OffsetDateTime getCreatedAt() { return createdAt; @@ -193,11 +219,21 @@ public OffsetDateTime getUpdatedAt() { return updatedAt; } + @JsonProperty("usage_based_product") + public Optional getUsageBasedProduct() { + return usageBasedProduct; + } + @JsonProperty("value_bool") public Optional getValueBool() { return valueBool; } + @JsonProperty("value_credit") + public Optional getValueCredit() { + return valueCredit; + } + @JsonProperty("value_numeric") public Optional getValueNumeric() { return valueNumeric; @@ -230,7 +266,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(PlanEntitlementResponseData other) { - return createdAt.equals(other.createdAt) + return billingThreshold.equals(other.billingThreshold) + && consumptionRate.equals(other.consumptionRate) + && createdAt.equals(other.createdAt) && environmentId.equals(other.environmentId) && feature.equals(other.feature) && featureId.equals(other.featureId) @@ -246,7 +284,9 @@ private boolean equalTo(PlanEntitlementResponseData other) { && ruleIdUsageExceeded.equals(other.ruleIdUsageExceeded) && softLimit.equals(other.softLimit) && updatedAt.equals(other.updatedAt) + && usageBasedProduct.equals(other.usageBasedProduct) && valueBool.equals(other.valueBool) + && valueCredit.equals(other.valueCredit) && valueNumeric.equals(other.valueNumeric) && valueTrait.equals(other.valueTrait) && valueTraitId.equals(other.valueTraitId) @@ -256,6 +296,8 @@ private boolean equalTo(PlanEntitlementResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.billingThreshold, + this.consumptionRate, this.createdAt, this.environmentId, this.feature, @@ -272,7 +314,9 @@ public int hashCode() { this.ruleIdUsageExceeded, this.softLimit, this.updatedAt, + this.usageBasedProduct, this.valueBool, + this.valueCredit, this.valueNumeric, this.valueTrait, this.valueTraitId, @@ -325,6 +369,14 @@ public interface ValueTypeStage { public interface _FinalStage { PlanEntitlementResponseData build(); + _FinalStage billingThreshold(Optional billingThreshold); + + _FinalStage billingThreshold(Integer billingThreshold); + + _FinalStage consumptionRate(Optional consumptionRate); + + _FinalStage consumptionRate(Double consumptionRate); + _FinalStage feature(Optional feature); _FinalStage feature(FeatureResponseData feature); @@ -361,10 +413,18 @@ public interface _FinalStage { _FinalStage softLimit(Integer softLimit); + _FinalStage usageBasedProduct(Optional usageBasedProduct); + + _FinalStage usageBasedProduct(BillingProductResponseData usageBasedProduct); + _FinalStage valueBool(Optional valueBool); _FinalStage valueBool(Boolean valueBool); + _FinalStage valueCredit(Optional valueCredit); + + _FinalStage valueCredit(BillingCreditResponseData valueCredit); + _FinalStage valueNumeric(Optional valueNumeric); _FinalStage valueNumeric(Integer valueNumeric); @@ -411,8 +471,12 @@ public static final class Builder private Optional valueNumeric = Optional.empty(); + private Optional valueCredit = Optional.empty(); + private Optional valueBool = Optional.empty(); + private Optional usageBasedProduct = Optional.empty(); + private Optional softLimit = Optional.empty(); private Optional ruleIdUsageExceeded = Optional.empty(); @@ -431,6 +495,10 @@ public static final class Builder private Optional feature = Optional.empty(); + private Optional consumptionRate = Optional.empty(); + + private Optional billingThreshold = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -438,6 +506,8 @@ private Builder() {} @java.lang.Override public Builder from(PlanEntitlementResponseData other) { + billingThreshold(other.getBillingThreshold()); + consumptionRate(other.getConsumptionRate()); createdAt(other.getCreatedAt()); environmentId(other.getEnvironmentId()); feature(other.getFeature()); @@ -454,7 +524,9 @@ public Builder from(PlanEntitlementResponseData other) { ruleIdUsageExceeded(other.getRuleIdUsageExceeded()); softLimit(other.getSoftLimit()); updatedAt(other.getUpdatedAt()); + usageBasedProduct(other.getUsageBasedProduct()); valueBool(other.getValueBool()); + valueCredit(other.getValueCredit()); valueNumeric(other.getValueNumeric()); valueTrait(other.getValueTrait()); valueTraitId(other.getValueTraitId()); @@ -557,6 +629,19 @@ public _FinalStage valueNumeric(Optional valueNumeric) { return this; } + @java.lang.Override + public _FinalStage valueCredit(BillingCreditResponseData valueCredit) { + this.valueCredit = Optional.ofNullable(valueCredit); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit", nulls = Nulls.SKIP) + public _FinalStage valueCredit(Optional valueCredit) { + this.valueCredit = valueCredit; + return this; + } + @java.lang.Override public _FinalStage valueBool(Boolean valueBool) { this.valueBool = Optional.ofNullable(valueBool); @@ -570,6 +655,19 @@ public _FinalStage valueBool(Optional valueBool) { return this; } + @java.lang.Override + public _FinalStage usageBasedProduct(BillingProductResponseData usageBasedProduct) { + this.usageBasedProduct = Optional.ofNullable(usageBasedProduct); + return this; + } + + @java.lang.Override + @JsonSetter(value = "usage_based_product", nulls = Nulls.SKIP) + public _FinalStage usageBasedProduct(Optional usageBasedProduct) { + this.usageBasedProduct = usageBasedProduct; + return this; + } + @java.lang.Override public _FinalStage softLimit(Integer softLimit) { this.softLimit = Optional.ofNullable(softLimit); @@ -687,9 +785,37 @@ public _FinalStage feature(Optional feature) { return this; } + @java.lang.Override + public _FinalStage consumptionRate(Double consumptionRate) { + this.consumptionRate = Optional.ofNullable(consumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "consumption_rate", nulls = Nulls.SKIP) + public _FinalStage consumptionRate(Optional consumptionRate) { + this.consumptionRate = consumptionRate; + return this; + } + + @java.lang.Override + public _FinalStage billingThreshold(Integer billingThreshold) { + this.billingThreshold = Optional.ofNullable(billingThreshold); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_threshold", nulls = Nulls.SKIP) + public _FinalStage billingThreshold(Optional billingThreshold) { + this.billingThreshold = billingThreshold; + return this; + } + @java.lang.Override public PlanEntitlementResponseData build() { return new PlanEntitlementResponseData( + billingThreshold, + consumptionRate, createdAt, environmentId, feature, @@ -706,7 +832,9 @@ public PlanEntitlementResponseData build() { ruleIdUsageExceeded, softLimit, updatedAt, + usageBasedProduct, valueBool, + valueCredit, valueNumeric, valueTrait, valueTraitId, diff --git a/src/main/java/com/schematic/api/types/PlanGroupBundleOrder.java b/src/main/java/com/schematic/api/types/PlanGroupBundleOrder.java new file mode 100644 index 0000000..04f892c --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanGroupBundleOrder.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PlanGroupBundleOrder.Builder.class) +public final class PlanGroupBundleOrder { + private final String bundleId; + + private final Map additionalProperties; + + private PlanGroupBundleOrder(String bundleId, Map additionalProperties) { + this.bundleId = bundleId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("bundleId") + public String getBundleId() { + return bundleId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PlanGroupBundleOrder && equalTo((PlanGroupBundleOrder) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PlanGroupBundleOrder other) { + return bundleId.equals(other.bundleId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.bundleId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BundleIdStage builder() { + return new Builder(); + } + + public interface BundleIdStage { + _FinalStage bundleId(@NotNull String bundleId); + + Builder from(PlanGroupBundleOrder other); + } + + public interface _FinalStage { + PlanGroupBundleOrder build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements BundleIdStage, _FinalStage { + private String bundleId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PlanGroupBundleOrder other) { + bundleId(other.getBundleId()); + return this; + } + + @java.lang.Override + @JsonSetter("bundleId") + public _FinalStage bundleId(@NotNull String bundleId) { + this.bundleId = Objects.requireNonNull(bundleId, "bundleId must not be null"); + return this; + } + + @java.lang.Override + public PlanGroupBundleOrder build() { + return new PlanGroupBundleOrder(bundleId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PlanGroupDetailResponseData.java b/src/main/java/com/schematic/api/types/PlanGroupDetailResponseData.java index f8f3a90..39b50df 100644 --- a/src/main/java/com/schematic/api/types/PlanGroupDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanGroupDetailResponseData.java @@ -25,6 +25,8 @@ public final class PlanGroupDetailResponseData { private final List addOns; + private final CheckoutSettingsResponseData checkoutSettings; + private final Optional customPlanConfig; private final Optional customPlanId; @@ -33,39 +35,113 @@ public final class PlanGroupDetailResponseData { private final Optional defaultPlanId; + private final Optional fallbackPlan; + + private final Optional fallbackPlanId; + private final String id; + private final Optional initialPlan; + + private final Optional initialPlanId; + + private final Optional initialPlanPrice; + + private final Optional initialPlanPriceId; + + private final List orderedAddOnList; + + private final List orderedBundleList; + private final List orderedPlanList; private final List plans; + private final boolean preventDowngradesWhenOverLimit; + + private final boolean showCredits; + + private final boolean showPeriodToggle; + + private final boolean showZeroPriceAsFree; + + private final boolean syncCustomerBillingDetailsForTax; + + private final boolean taxCollectionEnabled; + private final Optional trialDays; + private final Optional trialExpiryPlan; + + private final Optional trialExpiryPlanId; + + private final Optional trialExpiryPlanPrice; + + private final Optional trialExpiryPlanPriceId; + private final Optional trialPaymentMethodRequired; private final Map additionalProperties; private PlanGroupDetailResponseData( List addOns, + CheckoutSettingsResponseData checkoutSettings, Optional customPlanConfig, Optional customPlanId, Optional defaultPlan, Optional defaultPlanId, + Optional fallbackPlan, + Optional fallbackPlanId, String id, + Optional initialPlan, + Optional initialPlanId, + Optional initialPlanPrice, + Optional initialPlanPriceId, + List orderedAddOnList, + List orderedBundleList, List orderedPlanList, List plans, + boolean preventDowngradesWhenOverLimit, + boolean showCredits, + boolean showPeriodToggle, + boolean showZeroPriceAsFree, + boolean syncCustomerBillingDetailsForTax, + boolean taxCollectionEnabled, Optional trialDays, + Optional trialExpiryPlan, + Optional trialExpiryPlanId, + Optional trialExpiryPlanPrice, + Optional trialExpiryPlanPriceId, Optional trialPaymentMethodRequired, Map additionalProperties) { this.addOns = addOns; + this.checkoutSettings = checkoutSettings; this.customPlanConfig = customPlanConfig; this.customPlanId = customPlanId; this.defaultPlan = defaultPlan; this.defaultPlanId = defaultPlanId; + this.fallbackPlan = fallbackPlan; + this.fallbackPlanId = fallbackPlanId; this.id = id; + this.initialPlan = initialPlan; + this.initialPlanId = initialPlanId; + this.initialPlanPrice = initialPlanPrice; + this.initialPlanPriceId = initialPlanPriceId; + this.orderedAddOnList = orderedAddOnList; + this.orderedBundleList = orderedBundleList; this.orderedPlanList = orderedPlanList; this.plans = plans; + this.preventDowngradesWhenOverLimit = preventDowngradesWhenOverLimit; + this.showCredits = showCredits; + this.showPeriodToggle = showPeriodToggle; + this.showZeroPriceAsFree = showZeroPriceAsFree; + this.syncCustomerBillingDetailsForTax = syncCustomerBillingDetailsForTax; + this.taxCollectionEnabled = taxCollectionEnabled; this.trialDays = trialDays; + this.trialExpiryPlan = trialExpiryPlan; + this.trialExpiryPlanId = trialExpiryPlanId; + this.trialExpiryPlanPrice = trialExpiryPlanPrice; + this.trialExpiryPlanPriceId = trialExpiryPlanPriceId; this.trialPaymentMethodRequired = trialPaymentMethodRequired; this.additionalProperties = additionalProperties; } @@ -75,6 +151,11 @@ public List getAddOns() { return addOns; } + @JsonProperty("checkout_settings") + public CheckoutSettingsResponseData getCheckoutSettings() { + return checkoutSettings; + } + @JsonProperty("custom_plan_config") public Optional getCustomPlanConfig() { return customPlanConfig; @@ -95,11 +176,51 @@ public Optional getDefaultPlanId() { return defaultPlanId; } + @JsonProperty("fallback_plan") + public Optional getFallbackPlan() { + return fallbackPlan; + } + + @JsonProperty("fallback_plan_id") + public Optional getFallbackPlanId() { + return fallbackPlanId; + } + @JsonProperty("id") public String getId() { return id; } + @JsonProperty("initial_plan") + public Optional getInitialPlan() { + return initialPlan; + } + + @JsonProperty("initial_plan_id") + public Optional getInitialPlanId() { + return initialPlanId; + } + + @JsonProperty("initial_plan_price") + public Optional getInitialPlanPrice() { + return initialPlanPrice; + } + + @JsonProperty("initial_plan_price_id") + public Optional getInitialPlanPriceId() { + return initialPlanPriceId; + } + + @JsonProperty("ordered_add_on_list") + public List getOrderedAddOnList() { + return orderedAddOnList; + } + + @JsonProperty("ordered_bundle_list") + public List getOrderedBundleList() { + return orderedBundleList; + } + @JsonProperty("ordered_plan_list") public List getOrderedPlanList() { return orderedPlanList; @@ -110,11 +231,61 @@ public List getPlans() { return plans; } + @JsonProperty("prevent_downgrades_when_over_limit") + public boolean getPreventDowngradesWhenOverLimit() { + return preventDowngradesWhenOverLimit; + } + + @JsonProperty("show_credits") + public boolean getShowCredits() { + return showCredits; + } + + @JsonProperty("show_period_toggle") + public boolean getShowPeriodToggle() { + return showPeriodToggle; + } + + @JsonProperty("show_zero_price_as_free") + public boolean getShowZeroPriceAsFree() { + return showZeroPriceAsFree; + } + + @JsonProperty("sync_customer_billing_details_for_tax") + public boolean getSyncCustomerBillingDetailsForTax() { + return syncCustomerBillingDetailsForTax; + } + + @JsonProperty("tax_collection_enabled") + public boolean getTaxCollectionEnabled() { + return taxCollectionEnabled; + } + @JsonProperty("trial_days") public Optional getTrialDays() { return trialDays; } + @JsonProperty("trial_expiry_plan") + public Optional getTrialExpiryPlan() { + return trialExpiryPlan; + } + + @JsonProperty("trial_expiry_plan_id") + public Optional getTrialExpiryPlanId() { + return trialExpiryPlanId; + } + + @JsonProperty("trial_expiry_plan_price") + public Optional getTrialExpiryPlanPrice() { + return trialExpiryPlanPrice; + } + + @JsonProperty("trial_expiry_plan_price_id") + public Optional getTrialExpiryPlanPriceId() { + return trialExpiryPlanPriceId; + } + @JsonProperty("trial_payment_method_required") public Optional getTrialPaymentMethodRequired() { return trialPaymentMethodRequired; @@ -133,14 +304,33 @@ public Map getAdditionalProperties() { private boolean equalTo(PlanGroupDetailResponseData other) { return addOns.equals(other.addOns) + && checkoutSettings.equals(other.checkoutSettings) && customPlanConfig.equals(other.customPlanConfig) && customPlanId.equals(other.customPlanId) && defaultPlan.equals(other.defaultPlan) && defaultPlanId.equals(other.defaultPlanId) + && fallbackPlan.equals(other.fallbackPlan) + && fallbackPlanId.equals(other.fallbackPlanId) && id.equals(other.id) + && initialPlan.equals(other.initialPlan) + && initialPlanId.equals(other.initialPlanId) + && initialPlanPrice.equals(other.initialPlanPrice) + && initialPlanPriceId.equals(other.initialPlanPriceId) + && orderedAddOnList.equals(other.orderedAddOnList) + && orderedBundleList.equals(other.orderedBundleList) && orderedPlanList.equals(other.orderedPlanList) && plans.equals(other.plans) + && preventDowngradesWhenOverLimit == other.preventDowngradesWhenOverLimit + && showCredits == other.showCredits + && showPeriodToggle == other.showPeriodToggle + && showZeroPriceAsFree == other.showZeroPriceAsFree + && syncCustomerBillingDetailsForTax == other.syncCustomerBillingDetailsForTax + && taxCollectionEnabled == other.taxCollectionEnabled && trialDays.equals(other.trialDays) + && trialExpiryPlan.equals(other.trialExpiryPlan) + && trialExpiryPlanId.equals(other.trialExpiryPlanId) + && trialExpiryPlanPrice.equals(other.trialExpiryPlanPrice) + && trialExpiryPlanPriceId.equals(other.trialExpiryPlanPriceId) && trialPaymentMethodRequired.equals(other.trialPaymentMethodRequired); } @@ -148,14 +338,33 @@ private boolean equalTo(PlanGroupDetailResponseData other) { public int hashCode() { return Objects.hash( this.addOns, + this.checkoutSettings, this.customPlanConfig, this.customPlanId, this.defaultPlan, this.defaultPlanId, + this.fallbackPlan, + this.fallbackPlanId, this.id, + this.initialPlan, + this.initialPlanId, + this.initialPlanPrice, + this.initialPlanPriceId, + this.orderedAddOnList, + this.orderedBundleList, this.orderedPlanList, this.plans, + this.preventDowngradesWhenOverLimit, + this.showCredits, + this.showPeriodToggle, + this.showZeroPriceAsFree, + this.syncCustomerBillingDetailsForTax, + this.taxCollectionEnabled, this.trialDays, + this.trialExpiryPlan, + this.trialExpiryPlanId, + this.trialExpiryPlanPrice, + this.trialExpiryPlanPriceId, this.trialPaymentMethodRequired); } @@ -164,16 +373,44 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static CheckoutSettingsStage builder() { return new Builder(); } - public interface IdStage { - _FinalStage id(@NotNull String id); + public interface CheckoutSettingsStage { + IdStage checkoutSettings(@NotNull CheckoutSettingsResponseData checkoutSettings); Builder from(PlanGroupDetailResponseData other); } + public interface IdStage { + PreventDowngradesWhenOverLimitStage id(@NotNull String id); + } + + public interface PreventDowngradesWhenOverLimitStage { + ShowCreditsStage preventDowngradesWhenOverLimit(boolean preventDowngradesWhenOverLimit); + } + + public interface ShowCreditsStage { + ShowPeriodToggleStage showCredits(boolean showCredits); + } + + public interface ShowPeriodToggleStage { + ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle); + } + + public interface ShowZeroPriceAsFreeStage { + SyncCustomerBillingDetailsForTaxStage showZeroPriceAsFree(boolean showZeroPriceAsFree); + } + + public interface SyncCustomerBillingDetailsForTaxStage { + TaxCollectionEnabledStage syncCustomerBillingDetailsForTax(boolean syncCustomerBillingDetailsForTax); + } + + public interface TaxCollectionEnabledStage { + _FinalStage taxCollectionEnabled(boolean taxCollectionEnabled); + } + public interface _FinalStage { PlanGroupDetailResponseData build(); @@ -199,6 +436,42 @@ public interface _FinalStage { _FinalStage defaultPlanId(String defaultPlanId); + _FinalStage fallbackPlan(Optional fallbackPlan); + + _FinalStage fallbackPlan(PlanGroupPlanDetailResponseData fallbackPlan); + + _FinalStage fallbackPlanId(Optional fallbackPlanId); + + _FinalStage fallbackPlanId(String fallbackPlanId); + + _FinalStage initialPlan(Optional initialPlan); + + _FinalStage initialPlan(PlanGroupPlanDetailResponseData initialPlan); + + _FinalStage initialPlanId(Optional initialPlanId); + + _FinalStage initialPlanId(String initialPlanId); + + _FinalStage initialPlanPrice(Optional initialPlanPrice); + + _FinalStage initialPlanPrice(BillingPriceResponseData initialPlanPrice); + + _FinalStage initialPlanPriceId(Optional initialPlanPriceId); + + _FinalStage initialPlanPriceId(String initialPlanPriceId); + + _FinalStage orderedAddOnList(List orderedAddOnList); + + _FinalStage addOrderedAddOnList(PlanGroupPlanEntitlementsOrder orderedAddOnList); + + _FinalStage addAllOrderedAddOnList(List orderedAddOnList); + + _FinalStage orderedBundleList(List orderedBundleList); + + _FinalStage addOrderedBundleList(PlanGroupBundleOrder orderedBundleList); + + _FinalStage addAllOrderedBundleList(List orderedBundleList); + _FinalStage orderedPlanList(List orderedPlanList); _FinalStage addOrderedPlanList(PlanGroupPlanEntitlementsOrder orderedPlanList); @@ -215,23 +488,86 @@ public interface _FinalStage { _FinalStage trialDays(Integer trialDays); + _FinalStage trialExpiryPlan(Optional trialExpiryPlan); + + _FinalStage trialExpiryPlan(PlanGroupPlanDetailResponseData trialExpiryPlan); + + _FinalStage trialExpiryPlanId(Optional trialExpiryPlanId); + + _FinalStage trialExpiryPlanId(String trialExpiryPlanId); + + _FinalStage trialExpiryPlanPrice(Optional trialExpiryPlanPrice); + + _FinalStage trialExpiryPlanPrice(BillingPriceResponseData trialExpiryPlanPrice); + + _FinalStage trialExpiryPlanPriceId(Optional trialExpiryPlanPriceId); + + _FinalStage trialExpiryPlanPriceId(String trialExpiryPlanPriceId); + _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired); _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, _FinalStage { + public static final class Builder + implements CheckoutSettingsStage, + IdStage, + PreventDowngradesWhenOverLimitStage, + ShowCreditsStage, + ShowPeriodToggleStage, + ShowZeroPriceAsFreeStage, + SyncCustomerBillingDetailsForTaxStage, + TaxCollectionEnabledStage, + _FinalStage { + private CheckoutSettingsResponseData checkoutSettings; + private String id; + private boolean preventDowngradesWhenOverLimit; + + private boolean showCredits; + + private boolean showPeriodToggle; + + private boolean showZeroPriceAsFree; + + private boolean syncCustomerBillingDetailsForTax; + + private boolean taxCollectionEnabled; + private Optional trialPaymentMethodRequired = Optional.empty(); + private Optional trialExpiryPlanPriceId = Optional.empty(); + + private Optional trialExpiryPlanPrice = Optional.empty(); + + private Optional trialExpiryPlanId = Optional.empty(); + + private Optional trialExpiryPlan = Optional.empty(); + private Optional trialDays = Optional.empty(); private List plans = new ArrayList<>(); private List orderedPlanList = new ArrayList<>(); + private List orderedBundleList = new ArrayList<>(); + + private List orderedAddOnList = new ArrayList<>(); + + private Optional initialPlanPriceId = Optional.empty(); + + private Optional initialPlanPrice = Optional.empty(); + + private Optional initialPlanId = Optional.empty(); + + private Optional initialPlan = Optional.empty(); + + private Optional fallbackPlanId = Optional.empty(); + + private Optional fallbackPlan = Optional.empty(); + private Optional defaultPlanId = Optional.empty(); private Optional defaultPlan = Optional.empty(); @@ -250,25 +586,93 @@ private Builder() {} @java.lang.Override public Builder from(PlanGroupDetailResponseData other) { addOns(other.getAddOns()); + checkoutSettings(other.getCheckoutSettings()); customPlanConfig(other.getCustomPlanConfig()); customPlanId(other.getCustomPlanId()); defaultPlan(other.getDefaultPlan()); defaultPlanId(other.getDefaultPlanId()); + fallbackPlan(other.getFallbackPlan()); + fallbackPlanId(other.getFallbackPlanId()); id(other.getId()); + initialPlan(other.getInitialPlan()); + initialPlanId(other.getInitialPlanId()); + initialPlanPrice(other.getInitialPlanPrice()); + initialPlanPriceId(other.getInitialPlanPriceId()); + orderedAddOnList(other.getOrderedAddOnList()); + orderedBundleList(other.getOrderedBundleList()); orderedPlanList(other.getOrderedPlanList()); plans(other.getPlans()); + preventDowngradesWhenOverLimit(other.getPreventDowngradesWhenOverLimit()); + showCredits(other.getShowCredits()); + showPeriodToggle(other.getShowPeriodToggle()); + showZeroPriceAsFree(other.getShowZeroPriceAsFree()); + syncCustomerBillingDetailsForTax(other.getSyncCustomerBillingDetailsForTax()); + taxCollectionEnabled(other.getTaxCollectionEnabled()); trialDays(other.getTrialDays()); + trialExpiryPlan(other.getTrialExpiryPlan()); + trialExpiryPlanId(other.getTrialExpiryPlanId()); + trialExpiryPlanPrice(other.getTrialExpiryPlanPrice()); + trialExpiryPlanPriceId(other.getTrialExpiryPlanPriceId()); trialPaymentMethodRequired(other.getTrialPaymentMethodRequired()); return this; } + @java.lang.Override + @JsonSetter("checkout_settings") + public IdStage checkoutSettings(@NotNull CheckoutSettingsResponseData checkoutSettings) { + this.checkoutSettings = Objects.requireNonNull(checkoutSettings, "checkoutSettings must not be null"); + return this; + } + @java.lang.Override @JsonSetter("id") - public _FinalStage id(@NotNull String id) { + public PreventDowngradesWhenOverLimitStage id(@NotNull String id) { this.id = Objects.requireNonNull(id, "id must not be null"); return this; } + @java.lang.Override + @JsonSetter("prevent_downgrades_when_over_limit") + public ShowCreditsStage preventDowngradesWhenOverLimit(boolean preventDowngradesWhenOverLimit) { + this.preventDowngradesWhenOverLimit = preventDowngradesWhenOverLimit; + return this; + } + + @java.lang.Override + @JsonSetter("show_credits") + public ShowPeriodToggleStage showCredits(boolean showCredits) { + this.showCredits = showCredits; + return this; + } + + @java.lang.Override + @JsonSetter("show_period_toggle") + public ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle) { + this.showPeriodToggle = showPeriodToggle; + return this; + } + + @java.lang.Override + @JsonSetter("show_zero_price_as_free") + public SyncCustomerBillingDetailsForTaxStage showZeroPriceAsFree(boolean showZeroPriceAsFree) { + this.showZeroPriceAsFree = showZeroPriceAsFree; + return this; + } + + @java.lang.Override + @JsonSetter("sync_customer_billing_details_for_tax") + public TaxCollectionEnabledStage syncCustomerBillingDetailsForTax(boolean syncCustomerBillingDetailsForTax) { + this.syncCustomerBillingDetailsForTax = syncCustomerBillingDetailsForTax; + return this; + } + + @java.lang.Override + @JsonSetter("tax_collection_enabled") + public _FinalStage taxCollectionEnabled(boolean taxCollectionEnabled) { + this.taxCollectionEnabled = taxCollectionEnabled; + return this; + } + @java.lang.Override public _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); @@ -282,6 +686,58 @@ public _FinalStage trialPaymentMethodRequired(Optional trialPaymentMeth return this; } + @java.lang.Override + public _FinalStage trialExpiryPlanPriceId(String trialExpiryPlanPriceId) { + this.trialExpiryPlanPriceId = Optional.ofNullable(trialExpiryPlanPriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanPriceId(Optional trialExpiryPlanPriceId) { + this.trialExpiryPlanPriceId = trialExpiryPlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage trialExpiryPlanPrice(BillingPriceResponseData trialExpiryPlanPrice) { + this.trialExpiryPlanPrice = Optional.ofNullable(trialExpiryPlanPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_price", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanPrice(Optional trialExpiryPlanPrice) { + this.trialExpiryPlanPrice = trialExpiryPlanPrice; + return this; + } + + @java.lang.Override + public _FinalStage trialExpiryPlanId(String trialExpiryPlanId) { + this.trialExpiryPlanId = Optional.ofNullable(trialExpiryPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_id", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanId(Optional trialExpiryPlanId) { + this.trialExpiryPlanId = trialExpiryPlanId; + return this; + } + + @java.lang.Override + public _FinalStage trialExpiryPlan(PlanGroupPlanDetailResponseData trialExpiryPlan) { + this.trialExpiryPlan = Optional.ofNullable(trialExpiryPlan); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlan(Optional trialExpiryPlan) { + this.trialExpiryPlan = trialExpiryPlan; + return this; + } + @java.lang.Override public _FinalStage trialDays(Integer trialDays) { this.trialDays = Optional.ofNullable(trialDays); @@ -297,7 +753,9 @@ public _FinalStage trialDays(Optional trialDays) { @java.lang.Override public _FinalStage addAllPlans(List plans) { - this.plans.addAll(plans); + if (plans != null) { + this.plans.addAll(plans); + } return this; } @@ -311,13 +769,17 @@ public _FinalStage addPlans(PlanGroupPlanDetailResponseData plans) { @JsonSetter(value = "plans", nulls = Nulls.SKIP) public _FinalStage plans(List plans) { this.plans.clear(); - this.plans.addAll(plans); + if (plans != null) { + this.plans.addAll(plans); + } return this; } @java.lang.Override public _FinalStage addAllOrderedPlanList(List orderedPlanList) { - this.orderedPlanList.addAll(orderedPlanList); + if (orderedPlanList != null) { + this.orderedPlanList.addAll(orderedPlanList); + } return this; } @@ -331,7 +793,135 @@ public _FinalStage addOrderedPlanList(PlanGroupPlanEntitlementsOrder orderedPlan @JsonSetter(value = "ordered_plan_list", nulls = Nulls.SKIP) public _FinalStage orderedPlanList(List orderedPlanList) { this.orderedPlanList.clear(); - this.orderedPlanList.addAll(orderedPlanList); + if (orderedPlanList != null) { + this.orderedPlanList.addAll(orderedPlanList); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllOrderedBundleList(List orderedBundleList) { + if (orderedBundleList != null) { + this.orderedBundleList.addAll(orderedBundleList); + } + return this; + } + + @java.lang.Override + public _FinalStage addOrderedBundleList(PlanGroupBundleOrder orderedBundleList) { + this.orderedBundleList.add(orderedBundleList); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ordered_bundle_list", nulls = Nulls.SKIP) + public _FinalStage orderedBundleList(List orderedBundleList) { + this.orderedBundleList.clear(); + if (orderedBundleList != null) { + this.orderedBundleList.addAll(orderedBundleList); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllOrderedAddOnList(List orderedAddOnList) { + if (orderedAddOnList != null) { + this.orderedAddOnList.addAll(orderedAddOnList); + } + return this; + } + + @java.lang.Override + public _FinalStage addOrderedAddOnList(PlanGroupPlanEntitlementsOrder orderedAddOnList) { + this.orderedAddOnList.add(orderedAddOnList); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ordered_add_on_list", nulls = Nulls.SKIP) + public _FinalStage orderedAddOnList(List orderedAddOnList) { + this.orderedAddOnList.clear(); + if (orderedAddOnList != null) { + this.orderedAddOnList.addAll(orderedAddOnList); + } + return this; + } + + @java.lang.Override + public _FinalStage initialPlanPriceId(String initialPlanPriceId) { + this.initialPlanPriceId = Optional.ofNullable(initialPlanPriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage initialPlanPriceId(Optional initialPlanPriceId) { + this.initialPlanPriceId = initialPlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage initialPlanPrice(BillingPriceResponseData initialPlanPrice) { + this.initialPlanPrice = Optional.ofNullable(initialPlanPrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_price", nulls = Nulls.SKIP) + public _FinalStage initialPlanPrice(Optional initialPlanPrice) { + this.initialPlanPrice = initialPlanPrice; + return this; + } + + @java.lang.Override + public _FinalStage initialPlanId(String initialPlanId) { + this.initialPlanId = Optional.ofNullable(initialPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_id", nulls = Nulls.SKIP) + public _FinalStage initialPlanId(Optional initialPlanId) { + this.initialPlanId = initialPlanId; + return this; + } + + @java.lang.Override + public _FinalStage initialPlan(PlanGroupPlanDetailResponseData initialPlan) { + this.initialPlan = Optional.ofNullable(initialPlan); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan", nulls = Nulls.SKIP) + public _FinalStage initialPlan(Optional initialPlan) { + this.initialPlan = initialPlan; + return this; + } + + @java.lang.Override + public _FinalStage fallbackPlanId(String fallbackPlanId) { + this.fallbackPlanId = Optional.ofNullable(fallbackPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "fallback_plan_id", nulls = Nulls.SKIP) + public _FinalStage fallbackPlanId(Optional fallbackPlanId) { + this.fallbackPlanId = fallbackPlanId; + return this; + } + + @java.lang.Override + public _FinalStage fallbackPlan(PlanGroupPlanDetailResponseData fallbackPlan) { + this.fallbackPlan = Optional.ofNullable(fallbackPlan); + return this; + } + + @java.lang.Override + @JsonSetter(value = "fallback_plan", nulls = Nulls.SKIP) + public _FinalStage fallbackPlan(Optional fallbackPlan) { + this.fallbackPlan = fallbackPlan; return this; } @@ -389,7 +979,9 @@ public _FinalStage customPlanConfig(Optional c @java.lang.Override public _FinalStage addAllAddOns(List addOns) { - this.addOns.addAll(addOns); + if (addOns != null) { + this.addOns.addAll(addOns); + } return this; } @@ -403,7 +995,9 @@ public _FinalStage addAddOns(PlanGroupPlanDetailResponseData addOns) { @JsonSetter(value = "add_ons", nulls = Nulls.SKIP) public _FinalStage addOns(List addOns) { this.addOns.clear(); - this.addOns.addAll(addOns); + if (addOns != null) { + this.addOns.addAll(addOns); + } return this; } @@ -411,14 +1005,33 @@ public _FinalStage addOns(List addOns) { public PlanGroupDetailResponseData build() { return new PlanGroupDetailResponseData( addOns, + checkoutSettings, customPlanConfig, customPlanId, defaultPlan, defaultPlanId, + fallbackPlan, + fallbackPlanId, id, + initialPlan, + initialPlanId, + initialPlanPrice, + initialPlanPriceId, + orderedAddOnList, + orderedBundleList, orderedPlanList, plans, + preventDowngradesWhenOverLimit, + showCredits, + showPeriodToggle, + showZeroPriceAsFree, + syncCustomerBillingDetailsForTax, + taxCollectionEnabled, trialDays, + trialExpiryPlan, + trialExpiryPlanId, + trialExpiryPlanPrice, + trialExpiryPlanPriceId, trialPaymentMethodRequired, additionalProperties); } diff --git a/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java b/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java index 8cf5efd..02b7440 100644 --- a/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanGroupPlanDetailResponseData.java @@ -28,8 +28,14 @@ public final class PlanGroupPlanDetailResponseData { private final Optional billingProduct; + private final String chargeType; + private final int companyCount; + private final List compatiblePlanIds; + + private final String controlledBy; + private final OffsetDateTime createdAt; private final Optional customPlanConfig; @@ -44,6 +50,8 @@ public final class PlanGroupPlanDetailResponseData { private final String id; + private final Optional> includedCreditGrants; + private final boolean isCustom; private final boolean isDefault; @@ -56,6 +64,8 @@ public final class PlanGroupPlanDetailResponseData { private final String name; + private final Optional oneTimePrice; + private final String planType; private final Optional trialDays; @@ -69,7 +79,10 @@ public final class PlanGroupPlanDetailResponseData { private PlanGroupPlanDetailResponseData( Optional audienceType, Optional billingProduct, + String chargeType, int companyCount, + List compatiblePlanIds, + String controlledBy, OffsetDateTime createdAt, Optional customPlanConfig, String description, @@ -77,12 +90,14 @@ private PlanGroupPlanDetailResponseData( List features, String icon, String id, + Optional> includedCreditGrants, boolean isCustom, boolean isDefault, boolean isFree, boolean isTrialable, Optional monthlyPrice, String name, + Optional oneTimePrice, String planType, Optional trialDays, OffsetDateTime updatedAt, @@ -90,7 +105,10 @@ private PlanGroupPlanDetailResponseData( Map additionalProperties) { this.audienceType = audienceType; this.billingProduct = billingProduct; + this.chargeType = chargeType; this.companyCount = companyCount; + this.compatiblePlanIds = compatiblePlanIds; + this.controlledBy = controlledBy; this.createdAt = createdAt; this.customPlanConfig = customPlanConfig; this.description = description; @@ -98,12 +116,14 @@ private PlanGroupPlanDetailResponseData( this.features = features; this.icon = icon; this.id = id; + this.includedCreditGrants = includedCreditGrants; this.isCustom = isCustom; this.isDefault = isDefault; this.isFree = isFree; this.isTrialable = isTrialable; this.monthlyPrice = monthlyPrice; this.name = name; + this.oneTimePrice = oneTimePrice; this.planType = planType; this.trialDays = trialDays; this.updatedAt = updatedAt; @@ -121,11 +141,26 @@ public Optional getBillingProduct() { return billingProduct; } + @JsonProperty("charge_type") + public String getChargeType() { + return chargeType; + } + @JsonProperty("company_count") public int getCompanyCount() { return companyCount; } + @JsonProperty("compatible_plan_ids") + public List getCompatiblePlanIds() { + return compatiblePlanIds; + } + + @JsonProperty("controlled_by") + public String getControlledBy() { + return controlledBy; + } + @JsonProperty("created_at") public OffsetDateTime getCreatedAt() { return createdAt; @@ -161,6 +196,11 @@ public String getId() { return id; } + @JsonProperty("included_credit_grants") + public Optional> getIncludedCreditGrants() { + return includedCreditGrants; + } + @JsonProperty("is_custom") public boolean getIsCustom() { return isCustom; @@ -191,6 +231,11 @@ public String getName() { return name; } + @JsonProperty("one_time_price") + public Optional getOneTimePrice() { + return oneTimePrice; + } + @JsonProperty("plan_type") public String getPlanType() { return planType; @@ -225,7 +270,10 @@ public Map getAdditionalProperties() { private boolean equalTo(PlanGroupPlanDetailResponseData other) { return audienceType.equals(other.audienceType) && billingProduct.equals(other.billingProduct) + && chargeType.equals(other.chargeType) && companyCount == other.companyCount + && compatiblePlanIds.equals(other.compatiblePlanIds) + && controlledBy.equals(other.controlledBy) && createdAt.equals(other.createdAt) && customPlanConfig.equals(other.customPlanConfig) && description.equals(other.description) @@ -233,12 +281,14 @@ private boolean equalTo(PlanGroupPlanDetailResponseData other) { && features.equals(other.features) && icon.equals(other.icon) && id.equals(other.id) + && includedCreditGrants.equals(other.includedCreditGrants) && isCustom == other.isCustom && isDefault == other.isDefault && isFree == other.isFree && isTrialable == other.isTrialable && monthlyPrice.equals(other.monthlyPrice) && name.equals(other.name) + && oneTimePrice.equals(other.oneTimePrice) && planType.equals(other.planType) && trialDays.equals(other.trialDays) && updatedAt.equals(other.updatedAt) @@ -250,7 +300,10 @@ public int hashCode() { return Objects.hash( this.audienceType, this.billingProduct, + this.chargeType, this.companyCount, + this.compatiblePlanIds, + this.controlledBy, this.createdAt, this.customPlanConfig, this.description, @@ -258,12 +311,14 @@ public int hashCode() { this.features, this.icon, this.id, + this.includedCreditGrants, this.isCustom, this.isDefault, this.isFree, this.isTrialable, this.monthlyPrice, this.name, + this.oneTimePrice, this.planType, this.trialDays, this.updatedAt, @@ -275,16 +330,24 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CompanyCountStage builder() { + public static ChargeTypeStage builder() { return new Builder(); } - public interface CompanyCountStage { - CreatedAtStage companyCount(int companyCount); + public interface ChargeTypeStage { + CompanyCountStage chargeType(@NotNull String chargeType); Builder from(PlanGroupPlanDetailResponseData other); } + public interface CompanyCountStage { + ControlledByStage companyCount(int companyCount); + } + + public interface ControlledByStage { + CreatedAtStage controlledBy(@NotNull String controlledBy); + } + public interface CreatedAtStage { DescriptionStage createdAt(@NotNull OffsetDateTime createdAt); } @@ -340,6 +403,12 @@ public interface _FinalStage { _FinalStage billingProduct(BillingProductDetailResponseData billingProduct); + _FinalStage compatiblePlanIds(List compatiblePlanIds); + + _FinalStage addCompatiblePlanIds(String compatiblePlanIds); + + _FinalStage addAllCompatiblePlanIds(List compatiblePlanIds); + _FinalStage customPlanConfig(Optional customPlanConfig); _FinalStage customPlanConfig(CustomPlanViewConfigResponseData customPlanConfig); @@ -356,10 +425,18 @@ public interface _FinalStage { _FinalStage addAllFeatures(List features); + _FinalStage includedCreditGrants(Optional> includedCreditGrants); + + _FinalStage includedCreditGrants(List includedCreditGrants); + _FinalStage monthlyPrice(Optional monthlyPrice); _FinalStage monthlyPrice(BillingPriceResponseData monthlyPrice); + _FinalStage oneTimePrice(Optional oneTimePrice); + + _FinalStage oneTimePrice(BillingPriceResponseData oneTimePrice); + _FinalStage trialDays(Optional trialDays); _FinalStage trialDays(Integer trialDays); @@ -371,7 +448,9 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CompanyCountStage, + implements ChargeTypeStage, + CompanyCountStage, + ControlledByStage, CreatedAtStage, DescriptionStage, IconStage, @@ -384,8 +463,12 @@ public static final class Builder PlanTypeStage, UpdatedAtStage, _FinalStage { + private String chargeType; + private int companyCount; + private String controlledBy; + private OffsetDateTime createdAt; private String description; @@ -412,14 +495,20 @@ public static final class Builder private Optional trialDays = Optional.empty(); + private Optional oneTimePrice = Optional.empty(); + private Optional monthlyPrice = Optional.empty(); + private Optional> includedCreditGrants = Optional.empty(); + private List features = new ArrayList<>(); private List entitlements = new ArrayList<>(); private Optional customPlanConfig = Optional.empty(); + private List compatiblePlanIds = new ArrayList<>(); + private Optional billingProduct = Optional.empty(); private Optional audienceType = Optional.empty(); @@ -433,7 +522,10 @@ private Builder() {} public Builder from(PlanGroupPlanDetailResponseData other) { audienceType(other.getAudienceType()); billingProduct(other.getBillingProduct()); + chargeType(other.getChargeType()); companyCount(other.getCompanyCount()); + compatiblePlanIds(other.getCompatiblePlanIds()); + controlledBy(other.getControlledBy()); createdAt(other.getCreatedAt()); customPlanConfig(other.getCustomPlanConfig()); description(other.getDescription()); @@ -441,12 +533,14 @@ public Builder from(PlanGroupPlanDetailResponseData other) { features(other.getFeatures()); icon(other.getIcon()); id(other.getId()); + includedCreditGrants(other.getIncludedCreditGrants()); isCustom(other.getIsCustom()); isDefault(other.getIsDefault()); isFree(other.getIsFree()); isTrialable(other.getIsTrialable()); monthlyPrice(other.getMonthlyPrice()); name(other.getName()); + oneTimePrice(other.getOneTimePrice()); planType(other.getPlanType()); trialDays(other.getTrialDays()); updatedAt(other.getUpdatedAt()); @@ -454,13 +548,27 @@ public Builder from(PlanGroupPlanDetailResponseData other) { return this; } + @java.lang.Override + @JsonSetter("charge_type") + public CompanyCountStage chargeType(@NotNull String chargeType) { + this.chargeType = Objects.requireNonNull(chargeType, "chargeType must not be null"); + return this; + } + @java.lang.Override @JsonSetter("company_count") - public CreatedAtStage companyCount(int companyCount) { + public ControlledByStage companyCount(int companyCount) { this.companyCount = companyCount; return this; } + @java.lang.Override + @JsonSetter("controlled_by") + public CreatedAtStage controlledBy(@NotNull String controlledBy) { + this.controlledBy = Objects.requireNonNull(controlledBy, "controlledBy must not be null"); + return this; + } + @java.lang.Override @JsonSetter("created_at") public DescriptionStage createdAt(@NotNull OffsetDateTime createdAt) { @@ -564,6 +672,19 @@ public _FinalStage trialDays(Optional trialDays) { return this; } + @java.lang.Override + public _FinalStage oneTimePrice(BillingPriceResponseData oneTimePrice) { + this.oneTimePrice = Optional.ofNullable(oneTimePrice); + return this; + } + + @java.lang.Override + @JsonSetter(value = "one_time_price", nulls = Nulls.SKIP) + public _FinalStage oneTimePrice(Optional oneTimePrice) { + this.oneTimePrice = oneTimePrice; + return this; + } + @java.lang.Override public _FinalStage monthlyPrice(BillingPriceResponseData monthlyPrice) { this.monthlyPrice = Optional.ofNullable(monthlyPrice); @@ -577,9 +698,25 @@ public _FinalStage monthlyPrice(Optional monthlyPrice) return this; } + @java.lang.Override + public _FinalStage includedCreditGrants(List includedCreditGrants) { + this.includedCreditGrants = Optional.ofNullable(includedCreditGrants); + return this; + } + + @java.lang.Override + @JsonSetter(value = "included_credit_grants", nulls = Nulls.SKIP) + public _FinalStage includedCreditGrants( + Optional> includedCreditGrants) { + this.includedCreditGrants = includedCreditGrants; + return this; + } + @java.lang.Override public _FinalStage addAllFeatures(List features) { - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @@ -593,13 +730,17 @@ public _FinalStage addFeatures(FeatureDetailResponseData features) { @JsonSetter(value = "features", nulls = Nulls.SKIP) public _FinalStage features(List features) { this.features.clear(); - this.features.addAll(features); + if (features != null) { + this.features.addAll(features); + } return this; } @java.lang.Override public _FinalStage addAllEntitlements(List entitlements) { - this.entitlements.addAll(entitlements); + if (entitlements != null) { + this.entitlements.addAll(entitlements); + } return this; } @@ -613,7 +754,9 @@ public _FinalStage addEntitlements(PlanEntitlementResponseData entitlements) { @JsonSetter(value = "entitlements", nulls = Nulls.SKIP) public _FinalStage entitlements(List entitlements) { this.entitlements.clear(); - this.entitlements.addAll(entitlements); + if (entitlements != null) { + this.entitlements.addAll(entitlements); + } return this; } @@ -630,6 +773,30 @@ public _FinalStage customPlanConfig(Optional c return this; } + @java.lang.Override + public _FinalStage addAllCompatiblePlanIds(List compatiblePlanIds) { + if (compatiblePlanIds != null) { + this.compatiblePlanIds.addAll(compatiblePlanIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addCompatiblePlanIds(String compatiblePlanIds) { + this.compatiblePlanIds.add(compatiblePlanIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "compatible_plan_ids", nulls = Nulls.SKIP) + public _FinalStage compatiblePlanIds(List compatiblePlanIds) { + this.compatiblePlanIds.clear(); + if (compatiblePlanIds != null) { + this.compatiblePlanIds.addAll(compatiblePlanIds); + } + return this; + } + @java.lang.Override public _FinalStage billingProduct(BillingProductDetailResponseData billingProduct) { this.billingProduct = Optional.ofNullable(billingProduct); @@ -661,7 +828,10 @@ public PlanGroupPlanDetailResponseData build() { return new PlanGroupPlanDetailResponseData( audienceType, billingProduct, + chargeType, companyCount, + compatiblePlanIds, + controlledBy, createdAt, customPlanConfig, description, @@ -669,12 +839,14 @@ public PlanGroupPlanDetailResponseData build() { features, icon, id, + includedCreditGrants, isCustom, isDefault, isFree, isTrialable, monthlyPrice, name, + oneTimePrice, planType, trialDays, updatedAt, diff --git a/src/main/java/com/schematic/api/types/PlanGroupResponseData.java b/src/main/java/com/schematic/api/types/PlanGroupResponseData.java index 0fd8419..9772bfb 100644 --- a/src/main/java/com/schematic/api/types/PlanGroupResponseData.java +++ b/src/main/java/com/schematic/api/types/PlanGroupResponseData.java @@ -23,62 +23,188 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PlanGroupResponseData.Builder.class) public final class PlanGroupResponseData { + private final List addOnCompatibilities; + private final List addOnIds; + private final CheckoutSettingsResponseData checkoutSettings; + private final Optional defaultPlanId; + private final Optional fallbackPlanId; + private final String id; + private final Optional initialPlanId; + + private final Optional initialPlanPriceId; + + private final List orderedAddOnIds; + private final List planIds; + private final boolean preventDowngradesWhenOverLimit; + + private final boolean showCredits; + + private final boolean showPeriodToggle; + + private final boolean showZeroPriceAsFree; + + private final boolean syncCustomerBillingDetailsForTax; + + private final boolean taxCollectionEnabled; + private final Optional trialDays; + private final Optional trialExpiryPlanId; + + private final Optional trialExpiryPlanPriceId; + private final Optional trialPaymentMethodRequired; private final Map additionalProperties; private PlanGroupResponseData( + List addOnCompatibilities, List addOnIds, + CheckoutSettingsResponseData checkoutSettings, Optional defaultPlanId, + Optional fallbackPlanId, String id, + Optional initialPlanId, + Optional initialPlanPriceId, + List orderedAddOnIds, List planIds, + boolean preventDowngradesWhenOverLimit, + boolean showCredits, + boolean showPeriodToggle, + boolean showZeroPriceAsFree, + boolean syncCustomerBillingDetailsForTax, + boolean taxCollectionEnabled, Optional trialDays, + Optional trialExpiryPlanId, + Optional trialExpiryPlanPriceId, Optional trialPaymentMethodRequired, Map additionalProperties) { + this.addOnCompatibilities = addOnCompatibilities; this.addOnIds = addOnIds; + this.checkoutSettings = checkoutSettings; this.defaultPlanId = defaultPlanId; + this.fallbackPlanId = fallbackPlanId; this.id = id; + this.initialPlanId = initialPlanId; + this.initialPlanPriceId = initialPlanPriceId; + this.orderedAddOnIds = orderedAddOnIds; this.planIds = planIds; + this.preventDowngradesWhenOverLimit = preventDowngradesWhenOverLimit; + this.showCredits = showCredits; + this.showPeriodToggle = showPeriodToggle; + this.showZeroPriceAsFree = showZeroPriceAsFree; + this.syncCustomerBillingDetailsForTax = syncCustomerBillingDetailsForTax; + this.taxCollectionEnabled = taxCollectionEnabled; this.trialDays = trialDays; + this.trialExpiryPlanId = trialExpiryPlanId; + this.trialExpiryPlanPriceId = trialExpiryPlanPriceId; this.trialPaymentMethodRequired = trialPaymentMethodRequired; this.additionalProperties = additionalProperties; } + @JsonProperty("add_on_compatibilities") + public List getAddOnCompatibilities() { + return addOnCompatibilities; + } + @JsonProperty("add_on_ids") public List getAddOnIds() { return addOnIds; } + @JsonProperty("checkout_settings") + public CheckoutSettingsResponseData getCheckoutSettings() { + return checkoutSettings; + } + @JsonProperty("default_plan_id") public Optional getDefaultPlanId() { return defaultPlanId; } + @JsonProperty("fallback_plan_id") + public Optional getFallbackPlanId() { + return fallbackPlanId; + } + @JsonProperty("id") public String getId() { return id; } + @JsonProperty("initial_plan_id") + public Optional getInitialPlanId() { + return initialPlanId; + } + + @JsonProperty("initial_plan_price_id") + public Optional getInitialPlanPriceId() { + return initialPlanPriceId; + } + + @JsonProperty("ordered_add_on_ids") + public List getOrderedAddOnIds() { + return orderedAddOnIds; + } + @JsonProperty("plan_ids") public List getPlanIds() { return planIds; } + @JsonProperty("prevent_downgrades_when_over_limit") + public boolean getPreventDowngradesWhenOverLimit() { + return preventDowngradesWhenOverLimit; + } + + @JsonProperty("show_credits") + public boolean getShowCredits() { + return showCredits; + } + + @JsonProperty("show_period_toggle") + public boolean getShowPeriodToggle() { + return showPeriodToggle; + } + + @JsonProperty("show_zero_price_as_free") + public boolean getShowZeroPriceAsFree() { + return showZeroPriceAsFree; + } + + @JsonProperty("sync_customer_billing_details_for_tax") + public boolean getSyncCustomerBillingDetailsForTax() { + return syncCustomerBillingDetailsForTax; + } + + @JsonProperty("tax_collection_enabled") + public boolean getTaxCollectionEnabled() { + return taxCollectionEnabled; + } + @JsonProperty("trial_days") public Optional getTrialDays() { return trialDays; } + @JsonProperty("trial_expiry_plan_id") + public Optional getTrialExpiryPlanId() { + return trialExpiryPlanId; + } + + @JsonProperty("trial_expiry_plan_price_id") + public Optional getTrialExpiryPlanPriceId() { + return trialExpiryPlanPriceId; + } + @JsonProperty("trial_payment_method_required") public Optional getTrialPaymentMethodRequired() { return trialPaymentMethodRequired; @@ -96,22 +222,50 @@ public Map getAdditionalProperties() { } private boolean equalTo(PlanGroupResponseData other) { - return addOnIds.equals(other.addOnIds) + return addOnCompatibilities.equals(other.addOnCompatibilities) + && addOnIds.equals(other.addOnIds) + && checkoutSettings.equals(other.checkoutSettings) && defaultPlanId.equals(other.defaultPlanId) + && fallbackPlanId.equals(other.fallbackPlanId) && id.equals(other.id) + && initialPlanId.equals(other.initialPlanId) + && initialPlanPriceId.equals(other.initialPlanPriceId) + && orderedAddOnIds.equals(other.orderedAddOnIds) && planIds.equals(other.planIds) + && preventDowngradesWhenOverLimit == other.preventDowngradesWhenOverLimit + && showCredits == other.showCredits + && showPeriodToggle == other.showPeriodToggle + && showZeroPriceAsFree == other.showZeroPriceAsFree + && syncCustomerBillingDetailsForTax == other.syncCustomerBillingDetailsForTax + && taxCollectionEnabled == other.taxCollectionEnabled && trialDays.equals(other.trialDays) + && trialExpiryPlanId.equals(other.trialExpiryPlanId) + && trialExpiryPlanPriceId.equals(other.trialExpiryPlanPriceId) && trialPaymentMethodRequired.equals(other.trialPaymentMethodRequired); } @java.lang.Override public int hashCode() { return Objects.hash( + this.addOnCompatibilities, this.addOnIds, + this.checkoutSettings, this.defaultPlanId, + this.fallbackPlanId, this.id, + this.initialPlanId, + this.initialPlanPriceId, + this.orderedAddOnIds, this.planIds, + this.preventDowngradesWhenOverLimit, + this.showCredits, + this.showPeriodToggle, + this.showZeroPriceAsFree, + this.syncCustomerBillingDetailsForTax, + this.taxCollectionEnabled, this.trialDays, + this.trialExpiryPlanId, + this.trialExpiryPlanPriceId, this.trialPaymentMethodRequired); } @@ -120,19 +274,53 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static CheckoutSettingsStage builder() { return new Builder(); } - public interface IdStage { - _FinalStage id(@NotNull String id); + public interface CheckoutSettingsStage { + IdStage checkoutSettings(@NotNull CheckoutSettingsResponseData checkoutSettings); Builder from(PlanGroupResponseData other); } + public interface IdStage { + PreventDowngradesWhenOverLimitStage id(@NotNull String id); + } + + public interface PreventDowngradesWhenOverLimitStage { + ShowCreditsStage preventDowngradesWhenOverLimit(boolean preventDowngradesWhenOverLimit); + } + + public interface ShowCreditsStage { + ShowPeriodToggleStage showCredits(boolean showCredits); + } + + public interface ShowPeriodToggleStage { + ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle); + } + + public interface ShowZeroPriceAsFreeStage { + SyncCustomerBillingDetailsForTaxStage showZeroPriceAsFree(boolean showZeroPriceAsFree); + } + + public interface SyncCustomerBillingDetailsForTaxStage { + TaxCollectionEnabledStage syncCustomerBillingDetailsForTax(boolean syncCustomerBillingDetailsForTax); + } + + public interface TaxCollectionEnabledStage { + _FinalStage taxCollectionEnabled(boolean taxCollectionEnabled); + } + public interface _FinalStage { PlanGroupResponseData build(); + _FinalStage addOnCompatibilities(List addOnCompatibilities); + + _FinalStage addAddOnCompatibilities(CompatiblePlansResponseData addOnCompatibilities); + + _FinalStage addAllAddOnCompatibilities(List addOnCompatibilities); + _FinalStage addOnIds(List addOnIds); _FinalStage addAddOnIds(String addOnIds); @@ -143,6 +331,24 @@ public interface _FinalStage { _FinalStage defaultPlanId(String defaultPlanId); + _FinalStage fallbackPlanId(Optional fallbackPlanId); + + _FinalStage fallbackPlanId(String fallbackPlanId); + + _FinalStage initialPlanId(Optional initialPlanId); + + _FinalStage initialPlanId(String initialPlanId); + + _FinalStage initialPlanPriceId(Optional initialPlanPriceId); + + _FinalStage initialPlanPriceId(String initialPlanPriceId); + + _FinalStage orderedAddOnIds(List orderedAddOnIds); + + _FinalStage addOrderedAddOnIds(OrderedPlansInGroup orderedAddOnIds); + + _FinalStage addAllOrderedAddOnIds(List orderedAddOnIds); + _FinalStage planIds(List planIds); _FinalStage addPlanIds(OrderedPlansInGroup planIds); @@ -153,25 +359,70 @@ public interface _FinalStage { _FinalStage trialDays(Integer trialDays); + _FinalStage trialExpiryPlanId(Optional trialExpiryPlanId); + + _FinalStage trialExpiryPlanId(String trialExpiryPlanId); + + _FinalStage trialExpiryPlanPriceId(Optional trialExpiryPlanPriceId); + + _FinalStage trialExpiryPlanPriceId(String trialExpiryPlanPriceId); + _FinalStage trialPaymentMethodRequired(Optional trialPaymentMethodRequired); _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, _FinalStage { + public static final class Builder + implements CheckoutSettingsStage, + IdStage, + PreventDowngradesWhenOverLimitStage, + ShowCreditsStage, + ShowPeriodToggleStage, + ShowZeroPriceAsFreeStage, + SyncCustomerBillingDetailsForTaxStage, + TaxCollectionEnabledStage, + _FinalStage { + private CheckoutSettingsResponseData checkoutSettings; + private String id; + private boolean preventDowngradesWhenOverLimit; + + private boolean showCredits; + + private boolean showPeriodToggle; + + private boolean showZeroPriceAsFree; + + private boolean syncCustomerBillingDetailsForTax; + + private boolean taxCollectionEnabled; + private Optional trialPaymentMethodRequired = Optional.empty(); + private Optional trialExpiryPlanPriceId = Optional.empty(); + + private Optional trialExpiryPlanId = Optional.empty(); + private Optional trialDays = Optional.empty(); private List planIds = new ArrayList<>(); + private List orderedAddOnIds = new ArrayList<>(); + + private Optional initialPlanPriceId = Optional.empty(); + + private Optional initialPlanId = Optional.empty(); + + private Optional fallbackPlanId = Optional.empty(); + private Optional defaultPlanId = Optional.empty(); private List addOnIds = new ArrayList<>(); + private List addOnCompatibilities = new ArrayList<>(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -179,22 +430,85 @@ private Builder() {} @java.lang.Override public Builder from(PlanGroupResponseData other) { + addOnCompatibilities(other.getAddOnCompatibilities()); addOnIds(other.getAddOnIds()); + checkoutSettings(other.getCheckoutSettings()); defaultPlanId(other.getDefaultPlanId()); + fallbackPlanId(other.getFallbackPlanId()); id(other.getId()); + initialPlanId(other.getInitialPlanId()); + initialPlanPriceId(other.getInitialPlanPriceId()); + orderedAddOnIds(other.getOrderedAddOnIds()); planIds(other.getPlanIds()); + preventDowngradesWhenOverLimit(other.getPreventDowngradesWhenOverLimit()); + showCredits(other.getShowCredits()); + showPeriodToggle(other.getShowPeriodToggle()); + showZeroPriceAsFree(other.getShowZeroPriceAsFree()); + syncCustomerBillingDetailsForTax(other.getSyncCustomerBillingDetailsForTax()); + taxCollectionEnabled(other.getTaxCollectionEnabled()); trialDays(other.getTrialDays()); + trialExpiryPlanId(other.getTrialExpiryPlanId()); + trialExpiryPlanPriceId(other.getTrialExpiryPlanPriceId()); trialPaymentMethodRequired(other.getTrialPaymentMethodRequired()); return this; } + @java.lang.Override + @JsonSetter("checkout_settings") + public IdStage checkoutSettings(@NotNull CheckoutSettingsResponseData checkoutSettings) { + this.checkoutSettings = Objects.requireNonNull(checkoutSettings, "checkoutSettings must not be null"); + return this; + } + @java.lang.Override @JsonSetter("id") - public _FinalStage id(@NotNull String id) { + public PreventDowngradesWhenOverLimitStage id(@NotNull String id) { this.id = Objects.requireNonNull(id, "id must not be null"); return this; } + @java.lang.Override + @JsonSetter("prevent_downgrades_when_over_limit") + public ShowCreditsStage preventDowngradesWhenOverLimit(boolean preventDowngradesWhenOverLimit) { + this.preventDowngradesWhenOverLimit = preventDowngradesWhenOverLimit; + return this; + } + + @java.lang.Override + @JsonSetter("show_credits") + public ShowPeriodToggleStage showCredits(boolean showCredits) { + this.showCredits = showCredits; + return this; + } + + @java.lang.Override + @JsonSetter("show_period_toggle") + public ShowZeroPriceAsFreeStage showPeriodToggle(boolean showPeriodToggle) { + this.showPeriodToggle = showPeriodToggle; + return this; + } + + @java.lang.Override + @JsonSetter("show_zero_price_as_free") + public SyncCustomerBillingDetailsForTaxStage showZeroPriceAsFree(boolean showZeroPriceAsFree) { + this.showZeroPriceAsFree = showZeroPriceAsFree; + return this; + } + + @java.lang.Override + @JsonSetter("sync_customer_billing_details_for_tax") + public TaxCollectionEnabledStage syncCustomerBillingDetailsForTax(boolean syncCustomerBillingDetailsForTax) { + this.syncCustomerBillingDetailsForTax = syncCustomerBillingDetailsForTax; + return this; + } + + @java.lang.Override + @JsonSetter("tax_collection_enabled") + public _FinalStage taxCollectionEnabled(boolean taxCollectionEnabled) { + this.taxCollectionEnabled = taxCollectionEnabled; + return this; + } + @java.lang.Override public _FinalStage trialPaymentMethodRequired(Boolean trialPaymentMethodRequired) { this.trialPaymentMethodRequired = Optional.ofNullable(trialPaymentMethodRequired); @@ -208,6 +522,32 @@ public _FinalStage trialPaymentMethodRequired(Optional trialPaymentMeth return this; } + @java.lang.Override + public _FinalStage trialExpiryPlanPriceId(String trialExpiryPlanPriceId) { + this.trialExpiryPlanPriceId = Optional.ofNullable(trialExpiryPlanPriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanPriceId(Optional trialExpiryPlanPriceId) { + this.trialExpiryPlanPriceId = trialExpiryPlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage trialExpiryPlanId(String trialExpiryPlanId) { + this.trialExpiryPlanId = Optional.ofNullable(trialExpiryPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_expiry_plan_id", nulls = Nulls.SKIP) + public _FinalStage trialExpiryPlanId(Optional trialExpiryPlanId) { + this.trialExpiryPlanId = trialExpiryPlanId; + return this; + } + @java.lang.Override public _FinalStage trialDays(Integer trialDays) { this.trialDays = Optional.ofNullable(trialDays); @@ -223,7 +563,9 @@ public _FinalStage trialDays(Optional trialDays) { @java.lang.Override public _FinalStage addAllPlanIds(List planIds) { - this.planIds.addAll(planIds); + if (planIds != null) { + this.planIds.addAll(planIds); + } return this; } @@ -237,7 +579,72 @@ public _FinalStage addPlanIds(OrderedPlansInGroup planIds) { @JsonSetter(value = "plan_ids", nulls = Nulls.SKIP) public _FinalStage planIds(List planIds) { this.planIds.clear(); - this.planIds.addAll(planIds); + if (planIds != null) { + this.planIds.addAll(planIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllOrderedAddOnIds(List orderedAddOnIds) { + if (orderedAddOnIds != null) { + this.orderedAddOnIds.addAll(orderedAddOnIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addOrderedAddOnIds(OrderedPlansInGroup orderedAddOnIds) { + this.orderedAddOnIds.add(orderedAddOnIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ordered_add_on_ids", nulls = Nulls.SKIP) + public _FinalStage orderedAddOnIds(List orderedAddOnIds) { + this.orderedAddOnIds.clear(); + if (orderedAddOnIds != null) { + this.orderedAddOnIds.addAll(orderedAddOnIds); + } + return this; + } + + @java.lang.Override + public _FinalStage initialPlanPriceId(String initialPlanPriceId) { + this.initialPlanPriceId = Optional.ofNullable(initialPlanPriceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_price_id", nulls = Nulls.SKIP) + public _FinalStage initialPlanPriceId(Optional initialPlanPriceId) { + this.initialPlanPriceId = initialPlanPriceId; + return this; + } + + @java.lang.Override + public _FinalStage initialPlanId(String initialPlanId) { + this.initialPlanId = Optional.ofNullable(initialPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "initial_plan_id", nulls = Nulls.SKIP) + public _FinalStage initialPlanId(Optional initialPlanId) { + this.initialPlanId = initialPlanId; + return this; + } + + @java.lang.Override + public _FinalStage fallbackPlanId(String fallbackPlanId) { + this.fallbackPlanId = Optional.ofNullable(fallbackPlanId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "fallback_plan_id", nulls = Nulls.SKIP) + public _FinalStage fallbackPlanId(Optional fallbackPlanId) { + this.fallbackPlanId = fallbackPlanId; return this; } @@ -256,7 +663,9 @@ public _FinalStage defaultPlanId(Optional defaultPlanId) { @java.lang.Override public _FinalStage addAllAddOnIds(List addOnIds) { - this.addOnIds.addAll(addOnIds); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } return this; } @@ -270,14 +679,60 @@ public _FinalStage addAddOnIds(String addOnIds) { @JsonSetter(value = "add_on_ids", nulls = Nulls.SKIP) public _FinalStage addOnIds(List addOnIds) { this.addOnIds.clear(); - this.addOnIds.addAll(addOnIds); + if (addOnIds != null) { + this.addOnIds.addAll(addOnIds); + } + return this; + } + + @java.lang.Override + public _FinalStage addAllAddOnCompatibilities(List addOnCompatibilities) { + if (addOnCompatibilities != null) { + this.addOnCompatibilities.addAll(addOnCompatibilities); + } + return this; + } + + @java.lang.Override + public _FinalStage addAddOnCompatibilities(CompatiblePlansResponseData addOnCompatibilities) { + this.addOnCompatibilities.add(addOnCompatibilities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "add_on_compatibilities", nulls = Nulls.SKIP) + public _FinalStage addOnCompatibilities(List addOnCompatibilities) { + this.addOnCompatibilities.clear(); + if (addOnCompatibilities != null) { + this.addOnCompatibilities.addAll(addOnCompatibilities); + } return this; } @java.lang.Override public PlanGroupResponseData build() { return new PlanGroupResponseData( - addOnIds, defaultPlanId, id, planIds, trialDays, trialPaymentMethodRequired, additionalProperties); + addOnCompatibilities, + addOnIds, + checkoutSettings, + defaultPlanId, + fallbackPlanId, + id, + initialPlanId, + initialPlanPriceId, + orderedAddOnIds, + planIds, + preventDowngradesWhenOverLimit, + showCredits, + showPeriodToggle, + showZeroPriceAsFree, + syncCustomerBillingDetailsForTax, + taxCollectionEnabled, + trialDays, + trialExpiryPlanId, + trialExpiryPlanPriceId, + trialPaymentMethodRequired, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/PlanIssueResponseData.java b/src/main/java/com/schematic/api/types/PlanIssueResponseData.java new file mode 100644 index 0000000..bc30d5b --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanIssueResponseData.java @@ -0,0 +1,190 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PlanIssueResponseData.Builder.class) +public final class PlanIssueResponseData { + private final String code; + + private final String description; + + private final Optional detail; + + private final Optional id; + + private final Map additionalProperties; + + private PlanIssueResponseData( + String code, + String description, + Optional detail, + Optional id, + Map additionalProperties) { + this.code = code; + this.description = description; + this.detail = detail; + this.id = id; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("code") + public String getCode() { + return code; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("detail") + public Optional getDetail() { + return detail; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PlanIssueResponseData && equalTo((PlanIssueResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PlanIssueResponseData other) { + return code.equals(other.code) + && description.equals(other.description) + && detail.equals(other.detail) + && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.code, this.description, this.detail, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CodeStage builder() { + return new Builder(); + } + + public interface CodeStage { + DescriptionStage code(@NotNull String code); + + Builder from(PlanIssueResponseData other); + } + + public interface DescriptionStage { + _FinalStage description(@NotNull String description); + } + + public interface _FinalStage { + PlanIssueResponseData build(); + + _FinalStage detail(Optional detail); + + _FinalStage detail(String detail); + + _FinalStage id(Optional id); + + _FinalStage id(String id); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CodeStage, DescriptionStage, _FinalStage { + private String code; + + private String description; + + private Optional id = Optional.empty(); + + private Optional detail = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PlanIssueResponseData other) { + code(other.getCode()); + description(other.getDescription()); + detail(other.getDetail()); + id(other.getId()); + return this; + } + + @java.lang.Override + @JsonSetter("code") + public DescriptionStage code(@NotNull String code) { + this.code = Objects.requireNonNull(code, "code must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("description") + public _FinalStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @java.lang.Override + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public _FinalStage id(Optional id) { + this.id = id; + return this; + } + + @java.lang.Override + public _FinalStage detail(String detail) { + this.detail = Optional.ofNullable(detail); + return this; + } + + @java.lang.Override + @JsonSetter(value = "detail", nulls = Nulls.SKIP) + public _FinalStage detail(Optional detail) { + this.detail = detail; + return this; + } + + @java.lang.Override + public PlanIssueResponseData build() { + return new PlanIssueResponseData(code, description, detail, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PlanSelection.java b/src/main/java/com/schematic/api/types/PlanSelection.java new file mode 100644 index 0000000..47b691b --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanSelection.java @@ -0,0 +1,132 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PlanSelection.Builder.class) +public final class PlanSelection { + private final String planId; + + private final Optional priceId; + + private final Map additionalProperties; + + private PlanSelection(String planId, Optional priceId, Map additionalProperties) { + this.planId = planId; + this.priceId = priceId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @JsonProperty("price_id") + public Optional getPriceId() { + return priceId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PlanSelection && equalTo((PlanSelection) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PlanSelection other) { + return planId.equals(other.planId) && priceId.equals(other.priceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.planId, this.priceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PlanIdStage builder() { + return new Builder(); + } + + public interface PlanIdStage { + _FinalStage planId(@NotNull String planId); + + Builder from(PlanSelection other); + } + + public interface _FinalStage { + PlanSelection build(); + + _FinalStage priceId(Optional priceId); + + _FinalStage priceId(String priceId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PlanIdStage, _FinalStage { + private String planId; + + private Optional priceId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PlanSelection other) { + planId(other.getPlanId()); + priceId(other.getPriceId()); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public _FinalStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage priceId(String priceId) { + this.priceId = Optional.ofNullable(priceId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "price_id", nulls = Nulls.SKIP) + public _FinalStage priceId(Optional priceId) { + this.priceId = priceId; + return this; + } + + @java.lang.Override + public PlanSelection build() { + return new PlanSelection(planId, priceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PlanSnapshotView.java b/src/main/java/com/schematic/api/types/PlanSnapshotView.java new file mode 100644 index 0000000..4ddddb6 --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanSnapshotView.java @@ -0,0 +1,201 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PlanSnapshotView.Builder.class) +public final class PlanSnapshotView { + private final boolean deleted; + + private final String description; + + private final String icon; + + private final String id; + + private final String name; + + private final Map additionalProperties; + + private PlanSnapshotView( + boolean deleted, + String description, + String icon, + String id, + String name, + Map additionalProperties) { + this.deleted = deleted; + this.description = description; + this.icon = icon; + this.id = id; + this.name = name; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("deleted") + public boolean getDeleted() { + return deleted; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("icon") + public String getIcon() { + return icon; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PlanSnapshotView && equalTo((PlanSnapshotView) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PlanSnapshotView other) { + return deleted == other.deleted + && description.equals(other.description) + && icon.equals(other.icon) + && id.equals(other.id) + && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.deleted, this.description, this.icon, this.id, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DeletedStage builder() { + return new Builder(); + } + + public interface DeletedStage { + DescriptionStage deleted(boolean deleted); + + Builder from(PlanSnapshotView other); + } + + public interface DescriptionStage { + IconStage description(@NotNull String description); + } + + public interface IconStage { + IdStage icon(@NotNull String icon); + } + + public interface IdStage { + NameStage id(@NotNull String id); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + PlanSnapshotView build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements DeletedStage, DescriptionStage, IconStage, IdStage, NameStage, _FinalStage { + private boolean deleted; + + private String description; + + private String icon; + + private String id; + + private String name; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PlanSnapshotView other) { + deleted(other.getDeleted()); + description(other.getDescription()); + icon(other.getIcon()); + id(other.getId()); + name(other.getName()); + return this; + } + + @java.lang.Override + @JsonSetter("deleted") + public DescriptionStage deleted(boolean deleted) { + this.deleted = deleted; + return this; + } + + @java.lang.Override + @JsonSetter("description") + public IconStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("icon") + public IdStage icon(@NotNull String icon) { + this.icon = Objects.requireNonNull(icon, "icon must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public NameStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + @java.lang.Override + public PlanSnapshotView build() { + return new PlanSnapshotView(deleted, description, icon, id, name, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PlanTraitResponseData.java b/src/main/java/com/schematic/api/types/PlanTraitResponseData.java new file mode 100644 index 0000000..f7e554c --- /dev/null +++ b/src/main/java/com/schematic/api/types/PlanTraitResponseData.java @@ -0,0 +1,326 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PlanTraitResponseData.Builder.class) +public final class PlanTraitResponseData { + private final String accountId; + + private final OffsetDateTime createdAt; + + private final String environmentId; + + private final String id; + + private final String planId; + + private final String planType; + + private final String traitId; + + private final String traitValue; + + private final OffsetDateTime updatedAt; + + private final Map additionalProperties; + + private PlanTraitResponseData( + String accountId, + OffsetDateTime createdAt, + String environmentId, + String id, + String planId, + String planType, + String traitId, + String traitValue, + OffsetDateTime updatedAt, + Map additionalProperties) { + this.accountId = accountId; + this.createdAt = createdAt; + this.environmentId = environmentId; + this.id = id; + this.planId = planId; + this.planType = planType; + this.traitId = traitId; + this.traitValue = traitValue; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("account_id") + public String getAccountId() { + return accountId; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @JsonProperty("environment_id") + public String getEnvironmentId() { + return environmentId; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("plan_id") + public String getPlanId() { + return planId; + } + + @JsonProperty("plan_type") + public String getPlanType() { + return planType; + } + + @JsonProperty("trait_id") + public String getTraitId() { + return traitId; + } + + @JsonProperty("trait_value") + public String getTraitValue() { + return traitValue; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PlanTraitResponseData && equalTo((PlanTraitResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PlanTraitResponseData other) { + return accountId.equals(other.accountId) + && createdAt.equals(other.createdAt) + && environmentId.equals(other.environmentId) + && id.equals(other.id) + && planId.equals(other.planId) + && planType.equals(other.planType) + && traitId.equals(other.traitId) + && traitValue.equals(other.traitValue) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.accountId, + this.createdAt, + this.environmentId, + this.id, + this.planId, + this.planType, + this.traitId, + this.traitValue, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AccountIdStage builder() { + return new Builder(); + } + + public interface AccountIdStage { + CreatedAtStage accountId(@NotNull String accountId); + + Builder from(PlanTraitResponseData other); + } + + public interface CreatedAtStage { + EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface EnvironmentIdStage { + IdStage environmentId(@NotNull String environmentId); + } + + public interface IdStage { + PlanIdStage id(@NotNull String id); + } + + public interface PlanIdStage { + PlanTypeStage planId(@NotNull String planId); + } + + public interface PlanTypeStage { + TraitIdStage planType(@NotNull String planType); + } + + public interface TraitIdStage { + TraitValueStage traitId(@NotNull String traitId); + } + + public interface TraitValueStage { + UpdatedAtStage traitValue(@NotNull String traitValue); + } + + public interface UpdatedAtStage { + _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface _FinalStage { + PlanTraitResponseData build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AccountIdStage, + CreatedAtStage, + EnvironmentIdStage, + IdStage, + PlanIdStage, + PlanTypeStage, + TraitIdStage, + TraitValueStage, + UpdatedAtStage, + _FinalStage { + private String accountId; + + private OffsetDateTime createdAt; + + private String environmentId; + + private String id; + + private String planId; + + private String planType; + + private String traitId; + + private String traitValue; + + private OffsetDateTime updatedAt; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PlanTraitResponseData other) { + accountId(other.getAccountId()); + createdAt(other.getCreatedAt()); + environmentId(other.getEnvironmentId()); + id(other.getId()); + planId(other.getPlanId()); + planType(other.getPlanType()); + traitId(other.getTraitId()); + traitValue(other.getTraitValue()); + updatedAt(other.getUpdatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("account_id") + public CreatedAtStage accountId(@NotNull String accountId) { + this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("environment_id") + public IdStage environmentId(@NotNull String environmentId) { + this.environmentId = Objects.requireNonNull(environmentId, "environmentId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public PlanIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("plan_id") + public PlanTypeStage planId(@NotNull String planId) { + this.planId = Objects.requireNonNull(planId, "planId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("plan_type") + public TraitIdStage planType(@NotNull String planType) { + this.planType = Objects.requireNonNull(planType, "planType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_id") + public TraitValueStage traitId(@NotNull String traitId) { + this.traitId = Objects.requireNonNull(traitId, "traitId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_value") + public UpdatedAtStage traitValue(@NotNull String traitValue) { + this.traitValue = Objects.requireNonNull(traitValue, "traitValue must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + public PlanTraitResponseData build() { + return new PlanTraitResponseData( + accountId, + createdAt, + environmentId, + id, + planId, + planType, + traitId, + traitValue, + updatedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PreviewSubscriptionChangeResponseData.java b/src/main/java/com/schematic/api/types/PreviewSubscriptionChangeResponseData.java index 7e87310..66a4ba6 100644 --- a/src/main/java/com/schematic/api/types/PreviewSubscriptionChangeResponseData.java +++ b/src/main/java/com/schematic/api/types/PreviewSubscriptionChangeResponseData.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -26,8 +28,12 @@ public final class PreviewSubscriptionChangeResponseData { private final int dueNow; + private final Optional finance; + private final int newCharges; + private final boolean paymentMethodRequired; + private final double percentOff; private final OffsetDateTime periodStart; @@ -38,26 +44,34 @@ public final class PreviewSubscriptionChangeResponseData { private final Optional trialEnd; + private final List usageViolations; + private final Map additionalProperties; private PreviewSubscriptionChangeResponseData( int amountOff, int dueNow, + Optional finance, int newCharges, + boolean paymentMethodRequired, double percentOff, OffsetDateTime periodStart, boolean promoCodeApplied, int proration, Optional trialEnd, + List usageViolations, Map additionalProperties) { this.amountOff = amountOff; this.dueNow = dueNow; + this.finance = finance; this.newCharges = newCharges; + this.paymentMethodRequired = paymentMethodRequired; this.percentOff = percentOff; this.periodStart = periodStart; this.promoCodeApplied = promoCodeApplied; this.proration = proration; this.trialEnd = trialEnd; + this.usageViolations = usageViolations; this.additionalProperties = additionalProperties; } @@ -71,11 +85,21 @@ public int getDueNow() { return dueNow; } + @JsonProperty("finance") + public Optional getFinance() { + return finance; + } + @JsonProperty("new_charges") public int getNewCharges() { return newCharges; } + @JsonProperty("payment_method_required") + public boolean getPaymentMethodRequired() { + return paymentMethodRequired; + } + @JsonProperty("percent_off") public double getPercentOff() { return percentOff; @@ -101,6 +125,11 @@ public Optional getTrialEnd() { return trialEnd; } + @JsonProperty("usage_violations") + public List getUsageViolations() { + return usageViolations; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -116,12 +145,15 @@ public Map getAdditionalProperties() { private boolean equalTo(PreviewSubscriptionChangeResponseData other) { return amountOff == other.amountOff && dueNow == other.dueNow + && finance.equals(other.finance) && newCharges == other.newCharges + && paymentMethodRequired == other.paymentMethodRequired && percentOff == other.percentOff && periodStart.equals(other.periodStart) && promoCodeApplied == other.promoCodeApplied && proration == other.proration - && trialEnd.equals(other.trialEnd); + && trialEnd.equals(other.trialEnd) + && usageViolations.equals(other.usageViolations); } @java.lang.Override @@ -129,12 +161,15 @@ public int hashCode() { return Objects.hash( this.amountOff, this.dueNow, + this.finance, this.newCharges, + this.paymentMethodRequired, this.percentOff, this.periodStart, this.promoCodeApplied, this.proration, - this.trialEnd); + this.trialEnd, + this.usageViolations); } @java.lang.Override @@ -157,7 +192,11 @@ public interface DueNowStage { } public interface NewChargesStage { - PercentOffStage newCharges(int newCharges); + PaymentMethodRequiredStage newCharges(int newCharges); + } + + public interface PaymentMethodRequiredStage { + PercentOffStage paymentMethodRequired(boolean paymentMethodRequired); } public interface PercentOffStage { @@ -179,9 +218,19 @@ public interface ProrationStage { public interface _FinalStage { PreviewSubscriptionChangeResponseData build(); + _FinalStage finance(Optional finance); + + _FinalStage finance(PreviewSubscriptionFinanceResponseData finance); + _FinalStage trialEnd(Optional trialEnd); _FinalStage trialEnd(OffsetDateTime trialEnd); + + _FinalStage usageViolations(List usageViolations); + + _FinalStage addUsageViolations(FeatureUsageResponseData usageViolations); + + _FinalStage addAllUsageViolations(List usageViolations); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -189,6 +238,7 @@ public static final class Builder implements AmountOffStage, DueNowStage, NewChargesStage, + PaymentMethodRequiredStage, PercentOffStage, PeriodStartStage, PromoCodeAppliedStage, @@ -200,6 +250,8 @@ public static final class Builder private int newCharges; + private boolean paymentMethodRequired; + private double percentOff; private OffsetDateTime periodStart; @@ -208,8 +260,12 @@ public static final class Builder private int proration; + private List usageViolations = new ArrayList<>(); + private Optional trialEnd = Optional.empty(); + private Optional finance = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -219,12 +275,15 @@ private Builder() {} public Builder from(PreviewSubscriptionChangeResponseData other) { amountOff(other.getAmountOff()); dueNow(other.getDueNow()); + finance(other.getFinance()); newCharges(other.getNewCharges()); + paymentMethodRequired(other.getPaymentMethodRequired()); percentOff(other.getPercentOff()); periodStart(other.getPeriodStart()); promoCodeApplied(other.getPromoCodeApplied()); proration(other.getProration()); trialEnd(other.getTrialEnd()); + usageViolations(other.getUsageViolations()); return this; } @@ -244,11 +303,18 @@ public NewChargesStage dueNow(int dueNow) { @java.lang.Override @JsonSetter("new_charges") - public PercentOffStage newCharges(int newCharges) { + public PaymentMethodRequiredStage newCharges(int newCharges) { this.newCharges = newCharges; return this; } + @java.lang.Override + @JsonSetter("payment_method_required") + public PercentOffStage paymentMethodRequired(boolean paymentMethodRequired) { + this.paymentMethodRequired = paymentMethodRequired; + return this; + } + @java.lang.Override @JsonSetter("percent_off") public PeriodStartStage percentOff(double percentOff) { @@ -277,6 +343,30 @@ public _FinalStage proration(int proration) { return this; } + @java.lang.Override + public _FinalStage addAllUsageViolations(List usageViolations) { + if (usageViolations != null) { + this.usageViolations.addAll(usageViolations); + } + return this; + } + + @java.lang.Override + public _FinalStage addUsageViolations(FeatureUsageResponseData usageViolations) { + this.usageViolations.add(usageViolations); + return this; + } + + @java.lang.Override + @JsonSetter(value = "usage_violations", nulls = Nulls.SKIP) + public _FinalStage usageViolations(List usageViolations) { + this.usageViolations.clear(); + if (usageViolations != null) { + this.usageViolations.addAll(usageViolations); + } + return this; + } + @java.lang.Override public _FinalStage trialEnd(OffsetDateTime trialEnd) { this.trialEnd = Optional.ofNullable(trialEnd); @@ -290,17 +380,33 @@ public _FinalStage trialEnd(Optional trialEnd) { return this; } + @java.lang.Override + public _FinalStage finance(PreviewSubscriptionFinanceResponseData finance) { + this.finance = Optional.ofNullable(finance); + return this; + } + + @java.lang.Override + @JsonSetter(value = "finance", nulls = Nulls.SKIP) + public _FinalStage finance(Optional finance) { + this.finance = finance; + return this; + } + @java.lang.Override public PreviewSubscriptionChangeResponseData build() { return new PreviewSubscriptionChangeResponseData( amountOff, dueNow, + finance, newCharges, + paymentMethodRequired, percentOff, periodStart, promoCodeApplied, proration, trialEnd, + usageViolations, additionalProperties); } } diff --git a/src/main/java/com/schematic/api/types/PreviewSubscriptionFinanceResponseData.java b/src/main/java/com/schematic/api/types/PreviewSubscriptionFinanceResponseData.java new file mode 100644 index 0000000..eaeb24b --- /dev/null +++ b/src/main/java/com/schematic/api/types/PreviewSubscriptionFinanceResponseData.java @@ -0,0 +1,450 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PreviewSubscriptionFinanceResponseData.Builder.class) +public final class PreviewSubscriptionFinanceResponseData { + private final int amountOff; + + private final int dueNow; + + private final int newCharges; + + private final double percentOff; + + private final OffsetDateTime periodStart; + + private final boolean promoCodeApplied; + + private final int proration; + + private final Optional taxAmount; + + private final Optional taxDisplayName; + + private final boolean taxRequireBillingDetails; + + private final Optional trialEnd; + + private final List upcomingInvoiceLineItems; + + private final Map additionalProperties; + + private PreviewSubscriptionFinanceResponseData( + int amountOff, + int dueNow, + int newCharges, + double percentOff, + OffsetDateTime periodStart, + boolean promoCodeApplied, + int proration, + Optional taxAmount, + Optional taxDisplayName, + boolean taxRequireBillingDetails, + Optional trialEnd, + List upcomingInvoiceLineItems, + Map additionalProperties) { + this.amountOff = amountOff; + this.dueNow = dueNow; + this.newCharges = newCharges; + this.percentOff = percentOff; + this.periodStart = periodStart; + this.promoCodeApplied = promoCodeApplied; + this.proration = proration; + this.taxAmount = taxAmount; + this.taxDisplayName = taxDisplayName; + this.taxRequireBillingDetails = taxRequireBillingDetails; + this.trialEnd = trialEnd; + this.upcomingInvoiceLineItems = upcomingInvoiceLineItems; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("amount_off") + public int getAmountOff() { + return amountOff; + } + + @JsonProperty("due_now") + public int getDueNow() { + return dueNow; + } + + @JsonProperty("new_charges") + public int getNewCharges() { + return newCharges; + } + + @JsonProperty("percent_off") + public double getPercentOff() { + return percentOff; + } + + @JsonProperty("period_start") + public OffsetDateTime getPeriodStart() { + return periodStart; + } + + @JsonProperty("promo_code_applied") + public boolean getPromoCodeApplied() { + return promoCodeApplied; + } + + @JsonProperty("proration") + public int getProration() { + return proration; + } + + @JsonProperty("tax_amount") + public Optional getTaxAmount() { + return taxAmount; + } + + @JsonProperty("tax_display_name") + public Optional getTaxDisplayName() { + return taxDisplayName; + } + + @JsonProperty("tax_require_billing_details") + public boolean getTaxRequireBillingDetails() { + return taxRequireBillingDetails; + } + + @JsonProperty("trial_end") + public Optional getTrialEnd() { + return trialEnd; + } + + @JsonProperty("upcoming_invoice_line_items") + public List getUpcomingInvoiceLineItems() { + return upcomingInvoiceLineItems; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PreviewSubscriptionFinanceResponseData + && equalTo((PreviewSubscriptionFinanceResponseData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PreviewSubscriptionFinanceResponseData other) { + return amountOff == other.amountOff + && dueNow == other.dueNow + && newCharges == other.newCharges + && percentOff == other.percentOff + && periodStart.equals(other.periodStart) + && promoCodeApplied == other.promoCodeApplied + && proration == other.proration + && taxAmount.equals(other.taxAmount) + && taxDisplayName.equals(other.taxDisplayName) + && taxRequireBillingDetails == other.taxRequireBillingDetails + && trialEnd.equals(other.trialEnd) + && upcomingInvoiceLineItems.equals(other.upcomingInvoiceLineItems); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.amountOff, + this.dueNow, + this.newCharges, + this.percentOff, + this.periodStart, + this.promoCodeApplied, + this.proration, + this.taxAmount, + this.taxDisplayName, + this.taxRequireBillingDetails, + this.trialEnd, + this.upcomingInvoiceLineItems); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AmountOffStage builder() { + return new Builder(); + } + + public interface AmountOffStage { + DueNowStage amountOff(int amountOff); + + Builder from(PreviewSubscriptionFinanceResponseData other); + } + + public interface DueNowStage { + NewChargesStage dueNow(int dueNow); + } + + public interface NewChargesStage { + PercentOffStage newCharges(int newCharges); + } + + public interface PercentOffStage { + PeriodStartStage percentOff(double percentOff); + } + + public interface PeriodStartStage { + PromoCodeAppliedStage periodStart(@NotNull OffsetDateTime periodStart); + } + + public interface PromoCodeAppliedStage { + ProrationStage promoCodeApplied(boolean promoCodeApplied); + } + + public interface ProrationStage { + TaxRequireBillingDetailsStage proration(int proration); + } + + public interface TaxRequireBillingDetailsStage { + _FinalStage taxRequireBillingDetails(boolean taxRequireBillingDetails); + } + + public interface _FinalStage { + PreviewSubscriptionFinanceResponseData build(); + + _FinalStage taxAmount(Optional taxAmount); + + _FinalStage taxAmount(Integer taxAmount); + + _FinalStage taxDisplayName(Optional taxDisplayName); + + _FinalStage taxDisplayName(String taxDisplayName); + + _FinalStage trialEnd(Optional trialEnd); + + _FinalStage trialEnd(OffsetDateTime trialEnd); + + _FinalStage upcomingInvoiceLineItems( + List upcomingInvoiceLineItems); + + _FinalStage addUpcomingInvoiceLineItems(PreviewSubscriptionUpcomingInvoiceLineItems upcomingInvoiceLineItems); + + _FinalStage addAllUpcomingInvoiceLineItems( + List upcomingInvoiceLineItems); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AmountOffStage, + DueNowStage, + NewChargesStage, + PercentOffStage, + PeriodStartStage, + PromoCodeAppliedStage, + ProrationStage, + TaxRequireBillingDetailsStage, + _FinalStage { + private int amountOff; + + private int dueNow; + + private int newCharges; + + private double percentOff; + + private OffsetDateTime periodStart; + + private boolean promoCodeApplied; + + private int proration; + + private boolean taxRequireBillingDetails; + + private List upcomingInvoiceLineItems = new ArrayList<>(); + + private Optional trialEnd = Optional.empty(); + + private Optional taxDisplayName = Optional.empty(); + + private Optional taxAmount = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PreviewSubscriptionFinanceResponseData other) { + amountOff(other.getAmountOff()); + dueNow(other.getDueNow()); + newCharges(other.getNewCharges()); + percentOff(other.getPercentOff()); + periodStart(other.getPeriodStart()); + promoCodeApplied(other.getPromoCodeApplied()); + proration(other.getProration()); + taxAmount(other.getTaxAmount()); + taxDisplayName(other.getTaxDisplayName()); + taxRequireBillingDetails(other.getTaxRequireBillingDetails()); + trialEnd(other.getTrialEnd()); + upcomingInvoiceLineItems(other.getUpcomingInvoiceLineItems()); + return this; + } + + @java.lang.Override + @JsonSetter("amount_off") + public DueNowStage amountOff(int amountOff) { + this.amountOff = amountOff; + return this; + } + + @java.lang.Override + @JsonSetter("due_now") + public NewChargesStage dueNow(int dueNow) { + this.dueNow = dueNow; + return this; + } + + @java.lang.Override + @JsonSetter("new_charges") + public PercentOffStage newCharges(int newCharges) { + this.newCharges = newCharges; + return this; + } + + @java.lang.Override + @JsonSetter("percent_off") + public PeriodStartStage percentOff(double percentOff) { + this.percentOff = percentOff; + return this; + } + + @java.lang.Override + @JsonSetter("period_start") + public PromoCodeAppliedStage periodStart(@NotNull OffsetDateTime periodStart) { + this.periodStart = Objects.requireNonNull(periodStart, "periodStart must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("promo_code_applied") + public ProrationStage promoCodeApplied(boolean promoCodeApplied) { + this.promoCodeApplied = promoCodeApplied; + return this; + } + + @java.lang.Override + @JsonSetter("proration") + public TaxRequireBillingDetailsStage proration(int proration) { + this.proration = proration; + return this; + } + + @java.lang.Override + @JsonSetter("tax_require_billing_details") + public _FinalStage taxRequireBillingDetails(boolean taxRequireBillingDetails) { + this.taxRequireBillingDetails = taxRequireBillingDetails; + return this; + } + + @java.lang.Override + public _FinalStage addAllUpcomingInvoiceLineItems( + List upcomingInvoiceLineItems) { + if (upcomingInvoiceLineItems != null) { + this.upcomingInvoiceLineItems.addAll(upcomingInvoiceLineItems); + } + return this; + } + + @java.lang.Override + public _FinalStage addUpcomingInvoiceLineItems( + PreviewSubscriptionUpcomingInvoiceLineItems upcomingInvoiceLineItems) { + this.upcomingInvoiceLineItems.add(upcomingInvoiceLineItems); + return this; + } + + @java.lang.Override + @JsonSetter(value = "upcoming_invoice_line_items", nulls = Nulls.SKIP) + public _FinalStage upcomingInvoiceLineItems( + List upcomingInvoiceLineItems) { + this.upcomingInvoiceLineItems.clear(); + if (upcomingInvoiceLineItems != null) { + this.upcomingInvoiceLineItems.addAll(upcomingInvoiceLineItems); + } + return this; + } + + @java.lang.Override + public _FinalStage trialEnd(OffsetDateTime trialEnd) { + this.trialEnd = Optional.ofNullable(trialEnd); + return this; + } + + @java.lang.Override + @JsonSetter(value = "trial_end", nulls = Nulls.SKIP) + public _FinalStage trialEnd(Optional trialEnd) { + this.trialEnd = trialEnd; + return this; + } + + @java.lang.Override + public _FinalStage taxDisplayName(String taxDisplayName) { + this.taxDisplayName = Optional.ofNullable(taxDisplayName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tax_display_name", nulls = Nulls.SKIP) + public _FinalStage taxDisplayName(Optional taxDisplayName) { + this.taxDisplayName = taxDisplayName; + return this; + } + + @java.lang.Override + public _FinalStage taxAmount(Integer taxAmount) { + this.taxAmount = Optional.ofNullable(taxAmount); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tax_amount", nulls = Nulls.SKIP) + public _FinalStage taxAmount(Optional taxAmount) { + this.taxAmount = taxAmount; + return this; + } + + @java.lang.Override + public PreviewSubscriptionFinanceResponseData build() { + return new PreviewSubscriptionFinanceResponseData( + amountOff, + dueNow, + newCharges, + percentOff, + periodStart, + promoCodeApplied, + proration, + taxAmount, + taxDisplayName, + taxRequireBillingDetails, + trialEnd, + upcomingInvoiceLineItems, + additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/PreviewSubscriptionUpcomingInvoiceLineItems.java b/src/main/java/com/schematic/api/types/PreviewSubscriptionUpcomingInvoiceLineItems.java new file mode 100644 index 0000000..561848b --- /dev/null +++ b/src/main/java/com/schematic/api/types/PreviewSubscriptionUpcomingInvoiceLineItems.java @@ -0,0 +1,203 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PreviewSubscriptionUpcomingInvoiceLineItems.Builder.class) +public final class PreviewSubscriptionUpcomingInvoiceLineItems { + private final int amount; + + private final String description; + + private final String priceId; + + private final boolean proration; + + private final int quantity; + + private final Map additionalProperties; + + private PreviewSubscriptionUpcomingInvoiceLineItems( + int amount, + String description, + String priceId, + boolean proration, + int quantity, + Map additionalProperties) { + this.amount = amount; + this.description = description; + this.priceId = priceId; + this.proration = proration; + this.quantity = quantity; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("amount") + public int getAmount() { + return amount; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("price_id") + public String getPriceId() { + return priceId; + } + + @JsonProperty("proration") + public boolean getProration() { + return proration; + } + + @JsonProperty("quantity") + public int getQuantity() { + return quantity; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PreviewSubscriptionUpcomingInvoiceLineItems + && equalTo((PreviewSubscriptionUpcomingInvoiceLineItems) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PreviewSubscriptionUpcomingInvoiceLineItems other) { + return amount == other.amount + && description.equals(other.description) + && priceId.equals(other.priceId) + && proration == other.proration + && quantity == other.quantity; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.amount, this.description, this.priceId, this.proration, this.quantity); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AmountStage builder() { + return new Builder(); + } + + public interface AmountStage { + DescriptionStage amount(int amount); + + Builder from(PreviewSubscriptionUpcomingInvoiceLineItems other); + } + + public interface DescriptionStage { + PriceIdStage description(@NotNull String description); + } + + public interface PriceIdStage { + ProrationStage priceId(@NotNull String priceId); + } + + public interface ProrationStage { + QuantityStage proration(boolean proration); + } + + public interface QuantityStage { + _FinalStage quantity(int quantity); + } + + public interface _FinalStage { + PreviewSubscriptionUpcomingInvoiceLineItems build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements AmountStage, DescriptionStage, PriceIdStage, ProrationStage, QuantityStage, _FinalStage { + private int amount; + + private String description; + + private String priceId; + + private boolean proration; + + private int quantity; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PreviewSubscriptionUpcomingInvoiceLineItems other) { + amount(other.getAmount()); + description(other.getDescription()); + priceId(other.getPriceId()); + proration(other.getProration()); + quantity(other.getQuantity()); + return this; + } + + @java.lang.Override + @JsonSetter("amount") + public DescriptionStage amount(int amount) { + this.amount = amount; + return this; + } + + @java.lang.Override + @JsonSetter("description") + public PriceIdStage description(@NotNull String description) { + this.description = Objects.requireNonNull(description, "description must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("price_id") + public ProrationStage priceId(@NotNull String priceId) { + this.priceId = Objects.requireNonNull(priceId, "priceId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("proration") + public QuantityStage proration(boolean proration) { + this.proration = proration; + return this; + } + + @java.lang.Override + @JsonSetter("quantity") + public _FinalStage quantity(int quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + public PreviewSubscriptionUpcomingInvoiceLineItems build() { + return new PreviewSubscriptionUpcomingInvoiceLineItems( + amount, description, priceId, proration, quantity, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/QuickstartResp.java b/src/main/java/com/schematic/api/types/QuickstartResp.java new file mode 100644 index 0000000..49ace77 --- /dev/null +++ b/src/main/java/com/schematic/api/types/QuickstartResp.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = QuickstartResp.Builder.class) +public final class QuickstartResp { + private final boolean ok; + + private final Map additionalProperties; + + private QuickstartResp(boolean ok, Map additionalProperties) { + this.ok = ok; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("ok") + public boolean getOk() { + return ok; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof QuickstartResp && equalTo((QuickstartResp) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(QuickstartResp other) { + return ok == other.ok; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ok); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static OkStage builder() { + return new Builder(); + } + + public interface OkStage { + _FinalStage ok(boolean ok); + + Builder from(QuickstartResp other); + } + + public interface _FinalStage { + QuickstartResp build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements OkStage, _FinalStage { + private boolean ok; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(QuickstartResp other) { + ok(other.getOk()); + return this; + } + + @java.lang.Override + @JsonSetter("ok") + public _FinalStage ok(boolean ok) { + this.ok = ok; + return this; + } + + @java.lang.Override + public QuickstartResp build() { + return new QuickstartResp(ok, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/RawEventBatchResponseData.java b/src/main/java/com/schematic/api/types/RawEventBatchResponseData.java index c7d8641..960a2d1 100644 --- a/src/main/java/com/schematic/api/types/RawEventBatchResponseData.java +++ b/src/main/java/com/schematic/api/types/RawEventBatchResponseData.java @@ -81,7 +81,9 @@ public Builder from(RawEventBatchResponseData other) { @JsonSetter(value = "events", nulls = Nulls.SKIP) public Builder events(List events) { this.events.clear(); - this.events.addAll(events); + if (events != null) { + this.events.addAll(events); + } return this; } @@ -91,7 +93,9 @@ public Builder addEvents(RawEventResponseData events) { } public Builder addAllEvents(List events) { - this.events.addAll(events); + if (events != null) { + this.events.addAll(events); + } return this; } diff --git a/src/main/java/com/schematic/api/types/PlanAudienceResponseData.java b/src/main/java/com/schematic/api/types/Rule.java similarity index 63% rename from src/main/java/com/schematic/api/types/PlanAudienceResponseData.java rename to src/main/java/com/schematic/api/types/Rule.java index d345528..9d8eeba 100644 --- a/src/main/java/com/schematic/api/types/PlanAudienceResponseData.java +++ b/src/main/java/com/schematic/api/types/Rule.java @@ -12,17 +12,22 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; -import java.time.OffsetDateTime; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = PlanAudienceResponseData.Builder.class) -public final class PlanAudienceResponseData { - private final OffsetDateTime createdAt; +@JsonDeserialize(builder = Rule.Builder.class) +public final class Rule { + private final String accountId; + + private final List conditionGroups; + + private final List conditions; private final String environmentId; @@ -32,46 +37,52 @@ public final class PlanAudienceResponseData { private final String name; - private final Optional planId; - private final int priority; private final String ruleType; - private final OffsetDateTime updatedAt; - private final boolean value; private final Map additionalProperties; - private PlanAudienceResponseData( - OffsetDateTime createdAt, + private Rule( + String accountId, + List conditionGroups, + List conditions, String environmentId, Optional flagId, String id, String name, - Optional planId, int priority, String ruleType, - OffsetDateTime updatedAt, boolean value, Map additionalProperties) { - this.createdAt = createdAt; + this.accountId = accountId; + this.conditionGroups = conditionGroups; + this.conditions = conditions; this.environmentId = environmentId; this.flagId = flagId; this.id = id; this.name = name; - this.planId = planId; this.priority = priority; this.ruleType = ruleType; - this.updatedAt = updatedAt; this.value = value; this.additionalProperties = additionalProperties; } - @JsonProperty("created_at") - public OffsetDateTime getCreatedAt() { - return createdAt; + @JsonProperty("account_id") + public String getAccountId() { + return accountId; + } + + @JsonProperty("condition_groups") + public List getConditionGroups() { + return conditionGroups; + } + + @JsonProperty("conditions") + public List getConditions() { + return conditions; } @JsonProperty("environment_id") @@ -94,11 +105,6 @@ public String getName() { return name; } - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - @JsonProperty("priority") public int getPriority() { return priority; @@ -109,11 +115,6 @@ public String getRuleType() { return ruleType; } - @JsonProperty("updated_at") - public OffsetDateTime getUpdatedAt() { - return updatedAt; - } - @JsonProperty("value") public boolean getValue() { return value; @@ -122,7 +123,7 @@ public boolean getValue() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof PlanAudienceResponseData && equalTo((PlanAudienceResponseData) other); + return other instanceof Rule && equalTo((Rule) other); } @JsonAnyGetter @@ -130,31 +131,31 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(PlanAudienceResponseData other) { - return createdAt.equals(other.createdAt) + private boolean equalTo(Rule other) { + return accountId.equals(other.accountId) + && conditionGroups.equals(other.conditionGroups) + && conditions.equals(other.conditions) && environmentId.equals(other.environmentId) && flagId.equals(other.flagId) && id.equals(other.id) && name.equals(other.name) - && planId.equals(other.planId) && priority == other.priority && ruleType.equals(other.ruleType) - && updatedAt.equals(other.updatedAt) && value == other.value; } @java.lang.Override public int hashCode() { return Objects.hash( - this.createdAt, + this.accountId, + this.conditionGroups, + this.conditions, this.environmentId, this.flagId, this.id, this.name, - this.planId, this.priority, this.ruleType, - this.updatedAt, this.value); } @@ -163,14 +164,14 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CreatedAtStage builder() { + public static AccountIdStage builder() { return new Builder(); } - public interface CreatedAtStage { - EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt); + public interface AccountIdStage { + EnvironmentIdStage accountId(@NotNull String accountId); - Builder from(PlanAudienceResponseData other); + Builder from(Rule other); } public interface EnvironmentIdStage { @@ -190,11 +191,7 @@ public interface PriorityStage { } public interface RuleTypeStage { - UpdatedAtStage ruleType(@NotNull String ruleType); - } - - public interface UpdatedAtStage { - ValueStage updatedAt(@NotNull OffsetDateTime updatedAt); + ValueStage ruleType(@NotNull String ruleType); } public interface ValueStage { @@ -202,29 +199,36 @@ public interface ValueStage { } public interface _FinalStage { - PlanAudienceResponseData build(); + Rule build(); - _FinalStage flagId(Optional flagId); + _FinalStage conditionGroups(List conditionGroups); - _FinalStage flagId(String flagId); + _FinalStage addConditionGroups(ConditionGroup conditionGroups); + + _FinalStage addAllConditionGroups(List conditionGroups); + + _FinalStage conditions(List conditions); - _FinalStage planId(Optional planId); + _FinalStage addConditions(Condition conditions); + + _FinalStage addAllConditions(List conditions); + + _FinalStage flagId(Optional flagId); - _FinalStage planId(String planId); + _FinalStage flagId(String flagId); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements CreatedAtStage, + implements AccountIdStage, EnvironmentIdStage, IdStage, NameStage, PriorityStage, RuleTypeStage, - UpdatedAtStage, ValueStage, _FinalStage { - private OffsetDateTime createdAt; + private String accountId; private String environmentId; @@ -236,38 +240,38 @@ public static final class Builder private String ruleType; - private OffsetDateTime updatedAt; - private boolean value; - private Optional planId = Optional.empty(); - private Optional flagId = Optional.empty(); + private List conditions = new ArrayList<>(); + + private List conditionGroups = new ArrayList<>(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} @java.lang.Override - public Builder from(PlanAudienceResponseData other) { - createdAt(other.getCreatedAt()); + public Builder from(Rule other) { + accountId(other.getAccountId()); + conditionGroups(other.getConditionGroups()); + conditions(other.getConditions()); environmentId(other.getEnvironmentId()); flagId(other.getFlagId()); id(other.getId()); name(other.getName()); - planId(other.getPlanId()); priority(other.getPriority()); ruleType(other.getRuleType()); - updatedAt(other.getUpdatedAt()); value(other.getValue()); return this; } @java.lang.Override - @JsonSetter("created_at") - public EnvironmentIdStage createdAt(@NotNull OffsetDateTime createdAt) { - this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + @JsonSetter("account_id") + public EnvironmentIdStage accountId(@NotNull String accountId) { + this.accountId = Objects.requireNonNull(accountId, "accountId must not be null"); return this; } @@ -301,63 +305,91 @@ public RuleTypeStage priority(int priority) { @java.lang.Override @JsonSetter("rule_type") - public UpdatedAtStage ruleType(@NotNull String ruleType) { + public ValueStage ruleType(@NotNull String ruleType) { this.ruleType = Objects.requireNonNull(ruleType, "ruleType must not be null"); return this; } @java.lang.Override - @JsonSetter("updated_at") - public ValueStage updatedAt(@NotNull OffsetDateTime updatedAt) { - this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + @JsonSetter("value") + public _FinalStage value(boolean value) { + this.value = value; + return this; + } + + @java.lang.Override + public _FinalStage flagId(String flagId) { + this.flagId = Optional.ofNullable(flagId); return this; } @java.lang.Override - @JsonSetter("value") - public _FinalStage value(boolean value) { - this.value = value; + @JsonSetter(value = "flag_id", nulls = Nulls.SKIP) + public _FinalStage flagId(Optional flagId) { + this.flagId = flagId; return this; } @java.lang.Override - public _FinalStage planId(String planId) { - this.planId = Optional.ofNullable(planId); + public _FinalStage addAllConditions(List conditions) { + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @java.lang.Override - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public _FinalStage planId(Optional planId) { - this.planId = planId; + public _FinalStage addConditions(Condition conditions) { + this.conditions.add(conditions); return this; } @java.lang.Override - public _FinalStage flagId(String flagId) { - this.flagId = Optional.ofNullable(flagId); + @JsonSetter(value = "conditions", nulls = Nulls.SKIP) + public _FinalStage conditions(List conditions) { + this.conditions.clear(); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @java.lang.Override - @JsonSetter(value = "flag_id", nulls = Nulls.SKIP) - public _FinalStage flagId(Optional flagId) { - this.flagId = flagId; + public _FinalStage addAllConditionGroups(List conditionGroups) { + if (conditionGroups != null) { + this.conditionGroups.addAll(conditionGroups); + } + return this; + } + + @java.lang.Override + public _FinalStage addConditionGroups(ConditionGroup conditionGroups) { + this.conditionGroups.add(conditionGroups); + return this; + } + + @java.lang.Override + @JsonSetter(value = "condition_groups", nulls = Nulls.SKIP) + public _FinalStage conditionGroups(List conditionGroups) { + this.conditionGroups.clear(); + if (conditionGroups != null) { + this.conditionGroups.addAll(conditionGroups); + } return this; } @java.lang.Override - public PlanAudienceResponseData build() { - return new PlanAudienceResponseData( - createdAt, + public Rule build() { + return new Rule( + accountId, + conditionGroups, + conditions, environmentId, flagId, id, name, - planId, priority, ruleType, - updatedAt, value, additionalProperties); } diff --git a/src/main/java/com/schematic/api/types/RuleConditionDetailResponseData.java b/src/main/java/com/schematic/api/types/RuleConditionDetailResponseData.java index 7b072b7..b94bef5 100644 --- a/src/main/java/com/schematic/api/types/RuleConditionDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/RuleConditionDetailResponseData.java @@ -50,8 +50,6 @@ public final class RuleConditionDetailResponseData { private final String operator; - private final Optional planId; - private final List resourceIds; private final List resources; @@ -84,7 +82,6 @@ private RuleConditionDetailResponseData( Optional metricPeriodMonthReset, Optional metricValue, String operator, - Optional planId, List resourceIds, List resources, String ruleId, @@ -107,7 +104,6 @@ private RuleConditionDetailResponseData( this.metricPeriodMonthReset = metricPeriodMonthReset; this.metricValue = metricValue; this.operator = operator; - this.planId = planId; this.resourceIds = resourceIds; this.resources = resources; this.ruleId = ruleId; @@ -184,11 +180,6 @@ public String getOperator() { return operator; } - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - @JsonProperty("resource_ids") public List getResourceIds() { return resourceIds; @@ -254,7 +245,6 @@ private boolean equalTo(RuleConditionDetailResponseData other) { && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) && metricValue.equals(other.metricValue) && operator.equals(other.operator) - && planId.equals(other.planId) && resourceIds.equals(other.resourceIds) && resources.equals(other.resources) && ruleId.equals(other.ruleId) @@ -281,7 +271,6 @@ public int hashCode() { this.metricPeriodMonthReset, this.metricValue, this.operator, - this.planId, this.resourceIds, this.resources, this.ruleId, @@ -370,10 +359,6 @@ public interface _FinalStage { _FinalStage metricValue(Integer metricValue); - _FinalStage planId(Optional planId); - - _FinalStage planId(String planId); - _FinalStage resourceIds(List resourceIds); _FinalStage addResourceIds(String resourceIds); @@ -436,8 +421,6 @@ public static final class Builder private List resourceIds = new ArrayList<>(); - private Optional planId = Optional.empty(); - private Optional metricValue = Optional.empty(); private Optional metricPeriodMonthReset = Optional.empty(); @@ -474,7 +457,6 @@ public Builder from(RuleConditionDetailResponseData other) { metricPeriodMonthReset(other.getMetricPeriodMonthReset()); metricValue(other.getMetricValue()); operator(other.getOperator()); - planId(other.getPlanId()); resourceIds(other.getResourceIds()); resources(other.getResources()); ruleId(other.getRuleId()); @@ -583,7 +565,9 @@ public _FinalStage trait(Optional trait) { @java.lang.Override public _FinalStage addAllResources(List resources) { - this.resources.addAll(resources); + if (resources != null) { + this.resources.addAll(resources); + } return this; } @@ -597,13 +581,17 @@ public _FinalStage addResources(PreviewObjectResponseData resources) { @JsonSetter(value = "resources", nulls = Nulls.SKIP) public _FinalStage resources(List resources) { this.resources.clear(); - this.resources.addAll(resources); + if (resources != null) { + this.resources.addAll(resources); + } return this; } @java.lang.Override public _FinalStage addAllResourceIds(List resourceIds) { - this.resourceIds.addAll(resourceIds); + if (resourceIds != null) { + this.resourceIds.addAll(resourceIds); + } return this; } @@ -617,20 +605,9 @@ public _FinalStage addResourceIds(String resourceIds) { @JsonSetter(value = "resource_ids", nulls = Nulls.SKIP) public _FinalStage resourceIds(List resourceIds) { this.resourceIds.clear(); - this.resourceIds.addAll(resourceIds); - return this; - } - - @java.lang.Override - public _FinalStage planId(String planId) { - this.planId = Optional.ofNullable(planId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public _FinalStage planId(Optional planId) { - this.planId = planId; + if (resourceIds != null) { + this.resourceIds.addAll(resourceIds); + } return this; } @@ -754,7 +731,6 @@ public RuleConditionDetailResponseData build() { metricPeriodMonthReset, metricValue, operator, - planId, resourceIds, resources, ruleId, diff --git a/src/main/java/com/schematic/api/types/RuleConditionGroupDetailResponseData.java b/src/main/java/com/schematic/api/types/RuleConditionGroupDetailResponseData.java index eda3a8e..2dbc94a 100644 --- a/src/main/java/com/schematic/api/types/RuleConditionGroupDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/RuleConditionGroupDetailResponseData.java @@ -34,8 +34,6 @@ public final class RuleConditionGroupDetailResponseData { private final String id; - private final Optional planId; - private final String ruleId; private final OffsetDateTime updatedAt; @@ -48,7 +46,6 @@ private RuleConditionGroupDetailResponseData( String environmentId, Optional flagId, String id, - Optional planId, String ruleId, OffsetDateTime updatedAt, Map additionalProperties) { @@ -57,7 +54,6 @@ private RuleConditionGroupDetailResponseData( this.environmentId = environmentId; this.flagId = flagId; this.id = id; - this.planId = planId; this.ruleId = ruleId; this.updatedAt = updatedAt; this.additionalProperties = additionalProperties; @@ -88,11 +84,6 @@ public String getId() { return id; } - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - @JsonProperty("rule_id") public String getRuleId() { return ruleId; @@ -121,7 +112,6 @@ private boolean equalTo(RuleConditionGroupDetailResponseData other) { && environmentId.equals(other.environmentId) && flagId.equals(other.flagId) && id.equals(other.id) - && planId.equals(other.planId) && ruleId.equals(other.ruleId) && updatedAt.equals(other.updatedAt); } @@ -129,14 +119,7 @@ private boolean equalTo(RuleConditionGroupDetailResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.conditions, - this.createdAt, - this.environmentId, - this.flagId, - this.id, - this.planId, - this.ruleId, - this.updatedAt); + this.conditions, this.createdAt, this.environmentId, this.flagId, this.id, this.ruleId, this.updatedAt); } @java.lang.Override @@ -182,10 +165,6 @@ public interface _FinalStage { _FinalStage flagId(Optional flagId); _FinalStage flagId(String flagId); - - _FinalStage planId(Optional planId); - - _FinalStage planId(String planId); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -201,8 +180,6 @@ public static final class Builder private OffsetDateTime updatedAt; - private Optional planId = Optional.empty(); - private Optional flagId = Optional.empty(); private List conditions = new ArrayList<>(); @@ -219,7 +196,6 @@ public Builder from(RuleConditionGroupDetailResponseData other) { environmentId(other.getEnvironmentId()); flagId(other.getFlagId()); id(other.getId()); - planId(other.getPlanId()); ruleId(other.getRuleId()); updatedAt(other.getUpdatedAt()); return this; @@ -260,19 +236,6 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { return this; } - @java.lang.Override - public _FinalStage planId(String planId) { - this.planId = Optional.ofNullable(planId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public _FinalStage planId(Optional planId) { - this.planId = planId; - return this; - } - @java.lang.Override public _FinalStage flagId(String flagId) { this.flagId = Optional.ofNullable(flagId); @@ -288,7 +251,9 @@ public _FinalStage flagId(Optional flagId) { @java.lang.Override public _FinalStage addAllConditions(List conditions) { - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @@ -302,14 +267,16 @@ public _FinalStage addConditions(RuleConditionDetailResponseData conditions) { @JsonSetter(value = "conditions", nulls = Nulls.SKIP) public _FinalStage conditions(List conditions) { this.conditions.clear(); - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @java.lang.Override public RuleConditionGroupDetailResponseData build() { return new RuleConditionGroupDetailResponseData( - conditions, createdAt, environmentId, flagId, id, planId, ruleId, updatedAt, additionalProperties); + conditions, createdAt, environmentId, flagId, id, ruleId, updatedAt, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/RuleConditionGroupResponseData.java b/src/main/java/com/schematic/api/types/RuleConditionGroupResponseData.java index 5b726c3..14ae8ba 100644 --- a/src/main/java/com/schematic/api/types/RuleConditionGroupResponseData.java +++ b/src/main/java/com/schematic/api/types/RuleConditionGroupResponseData.java @@ -30,8 +30,6 @@ public final class RuleConditionGroupResponseData { private final String id; - private final Optional planId; - private final String ruleId; private final OffsetDateTime updatedAt; @@ -43,7 +41,6 @@ private RuleConditionGroupResponseData( String environmentId, Optional flagId, String id, - Optional planId, String ruleId, OffsetDateTime updatedAt, Map additionalProperties) { @@ -51,7 +48,6 @@ private RuleConditionGroupResponseData( this.environmentId = environmentId; this.flagId = flagId; this.id = id; - this.planId = planId; this.ruleId = ruleId; this.updatedAt = updatedAt; this.additionalProperties = additionalProperties; @@ -77,11 +73,6 @@ public String getId() { return id; } - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - @JsonProperty("rule_id") public String getRuleId() { return ruleId; @@ -108,15 +99,13 @@ private boolean equalTo(RuleConditionGroupResponseData other) { && environmentId.equals(other.environmentId) && flagId.equals(other.flagId) && id.equals(other.id) - && planId.equals(other.planId) && ruleId.equals(other.ruleId) && updatedAt.equals(other.updatedAt); } @java.lang.Override public int hashCode() { - return Objects.hash( - this.createdAt, this.environmentId, this.flagId, this.id, this.planId, this.ruleId, this.updatedAt); + return Objects.hash(this.createdAt, this.environmentId, this.flagId, this.id, this.ruleId, this.updatedAt); } @java.lang.Override @@ -156,10 +145,6 @@ public interface _FinalStage { _FinalStage flagId(Optional flagId); _FinalStage flagId(String flagId); - - _FinalStage planId(Optional planId); - - _FinalStage planId(String planId); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -175,8 +160,6 @@ public static final class Builder private OffsetDateTime updatedAt; - private Optional planId = Optional.empty(); - private Optional flagId = Optional.empty(); @JsonAnySetter @@ -190,7 +173,6 @@ public Builder from(RuleConditionGroupResponseData other) { environmentId(other.getEnvironmentId()); flagId(other.getFlagId()); id(other.getId()); - planId(other.getPlanId()); ruleId(other.getRuleId()); updatedAt(other.getUpdatedAt()); return this; @@ -231,19 +213,6 @@ public _FinalStage updatedAt(@NotNull OffsetDateTime updatedAt) { return this; } - @java.lang.Override - public _FinalStage planId(String planId) { - this.planId = Optional.ofNullable(planId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public _FinalStage planId(Optional planId) { - this.planId = planId; - return this; - } - @java.lang.Override public _FinalStage flagId(String flagId) { this.flagId = Optional.ofNullable(flagId); @@ -260,7 +229,7 @@ public _FinalStage flagId(Optional flagId) { @java.lang.Override public RuleConditionGroupResponseData build() { return new RuleConditionGroupResponseData( - createdAt, environmentId, flagId, id, planId, ruleId, updatedAt, additionalProperties); + createdAt, environmentId, flagId, id, ruleId, updatedAt, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/RuleConditionResponseData.java b/src/main/java/com/schematic/api/types/RuleConditionResponseData.java index 5fb269f..56a4b50 100644 --- a/src/main/java/com/schematic/api/types/RuleConditionResponseData.java +++ b/src/main/java/com/schematic/api/types/RuleConditionResponseData.java @@ -48,8 +48,6 @@ public final class RuleConditionResponseData { private final String operator; - private final Optional planId; - private final List resourceIds; private final String ruleId; @@ -77,7 +75,6 @@ private RuleConditionResponseData( Optional metricPeriodMonthReset, Optional metricValue, String operator, - Optional planId, List resourceIds, String ruleId, Optional traitEntityType, @@ -97,7 +94,6 @@ private RuleConditionResponseData( this.metricPeriodMonthReset = metricPeriodMonthReset; this.metricValue = metricValue; this.operator = operator; - this.planId = planId; this.resourceIds = resourceIds; this.ruleId = ruleId; this.traitEntityType = traitEntityType; @@ -167,11 +163,6 @@ public String getOperator() { return operator; } - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - @JsonProperty("resource_ids") public List getResourceIds() { return resourceIds; @@ -226,7 +217,6 @@ private boolean equalTo(RuleConditionResponseData other) { && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) && metricValue.equals(other.metricValue) && operator.equals(other.operator) - && planId.equals(other.planId) && resourceIds.equals(other.resourceIds) && ruleId.equals(other.ruleId) && traitEntityType.equals(other.traitEntityType) @@ -250,7 +240,6 @@ public int hashCode() { this.metricPeriodMonthReset, this.metricValue, this.operator, - this.planId, this.resourceIds, this.ruleId, this.traitEntityType, @@ -333,10 +322,6 @@ public interface _FinalStage { _FinalStage metricValue(Integer metricValue); - _FinalStage planId(Optional planId); - - _FinalStage planId(String planId); - _FinalStage resourceIds(List resourceIds); _FinalStage addResourceIds(String resourceIds); @@ -385,8 +370,6 @@ public static final class Builder private List resourceIds = new ArrayList<>(); - private Optional planId = Optional.empty(); - private Optional metricValue = Optional.empty(); private Optional metricPeriodMonthReset = Optional.empty(); @@ -420,7 +403,6 @@ public Builder from(RuleConditionResponseData other) { metricPeriodMonthReset(other.getMetricPeriodMonthReset()); metricValue(other.getMetricValue()); operator(other.getOperator()); - planId(other.getPlanId()); resourceIds(other.getResourceIds()); ruleId(other.getRuleId()); traitEntityType(other.getTraitEntityType()); @@ -514,7 +496,9 @@ public _FinalStage traitEntityType(Optional traitEntityType) { @java.lang.Override public _FinalStage addAllResourceIds(List resourceIds) { - this.resourceIds.addAll(resourceIds); + if (resourceIds != null) { + this.resourceIds.addAll(resourceIds); + } return this; } @@ -528,20 +512,9 @@ public _FinalStage addResourceIds(String resourceIds) { @JsonSetter(value = "resource_ids", nulls = Nulls.SKIP) public _FinalStage resourceIds(List resourceIds) { this.resourceIds.clear(); - this.resourceIds.addAll(resourceIds); - return this; - } - - @java.lang.Override - public _FinalStage planId(String planId) { - this.planId = Optional.ofNullable(planId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public _FinalStage planId(Optional planId) { - this.planId = planId; + if (resourceIds != null) { + this.resourceIds.addAll(resourceIds); + } return this; } @@ -651,7 +624,6 @@ public RuleConditionResponseData build() { metricPeriodMonthReset, metricValue, operator, - planId, resourceIds, ruleId, traitEntityType, diff --git a/src/main/java/com/schematic/api/types/RuleDetailResponseData.java b/src/main/java/com/schematic/api/types/RuleDetailResponseData.java index 6f1e6cb..6e08c73 100644 --- a/src/main/java/com/schematic/api/types/RuleDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/RuleDetailResponseData.java @@ -38,8 +38,6 @@ public final class RuleDetailResponseData { private final String name; - private final Optional planId; - private final int priority; private final String ruleType; @@ -58,7 +56,6 @@ private RuleDetailResponseData( Optional flagId, String id, String name, - Optional planId, int priority, String ruleType, OffsetDateTime updatedAt, @@ -71,7 +68,6 @@ private RuleDetailResponseData( this.flagId = flagId; this.id = id; this.name = name; - this.planId = planId; this.priority = priority; this.ruleType = ruleType; this.updatedAt = updatedAt; @@ -114,11 +110,6 @@ public String getName() { return name; } - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - @JsonProperty("priority") public int getPriority() { return priority; @@ -158,7 +149,6 @@ private boolean equalTo(RuleDetailResponseData other) { && flagId.equals(other.flagId) && id.equals(other.id) && name.equals(other.name) - && planId.equals(other.planId) && priority == other.priority && ruleType.equals(other.ruleType) && updatedAt.equals(other.updatedAt) @@ -175,7 +165,6 @@ public int hashCode() { this.flagId, this.id, this.name, - this.planId, this.priority, this.ruleType, this.updatedAt, @@ -243,10 +232,6 @@ public interface _FinalStage { _FinalStage flagId(Optional flagId); _FinalStage flagId(String flagId); - - _FinalStage planId(Optional planId); - - _FinalStage planId(String planId); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -276,8 +261,6 @@ public static final class Builder private boolean value; - private Optional planId = Optional.empty(); - private Optional flagId = Optional.empty(); private List conditions = new ArrayList<>(); @@ -298,7 +281,6 @@ public Builder from(RuleDetailResponseData other) { flagId(other.getFlagId()); id(other.getId()); name(other.getName()); - planId(other.getPlanId()); priority(other.getPriority()); ruleType(other.getRuleType()); updatedAt(other.getUpdatedAt()); @@ -362,19 +344,6 @@ public _FinalStage value(boolean value) { return this; } - @java.lang.Override - public _FinalStage planId(String planId) { - this.planId = Optional.ofNullable(planId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public _FinalStage planId(Optional planId) { - this.planId = planId; - return this; - } - @java.lang.Override public _FinalStage flagId(String flagId) { this.flagId = Optional.ofNullable(flagId); @@ -390,7 +359,9 @@ public _FinalStage flagId(Optional flagId) { @java.lang.Override public _FinalStage addAllConditions(List conditions) { - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @@ -404,13 +375,17 @@ public _FinalStage addConditions(RuleConditionDetailResponseData conditions) { @JsonSetter(value = "conditions", nulls = Nulls.SKIP) public _FinalStage conditions(List conditions) { this.conditions.clear(); - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @java.lang.Override public _FinalStage addAllConditionGroups(List conditionGroups) { - this.conditionGroups.addAll(conditionGroups); + if (conditionGroups != null) { + this.conditionGroups.addAll(conditionGroups); + } return this; } @@ -424,7 +399,9 @@ public _FinalStage addConditionGroups(RuleConditionGroupDetailResponseData condi @JsonSetter(value = "condition_groups", nulls = Nulls.SKIP) public _FinalStage conditionGroups(List conditionGroups) { this.conditionGroups.clear(); - this.conditionGroups.addAll(conditionGroups); + if (conditionGroups != null) { + this.conditionGroups.addAll(conditionGroups); + } return this; } @@ -438,7 +415,6 @@ public RuleDetailResponseData build() { flagId, id, name, - planId, priority, ruleType, updatedAt, diff --git a/src/main/java/com/schematic/api/types/RuleResponseData.java b/src/main/java/com/schematic/api/types/RuleResponseData.java index c9a8bdc..faf0c93 100644 --- a/src/main/java/com/schematic/api/types/RuleResponseData.java +++ b/src/main/java/com/schematic/api/types/RuleResponseData.java @@ -32,8 +32,6 @@ public final class RuleResponseData { private final String name; - private final Optional planId; - private final int priority; private final String ruleType; @@ -50,7 +48,6 @@ private RuleResponseData( Optional flagId, String id, String name, - Optional planId, int priority, String ruleType, OffsetDateTime updatedAt, @@ -61,7 +58,6 @@ private RuleResponseData( this.flagId = flagId; this.id = id; this.name = name; - this.planId = planId; this.priority = priority; this.ruleType = ruleType; this.updatedAt = updatedAt; @@ -94,11 +90,6 @@ public String getName() { return name; } - @JsonProperty("plan_id") - public Optional getPlanId() { - return planId; - } - @JsonProperty("priority") public int getPriority() { return priority; @@ -136,7 +127,6 @@ private boolean equalTo(RuleResponseData other) { && flagId.equals(other.flagId) && id.equals(other.id) && name.equals(other.name) - && planId.equals(other.planId) && priority == other.priority && ruleType.equals(other.ruleType) && updatedAt.equals(other.updatedAt) @@ -151,7 +141,6 @@ public int hashCode() { this.flagId, this.id, this.name, - this.planId, this.priority, this.ruleType, this.updatedAt, @@ -207,10 +196,6 @@ public interface _FinalStage { _FinalStage flagId(Optional flagId); _FinalStage flagId(String flagId); - - _FinalStage planId(Optional planId); - - _FinalStage planId(String planId); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -240,8 +225,6 @@ public static final class Builder private boolean value; - private Optional planId = Optional.empty(); - private Optional flagId = Optional.empty(); @JsonAnySetter @@ -256,7 +239,6 @@ public Builder from(RuleResponseData other) { flagId(other.getFlagId()); id(other.getId()); name(other.getName()); - planId(other.getPlanId()); priority(other.getPriority()); ruleType(other.getRuleType()); updatedAt(other.getUpdatedAt()); @@ -320,19 +302,6 @@ public _FinalStage value(boolean value) { return this; } - @java.lang.Override - public _FinalStage planId(String planId) { - this.planId = Optional.ofNullable(planId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "plan_id", nulls = Nulls.SKIP) - public _FinalStage planId(Optional planId) { - this.planId = planId; - return this; - } - @java.lang.Override public _FinalStage flagId(String flagId) { this.flagId = Optional.ofNullable(flagId); @@ -354,7 +323,6 @@ public RuleResponseData build() { flagId, id, name, - planId, priority, ruleType, updatedAt, diff --git a/src/main/java/com/schematic/api/types/RulesDetailResponseData.java b/src/main/java/com/schematic/api/types/RulesDetailResponseData.java index 26ba49c..7149598 100644 --- a/src/main/java/com/schematic/api/types/RulesDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/RulesDetailResponseData.java @@ -107,7 +107,9 @@ public Builder flag(FlagResponseData flag) { @JsonSetter(value = "rules", nulls = Nulls.SKIP) public Builder rules(List rules) { this.rules.clear(); - this.rules.addAll(rules); + if (rules != null) { + this.rules.addAll(rules); + } return this; } @@ -117,7 +119,9 @@ public Builder addRules(RuleDetailResponseData rules) { } public Builder addAllRules(List rules) { - this.rules.addAll(rules); + if (rules != null) { + this.rules.addAll(rules); + } return this; } diff --git a/src/main/java/com/schematic/api/types/StripeEmbedInfo.java b/src/main/java/com/schematic/api/types/StripeEmbedInfo.java index 36a3c0f..6b6694d 100644 --- a/src/main/java/com/schematic/api/types/StripeEmbedInfo.java +++ b/src/main/java/com/schematic/api/types/StripeEmbedInfo.java @@ -21,24 +21,44 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = StripeEmbedInfo.Builder.class) public final class StripeEmbedInfo { - private final String publishableKey; + private final Optional accountId; + + private final Optional publishableKey; + + private final String schematicPublishableKey; private final Optional setupIntentClientSecret; private final Map additionalProperties; private StripeEmbedInfo( - String publishableKey, Optional setupIntentClientSecret, Map additionalProperties) { + Optional accountId, + Optional publishableKey, + String schematicPublishableKey, + Optional setupIntentClientSecret, + Map additionalProperties) { + this.accountId = accountId; this.publishableKey = publishableKey; + this.schematicPublishableKey = schematicPublishableKey; this.setupIntentClientSecret = setupIntentClientSecret; this.additionalProperties = additionalProperties; } + @JsonProperty("account_id") + public Optional getAccountId() { + return accountId; + } + @JsonProperty("publishable_key") - public String getPublishableKey() { + public Optional getPublishableKey() { return publishableKey; } + @JsonProperty("schematic_publishable_key") + public String getSchematicPublishableKey() { + return schematicPublishableKey; + } + @JsonProperty("setup_intent_client_secret") public Optional getSetupIntentClientSecret() { return setupIntentClientSecret; @@ -56,13 +76,16 @@ public Map getAdditionalProperties() { } private boolean equalTo(StripeEmbedInfo other) { - return publishableKey.equals(other.publishableKey) + return accountId.equals(other.accountId) + && publishableKey.equals(other.publishableKey) + && schematicPublishableKey.equals(other.schematicPublishableKey) && setupIntentClientSecret.equals(other.setupIntentClientSecret); } @java.lang.Override public int hashCode() { - return Objects.hash(this.publishableKey, this.setupIntentClientSecret); + return Objects.hash( + this.accountId, this.publishableKey, this.schematicPublishableKey, this.setupIntentClientSecret); } @java.lang.Override @@ -70,12 +93,12 @@ public String toString() { return ObjectMappers.stringify(this); } - public static PublishableKeyStage builder() { + public static SchematicPublishableKeyStage builder() { return new Builder(); } - public interface PublishableKeyStage { - _FinalStage publishableKey(@NotNull String publishableKey); + public interface SchematicPublishableKeyStage { + _FinalStage schematicPublishableKey(@NotNull String schematicPublishableKey); Builder from(StripeEmbedInfo other); } @@ -83,17 +106,29 @@ public interface PublishableKeyStage { public interface _FinalStage { StripeEmbedInfo build(); + _FinalStage accountId(Optional accountId); + + _FinalStage accountId(String accountId); + + _FinalStage publishableKey(Optional publishableKey); + + _FinalStage publishableKey(String publishableKey); + _FinalStage setupIntentClientSecret(Optional setupIntentClientSecret); _FinalStage setupIntentClientSecret(String setupIntentClientSecret); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PublishableKeyStage, _FinalStage { - private String publishableKey; + public static final class Builder implements SchematicPublishableKeyStage, _FinalStage { + private String schematicPublishableKey; private Optional setupIntentClientSecret = Optional.empty(); + private Optional publishableKey = Optional.empty(); + + private Optional accountId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -101,15 +136,18 @@ private Builder() {} @java.lang.Override public Builder from(StripeEmbedInfo other) { + accountId(other.getAccountId()); publishableKey(other.getPublishableKey()); + schematicPublishableKey(other.getSchematicPublishableKey()); setupIntentClientSecret(other.getSetupIntentClientSecret()); return this; } @java.lang.Override - @JsonSetter("publishable_key") - public _FinalStage publishableKey(@NotNull String publishableKey) { - this.publishableKey = Objects.requireNonNull(publishableKey, "publishableKey must not be null"); + @JsonSetter("schematic_publishable_key") + public _FinalStage schematicPublishableKey(@NotNull String schematicPublishableKey) { + this.schematicPublishableKey = + Objects.requireNonNull(schematicPublishableKey, "schematicPublishableKey must not be null"); return this; } @@ -126,9 +164,36 @@ public _FinalStage setupIntentClientSecret(Optional setupIntentClientSec return this; } + @java.lang.Override + public _FinalStage publishableKey(String publishableKey) { + this.publishableKey = Optional.ofNullable(publishableKey); + return this; + } + + @java.lang.Override + @JsonSetter(value = "publishable_key", nulls = Nulls.SKIP) + public _FinalStage publishableKey(Optional publishableKey) { + this.publishableKey = publishableKey; + return this; + } + + @java.lang.Override + public _FinalStage accountId(String accountId) { + this.accountId = Optional.ofNullable(accountId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "account_id", nulls = Nulls.SKIP) + public _FinalStage accountId(Optional accountId) { + this.accountId = accountId; + return this; + } + @java.lang.Override public StripeEmbedInfo build() { - return new StripeEmbedInfo(publishableKey, setupIntentClientSecret, additionalProperties); + return new StripeEmbedInfo( + accountId, publishableKey, schematicPublishableKey, setupIntentClientSecret, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/SubscriptionTraitUpdate.java b/src/main/java/com/schematic/api/types/SubscriptionTraitUpdate.java new file mode 100644 index 0000000..8f7ce4b --- /dev/null +++ b/src/main/java/com/schematic/api/types/SubscriptionTraitUpdate.java @@ -0,0 +1,279 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SubscriptionTraitUpdate.Builder.class) +public final class SubscriptionTraitUpdate { + private final String featureId; + + private final List hierarchy; + + private final String reason; + + private final String traitId; + + private final String traitName; + + private final String traitType; + + private final String value; + + private final Map additionalProperties; + + private SubscriptionTraitUpdate( + String featureId, + List hierarchy, + String reason, + String traitId, + String traitName, + String traitType, + String value, + Map additionalProperties) { + this.featureId = featureId; + this.hierarchy = hierarchy; + this.reason = reason; + this.traitId = traitId; + this.traitName = traitName; + this.traitType = traitType; + this.value = value; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("feature_id") + public String getFeatureId() { + return featureId; + } + + @JsonProperty("hierarchy") + public List getHierarchy() { + return hierarchy; + } + + @JsonProperty("reason") + public String getReason() { + return reason; + } + + @JsonProperty("trait_id") + public String getTraitId() { + return traitId; + } + + @JsonProperty("trait_name") + public String getTraitName() { + return traitName; + } + + @JsonProperty("trait_type") + public String getTraitType() { + return traitType; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SubscriptionTraitUpdate && equalTo((SubscriptionTraitUpdate) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SubscriptionTraitUpdate other) { + return featureId.equals(other.featureId) + && hierarchy.equals(other.hierarchy) + && reason.equals(other.reason) + && traitId.equals(other.traitId) + && traitName.equals(other.traitName) + && traitType.equals(other.traitType) + && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.featureId, this.hierarchy, this.reason, this.traitId, this.traitName, this.traitType, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static FeatureIdStage builder() { + return new Builder(); + } + + public interface FeatureIdStage { + ReasonStage featureId(@NotNull String featureId); + + Builder from(SubscriptionTraitUpdate other); + } + + public interface ReasonStage { + TraitIdStage reason(@NotNull String reason); + } + + public interface TraitIdStage { + TraitNameStage traitId(@NotNull String traitId); + } + + public interface TraitNameStage { + TraitTypeStage traitName(@NotNull String traitName); + } + + public interface TraitTypeStage { + ValueStage traitType(@NotNull String traitType); + } + + public interface ValueStage { + _FinalStage value(@NotNull String value); + } + + public interface _FinalStage { + SubscriptionTraitUpdate build(); + + _FinalStage hierarchy(List hierarchy); + + _FinalStage addHierarchy(String hierarchy); + + _FinalStage addAllHierarchy(List hierarchy); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements FeatureIdStage, + ReasonStage, + TraitIdStage, + TraitNameStage, + TraitTypeStage, + ValueStage, + _FinalStage { + private String featureId; + + private String reason; + + private String traitId; + + private String traitName; + + private String traitType; + + private String value; + + private List hierarchy = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SubscriptionTraitUpdate other) { + featureId(other.getFeatureId()); + hierarchy(other.getHierarchy()); + reason(other.getReason()); + traitId(other.getTraitId()); + traitName(other.getTraitName()); + traitType(other.getTraitType()); + value(other.getValue()); + return this; + } + + @java.lang.Override + @JsonSetter("feature_id") + public ReasonStage featureId(@NotNull String featureId) { + this.featureId = Objects.requireNonNull(featureId, "featureId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("reason") + public TraitIdStage reason(@NotNull String reason) { + this.reason = Objects.requireNonNull(reason, "reason must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_id") + public TraitNameStage traitId(@NotNull String traitId) { + this.traitId = Objects.requireNonNull(traitId, "traitId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_name") + public TraitTypeStage traitName(@NotNull String traitName) { + this.traitName = Objects.requireNonNull(traitName, "traitName must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_type") + public ValueStage traitType(@NotNull String traitType) { + this.traitType = Objects.requireNonNull(traitType, "traitType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("value") + public _FinalStage value(@NotNull String value) { + this.value = Objects.requireNonNull(value, "value must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage addAllHierarchy(List hierarchy) { + if (hierarchy != null) { + this.hierarchy.addAll(hierarchy); + } + return this; + } + + @java.lang.Override + public _FinalStage addHierarchy(String hierarchy) { + this.hierarchy.add(hierarchy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "hierarchy", nulls = Nulls.SKIP) + public _FinalStage hierarchy(List hierarchy) { + this.hierarchy.clear(); + if (hierarchy != null) { + this.hierarchy.addAll(hierarchy); + } + return this; + } + + @java.lang.Override + public SubscriptionTraitUpdate build() { + return new SubscriptionTraitUpdate( + featureId, hierarchy, reason, traitId, traitName, traitType, value, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/TraitDefinition.java b/src/main/java/com/schematic/api/types/TraitDefinition.java new file mode 100644 index 0000000..bfeaf2a --- /dev/null +++ b/src/main/java/com/schematic/api/types/TraitDefinition.java @@ -0,0 +1,149 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TraitDefinition.Builder.class) +public final class TraitDefinition { + private final String comparableType; + + private final String entityType; + + private final String id; + + private final Map additionalProperties; + + private TraitDefinition( + String comparableType, String entityType, String id, Map additionalProperties) { + this.comparableType = comparableType; + this.entityType = entityType; + this.id = id; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("comparable_type") + public String getComparableType() { + return comparableType; + } + + @JsonProperty("entity_type") + public String getEntityType() { + return entityType; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TraitDefinition && equalTo((TraitDefinition) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TraitDefinition other) { + return comparableType.equals(other.comparableType) + && entityType.equals(other.entityType) + && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.comparableType, this.entityType, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ComparableTypeStage builder() { + return new Builder(); + } + + public interface ComparableTypeStage { + EntityTypeStage comparableType(@NotNull String comparableType); + + Builder from(TraitDefinition other); + } + + public interface EntityTypeStage { + IdStage entityType(@NotNull String entityType); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + TraitDefinition build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ComparableTypeStage, EntityTypeStage, IdStage, _FinalStage { + private String comparableType; + + private String entityType; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TraitDefinition other) { + comparableType(other.getComparableType()); + entityType(other.getEntityType()); + id(other.getId()); + return this; + } + + @java.lang.Override + @JsonSetter("comparable_type") + public EntityTypeStage comparableType(@NotNull String comparableType) { + this.comparableType = Objects.requireNonNull(comparableType, "comparableType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("entity_type") + public IdStage entityType(@NotNull String entityType) { + this.entityType = Objects.requireNonNull(entityType, "entityType must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public TraitDefinition build() { + return new TraitDefinition(comparableType, entityType, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/UpdateCreditBundleRequestBody.java b/src/main/java/com/schematic/api/types/UpdateCreditBundleRequestBody.java new file mode 100644 index 0000000..b5a9a5a --- /dev/null +++ b/src/main/java/com/schematic/api/types/UpdateCreditBundleRequestBody.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateCreditBundleRequestBody.Builder.class) +public final class UpdateCreditBundleRequestBody { + private final String bundleId; + + private final int quantity; + + private final Map additionalProperties; + + private UpdateCreditBundleRequestBody(String bundleId, int quantity, Map additionalProperties) { + this.bundleId = bundleId; + this.quantity = quantity; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("bundle_id") + public String getBundleId() { + return bundleId; + } + + @JsonProperty("quantity") + public int getQuantity() { + return quantity; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCreditBundleRequestBody && equalTo((UpdateCreditBundleRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCreditBundleRequestBody other) { + return bundleId.equals(other.bundleId) && quantity == other.quantity; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.bundleId, this.quantity); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BundleIdStage builder() { + return new Builder(); + } + + public interface BundleIdStage { + QuantityStage bundleId(@NotNull String bundleId); + + Builder from(UpdateCreditBundleRequestBody other); + } + + public interface QuantityStage { + _FinalStage quantity(int quantity); + } + + public interface _FinalStage { + UpdateCreditBundleRequestBody build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements BundleIdStage, QuantityStage, _FinalStage { + private String bundleId; + + private int quantity; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCreditBundleRequestBody other) { + bundleId(other.getBundleId()); + quantity(other.getQuantity()); + return this; + } + + @java.lang.Override + @JsonSetter("bundle_id") + public QuantityStage bundleId(@NotNull String bundleId) { + this.bundleId = Objects.requireNonNull(bundleId, "bundleId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("quantity") + public _FinalStage quantity(int quantity) { + this.quantity = quantity; + return this; + } + + @java.lang.Override + public UpdateCreditBundleRequestBody build() { + return new UpdateCreditBundleRequestBody(bundleId, quantity, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommon.java b/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommon.java index 14ec27c..4a5ee27 100644 --- a/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommon.java +++ b/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommon.java @@ -21,12 +21,16 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateEntitlementReqCommon.Builder.class) public final class UpdateEntitlementReqCommon { + private final Optional creditConsumptionRate; + private final Optional metricPeriod; private final Optional metricPeriodMonthReset; private final Optional valueBool; + private final Optional valueCreditId; + private final Optional valueNumeric; private final Optional valueTraitId; @@ -36,22 +40,31 @@ public final class UpdateEntitlementReqCommon { private final Map additionalProperties; private UpdateEntitlementReqCommon( + Optional creditConsumptionRate, Optional metricPeriod, Optional metricPeriodMonthReset, Optional valueBool, + Optional valueCreditId, Optional valueNumeric, Optional valueTraitId, UpdateEntitlementReqCommonValueType valueType, Map additionalProperties) { + this.creditConsumptionRate = creditConsumptionRate; this.metricPeriod = metricPeriod; this.metricPeriodMonthReset = metricPeriodMonthReset; this.valueBool = valueBool; + this.valueCreditId = valueCreditId; this.valueNumeric = valueNumeric; this.valueTraitId = valueTraitId; this.valueType = valueType; this.additionalProperties = additionalProperties; } + @JsonProperty("credit_consumption_rate") + public Optional getCreditConsumptionRate() { + return creditConsumptionRate; + } + @JsonProperty("metric_period") public Optional getMetricPeriod() { return metricPeriod; @@ -67,6 +80,11 @@ public Optional getValueBool() { return valueBool; } + @JsonProperty("value_credit_id") + public Optional getValueCreditId() { + return valueCreditId; + } + @JsonProperty("value_numeric") public Optional getValueNumeric() { return valueNumeric; @@ -94,9 +112,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateEntitlementReqCommon other) { - return metricPeriod.equals(other.metricPeriod) + return creditConsumptionRate.equals(other.creditConsumptionRate) + && metricPeriod.equals(other.metricPeriod) && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) && valueBool.equals(other.valueBool) + && valueCreditId.equals(other.valueCreditId) && valueNumeric.equals(other.valueNumeric) && valueTraitId.equals(other.valueTraitId) && valueType.equals(other.valueType); @@ -105,9 +125,11 @@ private boolean equalTo(UpdateEntitlementReqCommon other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.creditConsumptionRate, this.metricPeriod, this.metricPeriodMonthReset, this.valueBool, + this.valueCreditId, this.valueNumeric, this.valueTraitId, this.valueType); @@ -131,6 +153,10 @@ public interface ValueTypeStage { public interface _FinalStage { UpdateEntitlementReqCommon build(); + _FinalStage creditConsumptionRate(Optional creditConsumptionRate); + + _FinalStage creditConsumptionRate(Double creditConsumptionRate); + _FinalStage metricPeriod(Optional metricPeriod); _FinalStage metricPeriod(UpdateEntitlementReqCommonMetricPeriod metricPeriod); @@ -144,6 +170,10 @@ _FinalStage metricPeriodMonthReset( _FinalStage valueBool(Boolean valueBool); + _FinalStage valueCreditId(Optional valueCreditId); + + _FinalStage valueCreditId(String valueCreditId); + _FinalStage valueNumeric(Optional valueNumeric); _FinalStage valueNumeric(Integer valueNumeric); @@ -161,12 +191,16 @@ public static final class Builder implements ValueTypeStage, _FinalStage { private Optional valueNumeric = Optional.empty(); + private Optional valueCreditId = Optional.empty(); + private Optional valueBool = Optional.empty(); private Optional metricPeriodMonthReset = Optional.empty(); private Optional metricPeriod = Optional.empty(); + private Optional creditConsumptionRate = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -174,9 +208,11 @@ private Builder() {} @java.lang.Override public Builder from(UpdateEntitlementReqCommon other) { + creditConsumptionRate(other.getCreditConsumptionRate()); metricPeriod(other.getMetricPeriod()); metricPeriodMonthReset(other.getMetricPeriodMonthReset()); valueBool(other.getValueBool()); + valueCreditId(other.getValueCreditId()); valueNumeric(other.getValueNumeric()); valueTraitId(other.getValueTraitId()); valueType(other.getValueType()); @@ -216,6 +252,19 @@ public _FinalStage valueNumeric(Optional valueNumeric) { return this; } + @java.lang.Override + public _FinalStage valueCreditId(String valueCreditId) { + this.valueCreditId = Optional.ofNullable(valueCreditId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "value_credit_id", nulls = Nulls.SKIP) + public _FinalStage valueCreditId(Optional valueCreditId) { + this.valueCreditId = valueCreditId; + return this; + } + @java.lang.Override public _FinalStage valueBool(Boolean valueBool) { this.valueBool = Optional.ofNullable(valueBool); @@ -257,12 +306,27 @@ public _FinalStage metricPeriod(Optional return this; } + @java.lang.Override + public _FinalStage creditConsumptionRate(Double creditConsumptionRate) { + this.creditConsumptionRate = Optional.ofNullable(creditConsumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_consumption_rate", nulls = Nulls.SKIP) + public _FinalStage creditConsumptionRate(Optional creditConsumptionRate) { + this.creditConsumptionRate = creditConsumptionRate; + return this; + } + @java.lang.Override public UpdateEntitlementReqCommon build() { return new UpdateEntitlementReqCommon( + creditConsumptionRate, metricPeriod, metricPeriodMonthReset, valueBool, + valueCreditId, valueNumeric, valueTraitId, valueType, diff --git a/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonMetricPeriod.java b/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonMetricPeriod.java index 98ba2a0..bf58274 100644 --- a/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonMetricPeriod.java +++ b/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonMetricPeriod.java @@ -3,26 +3,106 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateEntitlementReqCommonMetricPeriod { - ALL_TIME("all_time"), +public final class UpdateEntitlementReqCommonMetricPeriod { + public static final UpdateEntitlementReqCommonMetricPeriod CURRENT_DAY = + new UpdateEntitlementReqCommonMetricPeriod(Value.CURRENT_DAY, "current_day"); - CURRENT_MONTH("current_month"), + public static final UpdateEntitlementReqCommonMetricPeriod ALL_TIME = + new UpdateEntitlementReqCommonMetricPeriod(Value.ALL_TIME, "all_time"); - CURRENT_WEEK("current_week"), + public static final UpdateEntitlementReqCommonMetricPeriod CURRENT_WEEK = + new UpdateEntitlementReqCommonMetricPeriod(Value.CURRENT_WEEK, "current_week"); - CURRENT_DAY("current_day"); + public static final UpdateEntitlementReqCommonMetricPeriod CURRENT_MONTH = + new UpdateEntitlementReqCommonMetricPeriod(Value.CURRENT_MONTH, "current_month"); - private final String value; + private final Value value; - UpdateEntitlementReqCommonMetricPeriod(String value) { + private final String string; + + UpdateEntitlementReqCommonMetricPeriod(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateEntitlementReqCommonMetricPeriod + && this.string.equals(((UpdateEntitlementReqCommonMetricPeriod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CURRENT_DAY: + return visitor.visitCurrentDay(); + case ALL_TIME: + return visitor.visitAllTime(); + case CURRENT_WEEK: + return visitor.visitCurrentWeek(); + case CURRENT_MONTH: + return visitor.visitCurrentMonth(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateEntitlementReqCommonMetricPeriod valueOf(String value) { + switch (value) { + case "current_day": + return CURRENT_DAY; + case "all_time": + return ALL_TIME; + case "current_week": + return CURRENT_WEEK; + case "current_month": + return CURRENT_MONTH; + default: + return new UpdateEntitlementReqCommonMetricPeriod(Value.UNKNOWN, value); + } + } + + public enum Value { + ALL_TIME, + + CURRENT_MONTH, + + CURRENT_WEEK, + + CURRENT_DAY, + + UNKNOWN + } + + public interface Visitor { + T visitAllTime(); + + T visitCurrentMonth(); + + T visitCurrentWeek(); + + T visitCurrentDay(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonMetricPeriodMonthReset.java b/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonMetricPeriodMonthReset.java index cdc71be..283b102 100644 --- a/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonMetricPeriodMonthReset.java +++ b/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonMetricPeriodMonthReset.java @@ -3,22 +3,84 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateEntitlementReqCommonMetricPeriodMonthReset { - FIRST_OF_MONTH("first_of_month"), +public final class UpdateEntitlementReqCommonMetricPeriodMonthReset { + public static final UpdateEntitlementReqCommonMetricPeriodMonthReset FIRST_OF_MONTH = + new UpdateEntitlementReqCommonMetricPeriodMonthReset(Value.FIRST_OF_MONTH, "first_of_month"); - BILLING_CYCLE("billing_cycle"); + public static final UpdateEntitlementReqCommonMetricPeriodMonthReset BILLING_CYCLE = + new UpdateEntitlementReqCommonMetricPeriodMonthReset(Value.BILLING_CYCLE, "billing_cycle"); - private final String value; + private final Value value; - UpdateEntitlementReqCommonMetricPeriodMonthReset(String value) { + private final String string; + + UpdateEntitlementReqCommonMetricPeriodMonthReset(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateEntitlementReqCommonMetricPeriodMonthReset + && this.string.equals(((UpdateEntitlementReqCommonMetricPeriodMonthReset) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FIRST_OF_MONTH: + return visitor.visitFirstOfMonth(); + case BILLING_CYCLE: + return visitor.visitBillingCycle(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateEntitlementReqCommonMetricPeriodMonthReset valueOf(String value) { + switch (value) { + case "first_of_month": + return FIRST_OF_MONTH; + case "billing_cycle": + return BILLING_CYCLE; + default: + return new UpdateEntitlementReqCommonMetricPeriodMonthReset(Value.UNKNOWN, value); + } + } + + public enum Value { + FIRST_OF_MONTH, + + BILLING_CYCLE, + + UNKNOWN + } + + public interface Visitor { + T visitFirstOfMonth(); + + T visitBillingCycle(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonValueType.java b/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonValueType.java index 661300b..3023fc0 100644 --- a/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonValueType.java +++ b/src/main/java/com/schematic/api/types/UpdateEntitlementReqCommonValueType.java @@ -3,26 +3,117 @@ */ package com.schematic.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum UpdateEntitlementReqCommonValueType { - BOOLEAN("boolean"), +public final class UpdateEntitlementReqCommonValueType { + public static final UpdateEntitlementReqCommonValueType NUMERIC = + new UpdateEntitlementReqCommonValueType(Value.NUMERIC, "numeric"); - NUMERIC("numeric"), + public static final UpdateEntitlementReqCommonValueType TRAIT = + new UpdateEntitlementReqCommonValueType(Value.TRAIT, "trait"); - TRAIT("trait"), + public static final UpdateEntitlementReqCommonValueType BOOLEAN = + new UpdateEntitlementReqCommonValueType(Value.BOOLEAN, "boolean"); - UNLIMITED("unlimited"); + public static final UpdateEntitlementReqCommonValueType CREDIT = + new UpdateEntitlementReqCommonValueType(Value.CREDIT, "credit"); - private final String value; + public static final UpdateEntitlementReqCommonValueType UNLIMITED = + new UpdateEntitlementReqCommonValueType(Value.UNLIMITED, "unlimited"); - UpdateEntitlementReqCommonValueType(String value) { + private final Value value; + + private final String string; + + UpdateEntitlementReqCommonValueType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UpdateEntitlementReqCommonValueType + && this.string.equals(((UpdateEntitlementReqCommonValueType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NUMERIC: + return visitor.visitNumeric(); + case TRAIT: + return visitor.visitTrait(); + case BOOLEAN: + return visitor.visitBoolean(); + case CREDIT: + return visitor.visitCredit(); + case UNLIMITED: + return visitor.visitUnlimited(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UpdateEntitlementReqCommonValueType valueOf(String value) { + switch (value) { + case "numeric": + return NUMERIC; + case "trait": + return TRAIT; + case "boolean": + return BOOLEAN; + case "credit": + return CREDIT; + case "unlimited": + return UNLIMITED; + default: + return new UpdateEntitlementReqCommonValueType(Value.UNKNOWN, value); + } + } + + public enum Value { + BOOLEAN, + + CREDIT, + + NUMERIC, + + TRAIT, + + UNLIMITED, + + UNKNOWN + } + + public interface Visitor { + T visitBoolean(); + + T visitCredit(); + + T visitNumeric(); + + T visitTrait(); + + T visitUnlimited(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/schematic/api/types/UpdatePlanTraitTraitRequestBody.java b/src/main/java/com/schematic/api/types/UpdatePlanTraitTraitRequestBody.java new file mode 100644 index 0000000..0e43063 --- /dev/null +++ b/src/main/java/com/schematic/api/types/UpdatePlanTraitTraitRequestBody.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.schematic.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdatePlanTraitTraitRequestBody.Builder.class) +public final class UpdatePlanTraitTraitRequestBody { + private final String traitId; + + private final String traitValue; + + private final Map additionalProperties; + + private UpdatePlanTraitTraitRequestBody( + String traitId, String traitValue, Map additionalProperties) { + this.traitId = traitId; + this.traitValue = traitValue; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("trait_id") + public String getTraitId() { + return traitId; + } + + @JsonProperty("trait_value") + public String getTraitValue() { + return traitValue; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdatePlanTraitTraitRequestBody && equalTo((UpdatePlanTraitTraitRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdatePlanTraitTraitRequestBody other) { + return traitId.equals(other.traitId) && traitValue.equals(other.traitValue); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.traitId, this.traitValue); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TraitIdStage builder() { + return new Builder(); + } + + public interface TraitIdStage { + TraitValueStage traitId(@NotNull String traitId); + + Builder from(UpdatePlanTraitTraitRequestBody other); + } + + public interface TraitValueStage { + _FinalStage traitValue(@NotNull String traitValue); + } + + public interface _FinalStage { + UpdatePlanTraitTraitRequestBody build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TraitIdStage, TraitValueStage, _FinalStage { + private String traitId; + + private String traitValue; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdatePlanTraitTraitRequestBody other) { + traitId(other.getTraitId()); + traitValue(other.getTraitValue()); + return this; + } + + @java.lang.Override + @JsonSetter("trait_id") + public TraitValueStage traitId(@NotNull String traitId) { + this.traitId = Objects.requireNonNull(traitId, "traitId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("trait_value") + public _FinalStage traitValue(@NotNull String traitValue) { + this.traitValue = Objects.requireNonNull(traitValue, "traitValue must not be null"); + return this; + } + + @java.lang.Override + public UpdatePlanTraitTraitRequestBody build() { + return new UpdatePlanTraitTraitRequestBody(traitId, traitValue, additionalProperties); + } + } +} diff --git a/src/main/java/com/schematic/api/types/UpdateRuleRequestBody.java b/src/main/java/com/schematic/api/types/UpdateRuleRequestBody.java index f80aab6..36dd80f 100644 --- a/src/main/java/com/schematic/api/types/UpdateRuleRequestBody.java +++ b/src/main/java/com/schematic/api/types/UpdateRuleRequestBody.java @@ -187,7 +187,9 @@ public _FinalStage value(boolean value) { @java.lang.Override public _FinalStage addAllConditions(List conditions) { - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @@ -201,13 +203,17 @@ public _FinalStage addConditions(CreateOrUpdateConditionRequestBody conditions) @JsonSetter(value = "conditions", nulls = Nulls.SKIP) public _FinalStage conditions(List conditions) { this.conditions.clear(); - this.conditions.addAll(conditions); + if (conditions != null) { + this.conditions.addAll(conditions); + } return this; } @java.lang.Override public _FinalStage addAllConditionGroups(List conditionGroups) { - this.conditionGroups.addAll(conditionGroups); + if (conditionGroups != null) { + this.conditionGroups.addAll(conditionGroups); + } return this; } @@ -221,7 +227,9 @@ public _FinalStage addConditionGroups(CreateOrUpdateConditionGroupRequestBody co @JsonSetter(value = "condition_groups", nulls = Nulls.SKIP) public _FinalStage conditionGroups(List conditionGroups) { this.conditionGroups.clear(); - this.conditionGroups.addAll(conditionGroups); + if (conditionGroups != null) { + this.conditionGroups.addAll(conditionGroups); + } return this; } diff --git a/src/main/java/com/schematic/api/types/UpsertCompanyRequestBody.java b/src/main/java/com/schematic/api/types/UpsertCompanyRequestBody.java index 4af9d30..ab21a03 100644 --- a/src/main/java/com/schematic/api/types/UpsertCompanyRequestBody.java +++ b/src/main/java/com/schematic/api/types/UpsertCompanyRequestBody.java @@ -62,6 +62,9 @@ public Optional getId() { return id; } + /** + * @return See Key Management for more information + */ @JsonProperty("keys") public Map getKeys() { return keys; @@ -153,6 +156,9 @@ public Builder from(UpsertCompanyRequestBody other) { return this; } + /** + *

If you know the Schematic ID, you can use that here instead of keys

+ */ @JsonSetter(value = "id", nulls = Nulls.SKIP) public Builder id(Optional id) { this.id = id; @@ -164,15 +170,22 @@ public Builder id(String id) { return this; } + /** + *

See Key Management for more information

+ */ @JsonSetter(value = "keys", nulls = Nulls.SKIP) public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } @@ -203,6 +216,9 @@ public Builder name(String name) { return this; } + /** + *

A map of trait names to trait values

+ */ @JsonSetter(value = "traits", nulls = Nulls.SKIP) public Builder traits(Optional> traits) { this.traits = traits; diff --git a/src/main/java/com/schematic/api/types/UpsertTraitRequestBody.java b/src/main/java/com/schematic/api/types/UpsertTraitRequestBody.java index dc03bb6..857c4c8 100644 --- a/src/main/java/com/schematic/api/types/UpsertTraitRequestBody.java +++ b/src/main/java/com/schematic/api/types/UpsertTraitRequestBody.java @@ -58,7 +58,7 @@ public Optional getIncr() { } /** - * @return Key/value pairs too identify a company or user + * @return Key/value pairs to identify a company or user */ @JsonProperty("keys") public Map getKeys() { @@ -123,6 +123,9 @@ public static TraitStage builder() { } public interface TraitStage { + /** + *

Name of the trait to update

+ */ _FinalStage trait(@NotNull String trait); Builder from(UpsertTraitRequestBody other); @@ -131,20 +134,32 @@ public interface TraitStage { public interface _FinalStage { UpsertTraitRequestBody build(); + /** + *

Amount to increment the trait by (positive or negative)

+ */ _FinalStage incr(Optional incr); _FinalStage incr(Integer incr); + /** + *

Key/value pairs to identify a company or user

+ */ _FinalStage keys(Map keys); _FinalStage putAllKeys(Map keys); _FinalStage keys(String key, String value); + /** + *

Value to set the trait to

+ */ _FinalStage set(Optional set); _FinalStage set(String set); + /** + *

Unless this is set, the company or user will be created if it does not already exist

+ */ _FinalStage updateOnly(Optional updateOnly); _FinalStage updateOnly(Boolean updateOnly); @@ -178,6 +193,7 @@ public Builder from(UpsertTraitRequestBody other) { } /** + *

Name of the trait to update

*

Name of the trait to update

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -198,6 +214,9 @@ public _FinalStage updateOnly(Boolean updateOnly) { return this; } + /** + *

Unless this is set, the company or user will be created if it does not already exist

+ */ @java.lang.Override @JsonSetter(value = "update_only", nulls = Nulls.SKIP) public _FinalStage updateOnly(Optional updateOnly) { @@ -215,6 +234,9 @@ public _FinalStage set(String set) { return this; } + /** + *

Value to set the trait to

+ */ @java.lang.Override @JsonSetter(value = "set", nulls = Nulls.SKIP) public _FinalStage set(Optional set) { @@ -223,7 +245,7 @@ public _FinalStage set(Optional set) { } /** - *

Key/value pairs too identify a company or user

+ *

Key/value pairs to identify a company or user

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -233,20 +255,27 @@ public _FinalStage keys(String key, String value) { } /** - *

Key/value pairs too identify a company or user

+ *

Key/value pairs to identify a company or user

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override public _FinalStage putAllKeys(Map keys) { - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } + /** + *

Key/value pairs to identify a company or user

+ */ @java.lang.Override @JsonSetter(value = "keys", nulls = Nulls.SKIP) public _FinalStage keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } @@ -260,6 +289,9 @@ public _FinalStage incr(Integer incr) { return this; } + /** + *

Amount to increment the trait by (positive or negative)

+ */ @java.lang.Override @JsonSetter(value = "incr", nulls = Nulls.SKIP) public _FinalStage incr(Optional incr) { diff --git a/src/main/java/com/schematic/api/types/UpsertUserRequestBody.java b/src/main/java/com/schematic/api/types/UpsertUserRequestBody.java index f291232..89ac973 100644 --- a/src/main/java/com/schematic/api/types/UpsertUserRequestBody.java +++ b/src/main/java/com/schematic/api/types/UpsertUserRequestBody.java @@ -16,6 +16,7 @@ import java.time.OffsetDateTime; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,10 +24,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpsertUserRequestBody.Builder.class) public final class UpsertUserRequestBody { - private final Map company; + private final Optional>> companies; + + private final Optional> company; private final Optional companyId; + private final Optional> companyIds; + private final Optional id; private final Map keys; @@ -42,8 +47,10 @@ public final class UpsertUserRequestBody { private final Map additionalProperties; private UpsertUserRequestBody( - Map company, + Optional>> companies, + Optional> company, Optional companyId, + Optional> companyIds, Optional id, Map keys, Optional lastSeenAt, @@ -51,8 +58,10 @@ private UpsertUserRequestBody( Optional> traits, Optional updateOnly, Map additionalProperties) { + this.companies = companies; this.company = company; this.companyId = companyId; + this.companyIds = companyIds; this.id = id; this.keys = keys; this.lastSeenAt = lastSeenAt; @@ -63,21 +72,37 @@ private UpsertUserRequestBody( } /** - * @return Optionally specify company using key/value pairs + * @return Optionally specify companies using array of key/value pairs + */ + @JsonProperty("companies") + public Optional>> getCompanies() { + return companies; + } + + /** + * @return Add user to this company. Takes priority over companies. For exhaustive list of companies, use companies */ @JsonProperty("company") - public Map getCompany() { + public Optional> getCompany() { return company; } /** - * @return Optionally specify company using Schematic company ID + * @return Add user to this company. Takes priority over company_ids. For exhaustive list of companies, use company_ids */ @JsonProperty("company_id") public Optional getCompanyId() { return companyId; } + /** + * @return Optionally specify companies using Schematic company ID + */ + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + /** * @return If you know the Schematic ID, you can use that here instead of keys */ @@ -86,6 +111,9 @@ public Optional getId() { return id; } + /** + * @return See Key Management for more information + */ @JsonProperty("keys") public Map getKeys() { return keys; @@ -126,8 +154,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpsertUserRequestBody other) { - return company.equals(other.company) + return companies.equals(other.companies) + && company.equals(other.company) && companyId.equals(other.companyId) + && companyIds.equals(other.companyIds) && id.equals(other.id) && keys.equals(other.keys) && lastSeenAt.equals(other.lastSeenAt) @@ -139,8 +169,10 @@ private boolean equalTo(UpsertUserRequestBody other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.companies, this.company, this.companyId, + this.companyIds, this.id, this.keys, this.lastSeenAt, @@ -160,10 +192,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Map company = new LinkedHashMap<>(); + private Optional>> companies = Optional.empty(); + + private Optional> company = Optional.empty(); private Optional companyId = Optional.empty(); + private Optional> companyIds = Optional.empty(); + private Optional id = Optional.empty(); private Map keys = new LinkedHashMap<>(); @@ -182,8 +218,10 @@ public static final class Builder { private Builder() {} public Builder from(UpsertUserRequestBody other) { + companies(other.getCompanies()); company(other.getCompany()); companyId(other.getCompanyId()); + companyIds(other.getCompanyIds()); id(other.getId()); keys(other.getKeys()); lastSeenAt(other.getLastSeenAt()); @@ -193,23 +231,37 @@ public Builder from(UpsertUserRequestBody other) { return this; } - @JsonSetter(value = "company", nulls = Nulls.SKIP) - public Builder company(Map company) { - this.company.clear(); - this.company.putAll(company); + /** + *

Optionally specify companies using array of key/value pairs

+ */ + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional>> companies) { + this.companies = companies; return this; } - public Builder putAllCompany(Map company) { - this.company.putAll(company); + public Builder companies(List> companies) { + this.companies = Optional.ofNullable(companies); return this; } - public Builder company(String key, String value) { - this.company.put(key, value); + /** + *

Add user to this company. Takes priority over companies. For exhaustive list of companies, use companies

+ */ + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public Builder company(Optional> company) { + this.company = company; + return this; + } + + public Builder company(Map company) { + this.company = Optional.ofNullable(company); return this; } + /** + *

Add user to this company. Takes priority over company_ids. For exhaustive list of companies, use company_ids

+ */ @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -221,6 +273,23 @@ public Builder companyId(String companyId) { return this; } + /** + *

Optionally specify companies using Schematic company ID

+ */ + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; + return this; + } + + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); + return this; + } + + /** + *

If you know the Schematic ID, you can use that here instead of keys

+ */ @JsonSetter(value = "id", nulls = Nulls.SKIP) public Builder id(Optional id) { this.id = id; @@ -232,15 +301,22 @@ public Builder id(String id) { return this; } + /** + *

See Key Management for more information

+ */ @JsonSetter(value = "keys", nulls = Nulls.SKIP) public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } @@ -271,6 +347,9 @@ public Builder name(String name) { return this; } + /** + *

A map of trait names to trait values

+ */ @JsonSetter(value = "traits", nulls = Nulls.SKIP) public Builder traits(Optional> traits) { this.traits = traits; @@ -295,7 +374,17 @@ public Builder updateOnly(Boolean updateOnly) { public UpsertUserRequestBody build() { return new UpsertUserRequestBody( - company, companyId, id, keys, lastSeenAt, name, traits, updateOnly, additionalProperties); + companies, + company, + companyId, + companyIds, + id, + keys, + lastSeenAt, + name, + traits, + updateOnly, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/UpsertUserSubRequestBody.java b/src/main/java/com/schematic/api/types/UpsertUserSubRequestBody.java index aa9fb17..6a1a8e1 100644 --- a/src/main/java/com/schematic/api/types/UpsertUserSubRequestBody.java +++ b/src/main/java/com/schematic/api/types/UpsertUserSubRequestBody.java @@ -16,6 +16,7 @@ import java.time.OffsetDateTime; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -25,6 +26,8 @@ public final class UpsertUserSubRequestBody { private final Optional companyId; + private final Optional> companyIds; + private final Optional id; private final Map keys; @@ -41,6 +44,7 @@ public final class UpsertUserSubRequestBody { private UpsertUserSubRequestBody( Optional companyId, + Optional> companyIds, Optional id, Map keys, Optional lastSeenAt, @@ -49,6 +53,7 @@ private UpsertUserSubRequestBody( Optional updateOnly, Map additionalProperties) { this.companyId = companyId; + this.companyIds = companyIds; this.id = id; this.keys = keys; this.lastSeenAt = lastSeenAt; @@ -59,13 +64,21 @@ private UpsertUserSubRequestBody( } /** - * @return Optionally specify company using Schematic company ID + * @return Add user to this company. Takes priority over company_ids. For exhaustive list of companies, use company_ids */ @JsonProperty("company_id") public Optional getCompanyId() { return companyId; } + /** + * @return Optionally specify companies using Schematic company ID + */ + @JsonProperty("company_ids") + public Optional> getCompanyIds() { + return companyIds; + } + /** * @return If you know the Schematic ID, you can use that here instead of keys */ @@ -74,6 +87,9 @@ public Optional getId() { return id; } + /** + * @return See Key Management for more information + */ @JsonProperty("keys") public Map getKeys() { return keys; @@ -115,6 +131,7 @@ public Map getAdditionalProperties() { private boolean equalTo(UpsertUserSubRequestBody other) { return companyId.equals(other.companyId) + && companyIds.equals(other.companyIds) && id.equals(other.id) && keys.equals(other.keys) && lastSeenAt.equals(other.lastSeenAt) @@ -126,7 +143,14 @@ private boolean equalTo(UpsertUserSubRequestBody other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.companyId, this.id, this.keys, this.lastSeenAt, this.name, this.traits, this.updateOnly); + this.companyId, + this.companyIds, + this.id, + this.keys, + this.lastSeenAt, + this.name, + this.traits, + this.updateOnly); } @java.lang.Override @@ -142,6 +166,8 @@ public static Builder builder() { public static final class Builder { private Optional companyId = Optional.empty(); + private Optional> companyIds = Optional.empty(); + private Optional id = Optional.empty(); private Map keys = new LinkedHashMap<>(); @@ -161,6 +187,7 @@ private Builder() {} public Builder from(UpsertUserSubRequestBody other) { companyId(other.getCompanyId()); + companyIds(other.getCompanyIds()); id(other.getId()); keys(other.getKeys()); lastSeenAt(other.getLastSeenAt()); @@ -170,6 +197,9 @@ public Builder from(UpsertUserSubRequestBody other) { return this; } + /** + *

Add user to this company. Takes priority over company_ids. For exhaustive list of companies, use company_ids

+ */ @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -181,6 +211,23 @@ public Builder companyId(String companyId) { return this; } + /** + *

Optionally specify companies using Schematic company ID

+ */ + @JsonSetter(value = "company_ids", nulls = Nulls.SKIP) + public Builder companyIds(Optional> companyIds) { + this.companyIds = companyIds; + return this; + } + + public Builder companyIds(List companyIds) { + this.companyIds = Optional.ofNullable(companyIds); + return this; + } + + /** + *

If you know the Schematic ID, you can use that here instead of keys

+ */ @JsonSetter(value = "id", nulls = Nulls.SKIP) public Builder id(Optional id) { this.id = id; @@ -192,15 +239,22 @@ public Builder id(String id) { return this; } + /** + *

See Key Management for more information

+ */ @JsonSetter(value = "keys", nulls = Nulls.SKIP) public Builder keys(Map keys) { this.keys.clear(); - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } public Builder putAllKeys(Map keys) { - this.keys.putAll(keys); + if (keys != null) { + this.keys.putAll(keys); + } return this; } @@ -231,6 +285,9 @@ public Builder name(String name) { return this; } + /** + *

A map of trait names to trait values

+ */ @JsonSetter(value = "traits", nulls = Nulls.SKIP) public Builder traits(Optional> traits) { this.traits = traits; @@ -255,7 +312,7 @@ public Builder updateOnly(Boolean updateOnly) { public UpsertUserSubRequestBody build() { return new UpsertUserSubRequestBody( - companyId, id, keys, lastSeenAt, name, traits, updateOnly, additionalProperties); + companyId, companyIds, id, keys, lastSeenAt, name, traits, updateOnly, additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/UsageBasedEntitlementRequestBody.java b/src/main/java/com/schematic/api/types/UsageBasedEntitlementRequestBody.java index d72dcc3..6f12001 100644 --- a/src/main/java/com/schematic/api/types/UsageBasedEntitlementRequestBody.java +++ b/src/main/java/com/schematic/api/types/UsageBasedEntitlementRequestBody.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.schematic.api.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,49 +21,160 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UsageBasedEntitlementRequestBody.Builder.class) public final class UsageBasedEntitlementRequestBody { + private final Optional billingProductId; + + private final Optional billingThreshold; + + private final Optional currency; + private final Optional monthlyMeteredPriceId; - private final Optional priceBehavior; + private final Optional> monthlyPriceTiers; + + private final Optional monthlyUnitPrice; + + private final Optional monthlyUnitPriceDecimal; + + private final Optional overageBillingProductId; + + private final Optional priceBehavior; + + private final Optional> priceTiers; private final Optional softLimit; + private final Optional tierMode; + private final Optional yearlyMeteredPriceId; + private final Optional> yearlyPriceTiers; + + private final Optional yearlyUnitPrice; + + private final Optional yearlyUnitPriceDecimal; + private final Map additionalProperties; private UsageBasedEntitlementRequestBody( + Optional billingProductId, + Optional billingThreshold, + Optional currency, Optional monthlyMeteredPriceId, - Optional priceBehavior, + Optional> monthlyPriceTiers, + Optional monthlyUnitPrice, + Optional monthlyUnitPriceDecimal, + Optional overageBillingProductId, + Optional priceBehavior, + Optional> priceTiers, Optional softLimit, + Optional tierMode, Optional yearlyMeteredPriceId, + Optional> yearlyPriceTiers, + Optional yearlyUnitPrice, + Optional yearlyUnitPriceDecimal, Map additionalProperties) { + this.billingProductId = billingProductId; + this.billingThreshold = billingThreshold; + this.currency = currency; this.monthlyMeteredPriceId = monthlyMeteredPriceId; + this.monthlyPriceTiers = monthlyPriceTiers; + this.monthlyUnitPrice = monthlyUnitPrice; + this.monthlyUnitPriceDecimal = monthlyUnitPriceDecimal; + this.overageBillingProductId = overageBillingProductId; this.priceBehavior = priceBehavior; + this.priceTiers = priceTiers; this.softLimit = softLimit; + this.tierMode = tierMode; this.yearlyMeteredPriceId = yearlyMeteredPriceId; + this.yearlyPriceTiers = yearlyPriceTiers; + this.yearlyUnitPrice = yearlyUnitPrice; + this.yearlyUnitPriceDecimal = yearlyUnitPriceDecimal; this.additionalProperties = additionalProperties; } + @JsonProperty("billing_product_id") + public Optional getBillingProductId() { + return billingProductId; + } + + @JsonProperty("billing_threshold") + public Optional getBillingThreshold() { + return billingThreshold; + } + + @JsonProperty("currency") + public Optional getCurrency() { + return currency; + } + @JsonProperty("monthly_metered_price_id") public Optional getMonthlyMeteredPriceId() { return monthlyMeteredPriceId; } + @JsonProperty("monthly_price_tiers") + public Optional> getMonthlyPriceTiers() { + return monthlyPriceTiers; + } + + @JsonProperty("monthly_unit_price") + public Optional getMonthlyUnitPrice() { + return monthlyUnitPrice; + } + + @JsonProperty("monthly_unit_price_decimal") + public Optional getMonthlyUnitPriceDecimal() { + return monthlyUnitPriceDecimal; + } + + @JsonProperty("overage_billing_product_id") + public Optional getOverageBillingProductId() { + return overageBillingProductId; + } + @JsonProperty("price_behavior") - public Optional getPriceBehavior() { + public Optional getPriceBehavior() { return priceBehavior; } + /** + * @return Use MonthlyPriceTiers or YearlyPriceTiers instead + */ + @JsonProperty("price_tiers") + public Optional> getPriceTiers() { + return priceTiers; + } + @JsonProperty("soft_limit") public Optional getSoftLimit() { return softLimit; } + @JsonProperty("tier_mode") + public Optional getTierMode() { + return tierMode; + } + @JsonProperty("yearly_metered_price_id") public Optional getYearlyMeteredPriceId() { return yearlyMeteredPriceId; } + @JsonProperty("yearly_price_tiers") + public Optional> getYearlyPriceTiers() { + return yearlyPriceTiers; + } + + @JsonProperty("yearly_unit_price") + public Optional getYearlyUnitPrice() { + return yearlyUnitPrice; + } + + @JsonProperty("yearly_unit_price_decimal") + public Optional getYearlyUnitPriceDecimal() { + return yearlyUnitPriceDecimal; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -75,15 +187,43 @@ public Map getAdditionalProperties() { } private boolean equalTo(UsageBasedEntitlementRequestBody other) { - return monthlyMeteredPriceId.equals(other.monthlyMeteredPriceId) + return billingProductId.equals(other.billingProductId) + && billingThreshold.equals(other.billingThreshold) + && currency.equals(other.currency) + && monthlyMeteredPriceId.equals(other.monthlyMeteredPriceId) + && monthlyPriceTiers.equals(other.monthlyPriceTiers) + && monthlyUnitPrice.equals(other.monthlyUnitPrice) + && monthlyUnitPriceDecimal.equals(other.monthlyUnitPriceDecimal) + && overageBillingProductId.equals(other.overageBillingProductId) && priceBehavior.equals(other.priceBehavior) + && priceTiers.equals(other.priceTiers) && softLimit.equals(other.softLimit) - && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId); + && tierMode.equals(other.tierMode) + && yearlyMeteredPriceId.equals(other.yearlyMeteredPriceId) + && yearlyPriceTiers.equals(other.yearlyPriceTiers) + && yearlyUnitPrice.equals(other.yearlyUnitPrice) + && yearlyUnitPriceDecimal.equals(other.yearlyUnitPriceDecimal); } @java.lang.Override public int hashCode() { - return Objects.hash(this.monthlyMeteredPriceId, this.priceBehavior, this.softLimit, this.yearlyMeteredPriceId); + return Objects.hash( + this.billingProductId, + this.billingThreshold, + this.currency, + this.monthlyMeteredPriceId, + this.monthlyPriceTiers, + this.monthlyUnitPrice, + this.monthlyUnitPriceDecimal, + this.overageBillingProductId, + this.priceBehavior, + this.priceTiers, + this.softLimit, + this.tierMode, + this.yearlyMeteredPriceId, + this.yearlyPriceTiers, + this.yearlyUnitPrice, + this.yearlyUnitPriceDecimal); } @java.lang.Override @@ -97,24 +237,93 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional billingProductId = Optional.empty(); + + private Optional billingThreshold = Optional.empty(); + + private Optional currency = Optional.empty(); + private Optional monthlyMeteredPriceId = Optional.empty(); - private Optional priceBehavior = Optional.empty(); + private Optional> monthlyPriceTiers = Optional.empty(); + + private Optional monthlyUnitPrice = Optional.empty(); + + private Optional monthlyUnitPriceDecimal = Optional.empty(); + + private Optional overageBillingProductId = Optional.empty(); + + private Optional priceBehavior = Optional.empty(); + + private Optional> priceTiers = Optional.empty(); private Optional softLimit = Optional.empty(); + private Optional tierMode = Optional.empty(); + private Optional yearlyMeteredPriceId = Optional.empty(); + private Optional> yearlyPriceTiers = Optional.empty(); + + private Optional yearlyUnitPrice = Optional.empty(); + + private Optional yearlyUnitPriceDecimal = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} public Builder from(UsageBasedEntitlementRequestBody other) { + billingProductId(other.getBillingProductId()); + billingThreshold(other.getBillingThreshold()); + currency(other.getCurrency()); monthlyMeteredPriceId(other.getMonthlyMeteredPriceId()); + monthlyPriceTiers(other.getMonthlyPriceTiers()); + monthlyUnitPrice(other.getMonthlyUnitPrice()); + monthlyUnitPriceDecimal(other.getMonthlyUnitPriceDecimal()); + overageBillingProductId(other.getOverageBillingProductId()); priceBehavior(other.getPriceBehavior()); + priceTiers(other.getPriceTiers()); softLimit(other.getSoftLimit()); + tierMode(other.getTierMode()); yearlyMeteredPriceId(other.getYearlyMeteredPriceId()); + yearlyPriceTiers(other.getYearlyPriceTiers()); + yearlyUnitPrice(other.getYearlyUnitPrice()); + yearlyUnitPriceDecimal(other.getYearlyUnitPriceDecimal()); + return this; + } + + @JsonSetter(value = "billing_product_id", nulls = Nulls.SKIP) + public Builder billingProductId(Optional billingProductId) { + this.billingProductId = billingProductId; + return this; + } + + public Builder billingProductId(String billingProductId) { + this.billingProductId = Optional.ofNullable(billingProductId); + return this; + } + + @JsonSetter(value = "billing_threshold", nulls = Nulls.SKIP) + public Builder billingThreshold(Optional billingThreshold) { + this.billingThreshold = billingThreshold; + return this; + } + + public Builder billingThreshold(Integer billingThreshold) { + this.billingThreshold = Optional.ofNullable(billingThreshold); + return this; + } + + @JsonSetter(value = "currency", nulls = Nulls.SKIP) + public Builder currency(Optional currency) { + this.currency = currency; + return this; + } + + public Builder currency(String currency) { + this.currency = Optional.ofNullable(currency); return this; } @@ -129,17 +338,75 @@ public Builder monthlyMeteredPriceId(String monthlyMeteredPriceId) { return this; } + @JsonSetter(value = "monthly_price_tiers", nulls = Nulls.SKIP) + public Builder monthlyPriceTiers(Optional> monthlyPriceTiers) { + this.monthlyPriceTiers = monthlyPriceTiers; + return this; + } + + public Builder monthlyPriceTiers(List monthlyPriceTiers) { + this.monthlyPriceTiers = Optional.ofNullable(monthlyPriceTiers); + return this; + } + + @JsonSetter(value = "monthly_unit_price", nulls = Nulls.SKIP) + public Builder monthlyUnitPrice(Optional monthlyUnitPrice) { + this.monthlyUnitPrice = monthlyUnitPrice; + return this; + } + + public Builder monthlyUnitPrice(Integer monthlyUnitPrice) { + this.monthlyUnitPrice = Optional.ofNullable(monthlyUnitPrice); + return this; + } + + @JsonSetter(value = "monthly_unit_price_decimal", nulls = Nulls.SKIP) + public Builder monthlyUnitPriceDecimal(Optional monthlyUnitPriceDecimal) { + this.monthlyUnitPriceDecimal = monthlyUnitPriceDecimal; + return this; + } + + public Builder monthlyUnitPriceDecimal(String monthlyUnitPriceDecimal) { + this.monthlyUnitPriceDecimal = Optional.ofNullable(monthlyUnitPriceDecimal); + return this; + } + + @JsonSetter(value = "overage_billing_product_id", nulls = Nulls.SKIP) + public Builder overageBillingProductId(Optional overageBillingProductId) { + this.overageBillingProductId = overageBillingProductId; + return this; + } + + public Builder overageBillingProductId(String overageBillingProductId) { + this.overageBillingProductId = Optional.ofNullable(overageBillingProductId); + return this; + } + @JsonSetter(value = "price_behavior", nulls = Nulls.SKIP) - public Builder priceBehavior(Optional priceBehavior) { + public Builder priceBehavior(Optional priceBehavior) { this.priceBehavior = priceBehavior; return this; } - public Builder priceBehavior(String priceBehavior) { + public Builder priceBehavior(UsageBasedEntitlementRequestBodyPriceBehavior priceBehavior) { this.priceBehavior = Optional.ofNullable(priceBehavior); return this; } + /** + *

Use MonthlyPriceTiers or YearlyPriceTiers instead

+ */ + @JsonSetter(value = "price_tiers", nulls = Nulls.SKIP) + public Builder priceTiers(Optional> priceTiers) { + this.priceTiers = priceTiers; + return this; + } + + public Builder priceTiers(List priceTiers) { + this.priceTiers = Optional.ofNullable(priceTiers); + return this; + } + @JsonSetter(value = "soft_limit", nulls = Nulls.SKIP) public Builder softLimit(Optional softLimit) { this.softLimit = softLimit; @@ -151,6 +418,17 @@ public Builder softLimit(Integer softLimit) { return this; } + @JsonSetter(value = "tier_mode", nulls = Nulls.SKIP) + public Builder tierMode(Optional tierMode) { + this.tierMode = tierMode; + return this; + } + + public Builder tierMode(String tierMode) { + this.tierMode = Optional.ofNullable(tierMode); + return this; + } + @JsonSetter(value = "yearly_metered_price_id", nulls = Nulls.SKIP) public Builder yearlyMeteredPriceId(Optional yearlyMeteredPriceId) { this.yearlyMeteredPriceId = yearlyMeteredPriceId; @@ -162,9 +440,58 @@ public Builder yearlyMeteredPriceId(String yearlyMeteredPriceId) { return this; } + @JsonSetter(value = "yearly_price_tiers", nulls = Nulls.SKIP) + public Builder yearlyPriceTiers(Optional> yearlyPriceTiers) { + this.yearlyPriceTiers = yearlyPriceTiers; + return this; + } + + public Builder yearlyPriceTiers(List yearlyPriceTiers) { + this.yearlyPriceTiers = Optional.ofNullable(yearlyPriceTiers); + return this; + } + + @JsonSetter(value = "yearly_unit_price", nulls = Nulls.SKIP) + public Builder yearlyUnitPrice(Optional yearlyUnitPrice) { + this.yearlyUnitPrice = yearlyUnitPrice; + return this; + } + + public Builder yearlyUnitPrice(Integer yearlyUnitPrice) { + this.yearlyUnitPrice = Optional.ofNullable(yearlyUnitPrice); + return this; + } + + @JsonSetter(value = "yearly_unit_price_decimal", nulls = Nulls.SKIP) + public Builder yearlyUnitPriceDecimal(Optional yearlyUnitPriceDecimal) { + this.yearlyUnitPriceDecimal = yearlyUnitPriceDecimal; + return this; + } + + public Builder yearlyUnitPriceDecimal(String yearlyUnitPriceDecimal) { + this.yearlyUnitPriceDecimal = Optional.ofNullable(yearlyUnitPriceDecimal); + return this; + } + public UsageBasedEntitlementRequestBody build() { return new UsageBasedEntitlementRequestBody( - monthlyMeteredPriceId, priceBehavior, softLimit, yearlyMeteredPriceId, additionalProperties); + billingProductId, + billingThreshold, + currency, + monthlyMeteredPriceId, + monthlyPriceTiers, + monthlyUnitPrice, + monthlyUnitPriceDecimal, + overageBillingProductId, + priceBehavior, + priceTiers, + softLimit, + tierMode, + yearlyMeteredPriceId, + yearlyPriceTiers, + yearlyUnitPrice, + yearlyUnitPriceDecimal, + additionalProperties); } } } diff --git a/src/main/java/com/schematic/api/types/UsageBasedEntitlementRequestBodyPriceBehavior.java b/src/main/java/com/schematic/api/types/UsageBasedEntitlementRequestBodyPriceBehavior.java new file mode 100644 index 0000000..0a8299c --- /dev/null +++ b/src/main/java/com/schematic/api/types/UsageBasedEntitlementRequestBodyPriceBehavior.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class UsageBasedEntitlementRequestBodyPriceBehavior { + public static final UsageBasedEntitlementRequestBodyPriceBehavior TIER = + new UsageBasedEntitlementRequestBodyPriceBehavior(Value.TIER, "tier"); + + public static final UsageBasedEntitlementRequestBodyPriceBehavior CREDIT_BURNDOWN = + new UsageBasedEntitlementRequestBodyPriceBehavior(Value.CREDIT_BURNDOWN, "credit_burndown"); + + public static final UsageBasedEntitlementRequestBodyPriceBehavior OVERAGE = + new UsageBasedEntitlementRequestBodyPriceBehavior(Value.OVERAGE, "overage"); + + public static final UsageBasedEntitlementRequestBodyPriceBehavior PAY_AS_YOU_GO = + new UsageBasedEntitlementRequestBodyPriceBehavior(Value.PAY_AS_YOU_GO, "pay_as_you_go"); + + public static final UsageBasedEntitlementRequestBodyPriceBehavior PAY_IN_ADVANCE = + new UsageBasedEntitlementRequestBodyPriceBehavior(Value.PAY_IN_ADVANCE, "pay_in_advance"); + + private final Value value; + + private final String string; + + UsageBasedEntitlementRequestBodyPriceBehavior(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof UsageBasedEntitlementRequestBodyPriceBehavior + && this.string.equals(((UsageBasedEntitlementRequestBodyPriceBehavior) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case TIER: + return visitor.visitTier(); + case CREDIT_BURNDOWN: + return visitor.visitCreditBurndown(); + case OVERAGE: + return visitor.visitOverage(); + case PAY_AS_YOU_GO: + return visitor.visitPayAsYouGo(); + case PAY_IN_ADVANCE: + return visitor.visitPayInAdvance(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static UsageBasedEntitlementRequestBodyPriceBehavior valueOf(String value) { + switch (value) { + case "tier": + return TIER; + case "credit_burndown": + return CREDIT_BURNDOWN; + case "overage": + return OVERAGE; + case "pay_as_you_go": + return PAY_AS_YOU_GO; + case "pay_in_advance": + return PAY_IN_ADVANCE; + default: + return new UsageBasedEntitlementRequestBodyPriceBehavior(Value.UNKNOWN, value); + } + } + + public enum Value { + PAY_AS_YOU_GO, + + PAY_IN_ADVANCE, + + OVERAGE, + + CREDIT_BURNDOWN, + + TIER, + + UNKNOWN + } + + public interface Visitor { + T visitPayAsYouGo(); + + T visitPayInAdvance(); + + T visitOverage(); + + T visitCreditBurndown(); + + T visitTier(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/schematic/api/types/UsageBasedEntitlementResponseData.java b/src/main/java/com/schematic/api/types/UsageBasedEntitlementResponseData.java index 2df8855..82a011e 100644 --- a/src/main/java/com/schematic/api/types/UsageBasedEntitlementResponseData.java +++ b/src/main/java/com/schematic/api/types/UsageBasedEntitlementResponseData.java @@ -21,6 +21,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UsageBasedEntitlementResponseData.Builder.class) public final class UsageBasedEntitlementResponseData { + private final Optional billingThreshold; + + private final Optional consumptionRate; + private final String featureId; private final Optional meteredPrice; @@ -44,6 +48,8 @@ public final class UsageBasedEntitlementResponseData { private final Map additionalProperties; private UsageBasedEntitlementResponseData( + Optional billingThreshold, + Optional consumptionRate, String featureId, Optional meteredPrice, Optional metricPeriod, @@ -55,6 +61,8 @@ private UsageBasedEntitlementResponseData( String valueType, Optional yearlyUsageBasedPrice, Map additionalProperties) { + this.billingThreshold = billingThreshold; + this.consumptionRate = consumptionRate; this.featureId = featureId; this.meteredPrice = meteredPrice; this.metricPeriod = metricPeriod; @@ -68,6 +76,16 @@ private UsageBasedEntitlementResponseData( this.additionalProperties = additionalProperties; } + @JsonProperty("billing_threshold") + public Optional getBillingThreshold() { + return billingThreshold; + } + + @JsonProperty("consumption_rate") + public Optional getConsumptionRate() { + return consumptionRate; + } + @JsonProperty("feature_id") public String getFeatureId() { return featureId; @@ -130,7 +148,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(UsageBasedEntitlementResponseData other) { - return featureId.equals(other.featureId) + return billingThreshold.equals(other.billingThreshold) + && consumptionRate.equals(other.consumptionRate) + && featureId.equals(other.featureId) && meteredPrice.equals(other.meteredPrice) && metricPeriod.equals(other.metricPeriod) && metricPeriodMonthReset.equals(other.metricPeriodMonthReset) @@ -145,6 +165,8 @@ private boolean equalTo(UsageBasedEntitlementResponseData other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.billingThreshold, + this.consumptionRate, this.featureId, this.meteredPrice, this.metricPeriod, @@ -179,6 +201,14 @@ public interface ValueTypeStage { public interface _FinalStage { UsageBasedEntitlementResponseData build(); + _FinalStage billingThreshold(Optional billingThreshold); + + _FinalStage billingThreshold(Integer billingThreshold); + + _FinalStage consumptionRate(Optional consumptionRate); + + _FinalStage consumptionRate(Double consumptionRate); + _FinalStage meteredPrice(Optional meteredPrice); _FinalStage meteredPrice(BillingPriceView meteredPrice); @@ -234,6 +264,10 @@ public static final class Builder implements FeatureIdStage, ValueTypeStage, _Fi private Optional meteredPrice = Optional.empty(); + private Optional consumptionRate = Optional.empty(); + + private Optional billingThreshold = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -241,6 +275,8 @@ private Builder() {} @java.lang.Override public Builder from(UsageBasedEntitlementResponseData other) { + billingThreshold(other.getBillingThreshold()); + consumptionRate(other.getConsumptionRate()); featureId(other.getFeatureId()); meteredPrice(other.getMeteredPrice()); metricPeriod(other.getMetricPeriod()); @@ -372,9 +408,37 @@ public _FinalStage meteredPrice(Optional meteredPrice) { return this; } + @java.lang.Override + public _FinalStage consumptionRate(Double consumptionRate) { + this.consumptionRate = Optional.ofNullable(consumptionRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "consumption_rate", nulls = Nulls.SKIP) + public _FinalStage consumptionRate(Optional consumptionRate) { + this.consumptionRate = consumptionRate; + return this; + } + + @java.lang.Override + public _FinalStage billingThreshold(Integer billingThreshold) { + this.billingThreshold = Optional.ofNullable(billingThreshold); + return this; + } + + @java.lang.Override + @JsonSetter(value = "billing_threshold", nulls = Nulls.SKIP) + public _FinalStage billingThreshold(Optional billingThreshold) { + this.billingThreshold = billingThreshold; + return this; + } + @java.lang.Override public UsageBasedEntitlementResponseData build() { return new UsageBasedEntitlementResponseData( + billingThreshold, + consumptionRate, featureId, meteredPrice, metricPeriod, diff --git a/src/main/java/com/schematic/api/types/UserDetailResponseData.java b/src/main/java/com/schematic/api/types/UserDetailResponseData.java index 5d0879d..6a7614d 100644 --- a/src/main/java/com/schematic/api/types/UserDetailResponseData.java +++ b/src/main/java/com/schematic/api/types/UserDetailResponseData.java @@ -220,6 +220,9 @@ public interface _FinalStage { _FinalStage lastSeenAt(OffsetDateTime lastSeenAt); + /** + *

A map of trait names to trait values

+ */ _FinalStage traits(Optional> traits); _FinalStage traits(Map traits); @@ -313,6 +316,9 @@ public _FinalStage traits(Map traits) { return this; } + /** + *

A map of trait names to trait values

+ */ @java.lang.Override @JsonSetter(value = "traits", nulls = Nulls.SKIP) public _FinalStage traits(Optional> traits) { @@ -335,7 +341,9 @@ public _FinalStage lastSeenAt(Optional lastSeenAt) { @java.lang.Override public _FinalStage addAllKeys(List keys) { - this.keys.addAll(keys); + if (keys != null) { + this.keys.addAll(keys); + } return this; } @@ -349,13 +357,17 @@ public _FinalStage addKeys(EntityKeyDetailResponseData keys) { @JsonSetter(value = "keys", nulls = Nulls.SKIP) public _FinalStage keys(List keys) { this.keys.clear(); - this.keys.addAll(keys); + if (keys != null) { + this.keys.addAll(keys); + } return this; } @java.lang.Override public _FinalStage addAllEntityTraits(List entityTraits) { - this.entityTraits.addAll(entityTraits); + if (entityTraits != null) { + this.entityTraits.addAll(entityTraits); + } return this; } @@ -369,13 +381,17 @@ public _FinalStage addEntityTraits(EntityTraitDetailResponseData entityTraits) { @JsonSetter(value = "entity_traits", nulls = Nulls.SKIP) public _FinalStage entityTraits(List entityTraits) { this.entityTraits.clear(); - this.entityTraits.addAll(entityTraits); + if (entityTraits != null) { + this.entityTraits.addAll(entityTraits); + } return this; } @java.lang.Override public _FinalStage addAllCompanyMemberships(List companyMemberships) { - this.companyMemberships.addAll(companyMemberships); + if (companyMemberships != null) { + this.companyMemberships.addAll(companyMemberships); + } return this; } @@ -389,7 +405,9 @@ public _FinalStage addCompanyMemberships(CompanyMembershipDetailResponseData com @JsonSetter(value = "company_memberships", nulls = Nulls.SKIP) public _FinalStage companyMemberships(List companyMemberships) { this.companyMemberships.clear(); - this.companyMemberships.addAll(companyMemberships); + if (companyMemberships != null) { + this.companyMemberships.addAll(companyMemberships); + } return this; } diff --git a/src/main/java/com/schematic/api/types/WebhookResponseData.java b/src/main/java/com/schematic/api/types/WebhookResponseData.java index 74a414b..1c800ae 100644 --- a/src/main/java/com/schematic/api/types/WebhookResponseData.java +++ b/src/main/java/com/schematic/api/types/WebhookResponseData.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -25,6 +26,10 @@ public final class WebhookResponseData { private final OffsetDateTime createdAt; + private final Optional> creditTriggerConfigs; + + private final Optional> entitlementTriggerConfigs; + private final String id; private final String name; @@ -43,6 +48,8 @@ public final class WebhookResponseData { private WebhookResponseData( OffsetDateTime createdAt, + Optional> creditTriggerConfigs, + Optional> entitlementTriggerConfigs, String id, String name, List requestTypes, @@ -52,6 +59,8 @@ private WebhookResponseData( String url, Map additionalProperties) { this.createdAt = createdAt; + this.creditTriggerConfigs = creditTriggerConfigs; + this.entitlementTriggerConfigs = entitlementTriggerConfigs; this.id = id; this.name = name; this.requestTypes = requestTypes; @@ -67,6 +76,16 @@ public OffsetDateTime getCreatedAt() { return createdAt; } + @JsonProperty("credit_trigger_configs") + public Optional> getCreditTriggerConfigs() { + return creditTriggerConfigs; + } + + @JsonProperty("entitlement_trigger_configs") + public Optional> getEntitlementTriggerConfigs() { + return entitlementTriggerConfigs; + } + @JsonProperty("id") public String getId() { return id; @@ -115,6 +134,8 @@ public Map getAdditionalProperties() { private boolean equalTo(WebhookResponseData other) { return createdAt.equals(other.createdAt) + && creditTriggerConfigs.equals(other.creditTriggerConfigs) + && entitlementTriggerConfigs.equals(other.entitlementTriggerConfigs) && id.equals(other.id) && name.equals(other.name) && requestTypes.equals(other.requestTypes) @@ -128,6 +149,8 @@ private boolean equalTo(WebhookResponseData other) { public int hashCode() { return Objects.hash( this.createdAt, + this.creditTriggerConfigs, + this.entitlementTriggerConfigs, this.id, this.name, this.requestTypes, @@ -179,6 +202,14 @@ public interface UrlStage { public interface _FinalStage { WebhookResponseData build(); + _FinalStage creditTriggerConfigs(Optional> creditTriggerConfigs); + + _FinalStage creditTriggerConfigs(List creditTriggerConfigs); + + _FinalStage entitlementTriggerConfigs(Optional> entitlementTriggerConfigs); + + _FinalStage entitlementTriggerConfigs(List entitlementTriggerConfigs); + _FinalStage requestTypes(List requestTypes); _FinalStage addRequestTypes(String requestTypes); @@ -212,6 +243,10 @@ public static final class Builder private List requestTypes = new ArrayList<>(); + private Optional> entitlementTriggerConfigs = Optional.empty(); + + private Optional> creditTriggerConfigs = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -220,6 +255,8 @@ private Builder() {} @java.lang.Override public Builder from(WebhookResponseData other) { createdAt(other.getCreatedAt()); + creditTriggerConfigs(other.getCreditTriggerConfigs()); + entitlementTriggerConfigs(other.getEntitlementTriggerConfigs()); id(other.getId()); name(other.getName()); requestTypes(other.getRequestTypes()); @@ -281,7 +318,9 @@ public _FinalStage url(@NotNull String url) { @java.lang.Override public _FinalStage addAllRequestTypes(List requestTypes) { - this.requestTypes.addAll(requestTypes); + if (requestTypes != null) { + this.requestTypes.addAll(requestTypes); + } return this; } @@ -295,14 +334,53 @@ public _FinalStage addRequestTypes(String requestTypes) { @JsonSetter(value = "request_types", nulls = Nulls.SKIP) public _FinalStage requestTypes(List requestTypes) { this.requestTypes.clear(); - this.requestTypes.addAll(requestTypes); + if (requestTypes != null) { + this.requestTypes.addAll(requestTypes); + } + return this; + } + + @java.lang.Override + public _FinalStage entitlementTriggerConfigs(List entitlementTriggerConfigs) { + this.entitlementTriggerConfigs = Optional.ofNullable(entitlementTriggerConfigs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "entitlement_trigger_configs", nulls = Nulls.SKIP) + public _FinalStage entitlementTriggerConfigs( + Optional> entitlementTriggerConfigs) { + this.entitlementTriggerConfigs = entitlementTriggerConfigs; + return this; + } + + @java.lang.Override + public _FinalStage creditTriggerConfigs(List creditTriggerConfigs) { + this.creditTriggerConfigs = Optional.ofNullable(creditTriggerConfigs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "credit_trigger_configs", nulls = Nulls.SKIP) + public _FinalStage creditTriggerConfigs(Optional> creditTriggerConfigs) { + this.creditTriggerConfigs = creditTriggerConfigs; return this; } @java.lang.Override public WebhookResponseData build() { return new WebhookResponseData( - createdAt, id, name, requestTypes, secret, status, updatedAt, url, additionalProperties); + createdAt, + creditTriggerConfigs, + entitlementTriggerConfigs, + id, + name, + requestTypes, + secret, + status, + updatedAt, + url, + additionalProperties); } } } diff --git a/src/test/java/com/schematic/api/AccesstokensWireTest.java b/src/test/java/com/schematic/api/AccesstokensWireTest.java new file mode 100644 index 0000000..2df0922 --- /dev/null +++ b/src/test/java/com/schematic/api/AccesstokensWireTest.java @@ -0,0 +1,140 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.accesstokens.requests.IssueTemporaryAccessTokenRequestBody; +import com.schematic.api.resources.accesstokens.types.IssueTemporaryAccessTokenResponse; +import java.util.HashMap; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class AccesstokensWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testIssueTemporaryAccessToken() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"api_key_id\":\"api_key_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"resource_type\":\"resource_type\",\"token\":\"token\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + IssueTemporaryAccessTokenResponse response = client.accesstokens() + .issueTemporaryAccessToken(IssueTemporaryAccessTokenRequestBody.builder() + .lookup(new HashMap() { + { + put("key", "value"); + } + }) + .resourceType("company") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"lookup\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"resource_type\": \"company\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"api_key_id\": \"api_key_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"resource_type\": \"resource_type\",\n" + + " \"token\": \"token\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/AccountsWireTest.java b/src/test/java/com/schematic/api/AccountsWireTest.java new file mode 100644 index 0000000..7f1cf74 --- /dev/null +++ b/src/test/java/com/schematic/api/AccountsWireTest.java @@ -0,0 +1,1148 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.accounts.requests.CountApiKeysRequest; +import com.schematic.api.resources.accounts.requests.CountApiRequestsRequest; +import com.schematic.api.resources.accounts.requests.CreateApiKeyRequestBody; +import com.schematic.api.resources.accounts.requests.CreateEnvironmentRequestBody; +import com.schematic.api.resources.accounts.requests.ListApiKeysRequest; +import com.schematic.api.resources.accounts.requests.ListApiRequestsRequest; +import com.schematic.api.resources.accounts.requests.ListEnvironmentsRequest; +import com.schematic.api.resources.accounts.requests.UpdateApiKeyRequestBody; +import com.schematic.api.resources.accounts.requests.UpdateEnvironmentRequestBody; +import com.schematic.api.resources.accounts.types.CountApiKeysResponse; +import com.schematic.api.resources.accounts.types.CountApiRequestsResponse; +import com.schematic.api.resources.accounts.types.CreateApiKeyResponse; +import com.schematic.api.resources.accounts.types.CreateEnvironmentRequestBodyEnvironmentType; +import com.schematic.api.resources.accounts.types.CreateEnvironmentResponse; +import com.schematic.api.resources.accounts.types.DeleteApiKeyResponse; +import com.schematic.api.resources.accounts.types.DeleteEnvironmentResponse; +import com.schematic.api.resources.accounts.types.GetApiKeyResponse; +import com.schematic.api.resources.accounts.types.GetApiRequestResponse; +import com.schematic.api.resources.accounts.types.GetEnvironmentResponse; +import com.schematic.api.resources.accounts.types.ListApiKeysResponse; +import com.schematic.api.resources.accounts.types.ListApiRequestsResponse; +import com.schematic.api.resources.accounts.types.ListEnvironmentsResponse; +import com.schematic.api.resources.accounts.types.QuickstartResponse; +import com.schematic.api.resources.accounts.types.UpdateApiKeyResponse; +import com.schematic.api.resources.accounts.types.UpdateEnvironmentResponse; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class AccountsWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testListApiKeys() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_used_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"scopes\":[\"scopes\"],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"environment_id\":\"environment_id\",\"limit\":1,\"offset\":1,\"require_environment\":true}}")); + ListApiKeysResponse response = client.accounts() + .listApiKeys(ListApiKeysRequest.builder() + .requireEnvironment(true) + .environmentId("environment_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_used_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"scopes\": [\n" + + " \"scopes\"\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"require_environment\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateApiKey() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_used_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"scopes\":[\"scopes\"],\"secret\":\"secret\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateApiKeyResponse response = client.accounts() + .createApiKey(CreateApiKeyRequestBody.builder().name("name").build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"name\": \"name\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_used_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"scopes\": [\n" + + " \"scopes\"\n" + + " ],\n" + + " \"secret\": \"secret\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetApiKey() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_used_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"scopes\":[\"scopes\"],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetApiKeyResponse response = client.accounts().getApiKey("api_key_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_used_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"scopes\": [\n" + + " \"scopes\"\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateApiKey() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_used_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"scopes\":[\"scopes\"],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdateApiKeyResponse response = client.accounts() + .updateApiKey("api_key_id", UpdateApiKeyRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_used_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"scopes\": [\n" + + " \"scopes\"\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteApiKey() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteApiKeyResponse response = client.accounts().deleteApiKey("api_key_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountApiKeys() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"environment_id\":\"environment_id\",\"limit\":1,\"offset\":1,\"require_environment\":true}}")); + CountApiKeysResponse response = client.accounts() + .countApiKeys(CountApiKeysRequest.builder() + .requireEnvironment(true) + .environmentId("environment_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"require_environment\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListApiRequests() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"api_key_id\":\"api_key_id\",\"ended_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"method\":\"method\",\"req_body\":\"req_body\",\"request_type\":\"request_type\",\"resource_id\":1,\"resource_id_string\":\"resource_id_string\",\"resource_name\":\"resource_name\",\"resource_type\":\"resource_type\",\"resp_code\":1,\"secondary_resource\":\"secondary_resource\",\"started_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\",\"user_name\":\"user_name\"}],\"params\":{\"environment_id\":\"environment_id\",\"limit\":1,\"offset\":1,\"q\":\"q\",\"request_type\":\"request_type\"}}")); + ListApiRequestsResponse response = client.accounts() + .listApiRequests(ListApiRequestsRequest.builder() + .q("q") + .requestType("request_type") + .environmentId("environment_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"api_key_id\": \"api_key_id\",\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"method\": \"method\",\n" + + " \"req_body\": \"req_body\",\n" + + " \"request_type\": \"request_type\",\n" + + " \"resource_id\": 1,\n" + + " \"resource_id_string\": \"resource_id_string\",\n" + + " \"resource_name\": \"resource_name\",\n" + + " \"resource_type\": \"resource_type\",\n" + + " \"resp_code\": 1,\n" + + " \"secondary_resource\": \"secondary_resource\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\",\n" + + " \"user_name\": \"user_name\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"request_type\": \"request_type\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetApiRequest() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"api_key\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_used_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"scopes\":[\"scopes\"],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"api_key_id\":\"api_key_id\",\"ended_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"method\":\"method\",\"req_body\":\"req_body\",\"request_type\":\"request_type\",\"resource_id\":1,\"resource_id_string\":\"resource_id_string\",\"resource_name\":\"resource_name\",\"resource_type\":\"resource_type\",\"resp_body\":\"resp_body\",\"resp_code\":1,\"secondary_resource\":\"secondary_resource\",\"started_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\",\"user_agent\":\"user_agent\",\"user_id\":\"user_id\",\"user_name\":\"user_name\"},\"params\":{\"key\":\"value\"}}")); + GetApiRequestResponse response = client.accounts().getApiRequest("api_request_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"api_key\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_used_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"scopes\": [\n" + + " \"scopes\"\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"api_key_id\": \"api_key_id\",\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"method\": \"method\",\n" + + " \"req_body\": \"req_body\",\n" + + " \"request_type\": \"request_type\",\n" + + " \"resource_id\": 1,\n" + + " \"resource_id_string\": \"resource_id_string\",\n" + + " \"resource_name\": \"resource_name\",\n" + + " \"resource_type\": \"resource_type\",\n" + + " \"resp_body\": \"resp_body\",\n" + + " \"resp_code\": 1,\n" + + " \"secondary_resource\": \"secondary_resource\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\",\n" + + " \"user_agent\": \"user_agent\",\n" + + " \"user_id\": \"user_id\",\n" + + " \"user_name\": \"user_name\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountApiRequests() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"environment_id\":\"environment_id\",\"limit\":1,\"offset\":1,\"q\":\"q\",\"request_type\":\"request_type\"}}")); + CountApiRequestsResponse response = client.accounts() + .countApiRequests(CountApiRequestsRequest.builder() + .q("q") + .requestType("request_type") + .environmentId("environment_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"request_type\": \"request_type\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListEnvironments() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_type\":\"environment_type\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"offset\":1}}")); + ListEnvironmentsResponse response = client.accounts() + .listEnvironments( + ListEnvironmentsRequest.builder().limit(1).offset(1).build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_type\": \"environment_type\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateEnvironment() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"api_keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"name\":\"name\",\"scopes\":[\"scopes\"],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_type\":\"environment_type\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateEnvironmentResponse response = client.accounts() + .createEnvironment(CreateEnvironmentRequestBody.builder() + .environmentType(CreateEnvironmentRequestBodyEnvironmentType.DEVELOPMENT) + .name("name") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = + "" + "{\n" + " \"environment_type\": \"development\",\n" + " \"name\": \"name\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"api_keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"scopes\": [\n" + + " \"scopes\"\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_type\": \"environment_type\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetEnvironment() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_type\":\"environment_type\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetEnvironmentResponse response = client.accounts().getEnvironment("environment_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_type\": \"environment_type\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateEnvironment() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_type\":\"environment_type\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdateEnvironmentResponse response = client.accounts() + .updateEnvironment( + "environment_id", UpdateEnvironmentRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_type\": \"environment_type\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteEnvironment() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteEnvironmentResponse response = client.accounts().deleteEnvironment("environment_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testQuickstart() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"ok\":true},\"params\":{\"key\":\"value\"}}")); + QuickstartResponse response = client.accounts().quickstart(); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"ok\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/BillingWireTest.java b/src/test/java/com/schematic/api/BillingWireTest.java new file mode 100644 index 0000000..5af9e54 --- /dev/null +++ b/src/test/java/com/schematic/api/BillingWireTest.java @@ -0,0 +1,1954 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.billing.requests.CountBillingProductsRequest; +import com.schematic.api.resources.billing.requests.CountCustomersRequest; +import com.schematic.api.resources.billing.requests.CreateBillingCustomerRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingPriceRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingProductRequestBody; +import com.schematic.api.resources.billing.requests.CreateBillingSubscriptionRequestBody; +import com.schematic.api.resources.billing.requests.CreateCouponRequestBody; +import com.schematic.api.resources.billing.requests.CreateInvoiceRequestBody; +import com.schematic.api.resources.billing.requests.CreateMeterRequestBody; +import com.schematic.api.resources.billing.requests.CreatePaymentMethodRequestBody; +import com.schematic.api.resources.billing.requests.ListBillingProductsRequest; +import com.schematic.api.resources.billing.requests.ListCouponsRequest; +import com.schematic.api.resources.billing.requests.ListCustomersWithSubscriptionsRequest; +import com.schematic.api.resources.billing.requests.ListInvoicesRequest; +import com.schematic.api.resources.billing.requests.ListMetersRequest; +import com.schematic.api.resources.billing.requests.ListPaymentMethodsRequest; +import com.schematic.api.resources.billing.requests.ListProductPricesRequest; +import com.schematic.api.resources.billing.requests.SearchBillingPricesRequest; +import com.schematic.api.resources.billing.types.CountBillingProductsRequestPriceUsageType; +import com.schematic.api.resources.billing.types.CountBillingProductsResponse; +import com.schematic.api.resources.billing.types.CountCustomersResponse; +import com.schematic.api.resources.billing.types.CreateBillingPriceRequestBodyBillingScheme; +import com.schematic.api.resources.billing.types.CreateBillingPriceRequestBodyUsageType; +import com.schematic.api.resources.billing.types.DeleteBillingProductResponse; +import com.schematic.api.resources.billing.types.DeleteProductPriceResponse; +import com.schematic.api.resources.billing.types.ListBillingProductsRequestPriceUsageType; +import com.schematic.api.resources.billing.types.ListBillingProductsResponse; +import com.schematic.api.resources.billing.types.ListCouponsResponse; +import com.schematic.api.resources.billing.types.ListCustomersWithSubscriptionsResponse; +import com.schematic.api.resources.billing.types.ListInvoicesResponse; +import com.schematic.api.resources.billing.types.ListMetersResponse; +import com.schematic.api.resources.billing.types.ListPaymentMethodsResponse; +import com.schematic.api.resources.billing.types.ListProductPricesRequestPriceUsageType; +import com.schematic.api.resources.billing.types.ListProductPricesResponse; +import com.schematic.api.resources.billing.types.SearchBillingPricesRequestTiersMode; +import com.schematic.api.resources.billing.types.SearchBillingPricesRequestUsageType; +import com.schematic.api.resources.billing.types.SearchBillingPricesResponse; +import com.schematic.api.resources.billing.types.UpsertBillingCouponResponse; +import com.schematic.api.resources.billing.types.UpsertBillingCustomerResponse; +import com.schematic.api.resources.billing.types.UpsertBillingMeterResponse; +import com.schematic.api.resources.billing.types.UpsertBillingPriceResponse; +import com.schematic.api.resources.billing.types.UpsertBillingProductResponse; +import com.schematic.api.resources.billing.types.UpsertBillingSubscriptionResponse; +import com.schematic.api.resources.billing.types.UpsertInvoiceResponse; +import com.schematic.api.resources.billing.types.UpsertPaymentMethodResponse; +import com.schematic.api.types.BillingProductPricing; +import com.schematic.api.types.BillingProductPricingUsageType; +import com.schematic.api.types.BillingSubscriptionDiscount; +import com.schematic.api.types.CreateBillingPriceTierRequestBody; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class BillingWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testListCoupons() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"account_id\":\"account_id\",\"amount_off\":1,\"currency\":\"currency\",\"duration\":\"duration\",\"duration_in_months\":1,\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"is_active\":true,\"max_redemptions\":1,\"metadata\":{\"key\":\"value\"},\"name\":\"name\",\"percent_off\":1.1,\"times_redeemed\":1,\"valid_from\":\"2024-01-15T09:30:00Z\",\"valid_until\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"is_active\":true,\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + ListCouponsResponse response = client.billing() + .listCoupons(ListCouponsRequest.builder() + .isActive(true) + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"amount_off\": 1,\n" + + " \"currency\": \"currency\",\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"is_active\": true,\n" + + " \"max_redemptions\": 1,\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"percent_off\": 1.1,\n" + + " \"times_redeemed\": 1,\n" + + " \"valid_from\": \"2024-01-15T09:30:00Z\",\n" + + " \"valid_until\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"is_active\": true,\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertBillingCoupon() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"amount_off\":1,\"currency\":\"currency\",\"duration\":\"duration\",\"duration_in_months\":1,\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"is_active\":true,\"max_redemptions\":1,\"metadata\":{\"key\":\"value\"},\"name\":\"name\",\"percent_off\":1.1,\"times_redeemed\":1,\"valid_from\":\"2024-01-15T09:30:00Z\",\"valid_until\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertBillingCouponResponse response = client.billing() + .upsertBillingCoupon(CreateCouponRequestBody.builder() + .amountOff(1) + .duration("duration") + .durationInMonths(1) + .externalId("external_id") + .maxRedemptions(1) + .name("name") + .percentOff(1.1) + .timesRedeemed(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"amount_off\": 1,\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"external_id\": \"external_id\",\n" + + " \"max_redemptions\": 1,\n" + + " \"name\": \"name\",\n" + + " \"percent_off\": 1.1,\n" + + " \"times_redeemed\": 1\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"amount_off\": 1,\n" + + " \"currency\": \"currency\",\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"is_active\": true,\n" + + " \"max_redemptions\": 1,\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"percent_off\": 1.1,\n" + + " \"times_redeemed\": 1,\n" + + " \"valid_from\": \"2024-01-15T09:30:00Z\",\n" + + " \"valid_until\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertBillingCustomer() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_id\":\"company_id\",\"deleted_at\":\"2024-01-15T09:30:00Z\",\"email\":\"email\",\"external_id\":\"external_id\",\"failed_to_import\":true,\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertBillingCustomerResponse response = client.billing() + .upsertBillingCustomer(CreateBillingCustomerRequestBody.builder() + .email("email") + .externalId("external_id") + .failedToImport(true) + .meta(new HashMap() { + { + put("key", "value"); + } + }) + .name("name") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"email\": \"email\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"failed_to_import\": true,\n" + + " \"meta\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"name\": \"name\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"deleted_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"email\": \"email\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"failed_to_import\": true,\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListCustomersWithSubscriptions() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"company_id\":\"company_id\",\"deleted_at\":\"2024-01-15T09:30:00Z\",\"email\":\"email\",\"external_id\":\"external_id\",\"failed_to_import\":true,\"id\":\"id\",\"name\":\"name\",\"subscriptions\":[{\"currency\":\"currency\",\"interval\":\"interval\",\"metered_usage\":true,\"per_unit_price\":1,\"total_price\":1}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"company_ids\":[\"company_ids\"],\"failed_to_import\":true,\"limit\":1,\"name\":\"name\",\"offset\":1,\"q\":\"q\"}}")); + ListCustomersWithSubscriptionsResponse response = client.billing() + .listCustomersWithSubscriptions(ListCustomersWithSubscriptionsRequest.builder() + .name("name") + .failedToImport(true) + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"company_id\": \"company_id\",\n" + + " \"deleted_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"email\": \"email\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"failed_to_import\": true,\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"subscriptions\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"interval\": \"interval\",\n" + + " \"metered_usage\": true,\n" + + " \"per_unit_price\": 1,\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_ids\": [\n" + + " \"company_ids\"\n" + + " ],\n" + + " \"failed_to_import\": true,\n" + + " \"limit\": 1,\n" + + " \"name\": \"name\",\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountCustomers() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"company_ids\":[\"company_ids\"],\"failed_to_import\":true,\"limit\":1,\"name\":\"name\",\"offset\":1,\"q\":\"q\"}}")); + CountCustomersResponse response = client.billing() + .countCustomers(CountCustomersRequest.builder() + .name("name") + .failedToImport(true) + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"company_ids\": [\n" + + " \"company_ids\"\n" + + " ],\n" + + " \"failed_to_import\": true,\n" + + " \"limit\": 1,\n" + + " \"name\": \"name\",\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListInvoices() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"due_date\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_external_id\":\"payment_method_external_id\",\"subscription_external_id\":\"subscription_external_id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"}],\"params\":{\"company_id\":\"company_id\",\"customer_external_id\":\"customer_external_id\",\"limit\":1,\"offset\":1,\"subscription_external_id\":\"subscription_external_id\"}}")); + ListInvoicesResponse response = client.billing() + .listInvoices(ListInvoicesRequest.builder() + .customerExternalId("customer_external_id") + .subscriptionExternalId("subscription_external_id") + .companyId("company_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"due_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_external_id\": \"payment_method_external_id\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertInvoice() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"due_date\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_external_id\":\"payment_method_external_id\",\"subscription_external_id\":\"subscription_external_id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"params\":{\"key\":\"value\"}}")); + UpsertInvoiceResponse response = client.billing() + .upsertInvoice(CreateInvoiceRequestBody.builder() + .amountDue(1) + .amountPaid(1) + .amountRemaining(1) + .collectionMethod("collection_method") + .currency("currency") + .customerExternalId("customer_external_id") + .subtotal(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"subtotal\": 1\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"due_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_external_id\": \"payment_method_external_id\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListMeters() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"dispaly_name\":\"dispaly_name\",\"event_name\":\"event_name\",\"event_payload_key\":\"event_payload_key\",\"external_price_id\":\"external_price_id\",\"id\":\"id\"}],\"params\":{\"display_name\":\"display_name\",\"limit\":1,\"offset\":1}}")); + ListMetersResponse response = client.billing() + .listMeters(ListMetersRequest.builder() + .displayName("display_name") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"dispaly_name\": \"dispaly_name\",\n" + + " \"event_name\": \"event_name\",\n" + + " \"event_payload_key\": \"event_payload_key\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"display_name\": \"display_name\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertBillingMeter() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"dispaly_name\":\"dispaly_name\",\"event_name\":\"event_name\",\"event_payload_key\":\"event_payload_key\",\"external_price_id\":\"external_price_id\",\"id\":\"id\"},\"params\":{\"key\":\"value\"}}")); + UpsertBillingMeterResponse response = client.billing() + .upsertBillingMeter(CreateMeterRequestBody.builder() + .displayName("display_name") + .eventName("event_name") + .eventPayloadKey("event_payload_key") + .externalId("external_id") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"display_name\": \"display_name\",\n" + + " \"event_name\": \"event_name\",\n" + + " \"event_payload_key\": \"event_payload_key\",\n" + + " \"external_id\": \"external_id\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"dispaly_name\": \"dispaly_name\",\n" + + " \"event_name\": \"event_name\",\n" + + " \"event_payload_key\": \"event_payload_key\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListPaymentMethods() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"company_id\":\"company_id\",\"customer_external_id\":\"customer_external_id\",\"limit\":1,\"offset\":1}}")); + ListPaymentMethodsResponse response = client.billing() + .listPaymentMethods(ListPaymentMethodsRequest.builder() + .customerExternalId("customer_external_id") + .companyId("company_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertPaymentMethod() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertPaymentMethodResponse response = client.billing() + .upsertPaymentMethod(CreatePaymentMethodRequestBody.builder() + .customerExternalId("customer_external_id") + .externalId("external_id") + .paymentMethodType("payment_method_type") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"payment_method_type\": \"payment_method_type\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testSearchBillingPrices() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"params\":{\"for_initial_plan\":true,\"for_trial_expiry_plan\":true,\"ids\":[\"ids\"],\"interval\":\"interval\",\"limit\":1,\"offset\":1,\"price\":1,\"product_id\":\"product_id\",\"q\":\"q\",\"requires_payment_method\":true,\"tiers_mode\":\"volume\",\"usage_type\":\"licensed\"}}")); + SearchBillingPricesResponse response = client.billing() + .searchBillingPrices(SearchBillingPricesRequest.builder() + .forInitialPlan(true) + .forTrialExpiryPlan(true) + .productId("product_id") + .interval("interval") + .price(1) + .q("q") + .requiresPaymentMethod(true) + .tiersMode(SearchBillingPricesRequestTiersMode.VOLUME) + .usageType(SearchBillingPricesRequestUsageType.LICENSED) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"for_initial_plan\": true,\n" + + " \"for_trial_expiry_plan\": true,\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"interval\": \"interval\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"price\": 1,\n" + + " \"product_id\": \"product_id\",\n" + + " \"q\": \"q\",\n" + + " \"requires_payment_method\": true,\n" + + " \"tiers_mode\": \"volume\",\n" + + " \"usage_type\": \"licensed\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertBillingPrice() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"params\":{\"key\":\"value\"}}")); + UpsertBillingPriceResponse response = client.billing() + .upsertBillingPrice(CreateBillingPriceRequestBody.builder() + .billingScheme(CreateBillingPriceRequestBodyBillingScheme.PER_UNIT) + .currency("currency") + .externalAccountId("external_account_id") + .interval("interval") + .isActive(true) + .price(1) + .priceExternalId("price_external_id") + .priceTiers(Arrays.asList(CreateBillingPriceTierRequestBody.builder() + .priceExternalId("price_external_id") + .build())) + .productExternalId("product_external_id") + .usageType(CreateBillingPriceRequestBodyUsageType.LICENSED) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"billing_scheme\": \"per_unit\",\n" + + " \"currency\": \"currency\",\n" + + " \"external_account_id\": \"external_account_id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_tiers\": [\n" + + " {\n" + + " \"price_external_id\": \"price_external_id\"\n" + + " }\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"usage_type\": \"licensed\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteBillingProduct() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteBillingProductResponse response = client.billing().deleteBillingProduct("billing_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListProductPrices() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"}],\"params\":{\"ids\":[\"ids\"],\"is_active\":true,\"limit\":1,\"name\":\"name\",\"offset\":1,\"price_usage_type\":\"licensed\",\"q\":\"q\",\"with_one_time_charges\":true,\"with_prices_only\":true,\"with_zero_price\":true,\"without_linked_to_plan\":true}}")); + ListProductPricesResponse response = client.billing() + .listProductPrices(ListProductPricesRequest.builder() + .name("name") + .q("q") + .priceUsageType(ListProductPricesRequestPriceUsageType.LICENSED) + .withoutLinkedToPlan(true) + .withOneTimeCharges(true) + .withZeroPrice(true) + .withPricesOnly(true) + .isActive(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"is_active\": true,\n" + + " \"limit\": 1,\n" + + " \"name\": \"name\",\n" + + " \"offset\": 1,\n" + + " \"price_usage_type\": \"licensed\",\n" + + " \"q\": \"q\",\n" + + " \"with_one_time_charges\": true,\n" + + " \"with_prices_only\": true,\n" + + " \"with_zero_price\": true,\n" + + " \"without_linked_to_plan\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteProductPrice() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteProductPriceResponse response = client.billing().deleteProductPrice("billing_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertBillingProduct() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertBillingProductResponse response = client.billing() + .upsertBillingProduct(CreateBillingProductRequestBody.builder() + .externalId("external_id") + .name("name") + .price(1.1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"external_id\": \"external_id\",\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListBillingProducts() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"ids\":[\"ids\"],\"is_active\":true,\"limit\":1,\"name\":\"name\",\"offset\":1,\"price_usage_type\":\"licensed\",\"q\":\"q\",\"with_one_time_charges\":true,\"with_prices_only\":true,\"with_zero_price\":true,\"without_linked_to_plan\":true}}")); + ListBillingProductsResponse response = client.billing() + .listBillingProducts(ListBillingProductsRequest.builder() + .name("name") + .q("q") + .priceUsageType(ListBillingProductsRequestPriceUsageType.LICENSED) + .withoutLinkedToPlan(true) + .withOneTimeCharges(true) + .withZeroPrice(true) + .withPricesOnly(true) + .isActive(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"is_active\": true,\n" + + " \"limit\": 1,\n" + + " \"name\": \"name\",\n" + + " \"offset\": 1,\n" + + " \"price_usage_type\": \"licensed\",\n" + + " \"q\": \"q\",\n" + + " \"with_one_time_charges\": true,\n" + + " \"with_prices_only\": true,\n" + + " \"with_zero_price\": true,\n" + + " \"without_linked_to_plan\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountBillingProducts() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"ids\":[\"ids\"],\"is_active\":true,\"limit\":1,\"name\":\"name\",\"offset\":1,\"price_usage_type\":\"licensed\",\"q\":\"q\",\"with_one_time_charges\":true,\"with_prices_only\":true,\"with_zero_price\":true,\"without_linked_to_plan\":true}}")); + CountBillingProductsResponse response = client.billing() + .countBillingProducts(CountBillingProductsRequest.builder() + .name("name") + .q("q") + .priceUsageType(CountBillingProductsRequestPriceUsageType.LICENSED) + .withoutLinkedToPlan(true) + .withOneTimeCharges(true) + .withZeroPrice(true) + .withPricesOnly(true) + .isActive(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"is_active\": true,\n" + + " \"limit\": 1,\n" + + " \"name\": \"name\",\n" + + " \"offset\": 1,\n" + + " \"price_usage_type\": \"licensed\",\n" + + " \"q\": \"q\",\n" + + " \"with_one_time_charges\": true,\n" + + " \"with_prices_only\": true,\n" + + " \"with_zero_price\": true,\n" + + " \"without_linked_to_plan\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertBillingSubscription() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"metadata\":{\"key\":\"value\"},\"period_end\":1,\"period_start\":1,\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"params\":{\"key\":\"value\"}}")); + UpsertBillingSubscriptionResponse response = client.billing() + .upsertBillingSubscription(CreateBillingSubscriptionRequestBody.builder() + .cancelAtPeriodEnd(true) + .currency("currency") + .customerExternalId("customer_external_id") + .discounts(Arrays.asList(BillingSubscriptionDiscount.builder() + .couponExternalId("coupon_external_id") + .externalId("external_id") + .isActive(true) + .startedAt(OffsetDateTime.parse("2024-01-15T09:30:00Z")) + .build())) + .expiredAt(OffsetDateTime.parse("2024-01-15T09:30:00Z")) + .productExternalIds(Arrays.asList(BillingProductPricing.builder() + .currency("currency") + .interval("interval") + .price(1) + .priceExternalId("price_external_id") + .productExternalId("product_external_id") + .quantity(1) + .usageType(BillingProductPricingUsageType.LICENSED) + .build())) + .subscriptionExternalId("subscription_external_id") + .totalPrice(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"cancel_at_period_end\": true,\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_external_id\": \"coupon_external_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"product_external_ids\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"quantity\": 1,\n" + + " \"usage_type\": \"licensed\"\n" + + " }\n" + + " ],\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/CheckoutWireTest.java b/src/test/java/com/schematic/api/CheckoutWireTest.java new file mode 100644 index 0000000..1f82d08 --- /dev/null +++ b/src/test/java/com/schematic/api/CheckoutWireTest.java @@ -0,0 +1,1895 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.checkout.requests.CheckoutDataRequestBody; +import com.schematic.api.resources.checkout.requests.UpdateTrialEndRequestBody; +import com.schematic.api.resources.checkout.types.CheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.GetCheckoutDataResponse; +import com.schematic.api.resources.checkout.types.ManagePlanResponse; +import com.schematic.api.resources.checkout.types.PreviewCheckoutInternalResponse; +import com.schematic.api.resources.checkout.types.PreviewManagePlanResponse; +import com.schematic.api.resources.checkout.types.UpdateCustomerSubscriptionTrialEndResponse; +import com.schematic.api.types.ChangeSubscriptionInternalRequestBody; +import com.schematic.api.types.ManagePlanRequest; +import com.schematic.api.types.PlanSelection; +import com.schematic.api.types.UpdateAddOnRequestBody; +import com.schematic.api.types.UpdateCreditBundleRequestBody; +import com.schematic.api.types.UpdatePayInAdvanceRequestBody; +import java.util.Arrays; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class CheckoutWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testInternal() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"confirm_payment_intent_client_secret\":\"confirm_payment_intent_client_secret\",\"confirm_payment_intent_id\":\"confirm_payment_intent_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"metadata\":{\"key\":\"value\"},\"period_end\":1,\"period_start\":1,\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"params\":{\"key\":\"value\"}}")); + CheckoutInternalResponse response = client.checkout() + .internal(ChangeSubscriptionInternalRequestBody.builder() + .addOnIds(Arrays.asList(UpdateAddOnRequestBody.builder() + .addOnId("add_on_id") + .priceId("price_id") + .build())) + .companyId("company_id") + .creditBundles(Arrays.asList(UpdateCreditBundleRequestBody.builder() + .bundleId("bundle_id") + .quantity(1) + .build())) + .newPlanId("new_plan_id") + .newPriceId("new_price_id") + .payInAdvance(Arrays.asList(UpdatePayInAdvanceRequestBody.builder() + .priceId("price_id") + .quantity(1) + .build())) + .skipTrial(true) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"add_on_ids\": [\n" + + " {\n" + + " \"add_on_id\": \"add_on_id\",\n" + + " \"price_id\": \"price_id\"\n" + + " }\n" + + " ],\n" + + " \"company_id\": \"company_id\",\n" + + " \"credit_bundles\": [\n" + + " {\n" + + " \"bundle_id\": \"bundle_id\",\n" + + " \"quantity\": 1\n" + + " }\n" + + " ],\n" + + " \"new_plan_id\": \"new_plan_id\",\n" + + " \"new_price_id\": \"new_price_id\",\n" + + " \"pay_in_advance\": [\n" + + " {\n" + + " \"price_id\": \"price_id\",\n" + + " \"quantity\": 1\n" + + " }\n" + + " ],\n" + + " \"skip_trial\": true\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"confirm_payment_intent_client_secret\": \"confirm_payment_intent_client_secret\",\n" + + " \"confirm_payment_intent_id\": \"confirm_payment_intent_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetCheckoutData() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"active_add_ons\":[{\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"active_plan\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}},\"active_usage_based_entitlements\":[{\"feature_id\":\"feature_id\",\"value_type\":\"value_type\"}],\"available_credit_bundles\":[{\"bundle_type\":\"bundle_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expiry_type\":\"expiry_type\",\"expiry_unit\":\"expiry_unit\",\"has_grants\":true,\"id\":\"id\",\"name\":\"name\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"feature_usage\":{\"features\":[{\"access\":true,\"allocation_type\":\"boolean\",\"entitlement_id\":\"entitlement_id\",\"entitlement_type\":\"entitlement_type\"}]},\"selected_credit_bundles\":[{\"quantity\":1,\"total\":1}],\"selected_plan\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}},\"selected_usage_based_entitlements\":[{\"feature_id\":\"feature_id\",\"value_type\":\"value_type\"}],\"subscription\":{\"cancel_at\":\"2024-01-15T09:30:00Z\",\"cancel_at_period_end\":true,\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":\"2024-01-15T09:30:00Z\"}},\"params\":{\"key\":\"value\"}}")); + GetCheckoutDataResponse response = client.checkout() + .getCheckoutData(CheckoutDataRequestBody.builder() + .companyId("company_id") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"company_id\": \"company_id\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"active_add_ons\": [\n" + + " {\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"active_plan\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"active_usage_based_entitlements\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"available_credit_bundles\": [\n" + + " {\n" + + " \"bundle_type\": \"bundle_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expiry_type\": \"expiry_type\",\n" + + " \"expiry_unit\": \"expiry_unit\",\n" + + " \"has_grants\": true,\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"feature_usage\": {\n" + + " \"features\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_type\": \"entitlement_type\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"selected_credit_bundles\": [\n" + + " {\n" + + " \"quantity\": 1,\n" + + " \"total\": 1\n" + + " }\n" + + " ],\n" + + " \"selected_plan\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"selected_usage_based_entitlements\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"subscription\": {\n" + + " \"cancel_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"cancel_at_period_end\": true,\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testPreviewCheckoutInternal() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"amount_off\":1,\"due_now\":1,\"finance\":{\"amount_off\":1,\"due_now\":1,\"new_charges\":1,\"percent_off\":1.1,\"period_start\":\"2024-01-15T09:30:00Z\",\"promo_code_applied\":true,\"proration\":1,\"tax_amount\":1,\"tax_display_name\":\"tax_display_name\",\"tax_require_billing_details\":true,\"trial_end\":\"2024-01-15T09:30:00Z\",\"upcoming_invoice_line_items\":[{\"amount\":1,\"description\":\"description\",\"price_id\":\"price_id\",\"proration\":true,\"quantity\":1}]},\"new_charges\":1,\"payment_method_required\":true,\"percent_off\":1.1,\"period_start\":\"2024-01-15T09:30:00Z\",\"promo_code_applied\":true,\"proration\":1,\"usage_violations\":[{\"access\":true,\"allocation_type\":\"boolean\",\"entitlement_id\":\"entitlement_id\",\"entitlement_type\":\"entitlement_type\"}]},\"params\":{\"key\":\"value\"}}")); + PreviewCheckoutInternalResponse response = client.checkout() + .previewCheckoutInternal(ChangeSubscriptionInternalRequestBody.builder() + .addOnIds(Arrays.asList(UpdateAddOnRequestBody.builder() + .addOnId("add_on_id") + .priceId("price_id") + .build())) + .companyId("company_id") + .creditBundles(Arrays.asList(UpdateCreditBundleRequestBody.builder() + .bundleId("bundle_id") + .quantity(1) + .build())) + .newPlanId("new_plan_id") + .newPriceId("new_price_id") + .payInAdvance(Arrays.asList(UpdatePayInAdvanceRequestBody.builder() + .priceId("price_id") + .quantity(1) + .build())) + .skipTrial(true) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"add_on_ids\": [\n" + + " {\n" + + " \"add_on_id\": \"add_on_id\",\n" + + " \"price_id\": \"price_id\"\n" + + " }\n" + + " ],\n" + + " \"company_id\": \"company_id\",\n" + + " \"credit_bundles\": [\n" + + " {\n" + + " \"bundle_id\": \"bundle_id\",\n" + + " \"quantity\": 1\n" + + " }\n" + + " ],\n" + + " \"new_plan_id\": \"new_plan_id\",\n" + + " \"new_price_id\": \"new_price_id\",\n" + + " \"pay_in_advance\": [\n" + + " {\n" + + " \"price_id\": \"price_id\",\n" + + " \"quantity\": 1\n" + + " }\n" + + " ],\n" + + " \"skip_trial\": true\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"amount_off\": 1,\n" + + " \"due_now\": 1,\n" + + " \"finance\": {\n" + + " \"amount_off\": 1,\n" + + " \"due_now\": 1,\n" + + " \"new_charges\": 1,\n" + + " \"percent_off\": 1.1,\n" + + " \"period_start\": \"2024-01-15T09:30:00Z\",\n" + + " \"promo_code_applied\": true,\n" + + " \"proration\": 1,\n" + + " \"tax_amount\": 1,\n" + + " \"tax_display_name\": \"tax_display_name\",\n" + + " \"tax_require_billing_details\": true,\n" + + " \"trial_end\": \"2024-01-15T09:30:00Z\",\n" + + " \"upcoming_invoice_line_items\": [\n" + + " {\n" + + " \"amount\": 1,\n" + + " \"description\": \"description\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"proration\": true,\n" + + " \"quantity\": 1\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"new_charges\": 1,\n" + + " \"payment_method_required\": true,\n" + + " \"percent_off\": 1.1,\n" + + " \"period_start\": \"2024-01-15T09:30:00Z\",\n" + + " \"promo_code_applied\": true,\n" + + " \"proration\": 1,\n" + + " \"usage_violations\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_type\": \"entitlement_type\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testManagePlan() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"success\":true},\"params\":{\"key\":\"value\"}}")); + ManagePlanResponse response = client.checkout() + .managePlan(ManagePlanRequest.builder() + .addOnSelections(Arrays.asList( + PlanSelection.builder().planId("plan_id").build())) + .companyId("company_id") + .creditBundles(Arrays.asList(UpdateCreditBundleRequestBody.builder() + .bundleId("bundle_id") + .quantity(1) + .build())) + .payInAdvanceEntitlements(Arrays.asList(UpdatePayInAdvanceRequestBody.builder() + .priceId("price_id") + .quantity(1) + .build())) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"add_on_selections\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"company_id\": \"company_id\",\n" + + " \"credit_bundles\": [\n" + + " {\n" + + " \"bundle_id\": \"bundle_id\",\n" + + " \"quantity\": 1\n" + + " }\n" + + " ],\n" + + " \"pay_in_advance_entitlements\": [\n" + + " {\n" + + " \"price_id\": \"price_id\",\n" + + " \"quantity\": 1\n" + + " }\n" + + " ]\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"success\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testPreviewManagePlan() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"subscription_change_preview\":{\"amount_off\":1,\"due_now\":1,\"finance\":{\"amount_off\":1,\"due_now\":1,\"new_charges\":1,\"percent_off\":1.1,\"period_start\":\"2024-01-15T09:30:00Z\",\"promo_code_applied\":true,\"proration\":1,\"tax_require_billing_details\":true,\"upcoming_invoice_line_items\":[{\"amount\":1,\"description\":\"description\",\"price_id\":\"price_id\",\"proration\":true,\"quantity\":1}]},\"new_charges\":1,\"payment_method_required\":true,\"percent_off\":1.1,\"period_start\":\"2024-01-15T09:30:00Z\",\"promo_code_applied\":true,\"proration\":1,\"usage_violations\":[{\"access\":true,\"allocation_type\":\"boolean\",\"entitlement_id\":\"entitlement_id\",\"entitlement_type\":\"entitlement_type\"}]}},\"params\":{\"key\":\"value\"}}")); + PreviewManagePlanResponse response = client.checkout() + .previewManagePlan(ManagePlanRequest.builder() + .addOnSelections(Arrays.asList( + PlanSelection.builder().planId("plan_id").build())) + .companyId("company_id") + .creditBundles(Arrays.asList(UpdateCreditBundleRequestBody.builder() + .bundleId("bundle_id") + .quantity(1) + .build())) + .payInAdvanceEntitlements(Arrays.asList(UpdatePayInAdvanceRequestBody.builder() + .priceId("price_id") + .quantity(1) + .build())) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"add_on_selections\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"company_id\": \"company_id\",\n" + + " \"credit_bundles\": [\n" + + " {\n" + + " \"bundle_id\": \"bundle_id\",\n" + + " \"quantity\": 1\n" + + " }\n" + + " ],\n" + + " \"pay_in_advance_entitlements\": [\n" + + " {\n" + + " \"price_id\": \"price_id\",\n" + + " \"quantity\": 1\n" + + " }\n" + + " ]\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"subscription_change_preview\": {\n" + + " \"amount_off\": 1,\n" + + " \"due_now\": 1,\n" + + " \"finance\": {\n" + + " \"amount_off\": 1,\n" + + " \"due_now\": 1,\n" + + " \"new_charges\": 1,\n" + + " \"percent_off\": 1.1,\n" + + " \"period_start\": \"2024-01-15T09:30:00Z\",\n" + + " \"promo_code_applied\": true,\n" + + " \"proration\": 1,\n" + + " \"tax_require_billing_details\": true,\n" + + " \"upcoming_invoice_line_items\": [\n" + + " {\n" + + " \"amount\": 1,\n" + + " \"description\": \"description\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"proration\": true,\n" + + " \"quantity\": 1\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"new_charges\": 1,\n" + + " \"payment_method_required\": true,\n" + + " \"percent_off\": 1.1,\n" + + " \"period_start\": \"2024-01-15T09:30:00Z\",\n" + + " \"promo_code_applied\": true,\n" + + " \"proration\": 1,\n" + + " \"usage_violations\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_type\": \"entitlement_type\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateCustomerSubscriptionTrialEnd() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"due_date\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_external_id\":\"payment_method_external_id\",\"subscription_external_id\":\"subscription_external_id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"metadata\":{\"key\":\"value\"},\"payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"params\":{\"key\":\"value\"}}")); + UpdateCustomerSubscriptionTrialEndResponse response = client.checkout() + .updateCustomerSubscriptionTrialEnd( + "subscription_id", UpdateTrialEndRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"due_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_external_id\": \"payment_method_external_id\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/CompaniesWireTest.java b/src/test/java/com/schematic/api/CompaniesWireTest.java new file mode 100644 index 0000000..892a1e6 --- /dev/null +++ b/src/test/java/com/schematic/api/CompaniesWireTest.java @@ -0,0 +1,6587 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.companies.requests.CountCompaniesForAdvancedFilterRequest; +import com.schematic.api.resources.companies.requests.CountCompaniesRequest; +import com.schematic.api.resources.companies.requests.CountEntityKeyDefinitionsRequest; +import com.schematic.api.resources.companies.requests.CountEntityTraitDefinitionsRequest; +import com.schematic.api.resources.companies.requests.CountPlanTraitsRequest; +import com.schematic.api.resources.companies.requests.CountUsersRequest; +import com.schematic.api.resources.companies.requests.CreateEntityTraitDefinitionRequestBody; +import com.schematic.api.resources.companies.requests.CreatePlanTraitRequestBody; +import com.schematic.api.resources.companies.requests.GetActiveCompanySubscriptionRequest; +import com.schematic.api.resources.companies.requests.GetActiveDealsRequest; +import com.schematic.api.resources.companies.requests.GetEntityTraitValuesRequest; +import com.schematic.api.resources.companies.requests.GetOrCreateCompanyMembershipRequestBody; +import com.schematic.api.resources.companies.requests.ListCompaniesForAdvancedFilterRequest; +import com.schematic.api.resources.companies.requests.ListCompaniesRequest; +import com.schematic.api.resources.companies.requests.ListCompanyMembershipsRequest; +import com.schematic.api.resources.companies.requests.ListEntityKeyDefinitionsRequest; +import com.schematic.api.resources.companies.requests.ListEntityTraitDefinitionsRequest; +import com.schematic.api.resources.companies.requests.ListPlanChangesRequest; +import com.schematic.api.resources.companies.requests.ListPlanTraitsRequest; +import com.schematic.api.resources.companies.requests.ListUsersRequest; +import com.schematic.api.resources.companies.requests.LookupCompanyRequest; +import com.schematic.api.resources.companies.requests.LookupUserRequest; +import com.schematic.api.resources.companies.requests.UpdateEntityTraitDefinitionRequestBody; +import com.schematic.api.resources.companies.requests.UpdatePlanTraitBulkRequestBody; +import com.schematic.api.resources.companies.requests.UpdatePlanTraitRequestBody; +import com.schematic.api.resources.companies.types.CountCompaniesForAdvancedFilterRequestSortOrderDirection; +import com.schematic.api.resources.companies.types.CountCompaniesForAdvancedFilterResponse; +import com.schematic.api.resources.companies.types.CountCompaniesResponse; +import com.schematic.api.resources.companies.types.CountEntityKeyDefinitionsRequestEntityType; +import com.schematic.api.resources.companies.types.CountEntityKeyDefinitionsResponse; +import com.schematic.api.resources.companies.types.CountEntityTraitDefinitionsRequestEntityType; +import com.schematic.api.resources.companies.types.CountEntityTraitDefinitionsRequestTraitType; +import com.schematic.api.resources.companies.types.CountEntityTraitDefinitionsResponse; +import com.schematic.api.resources.companies.types.CountPlanTraitsResponse; +import com.schematic.api.resources.companies.types.CountUsersResponse; +import com.schematic.api.resources.companies.types.CreateCompanyResponse; +import com.schematic.api.resources.companies.types.CreateEntityTraitDefinitionRequestBodyEntityType; +import com.schematic.api.resources.companies.types.CreateEntityTraitDefinitionRequestBodyTraitType; +import com.schematic.api.resources.companies.types.CreatePlanTraitResponse; +import com.schematic.api.resources.companies.types.CreateUserResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyByKeysResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyMembershipResponse; +import com.schematic.api.resources.companies.types.DeleteCompanyResponse; +import com.schematic.api.resources.companies.types.DeletePlanTraitResponse; +import com.schematic.api.resources.companies.types.DeleteUserByKeysResponse; +import com.schematic.api.resources.companies.types.DeleteUserResponse; +import com.schematic.api.resources.companies.types.GetActiveCompanySubscriptionResponse; +import com.schematic.api.resources.companies.types.GetActiveDealsResponse; +import com.schematic.api.resources.companies.types.GetCompanyResponse; +import com.schematic.api.resources.companies.types.GetEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.GetEntityTraitValuesResponse; +import com.schematic.api.resources.companies.types.GetOrCreateCompanyMembershipResponse; +import com.schematic.api.resources.companies.types.GetOrCreateEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.GetPlanChangeResponse; +import com.schematic.api.resources.companies.types.GetPlanTraitResponse; +import com.schematic.api.resources.companies.types.GetUserResponse; +import com.schematic.api.resources.companies.types.ListCompaniesForAdvancedFilterRequestSortOrderDirection; +import com.schematic.api.resources.companies.types.ListCompaniesForAdvancedFilterResponse; +import com.schematic.api.resources.companies.types.ListCompaniesResponse; +import com.schematic.api.resources.companies.types.ListCompanyMembershipsResponse; +import com.schematic.api.resources.companies.types.ListEntityKeyDefinitionsRequestEntityType; +import com.schematic.api.resources.companies.types.ListEntityKeyDefinitionsResponse; +import com.schematic.api.resources.companies.types.ListEntityTraitDefinitionsRequestEntityType; +import com.schematic.api.resources.companies.types.ListEntityTraitDefinitionsRequestTraitType; +import com.schematic.api.resources.companies.types.ListEntityTraitDefinitionsResponse; +import com.schematic.api.resources.companies.types.ListPlanChangesResponse; +import com.schematic.api.resources.companies.types.ListPlanTraitsResponse; +import com.schematic.api.resources.companies.types.ListUsersResponse; +import com.schematic.api.resources.companies.types.LookupCompanyResponse; +import com.schematic.api.resources.companies.types.LookupUserResponse; +import com.schematic.api.resources.companies.types.UpdateEntityTraitDefinitionRequestBodyTraitType; +import com.schematic.api.resources.companies.types.UpdateEntityTraitDefinitionResponse; +import com.schematic.api.resources.companies.types.UpdatePlanTraitResponse; +import com.schematic.api.resources.companies.types.UpdatePlanTraitsBulkResponse; +import com.schematic.api.resources.companies.types.UpsertCompanyResponse; +import com.schematic.api.resources.companies.types.UpsertCompanyTraitResponse; +import com.schematic.api.resources.companies.types.UpsertUserResponse; +import com.schematic.api.resources.companies.types.UpsertUserTraitResponse; +import com.schematic.api.types.KeysRequestBody; +import com.schematic.api.types.UpdatePlanTraitTraitRequestBody; +import com.schematic.api.types.UpsertCompanyRequestBody; +import com.schematic.api.types.UpsertTraitRequestBody; +import com.schematic.api.types.UpsertUserRequestBody; +import java.util.Arrays; +import java.util.HashMap; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class CompaniesWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testListCompanies() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1}],\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"q\":\"q\",\"with_subscription\":true,\"without_feature_override_for\":\"without_feature_override_for\",\"without_plan\":true}}")); + ListCompaniesResponse response = client.companies() + .listCompanies(ListCompaniesRequest.builder() + .planId("plan_id") + .q("q") + .withoutFeatureOverrideFor("without_feature_override_for") + .withoutPlan(true) + .withSubscription(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"q\": \"q\",\n" + + " \"with_subscription\": true,\n" + + " \"without_feature_override_for\": \"without_feature_override_for\",\n" + + " \"without_plan\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertCompany() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"metadata\":{\"key\":\"value\"},\"payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"added_on\":\"2024-01-15T09:30:00Z\",\"billing_product_external_id\":\"billing_product_external_id\",\"billing_product_id\":\"billing_product_id\",\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\",\"plan_period\":\"plan_period\",\"plan_price\":1},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"params\":{\"key\":\"value\"}}")); + UpsertCompanyResponse response = client.companies() + .upsertCompany(UpsertCompanyRequestBody.builder() + .keys(new HashMap() { + { + put("key", "value"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"keys\": {\n" + " \"key\": \"value\"\n" + " }\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"added_on\": \"2024-01-15T09:30:00Z\",\n" + + " \"billing_product_external_id\": \"billing_product_external_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\",\n" + + " \"plan_period\": \"plan_period\",\n" + + " \"plan_price\": 1\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetCompany() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"metadata\":{\"key\":\"value\"},\"payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"added_on\":\"2024-01-15T09:30:00Z\",\"billing_product_external_id\":\"billing_product_external_id\",\"billing_product_id\":\"billing_product_id\",\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\",\"plan_period\":\"plan_period\",\"plan_price\":1},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"params\":{\"key\":\"value\"}}")); + GetCompanyResponse response = client.companies().getCompany("company_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"added_on\": \"2024-01-15T09:30:00Z\",\n" + + " \"billing_product_external_id\": \"billing_product_external_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\",\n" + + " \"plan_period\": \"plan_period\",\n" + + " \"plan_price\": 1\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteCompany() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteCompanyResponse response = client.companies().deleteCompany("company_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountCompanies() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"q\":\"q\",\"with_subscription\":true,\"without_feature_override_for\":\"without_feature_override_for\",\"without_plan\":true}}")); + CountCompaniesResponse response = client.companies() + .countCompanies(CountCompaniesRequest.builder() + .planId("plan_id") + .q("q") + .withoutFeatureOverrideFor("without_feature_override_for") + .withoutPlan(true) + .withSubscription(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"q\": \"q\",\n" + + " \"with_subscription\": true,\n" + + " \"without_feature_override_for\": \"without_feature_override_for\",\n" + + " \"without_plan\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountCompaniesForAdvancedFilter() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"credit_type_ids\":[\"credit_type_ids\"],\"display_properties\":[\"display_properties\"],\"feature_ids\":[\"feature_ids\"],\"ids\":[\"ids\"],\"limit\":1,\"monetized_subscriptions\":true,\"offset\":1,\"plan_ids\":[\"plan_ids\"],\"q\":\"q\",\"sort_order_column\":\"sort_order_column\",\"sort_order_direction\":\"asc\",\"subscription_statuses\":[\"subscription_statuses\"],\"subscription_types\":[\"subscription_types\"],\"without_plan\":true,\"without_subscription\":true}}")); + CountCompaniesForAdvancedFilterResponse response = client.companies() + .countCompaniesForAdvancedFilter(CountCompaniesForAdvancedFilterRequest.builder() + .monetizedSubscriptions(true) + .q("q") + .withoutPlan(true) + .withoutSubscription(true) + .sortOrderColumn("sort_order_column") + .sortOrderDirection(CountCompaniesForAdvancedFilterRequestSortOrderDirection.ASC) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"credit_type_ids\": [\n" + + " \"credit_type_ids\"\n" + + " ],\n" + + " \"display_properties\": [\n" + + " \"display_properties\"\n" + + " ],\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"monetized_subscriptions\": true,\n" + + " \"offset\": 1,\n" + + " \"plan_ids\": [\n" + + " \"plan_ids\"\n" + + " ],\n" + + " \"q\": \"q\",\n" + + " \"sort_order_column\": \"sort_order_column\",\n" + + " \"sort_order_direction\": \"asc\",\n" + + " \"subscription_statuses\": [\n" + + " \"subscription_statuses\"\n" + + " ],\n" + + " \"subscription_types\": [\n" + + " \"subscription_types\"\n" + + " ],\n" + + " \"without_plan\": true,\n" + + " \"without_subscription\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateCompany() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"metadata\":{\"key\":\"value\"},\"payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"added_on\":\"2024-01-15T09:30:00Z\",\"billing_product_external_id\":\"billing_product_external_id\",\"billing_product_id\":\"billing_product_id\",\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\",\"plan_period\":\"plan_period\",\"plan_price\":1},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"params\":{\"key\":\"value\"}}")); + CreateCompanyResponse response = client.companies() + .createCompany(UpsertCompanyRequestBody.builder() + .keys(new HashMap() { + { + put("key", "value"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"keys\": {\n" + " \"key\": \"value\"\n" + " }\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"added_on\": \"2024-01-15T09:30:00Z\",\n" + + " \"billing_product_external_id\": \"billing_product_external_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\",\n" + + " \"plan_period\": \"plan_period\",\n" + + " \"plan_price\": 1\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteCompanyByKeys() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + DeleteCompanyByKeysResponse response = client.companies() + .deleteCompanyByKeys(KeysRequestBody.builder() + .keys(new HashMap() { + { + put("key", "value"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"keys\": {\n" + " \"key\": \"value\"\n" + " }\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListCompaniesForAdvancedFilter() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"feature_usage\":[{\"entitlement_source\":\"entitlement_source\",\"entitlement_value_type\":\"entitlement_value_type\",\"feature_id\":\"feature_id\",\"feature_name\":\"feature_name\",\"feature_type\":\"feature_type\",\"hard_limit\":\"hard_limit\",\"has_access\":true,\"soft_limit\":\"soft_limit\",\"usage\":\"usage\"}],\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1}],\"params\":{\"credit_type_ids\":[\"credit_type_ids\"],\"display_properties\":[\"display_properties\"],\"feature_ids\":[\"feature_ids\"],\"ids\":[\"ids\"],\"limit\":1,\"monetized_subscriptions\":true,\"offset\":1,\"plan_ids\":[\"plan_ids\"],\"q\":\"q\",\"sort_order_column\":\"sort_order_column\",\"sort_order_direction\":\"asc\",\"subscription_statuses\":[\"subscription_statuses\"],\"subscription_types\":[\"subscription_types\"],\"without_plan\":true,\"without_subscription\":true}}")); + ListCompaniesForAdvancedFilterResponse response = client.companies() + .listCompaniesForAdvancedFilter(ListCompaniesForAdvancedFilterRequest.builder() + .monetizedSubscriptions(true) + .q("q") + .withoutPlan(true) + .withoutSubscription(true) + .sortOrderColumn("sort_order_column") + .sortOrderDirection(ListCompaniesForAdvancedFilterRequestSortOrderDirection.ASC) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_usage\": [\n" + + " {\n" + + " \"entitlement_source\": \"entitlement_source\",\n" + + " \"entitlement_value_type\": \"entitlement_value_type\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"feature_name\": \"feature_name\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"hard_limit\": \"hard_limit\",\n" + + " \"has_access\": true,\n" + + " \"soft_limit\": \"soft_limit\",\n" + + " \"usage\": \"usage\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"credit_type_ids\": [\n" + + " \"credit_type_ids\"\n" + + " ],\n" + + " \"display_properties\": [\n" + + " \"display_properties\"\n" + + " ],\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"monetized_subscriptions\": true,\n" + + " \"offset\": 1,\n" + + " \"plan_ids\": [\n" + + " \"plan_ids\"\n" + + " ],\n" + + " \"q\": \"q\",\n" + + " \"sort_order_column\": \"sort_order_column\",\n" + + " \"sort_order_direction\": \"asc\",\n" + + " \"subscription_statuses\": [\n" + + " \"subscription_statuses\"\n" + + " ],\n" + + " \"subscription_types\": [\n" + + " \"subscription_types\"\n" + + " ],\n" + + " \"without_plan\": true,\n" + + " \"without_subscription\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testLookupCompany() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_ons\":[{\"added_on\":\"2024-01-15T09:30:00Z\",\"billing_product_external_id\":\"billing_product_external_id\",\"billing_product_id\":\"billing_product_id\",\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\",\"plan_period\":\"plan_period\",\"plan_price\":1},{\"added_on\":\"2024-01-15T09:30:00Z\",\"billing_product_external_id\":\"billing_product_external_id\",\"billing_product_id\":\"billing_product_id\",\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\",\"plan_period\":\"plan_period\",\"plan_price\":1}],\"billing_credit_balances\":{\"billing_credit_balances\":1.1},\"billing_subscription\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"amount_off\":1,\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"currency\":\"currency\",\"customer_facing_code\":\"customer_facing_code\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"duration_in_months\":1,\"ended_at\":\"2024-01-15T09:30:00Z\",\"is_active\":true,\"percent_off\":1.1,\"promo_code_external_id\":\"promo_code_external_id\",\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"},{\"amount_off\":1,\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"currency\":\"currency\",\"customer_facing_code\":\"customer_facing_code\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"duration_in_months\":1,\"ended_at\":\"2024-01-15T09:30:00Z\",\"is_active\":true,\"percent_off\":1.1,\"promo_code_external_id\":\"promo_code_external_id\",\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"due_date\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_external_id\":\"payment_method_external_id\",\"subscription_external_id\":\"subscription_external_id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"metadata\":{\"metadata\":{\"key\":\"value\"}},\"payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"billing_threshold\":1,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"meter_id\":\"meter_id\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"subscription_item_external_id\":\"subscription_item_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},{\"billing_scheme\":\"billing_scheme\",\"billing_threshold\":1,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"meter_id\":\"meter_id\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"subscription_item_external_id\":\"subscription_item_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"billing_subscriptions\":[{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"amount_off\":1,\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"currency\":\"currency\",\"customer_facing_code\":\"customer_facing_code\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"duration_in_months\":1,\"ended_at\":\"2024-01-15T09:30:00Z\",\"is_active\":true,\"percent_off\":1.1,\"promo_code_external_id\":\"promo_code_external_id\",\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"},{\"amount_off\":1,\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"currency\":\"currency\",\"customer_facing_code\":\"customer_facing_code\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"duration_in_months\":1,\"ended_at\":\"2024-01-15T09:30:00Z\",\"is_active\":true,\"percent_off\":1.1,\"promo_code_external_id\":\"promo_code_external_id\",\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"due_date\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_external_id\":\"payment_method_external_id\",\"subscription_external_id\":\"subscription_external_id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"metadata\":{\"metadata\":{\"key\":\"value\"}},\"payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"billing_threshold\":1,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"meter_id\":\"meter_id\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"subscription_item_external_id\":\"subscription_item_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},{\"billing_scheme\":\"billing_scheme\",\"billing_threshold\":1,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"meter_id\":\"meter_id\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"subscription_item_external_id\":\"subscription_item_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"amount_off\":1,\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"currency\":\"currency\",\"customer_facing_code\":\"customer_facing_code\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"duration_in_months\":1,\"ended_at\":\"2024-01-15T09:30:00Z\",\"is_active\":true,\"percent_off\":1.1,\"promo_code_external_id\":\"promo_code_external_id\",\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"},{\"amount_off\":1,\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"currency\":\"currency\",\"customer_facing_code\":\"customer_facing_code\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"duration_in_months\":1,\"ended_at\":\"2024-01-15T09:30:00Z\",\"is_active\":true,\"percent_off\":1.1,\"promo_code_external_id\":\"promo_code_external_id\",\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"due_date\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_external_id\":\"payment_method_external_id\",\"subscription_external_id\":\"subscription_external_id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"metadata\":{\"metadata\":{\"key\":\"value\"}},\"payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"billing_threshold\":1,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"meter_id\":\"meter_id\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"subscription_item_external_id\":\"subscription_item_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},{\"billing_scheme\":\"billing_scheme\",\"billing_threshold\":1,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"meter_id\":\"meter_id\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"subscription_item_external_id\":\"subscription_item_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_type\":\"entity_type\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_type\":\"entity_type\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"valid_until\":\"2024-01-15T09:30:00Z\",\"value\":1},{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"valid_until\":\"2024-01-15T09:30:00Z\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"added_on\":\"2024-01-15T09:30:00Z\",\"billing_product_external_id\":\"billing_product_external_id\",\"billing_product_id\":\"billing_product_id\",\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\",\"plan_period\":\"plan_period\",\"plan_price\":1},\"plans\":[{\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\"},{\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"},{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"}]},{\"conditions\":[{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"},{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"},{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"flag_id\":\"flag_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true},{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"},{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"}]},{\"conditions\":[{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"},{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"},{\"account_id\":\"account_id\",\"comparison_trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"condition_type\":\"condition_type\",\"consumption_rate\":1.1,\"credit_id\":\"credit_id\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"metric_value\":1,\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\",\"resource_ids\"],\"trait_definition\":{\"comparable_type\":\"comparable_type\",\"entity_type\":\"entity_type\",\"id\":\"id\"},\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"flag_id\":\"flag_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"traits\":{\"key\":\"value\"}},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"params\":{\"keys\":{\"keys\":\"keys\"}}}")); + LookupCompanyResponse response = client.companies() + .lookupCompany(LookupCompanyRequest.builder() + .keys(new HashMap() { + { + put("keys", "keys"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"added_on\": \"2024-01-15T09:30:00Z\",\n" + + " \"billing_product_external_id\": \"billing_product_external_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\",\n" + + " \"plan_period\": \"plan_period\",\n" + + " \"plan_price\": 1\n" + + " },\n" + + " {\n" + + " \"added_on\": \"2024-01-15T09:30:00Z\",\n" + + " \"billing_product_external_id\": \"billing_product_external_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\",\n" + + " \"plan_period\": \"plan_period\",\n" + + " \"plan_price\": 1\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"billing_credit_balances\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"amount_off\": 1,\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_facing_code\": \"customer_facing_code\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"is_active\": true,\n" + + " \"percent_off\": 1.1,\n" + + " \"promo_code_external_id\": \"promo_code_external_id\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " },\n" + + " {\n" + + " \"amount_off\": 1,\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_facing_code\": \"customer_facing_code\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"is_active\": true,\n" + + " \"percent_off\": 1.1,\n" + + " \"promo_code_external_id\": \"promo_code_external_id\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"due_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_external_id\": \"payment_method_external_id\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"billing_threshold\": 1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"subscription_item_external_id\": \"subscription_item_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"billing_threshold\": 1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"subscription_item_external_id\": \"subscription_item_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"amount_off\": 1,\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_facing_code\": \"customer_facing_code\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"is_active\": true,\n" + + " \"percent_off\": 1.1,\n" + + " \"promo_code_external_id\": \"promo_code_external_id\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " },\n" + + " {\n" + + " \"amount_off\": 1,\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_facing_code\": \"customer_facing_code\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"is_active\": true,\n" + + " \"percent_off\": 1.1,\n" + + " \"promo_code_external_id\": \"promo_code_external_id\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"due_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_external_id\": \"payment_method_external_id\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"billing_threshold\": 1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"subscription_item_external_id\": \"subscription_item_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"billing_threshold\": 1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"subscription_item_external_id\": \"subscription_item_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"amount_off\": 1,\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_facing_code\": \"customer_facing_code\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"is_active\": true,\n" + + " \"percent_off\": 1.1,\n" + + " \"promo_code_external_id\": \"promo_code_external_id\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " },\n" + + " {\n" + + " \"amount_off\": 1,\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_facing_code\": \"customer_facing_code\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"duration_in_months\": 1,\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"is_active\": true,\n" + + " \"percent_off\": 1.1,\n" + + " \"promo_code_external_id\": \"promo_code_external_id\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"due_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_external_id\": \"payment_method_external_id\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"billing_threshold\": 1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"subscription_item_external_id\": \"subscription_item_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"billing_threshold\": 1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"subscription_item_external_id\": \"subscription_item_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"valid_until\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": 1\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"valid_until\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"added_on\": \"2024-01-15T09:30:00Z\",\n" + + " \"billing_product_external_id\": \"billing_product_external_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\",\n" + + " \"plan_period\": \"plan_period\",\n" + + " \"plan_price\": 1\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " {\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"flag_id\": \"flag_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"comparison_trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"metric_value\": 1,\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\",\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_definition\": {\n" + + " \"comparable_type\": \"comparable_type\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\"\n" + + " },\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"flag_id\": \"flag_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"keys\": {\n" + + " \"keys\": \"keys\"\n" + + " }\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetActiveDeals() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"deal_arr\":\"deal_arr\",\"deal_external_id\":\"deal_external_id\",\"deal_mrr\":\"deal_mrr\",\"deal_name\":\"deal_name\",\"line_items\":[{\"billing_frequency\":\"billing_frequency\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"description\":\"description\",\"id\":\"id\",\"name\":\"name\",\"price\":1.1,\"quantity\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"}]}],\"params\":{\"company_id\":\"company_id\",\"deal_stage\":\"deal_stage\",\"limit\":1,\"offset\":1}}")); + GetActiveDealsResponse response = client.companies() + .getActiveDeals(GetActiveDealsRequest.builder() + .companyId("company_id") + .dealStage("deal_stage") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"deal_arr\": \"deal_arr\",\n" + + " \"deal_external_id\": \"deal_external_id\",\n" + + " \"deal_mrr\": \"deal_mrr\",\n" + + " \"deal_name\": \"deal_name\",\n" + + " \"line_items\": [\n" + + " {\n" + + " \"billing_frequency\": \"billing_frequency\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"quantity\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"deal_stage\": \"deal_stage\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListCompanyMemberships() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"company\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"}],\"params\":{\"company_id\":\"company_id\",\"limit\":1,\"offset\":1,\"user_id\":\"user_id\"}}")); + ListCompanyMembershipsResponse response = client.companies() + .listCompanyMemberships(ListCompanyMembershipsRequest.builder() + .companyId("company_id") + .userId("user_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"company\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetOrCreateCompanyMembership() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"},\"params\":{\"key\":\"value\"}}")); + GetOrCreateCompanyMembershipResponse response = client.companies() + .getOrCreateCompanyMembership(GetOrCreateCompanyMembershipRequestBody.builder() + .companyId("company_id") + .userId("user_id") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = + "" + "{\n" + " \"company_id\": \"company_id\",\n" + " \"user_id\": \"user_id\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteCompanyMembership() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteCompanyMembershipResponse response = client.companies().deleteCompanyMembership("company_membership_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetActiveCompanySubscription() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"cancel_at\":\"2024-01-15T09:30:00Z\",\"cancel_at_period_end\":true,\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"company_id\":\"company_id\",\"company_ids\":[\"company_ids\"],\"limit\":1,\"offset\":1}}")); + GetActiveCompanySubscriptionResponse response = client.companies() + .getActiveCompanySubscription(GetActiveCompanySubscriptionRequest.builder() + .companyId("company_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"cancel_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"cancel_at_period_end\": true,\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_ids\": [\n" + + " \"company_ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertCompanyTrait() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"metadata\":{\"key\":\"value\"},\"payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"added_on\":\"2024-01-15T09:30:00Z\",\"billing_product_external_id\":\"billing_product_external_id\",\"billing_product_id\":\"billing_product_id\",\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\",\"plan_period\":\"plan_period\",\"plan_price\":1},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"params\":{\"key\":\"value\"}}")); + UpsertCompanyTraitResponse response = client.companies() + .upsertCompanyTrait(UpsertTraitRequestBody.builder() + .keys(new HashMap() { + { + put("key", "value"); + } + }) + .trait("trait") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"keys\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"trait\": \"trait\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"added_on\": \"2024-01-15T09:30:00Z\",\n" + + " \"billing_product_external_id\": \"billing_product_external_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\",\n" + + " \"plan_period\": \"plan_period\",\n" + + " \"plan_price\": 1\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListEntityKeyDefinitions() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_type\":\"entity_type\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"entity_type\":\"company\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + ListEntityKeyDefinitionsResponse response = client.companies() + .listEntityKeyDefinitions(ListEntityKeyDefinitionsRequest.builder() + .entityType(ListEntityKeyDefinitionsRequestEntityType.COMPANY) + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"entity_type\": \"company\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountEntityKeyDefinitions() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"entity_type\":\"company\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + CountEntityKeyDefinitionsResponse response = client.companies() + .countEntityKeyDefinitions(CountEntityKeyDefinitionsRequest.builder() + .entityType(CountEntityKeyDefinitionsRequestEntityType.COMPANY) + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"entity_type\": \"company\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListEntityTraitDefinitions() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"entity_type\":\"company\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"trait_type\":\"boolean\"}}")); + ListEntityTraitDefinitionsResponse response = client.companies() + .listEntityTraitDefinitions(ListEntityTraitDefinitionsRequest.builder() + .entityType(ListEntityTraitDefinitionsRequestEntityType.COMPANY) + .q("q") + .traitType(ListEntityTraitDefinitionsRequestTraitType.BOOLEAN) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"entity_type\": \"company\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"trait_type\": \"boolean\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetOrCreateEntityTraitDefinition() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetOrCreateEntityTraitDefinitionResponse response = client.companies() + .getOrCreateEntityTraitDefinition(CreateEntityTraitDefinitionRequestBody.builder() + .entityType(CreateEntityTraitDefinitionRequestBodyEntityType.COMPANY) + .hierarchy(Arrays.asList("hierarchy")) + .traitType(CreateEntityTraitDefinitionRequestBodyTraitType.BOOLEAN) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"entity_type\": \"company\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"trait_type\": \"boolean\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetEntityTraitDefinition() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetEntityTraitDefinitionResponse response = + client.companies().getEntityTraitDefinition("entity_trait_definition_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateEntityTraitDefinition() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdateEntityTraitDefinitionResponse response = client.companies() + .updateEntityTraitDefinition( + "entity_trait_definition_id", + UpdateEntityTraitDefinitionRequestBody.builder() + .traitType(UpdateEntityTraitDefinitionRequestBodyTraitType.BOOLEAN) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"trait_type\": \"boolean\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountEntityTraitDefinitions() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"entity_type\":\"company\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"trait_type\":\"boolean\"}}")); + CountEntityTraitDefinitionsResponse response = client.companies() + .countEntityTraitDefinitions(CountEntityTraitDefinitionsRequest.builder() + .entityType(CountEntityTraitDefinitionsRequestEntityType.COMPANY) + .q("q") + .traitType(CountEntityTraitDefinitionsRequestTraitType.BOOLEAN) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"entity_type\": \"company\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"trait_type\": \"boolean\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetEntityTraitValues() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"definition_id\":\"definition_id\",\"value\":\"value\"}],\"params\":{\"definition_id\":\"definition_id\",\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + GetEntityTraitValuesResponse response = client.companies() + .getEntityTraitValues(GetEntityTraitValuesRequest.builder() + .definitionId("definition_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListPlanChanges() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"action\":\"checkout\",\"actor_type\":\"app_user\",\"add_ons_added\":[{\"deleted\":true,\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\"}],\"add_ons_removed\":[{\"deleted\":true,\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\"}],\"api_key\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"name\":\"name\",\"scopes\":[\"scopes\"],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"api_key_request\":{\"api_key_id\":\"api_key_id\",\"id\":\"id\",\"method\":\"method\",\"started_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"base_plan\":{\"deleted\":true,\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\"},\"base_plan_action\":\"fallback\",\"company\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"previous_base_plan\":{\"deleted\":true,\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\"},\"request_id\":\"request_id\",\"subscription_change_action\":\"downgrade\",\"traits_updated\":[{\"feature_id\":\"feature_id\",\"hierarchy\":[\"hierarchy\"],\"reason\":\"reason\",\"trait_id\":\"trait_id\",\"trait_name\":\"trait_name\",\"trait_type\":\"trait_type\",\"value\":\"value\"}],\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\",\"user_name\":\"user_name\"}],\"params\":{\"action\":\"action\",\"base_plan_action\":\"base_plan_action\",\"company_id\":\"company_id\",\"company_ids\":[\"company_ids\"],\"limit\":1,\"offset\":1,\"plan_ids\":[\"plan_ids\"]}}")); + ListPlanChangesResponse response = client.companies() + .listPlanChanges(ListPlanChangesRequest.builder() + .action("action") + .basePlanAction("base_plan_action") + .companyId("company_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"action\": \"checkout\",\n" + + " \"actor_type\": \"app_user\",\n" + + " \"add_ons_added\": [\n" + + " {\n" + + " \"deleted\": true,\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"add_ons_removed\": [\n" + + " {\n" + + " \"deleted\": true,\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"api_key\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"scopes\": [\n" + + " \"scopes\"\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"api_key_request\": {\n" + + " \"api_key_id\": \"api_key_id\",\n" + + " \"id\": \"id\",\n" + + " \"method\": \"method\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"base_plan\": {\n" + + " \"deleted\": true,\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"base_plan_action\": \"fallback\",\n" + + " \"company\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"previous_base_plan\": {\n" + + " \"deleted\": true,\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"request_id\": \"request_id\",\n" + + " \"subscription_change_action\": \"downgrade\",\n" + + " \"traits_updated\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"reason\": \"reason\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_name\": \"trait_name\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\",\n" + + " \"user_name\": \"user_name\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"action\": \"action\",\n" + + " \"base_plan_action\": \"base_plan_action\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_ids\": [\n" + + " \"company_ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_ids\": [\n" + + " \"plan_ids\"\n" + + " ]\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetPlanChange() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"action\":\"checkout\",\"actor_type\":\"app_user\",\"add_ons_added\":[{\"deleted\":true,\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\"}],\"add_ons_removed\":[{\"deleted\":true,\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\"}],\"api_key\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_used_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"scopes\":[\"scopes\"],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"api_key_request\":{\"api_key_id\":\"api_key_id\",\"ended_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"method\":\"method\",\"req_body\":\"req_body\",\"request_type\":\"request_type\",\"resource_id\":1,\"resource_id_string\":\"resource_id_string\",\"resource_name\":\"resource_name\",\"resource_type\":\"resource_type\",\"resp_code\":1,\"secondary_resource\":\"secondary_resource\",\"started_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\",\"user_name\":\"user_name\"},\"base_plan\":{\"deleted\":true,\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\"},\"base_plan_action\":\"fallback\",\"company\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"previous_base_plan\":{\"deleted\":true,\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\"},\"request_id\":\"request_id\",\"subscription_change_action\":\"downgrade\",\"traits_updated\":[{\"feature_id\":\"feature_id\",\"hierarchy\":[\"hierarchy\"],\"reason\":\"reason\",\"trait_id\":\"trait_id\",\"trait_name\":\"trait_name\",\"trait_type\":\"trait_type\",\"value\":\"value\"}],\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\",\"user_name\":\"user_name\"},\"params\":{\"key\":\"value\"}}")); + GetPlanChangeResponse response = client.companies().getPlanChange("plan_change_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"action\": \"checkout\",\n" + + " \"actor_type\": \"app_user\",\n" + + " \"add_ons_added\": [\n" + + " {\n" + + " \"deleted\": true,\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"add_ons_removed\": [\n" + + " {\n" + + " \"deleted\": true,\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"api_key\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_used_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"scopes\": [\n" + + " \"scopes\"\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"api_key_request\": {\n" + + " \"api_key_id\": \"api_key_id\",\n" + + " \"ended_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"method\": \"method\",\n" + + " \"req_body\": \"req_body\",\n" + + " \"request_type\": \"request_type\",\n" + + " \"resource_id\": 1,\n" + + " \"resource_id_string\": \"resource_id_string\",\n" + + " \"resource_name\": \"resource_name\",\n" + + " \"resource_type\": \"resource_type\",\n" + + " \"resp_code\": 1,\n" + + " \"secondary_resource\": \"secondary_resource\",\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\",\n" + + " \"user_name\": \"user_name\"\n" + + " },\n" + + " \"base_plan\": {\n" + + " \"deleted\": true,\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"base_plan_action\": \"fallback\",\n" + + " \"company\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"previous_base_plan\": {\n" + + " \"deleted\": true,\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"request_id\": \"request_id\",\n" + + " \"subscription_change_action\": \"downgrade\",\n" + + " \"traits_updated\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"reason\": \"reason\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_name\": \"trait_name\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\",\n" + + " \"user_name\": \"user_name\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListPlanTraits() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_type\":\"plan_type\",\"trait_id\":\"trait_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"trait_id\":\"trait_id\",\"trait_ids\":[\"trait_ids\"]}}")); + ListPlanTraitsResponse response = client.companies() + .listPlanTraits(ListPlanTraitsRequest.builder() + .planId("plan_id") + .traitId("trait_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_ids\": [\n" + + " \"trait_ids\"\n" + + " ]\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreatePlanTrait() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_type\":\"plan_type\",\"trait_id\":\"trait_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreatePlanTraitResponse response = client.companies() + .createPlanTrait(CreatePlanTraitRequestBody.builder() + .planId("plan_id") + .traitId("trait_id") + .traitValue("trait_value") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_value\": \"trait_value\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetPlanTrait() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_type\":\"plan_type\",\"trait_id\":\"trait_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetPlanTraitResponse response = client.companies().getPlanTrait("plan_trait_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdatePlanTrait() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_type\":\"plan_type\",\"trait_id\":\"trait_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdatePlanTraitResponse response = client.companies() + .updatePlanTrait( + "plan_trait_id", + UpdatePlanTraitRequestBody.builder() + .planId("plan_id") + .traitValue("trait_value") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = + "" + "{\n" + " \"plan_id\": \"plan_id\",\n" + " \"trait_value\": \"trait_value\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeletePlanTrait() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeletePlanTraitResponse response = client.companies().deletePlanTrait("plan_trait_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdatePlanTraitsBulk() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_type\":\"plan_type\",\"trait_id\":\"trait_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"key\":\"value\"}}")); + UpdatePlanTraitsBulkResponse response = client.companies() + .updatePlanTraitsBulk(UpdatePlanTraitBulkRequestBody.builder() + .planId("plan_id") + .traits(Arrays.asList(UpdatePlanTraitTraitRequestBody.builder() + .traitId("trait_id") + .traitValue("trait_value") + .build())) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"traits\": [\n" + + " {\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountPlanTraits() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"trait_id\":\"trait_id\",\"trait_ids\":[\"trait_ids\"]}}")); + CountPlanTraitsResponse response = client.companies() + .countPlanTraits(CountPlanTraitsRequest.builder() + .planId("plan_id") + .traitId("trait_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"trait_ids\": [\n" + + " \"trait_ids\"\n" + + " ]\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertUserTrait() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_memberships\":[{\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertUserTraitResponse response = client.companies() + .upsertUserTrait(UpsertTraitRequestBody.builder() + .keys(new HashMap() { + { + put("key", "value"); + } + }) + .trait("trait") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"keys\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"trait\": \"trait\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_memberships\": [\n" + + " {\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListUsers() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"company_memberships\":[{\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"company_id\":\"company_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"q\":\"q\"}}")); + ListUsersResponse response = client.companies() + .listUsers(ListUsersRequest.builder() + .companyId("company_id") + .planId("plan_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"company_memberships\": [\n" + + " {\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertUser() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_memberships\":[{\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertUserResponse response = client.companies() + .upsertUser(UpsertUserRequestBody.builder() + .keys(new HashMap() { + { + put("key", "value"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"keys\": {\n" + " \"key\": \"value\"\n" + " }\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_memberships\": [\n" + + " {\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetUser() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_memberships\":[{\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetUserResponse response = client.companies().getUser("user_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_memberships\": [\n" + + " {\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteUser() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteUserResponse response = client.companies().deleteUser("user_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountUsers() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"company_id\":\"company_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"q\":\"q\"}}")); + CountUsersResponse response = client.companies() + .countUsers(CountUsersRequest.builder() + .companyId("company_id") + .planId("plan_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateUser() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_memberships\":[{\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateUserResponse response = client.companies() + .createUser(UpsertUserRequestBody.builder() + .keys(new HashMap() { + { + put("key", "value"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"keys\": {\n" + " \"key\": \"value\"\n" + " }\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_memberships\": [\n" + + " {\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteUserByKeys() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + DeleteUserByKeysResponse response = client.companies() + .deleteUserByKeys(KeysRequestBody.builder() + .keys(new HashMap() { + { + put("key", "value"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"keys\": {\n" + " \"key\": \"value\"\n" + " }\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testLookupUser() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_memberships\":[{\"company\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"},{\"company\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_id\":\"user_id\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_type\":\"entity_type\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_type\":\"entity_type\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"name\":\"name\",\"traits\":{\"traits\":{\"key\":\"value\"}},\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"keys\":{\"keys\":\"keys\"}}}")); + LookupUserResponse response = client.companies() + .lookupUser(LookupUserRequest.builder() + .keys(new HashMap() { + { + put("keys", "keys"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_memberships\": [\n" + + " {\n" + + " \"company\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " },\n" + + " {\n" + + " \"company\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"name\": \"name\",\n" + + " \"traits\": {\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"keys\": {\n" + + " \"keys\": \"keys\"\n" + + " }\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/ComponentsWireTest.java b/src/test/java/com/schematic/api/ComponentsWireTest.java new file mode 100644 index 0000000..e78a568 --- /dev/null +++ b/src/test/java/com/schematic/api/ComponentsWireTest.java @@ -0,0 +1,1596 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.components.requests.CountComponentsRequest; +import com.schematic.api.resources.components.requests.CreateComponentRequestBody; +import com.schematic.api.resources.components.requests.ListComponentsRequest; +import com.schematic.api.resources.components.requests.PreviewComponentDataRequest; +import com.schematic.api.resources.components.requests.UpdateComponentRequestBody; +import com.schematic.api.resources.components.types.CountComponentsResponse; +import com.schematic.api.resources.components.types.CreateComponentRequestBodyEntityType; +import com.schematic.api.resources.components.types.CreateComponentResponse; +import com.schematic.api.resources.components.types.DeleteComponentResponse; +import com.schematic.api.resources.components.types.GetComponentResponse; +import com.schematic.api.resources.components.types.ListComponentsResponse; +import com.schematic.api.resources.components.types.PreviewComponentDataResponse; +import com.schematic.api.resources.components.types.UpdateComponentResponse; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ComponentsWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testListComponents() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"ast\":{\"key\":1.1},\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"name\":\"name\",\"state\":\"state\",\"type\":\"type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + ListComponentsResponse response = client.components() + .listComponents(ListComponentsRequest.builder() + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"ast\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"state\": \"state\",\n" + + " \"type\": \"type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateComponent() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"ast\":{\"key\":1.1},\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"name\":\"name\",\"state\":\"state\",\"type\":\"type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateComponentResponse response = client.components() + .createComponent(CreateComponentRequestBody.builder() + .entityType(CreateComponentRequestBodyEntityType.ENTITLEMENT) + .name("name") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = + "" + "{\n" + " \"entity_type\": \"entitlement\",\n" + " \"name\": \"name\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"ast\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"state\": \"state\",\n" + + " \"type\": \"type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetComponent() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"ast\":{\"key\":1.1},\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"name\":\"name\",\"state\":\"state\",\"type\":\"type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetComponentResponse response = client.components().getComponent("component_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"ast\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"state\": \"state\",\n" + + " \"type\": \"type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateComponent() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"ast\":{\"key\":1.1},\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"name\":\"name\",\"state\":\"state\",\"type\":\"type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdateComponentResponse response = client.components() + .updateComponent( + "component_id", UpdateComponentRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"ast\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"state\": \"state\",\n" + + " \"type\": \"type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteComponent() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteComponentResponse response = client.components().deleteComponent("component_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountComponents() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"count\":1},\"params\":{\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + CountComponentsResponse response = client.components() + .countComponents(CountComponentsRequest.builder() + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testPreviewComponentData() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"active_add_ons\":[{\"charge_type\":\"charge_type\",\"company_can_trial\":true,\"company_count\":1,\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"current\":true,\"custom\":true,\"description\":\"description\",\"entitlements\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"}],\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_description\":\"credit_description\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"reset_type\":\"reset_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_custom\":true,\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_violations\":[{\"access\":true,\"allocation_type\":\"boolean\",\"entitlement_id\":\"entitlement_id\",\"entitlement_type\":\"entitlement_type\"}],\"valid\":true}],\"active_plans\":[{\"charge_type\":\"charge_type\",\"company_can_trial\":true,\"company_count\":1,\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"current\":true,\"custom\":true,\"description\":\"description\",\"entitlements\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"}],\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_description\":\"credit_description\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"reset_type\":\"reset_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_custom\":true,\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_violations\":[{\"access\":true,\"allocation_type\":\"boolean\",\"entitlement_id\":\"entitlement_id\",\"entitlement_type\":\"entitlement_type\"}],\"valid\":true}],\"active_usage_based_entitlements\":[{\"feature_id\":\"feature_id\",\"value_type\":\"value_type\"}],\"add_on_compatibilities\":[{\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"source_plan_id\":\"source_plan_id\"}],\"capabilities\":{\"badge_visibility\":true,\"checkout\":true},\"checkout_settings\":{\"collect_address\":true,\"collect_email\":true,\"collect_phone\":true,\"tax_collection_enabled\":true},\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"component\":{\"ast\":{\"key\":1.1},\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"name\":\"name\",\"state\":\"state\",\"type\":\"type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"credit_bundles\":[{\"bundle_type\":\"bundle_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expiry_type\":\"expiry_type\",\"expiry_unit\":\"expiry_unit\",\"has_grants\":true,\"id\":\"id\",\"name\":\"name\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"credit_grants\":[{\"billing_credit_id\":\"billing_credit_id\",\"company_id\":\"company_id\",\"company_name\":\"company_name\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_description\":\"credit_description\",\"credit_name\":\"credit_name\",\"grant_reason\":\"grant_reason\",\"id\":\"id\",\"quantity\":1,\"quantity_remaining\":1.1,\"quantity_used\":1.1,\"source_label\":\"source_label\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"default_plan\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}},\"feature_usage\":{\"features\":[{\"access\":true,\"allocation_type\":\"boolean\",\"entitlement_id\":\"entitlement_id\",\"entitlement_type\":\"entitlement_type\"}]},\"invoices\":[{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"post_trial_plan\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}},\"show_credits\":true,\"show_period_toggle\":true,\"show_zero_price_as_free\":true,\"stripe_embed\":{\"account_id\":\"account_id\",\"publishable_key\":\"publishable_key\",\"schematic_publishable_key\":\"schematic_publishable_key\",\"setup_intent_client_secret\":\"setup_intent_client_secret\"},\"subscription\":{\"cancel_at\":\"2024-01-15T09:30:00Z\",\"cancel_at_period_end\":true,\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":\"2024-01-15T09:30:00Z\"},\"trial_payment_method_required\":true,\"upcoming_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"due_date\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_external_id\":\"payment_method_external_id\",\"subscription_external_id\":\"subscription_external_id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"}},\"params\":{\"company_id\":\"company_id\",\"component_id\":\"component_id\"}}")); + PreviewComponentDataResponse response = client.components() + .previewComponentData(PreviewComponentDataRequest.builder() + .companyId("company_id") + .componentId("component_id") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"active_add_ons\": [\n" + + " {\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_can_trial\": true,\n" + + " \"company_count\": 1,\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"current\": true,\n" + + " \"custom\": true,\n" + + " \"description\": \"description\",\n" + + " \"entitlements\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_description\": \"credit_description\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"reset_type\": \"reset_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_custom\": true,\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_violations\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_type\": \"entitlement_type\"\n" + + " }\n" + + " ],\n" + + " \"valid\": true\n" + + " }\n" + + " ],\n" + + " \"active_plans\": [\n" + + " {\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_can_trial\": true,\n" + + " \"company_count\": 1,\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"current\": true,\n" + + " \"custom\": true,\n" + + " \"description\": \"description\",\n" + + " \"entitlements\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_description\": \"credit_description\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"reset_type\": \"reset_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_custom\": true,\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_violations\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_type\": \"entitlement_type\"\n" + + " }\n" + + " ],\n" + + " \"valid\": true\n" + + " }\n" + + " ],\n" + + " \"active_usage_based_entitlements\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"add_on_compatibilities\": [\n" + + " {\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"source_plan_id\": \"source_plan_id\"\n" + + " }\n" + + " ],\n" + + " \"capabilities\": {\n" + + " \"badge_visibility\": true,\n" + + " \"checkout\": true\n" + + " },\n" + + " \"checkout_settings\": {\n" + + " \"collect_address\": true,\n" + + " \"collect_email\": true,\n" + + " \"collect_phone\": true,\n" + + " \"tax_collection_enabled\": true\n" + + " },\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"component\": {\n" + + " \"ast\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"state\": \"state\",\n" + + " \"type\": \"type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"credit_bundles\": [\n" + + " {\n" + + " \"bundle_type\": \"bundle_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expiry_type\": \"expiry_type\",\n" + + " \"expiry_unit\": \"expiry_unit\",\n" + + " \"has_grants\": true,\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"credit_grants\": [\n" + + " {\n" + + " \"billing_credit_id\": \"billing_credit_id\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_name\": \"company_name\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_description\": \"credit_description\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"grant_reason\": \"grant_reason\",\n" + + " \"id\": \"id\",\n" + + " \"quantity\": 1,\n" + + " \"quantity_remaining\": 1.1,\n" + + " \"quantity_used\": 1.1,\n" + + " \"source_label\": \"source_label\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"default_plan\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"feature_usage\": {\n" + + " \"features\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_type\": \"entitlement_type\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"invoices\": [\n" + + " {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"post_trial_plan\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"show_credits\": true,\n" + + " \"show_period_toggle\": true,\n" + + " \"show_zero_price_as_free\": true,\n" + + " \"stripe_embed\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"publishable_key\": \"publishable_key\",\n" + + " \"schematic_publishable_key\": \"schematic_publishable_key\",\n" + + " \"setup_intent_client_secret\": \"setup_intent_client_secret\"\n" + + " },\n" + + " \"subscription\": {\n" + + " \"cancel_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"cancel_at_period_end\": true,\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"trial_payment_method_required\": true,\n" + + " \"upcoming_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"due_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_external_id\": \"payment_method_external_id\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " }\n" + + " },\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"component_id\": \"component_id\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/CreditsWireTest.java b/src/test/java/com/schematic/api/CreditsWireTest.java new file mode 100644 index 0000000..75d34bf --- /dev/null +++ b/src/test/java/com/schematic/api/CreditsWireTest.java @@ -0,0 +1,2172 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.credits.requests.CountBillingCreditsGrantsRequest; +import com.schematic.api.resources.credits.requests.CountBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.CountBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.CountCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.CountCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.CreateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.CreateBillingPlanCreditGrantRequestBody; +import com.schematic.api.resources.credits.requests.CreateCompanyCreditGrant; +import com.schematic.api.resources.credits.requests.CreateCreditBundleRequestBody; +import com.schematic.api.resources.credits.requests.GetEnrichedCreditLedgerRequest; +import com.schematic.api.resources.credits.requests.ListBillingCreditsRequest; +import com.schematic.api.resources.credits.requests.ListBillingPlanCreditGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCompanyGrantsRequest; +import com.schematic.api.resources.credits.requests.ListCreditBundlesRequest; +import com.schematic.api.resources.credits.requests.ListGrantsForCreditRequest; +import com.schematic.api.resources.credits.requests.UpdateBillingCreditRequestBody; +import com.schematic.api.resources.credits.requests.UpdateCreditBundleDetailsRequestBody; +import com.schematic.api.resources.credits.requests.ZeroOutGrantRequestBody; +import com.schematic.api.resources.credits.types.CountBillingCreditsGrantsResponse; +import com.schematic.api.resources.credits.types.CountBillingCreditsResponse; +import com.schematic.api.resources.credits.types.CountBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.CountCreditBundlesRequestStatus; +import com.schematic.api.resources.credits.types.CountCreditBundlesResponse; +import com.schematic.api.resources.credits.types.CountCreditLedgerRequestPeriod; +import com.schematic.api.resources.credits.types.CountCreditLedgerResponse; +import com.schematic.api.resources.credits.types.CreateBillingCreditResponse; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantRequestBodyResetCadence; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantRequestBodyResetStart; +import com.schematic.api.resources.credits.types.CreateBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.CreateCreditBundleResponse; +import com.schematic.api.resources.credits.types.DeleteBillingPlanCreditGrantResponse; +import com.schematic.api.resources.credits.types.DeleteCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetCreditBundleResponse; +import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerRequestPeriod; +import com.schematic.api.resources.credits.types.GetEnrichedCreditLedgerResponse; +import com.schematic.api.resources.credits.types.GetSingleBillingCreditResponse; +import com.schematic.api.resources.credits.types.GrantBillingCreditsToCompanyResponse; +import com.schematic.api.resources.credits.types.ListBillingCreditsResponse; +import com.schematic.api.resources.credits.types.ListBillingPlanCreditGrantsResponse; +import com.schematic.api.resources.credits.types.ListCompanyGrantsRequestDir; +import com.schematic.api.resources.credits.types.ListCompanyGrantsRequestOrder; +import com.schematic.api.resources.credits.types.ListCompanyGrantsResponse; +import com.schematic.api.resources.credits.types.ListCreditBundlesRequestStatus; +import com.schematic.api.resources.credits.types.ListCreditBundlesResponse; +import com.schematic.api.resources.credits.types.ListGrantsForCreditResponse; +import com.schematic.api.resources.credits.types.SoftDeleteBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateBillingCreditResponse; +import com.schematic.api.resources.credits.types.UpdateCreditBundleDetailsResponse; +import com.schematic.api.resources.credits.types.ZeroOutGrantResponse; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class CreditsWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testListBillingCredits() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"name\":\"name\",\"offset\":1}}")); + ListBillingCreditsResponse response = client.credits() + .listBillingCredits(ListBillingCreditsRequest.builder() + .name("name") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"name\": \"name\",\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateBillingCredit() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateBillingCreditResponse response = client.credits() + .createBillingCredit(CreateBillingCreditRequestBody.builder() + .currency("currency") + .description("description") + .name("name") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"currency\": \"currency\",\n" + + " \"description\": \"description\",\n" + + " \"name\": \"name\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetSingleBillingCredit() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetSingleBillingCreditResponse response = client.credits().getSingleBillingCredit("credit_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateBillingCredit() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdateBillingCreditResponse response = client.credits() + .updateBillingCredit( + "credit_id", + UpdateBillingCreditRequestBody.builder() + .description("description") + .name("name") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = + "" + "{\n" + " \"description\": \"description\",\n" + " \"name\": \"name\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testSoftDeleteBillingCredit() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + SoftDeleteBillingCreditResponse response = client.credits().softDeleteBillingCredit("credit_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListCreditBundles() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"billing_invoice_id\":\"billing_invoice_id\",\"bundle_type\":\"bundle_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_description\":\"credit_description\",\"credit_icon\":\"credit_icon\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expiry_type\":\"expiry_type\",\"expiry_unit\":\"expiry_unit\",\"expiry_unit_count\":1,\"has_grants\":true,\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"quantity\":1,\"singular_name\":\"singular_name\",\"status\":\"status\",\"unit_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"bundle_type\":\"fixed\",\"credit_id\":\"credit_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"status\":\"active\"}}")); + ListCreditBundlesResponse response = client.credits() + .listCreditBundles(ListCreditBundlesRequest.builder() + .creditId("credit_id") + .status(ListCreditBundlesRequestStatus.ACTIVE) + .bundleType("fixed") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"billing_invoice_id\": \"billing_invoice_id\",\n" + + " \"bundle_type\": \"bundle_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_description\": \"credit_description\",\n" + + " \"credit_icon\": \"credit_icon\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expiry_type\": \"expiry_type\",\n" + + " \"expiry_unit\": \"expiry_unit\",\n" + + " \"expiry_unit_count\": 1,\n" + + " \"has_grants\": true,\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"quantity\": 1,\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"status\": \"status\",\n" + + " \"unit_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"bundle_type\": \"fixed\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"status\": \"active\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateCreditBundle() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_invoice_id\":\"billing_invoice_id\",\"bundle_type\":\"bundle_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_description\":\"credit_description\",\"credit_icon\":\"credit_icon\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expiry_type\":\"expiry_type\",\"expiry_unit\":\"expiry_unit\",\"expiry_unit_count\":1,\"has_grants\":true,\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"quantity\":1,\"singular_name\":\"singular_name\",\"status\":\"status\",\"unit_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateCreditBundleResponse response = client.credits() + .createCreditBundle(CreateCreditBundleRequestBody.builder() + .bundleName("bundle_name") + .creditId("credit_id") + .currency("currency") + .pricePerUnit(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"bundle_name\": \"bundle_name\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"currency\": \"currency\",\n" + + " \"price_per_unit\": 1\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_invoice_id\": \"billing_invoice_id\",\n" + + " \"bundle_type\": \"bundle_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_description\": \"credit_description\",\n" + + " \"credit_icon\": \"credit_icon\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expiry_type\": \"expiry_type\",\n" + + " \"expiry_unit\": \"expiry_unit\",\n" + + " \"expiry_unit_count\": 1,\n" + + " \"has_grants\": true,\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"quantity\": 1,\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"status\": \"status\",\n" + + " \"unit_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetCreditBundle() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_invoice_id\":\"billing_invoice_id\",\"bundle_type\":\"bundle_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_description\":\"credit_description\",\"credit_icon\":\"credit_icon\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expiry_type\":\"expiry_type\",\"expiry_unit\":\"expiry_unit\",\"expiry_unit_count\":1,\"has_grants\":true,\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"quantity\":1,\"singular_name\":\"singular_name\",\"status\":\"status\",\"unit_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetCreditBundleResponse response = client.credits().getCreditBundle("bundle_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_invoice_id\": \"billing_invoice_id\",\n" + + " \"bundle_type\": \"bundle_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_description\": \"credit_description\",\n" + + " \"credit_icon\": \"credit_icon\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expiry_type\": \"expiry_type\",\n" + + " \"expiry_unit\": \"expiry_unit\",\n" + + " \"expiry_unit_count\": 1,\n" + + " \"has_grants\": true,\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"quantity\": 1,\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"status\": \"status\",\n" + + " \"unit_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateCreditBundleDetails() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_invoice_id\":\"billing_invoice_id\",\"bundle_type\":\"bundle_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_description\":\"credit_description\",\"credit_icon\":\"credit_icon\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expiry_type\":\"expiry_type\",\"expiry_unit\":\"expiry_unit\",\"expiry_unit_count\":1,\"has_grants\":true,\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"quantity\":1,\"singular_name\":\"singular_name\",\"status\":\"status\",\"unit_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdateCreditBundleDetailsResponse response = client.credits() + .updateCreditBundleDetails( + "bundle_id", + UpdateCreditBundleDetailsRequestBody.builder() + .bundleName("bundle_name") + .pricePerUnit(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = + "" + "{\n" + " \"bundle_name\": \"bundle_name\",\n" + " \"price_per_unit\": 1\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_invoice_id\": \"billing_invoice_id\",\n" + + " \"bundle_type\": \"bundle_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_description\": \"credit_description\",\n" + + " \"credit_icon\": \"credit_icon\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expiry_type\": \"expiry_type\",\n" + + " \"expiry_unit\": \"expiry_unit\",\n" + + " \"expiry_unit_count\": 1,\n" + + " \"has_grants\": true,\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"quantity\": 1,\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"status\": \"status\",\n" + + " \"unit_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteCreditBundle() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteCreditBundleResponse response = client.credits().deleteCreditBundle("bundle_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountCreditBundles() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"bundle_type\":\"fixed\",\"credit_id\":\"credit_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"status\":\"active\"}}")); + CountCreditBundlesResponse response = client.credits() + .countCreditBundles(CountCreditBundlesRequest.builder() + .creditId("credit_id") + .status(CountCreditBundlesRequestStatus.ACTIVE) + .bundleType("fixed") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"bundle_type\": \"fixed\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"status\": \"active\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountBillingCredits() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"name\":\"name\",\"offset\":1}}")); + CountBillingCreditsResponse response = client.credits() + .countBillingCredits(CountBillingCreditsRequest.builder() + .name("name") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"name\": \"name\",\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testZeroOutGrant() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_id\":\"company_id\",\"company_name\":\"company_name\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_icon\":\"credit_icon\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expires_at\":\"2024-01-15T09:30:00Z\",\"grant_reason\":\"grant_reason\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"quantity\":1,\"quantity_remaining\":1.1,\"quantity_used\":1.1,\"source_label\":\"source_label\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"valid_from\":\"2024-01-15T09:30:00Z\",\"zeroed_out_date\":\"2024-01-15T09:30:00Z\",\"zeroed_out_reason\":\"zeroed_out_reason\"},\"params\":{\"key\":\"value\"}}")); + ZeroOutGrantResponse response = client.credits() + .zeroOutGrant("grant_id", ZeroOutGrantRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_name\": \"company_name\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_icon\": \"credit_icon\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expires_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"grant_reason\": \"grant_reason\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"quantity\": 1,\n" + + " \"quantity_remaining\": 1.1,\n" + + " \"quantity_used\": 1.1,\n" + + " \"source_label\": \"source_label\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"valid_from\": \"2024-01-15T09:30:00Z\",\n" + + " \"zeroed_out_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"zeroed_out_reason\": \"zeroed_out_reason\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGrantBillingCreditsToCompany() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_id\":\"company_id\",\"company_name\":\"company_name\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_icon\":\"credit_icon\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expires_at\":\"2024-01-15T09:30:00Z\",\"grant_reason\":\"grant_reason\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"quantity\":1,\"quantity_remaining\":1.1,\"quantity_used\":1.1,\"source_label\":\"source_label\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"valid_from\":\"2024-01-15T09:30:00Z\",\"zeroed_out_date\":\"2024-01-15T09:30:00Z\",\"zeroed_out_reason\":\"zeroed_out_reason\"},\"params\":{\"key\":\"value\"}}")); + GrantBillingCreditsToCompanyResponse response = client.credits() + .grantBillingCreditsToCompany(CreateCompanyCreditGrant.builder() + .companyId("company_id") + .creditId("credit_id") + .quantity(1) + .reason("reason") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"company_id\": \"company_id\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"quantity\": 1,\n" + + " \"reason\": \"reason\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_name\": \"company_name\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_icon\": \"credit_icon\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expires_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"grant_reason\": \"grant_reason\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"quantity\": 1,\n" + + " \"quantity_remaining\": 1.1,\n" + + " \"quantity_used\": 1.1,\n" + + " \"source_label\": \"source_label\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"valid_from\": \"2024-01-15T09:30:00Z\",\n" + + " \"zeroed_out_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"zeroed_out_reason\": \"zeroed_out_reason\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListCompanyGrants() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"company_id\":\"company_id\",\"company_name\":\"company_name\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_icon\":\"credit_icon\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expires_at\":\"2024-01-15T09:30:00Z\",\"grant_reason\":\"grant_reason\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"quantity\":1,\"quantity_remaining\":1.1,\"quantity_used\":1.1,\"source_label\":\"source_label\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"valid_from\":\"2024-01-15T09:30:00Z\",\"zeroed_out_date\":\"2024-01-15T09:30:00Z\",\"zeroed_out_reason\":\"zeroed_out_reason\"}],\"params\":{\"company_id\":\"company_id\",\"dir\":\"asc\",\"limit\":1,\"offset\":1,\"order\":\"created_at\"}}")); + ListCompanyGrantsResponse response = client.credits() + .listCompanyGrants(ListCompanyGrantsRequest.builder() + .companyId("company_id") + .order(ListCompanyGrantsRequestOrder.CREATED_AT) + .dir(ListCompanyGrantsRequestDir.ASC) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_name\": \"company_name\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_icon\": \"credit_icon\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expires_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"grant_reason\": \"grant_reason\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"quantity\": 1,\n" + + " \"quantity_remaining\": 1.1,\n" + + " \"quantity_used\": 1.1,\n" + + " \"source_label\": \"source_label\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"valid_from\": \"2024-01-15T09:30:00Z\",\n" + + " \"zeroed_out_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"zeroed_out_reason\": \"zeroed_out_reason\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"dir\": \"asc\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"order\": \"created_at\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountBillingCreditsGrants() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"credit_id\":\"credit_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1}}")); + CountBillingCreditsGrantsResponse response = client.credits() + .countBillingCreditsGrants(CountBillingCreditsGrantsRequest.builder() + .creditId("credit_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListGrantsForCredit() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"company_id\":\"company_id\",\"company_name\":\"company_name\",\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_icon\":\"credit_icon\",\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"expires_at\":\"2024-01-15T09:30:00Z\",\"grant_reason\":\"grant_reason\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"quantity\":1,\"quantity_remaining\":1.1,\"quantity_used\":1.1,\"source_label\":\"source_label\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"valid_from\":\"2024-01-15T09:30:00Z\",\"zeroed_out_date\":\"2024-01-15T09:30:00Z\",\"zeroed_out_reason\":\"zeroed_out_reason\"}],\"params\":{\"credit_id\":\"credit_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1}}")); + ListGrantsForCreditResponse response = client.credits() + .listGrantsForCredit(ListGrantsForCreditRequest.builder() + .creditId("credit_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_name\": \"company_name\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_icon\": \"credit_icon\",\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"expires_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"grant_reason\": \"grant_reason\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"quantity\": 1,\n" + + " \"quantity_remaining\": 1.1,\n" + + " \"quantity_used\": 1.1,\n" + + " \"source_label\": \"source_label\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"valid_from\": \"2024-01-15T09:30:00Z\",\n" + + " \"zeroed_out_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"zeroed_out_reason\": \"zeroed_out_reason\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetEnrichedCreditLedger() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"billing_credit_id\":\"billing_credit_id\",\"company\":{\"id\":\"id\",\"name\":\"name\"},\"company_id\":\"company_id\",\"credit\":{\"id\":\"id\",\"name\":\"name\"},\"expired_grant_count\":1,\"feature\":{\"id\":\"id\",\"name\":\"name\"},\"feature_id\":\"feature_id\",\"first_transaction_at\":\"2024-01-15T09:30:00Z\",\"free_grant_count\":1,\"grant_count\":1,\"last_transaction_at\":\"2024-01-15T09:30:00Z\",\"manually_zeroed_count\":1,\"net_change\":1.1,\"plan_grant_count\":1,\"purchased_grant_count\":1,\"time_bucket\":\"2024-01-15T09:30:00Z\",\"total_consumed\":1.1,\"total_granted\":1.1,\"transaction_count\":1,\"usage_count\":1,\"zeroed_out_count\":1}],\"params\":{\"billing_credit_id\":\"billing_credit_id\",\"company_id\":\"company_id\",\"end_time\":\"end_time\",\"feature_id\":\"feature_id\",\"limit\":1,\"offset\":1,\"period\":\"daily\",\"start_time\":\"start_time\"}}")); + GetEnrichedCreditLedgerResponse response = client.credits() + .getEnrichedCreditLedger(GetEnrichedCreditLedgerRequest.builder() + .companyId("company_id") + .period(GetEnrichedCreditLedgerRequestPeriod.DAILY) + .billingCreditId("billing_credit_id") + .featureId("feature_id") + .startTime("start_time") + .endTime("end_time") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"billing_credit_id\": \"billing_credit_id\",\n" + + " \"company\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"credit\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"expired_grant_count\": 1,\n" + + " \"feature\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"first_transaction_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"free_grant_count\": 1,\n" + + " \"grant_count\": 1,\n" + + " \"last_transaction_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"manually_zeroed_count\": 1,\n" + + " \"net_change\": 1.1,\n" + + " \"plan_grant_count\": 1,\n" + + " \"purchased_grant_count\": 1,\n" + + " \"time_bucket\": \"2024-01-15T09:30:00Z\",\n" + + " \"total_consumed\": 1.1,\n" + + " \"total_granted\": 1.1,\n" + + " \"transaction_count\": 1,\n" + + " \"usage_count\": 1,\n" + + " \"zeroed_out_count\": 1\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"billing_credit_id\": \"billing_credit_id\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"end_time\": \"end_time\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"period\": \"daily\",\n" + + " \"start_time\": \"start_time\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountCreditLedger() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"billing_credit_id\":\"billing_credit_id\",\"company_id\":\"company_id\",\"end_time\":\"end_time\",\"feature_id\":\"feature_id\",\"limit\":1,\"offset\":1,\"period\":\"daily\",\"start_time\":\"start_time\"}}")); + CountCreditLedgerResponse response = client.credits() + .countCreditLedger(CountCreditLedgerRequest.builder() + .companyId("company_id") + .period(CountCreditLedgerRequestPeriod.DAILY) + .billingCreditId("billing_credit_id") + .featureId("feature_id") + .startTime("start_time") + .endTime("end_time") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"billing_credit_id\": \"billing_credit_id\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"end_time\": \"end_time\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"period\": \"daily\",\n" + + " \"start_time\": \"start_time\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListBillingPlanCreditGrants() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"credit_plural_name\":\"credit_plural_name\",\"credit_singular_name\":\"credit_singular_name\",\"expiry_type\":\"expiry_type\",\"expiry_unit\":\"expiry_unit\",\"expiry_unit_count\":1,\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"reset_type\":\"reset_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"credit_id\":\"credit_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"plan_ids\":[\"plan_ids\"]}}")); + ListBillingPlanCreditGrantsResponse response = client.credits() + .listBillingPlanCreditGrants(ListBillingPlanCreditGrantsRequest.builder() + .creditId("credit_id") + .planId("plan_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"credit_plural_name\": \"credit_plural_name\",\n" + + " \"credit_singular_name\": \"credit_singular_name\",\n" + + " \"expiry_type\": \"expiry_type\",\n" + + " \"expiry_unit\": \"expiry_unit\",\n" + + " \"expiry_unit_count\": 1,\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"reset_type\": \"reset_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_ids\": [\n" + + " \"plan_ids\"\n" + + " ]\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateBillingPlanCreditGrant() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"credit_plural_name\":\"credit_plural_name\",\"credit_singular_name\":\"credit_singular_name\",\"expiry_type\":\"expiry_type\",\"expiry_unit\":\"expiry_unit\",\"expiry_unit_count\":1,\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"reset_type\":\"reset_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateBillingPlanCreditGrantResponse response = client.credits() + .createBillingPlanCreditGrant(CreateBillingPlanCreditGrantRequestBody.builder() + .creditAmount(1) + .creditId("credit_id") + .planId("plan_id") + .resetCadence(CreateBillingPlanCreditGrantRequestBodyResetCadence.MONTHLY) + .resetStart(CreateBillingPlanCreditGrantRequestBodyResetStart.BILLING_PERIOD) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"reset_cadence\": \"monthly\",\n" + + " \"reset_start\": \"billing_period\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"credit_plural_name\": \"credit_plural_name\",\n" + + " \"credit_singular_name\": \"credit_singular_name\",\n" + + " \"expiry_type\": \"expiry_type\",\n" + + " \"expiry_unit\": \"expiry_unit\",\n" + + " \"expiry_unit_count\": 1,\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"reset_type\": \"reset_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteBillingPlanCreditGrant() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteBillingPlanCreditGrantResponse response = client.credits().deleteBillingPlanCreditGrant("plan_grant_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountBillingPlanCreditGrants() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"credit_id\":\"credit_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"plan_ids\":[\"plan_ids\"]}}")); + CountBillingPlanCreditGrantsResponse response = client.credits() + .countBillingPlanCreditGrants(CountBillingPlanCreditGrantsRequest.builder() + .creditId("credit_id") + .planId("plan_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_ids\": [\n" + + " \"plan_ids\"\n" + + " ]\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/CrmWireTest.java b/src/test/java/com/schematic/api/CrmWireTest.java new file mode 100644 index 0000000..3344813 --- /dev/null +++ b/src/test/java/com/schematic/api/CrmWireTest.java @@ -0,0 +1,531 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.crm.requests.CreateCrmDealLineItemAssociationRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmDealRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmLineItemRequestBody; +import com.schematic.api.resources.crm.requests.CreateCrmProductRequestBody; +import com.schematic.api.resources.crm.requests.ListCrmProductsRequest; +import com.schematic.api.resources.crm.types.ListCrmProductsResponse; +import com.schematic.api.resources.crm.types.UpsertCrmDealResponse; +import com.schematic.api.resources.crm.types.UpsertCrmProductResponse; +import com.schematic.api.resources.crm.types.UpsertDealLineItemAssociationResponse; +import com.schematic.api.resources.crm.types.UpsertLineItemResponse; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class CrmWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testUpsertDealLineItemAssociation() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"deal_id\":\"deal_id\",\"environment_id\":\"environment_id\",\"product_external_id\":\"product_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertDealLineItemAssociationResponse response = client.crm() + .upsertDealLineItemAssociation(CreateCrmDealLineItemAssociationRequestBody.builder() + .dealExternalId("deal_external_id") + .lineItemExternalId("line_item_external_id") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"deal_external_id\": \"deal_external_id\",\n" + + " \"line_item_external_id\": \"line_item_external_id\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"deal_id\": \"deal_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertLineItem() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"deal_id\":\"deal_id\",\"environment_id\":\"environment_id\",\"product_external_id\":\"product_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertLineItemResponse response = client.crm() + .upsertLineItem(CreateCrmLineItemRequestBody.builder() + .amount("amount") + .interval("interval") + .lineItemExternalId("line_item_external_id") + .productExternalId("product_external_id") + .quantity(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"amount\": \"amount\",\n" + + " \"interval\": \"interval\",\n" + + " \"line_item_external_id\": \"line_item_external_id\",\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"quantity\": 1\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"deal_id\": \"deal_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertCrmDeal() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"arr\":\"arr\",\"company_external_id\":\"company_external_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"deal_external_id\":\"deal_external_id\",\"deal_id\":\"deal_id\",\"environment_id\":\"environment_id\",\"mrr\":\"mrr\",\"name\":\"name\",\"product_external_id\":\"product_external_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertCrmDealResponse response = client.crm() + .upsertCrmDeal(CreateCrmDealRequestBody.builder() + .crmCompanyKey("crm_company_key") + .crmType("crm_type") + .dealExternalId("deal_external_id") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"crm_company_key\": \"crm_company_key\",\n" + + " \"crm_type\": \"crm_type\",\n" + + " \"deal_external_id\": \"deal_external_id\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"arr\": \"arr\",\n" + + " \"company_external_id\": \"company_external_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"deal_external_id\": \"deal_external_id\",\n" + + " \"deal_id\": \"deal_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"mrr\": \"mrr\",\n" + + " \"name\": \"name\",\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListCrmProducts() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"name\":\"name\",\"price\":\"price\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"name\":\"name\",\"offset\":1}}")); + ListCrmProductsResponse response = client.crm() + .listCrmProducts(ListCrmProductsRequest.builder() + .name("name") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"name\": \"name\",\n" + + " \"price\": \"price\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"name\": \"name\",\n" + + " \"offset\": 1\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertCrmProduct() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"name\":\"name\",\"price\":\"price\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpsertCrmProductResponse response = client.crm() + .upsertCrmProduct(CreateCrmProductRequestBody.builder() + .currency("currency") + .description("description") + .externalId("external_id") + .interval("interval") + .name("name") + .price("price") + .quantity(1) + .sku("sku") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"currency\": \"currency\",\n" + + " \"description\": \"description\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"price\": \"price\",\n" + + " \"quantity\": 1,\n" + + " \"sku\": \"sku\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"name\": \"name\",\n" + + " \"price\": \"price\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/DataexportsWireTest.java b/src/test/java/com/schematic/api/DataexportsWireTest.java new file mode 100644 index 0000000..144eb5f --- /dev/null +++ b/src/test/java/com/schematic/api/DataexportsWireTest.java @@ -0,0 +1,136 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.dataexports.requests.CreateDataExportRequestBody; +import com.schematic.api.resources.dataexports.types.CreateDataExportResponse; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DataexportsWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testCreateDataExport() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"export_type\":\"export_type\",\"id\":\"id\",\"metadata\":\"metadata\",\"output_file_type\":\"output_file_type\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateDataExportResponse response = client.dataexports() + .createDataExport(CreateDataExportRequestBody.builder() + .exportType("company-feature-usage") + .metadata("metadata") + .outputFileType("csv") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"export_type\": \"company-feature-usage\",\n" + + " \"metadata\": \"metadata\",\n" + + " \"output_file_type\": \"csv\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"export_type\": \"export_type\",\n" + + " \"id\": \"id\",\n" + + " \"metadata\": \"metadata\",\n" + + " \"output_file_type\": \"output_file_type\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/EntitlementsWireTest.java b/src/test/java/com/schematic/api/EntitlementsWireTest.java new file mode 100644 index 0000000..b91a0d2 --- /dev/null +++ b/src/test/java/com/schematic/api/EntitlementsWireTest.java @@ -0,0 +1,5245 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.entitlements.requests.CountCompanyOverridesRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureCompaniesRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureUsageRequest; +import com.schematic.api.resources.entitlements.requests.CountFeatureUsersRequest; +import com.schematic.api.resources.entitlements.requests.CountPlanEntitlementsRequest; +import com.schematic.api.resources.entitlements.requests.CreateCompanyOverrideRequestBody; +import com.schematic.api.resources.entitlements.requests.CreatePlanEntitlementRequestBody; +import com.schematic.api.resources.entitlements.requests.GetFeatureUsageByCompanyRequest; +import com.schematic.api.resources.entitlements.requests.ListCompanyOverridesRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureCompaniesRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureUsageRequest; +import com.schematic.api.resources.entitlements.requests.ListFeatureUsersRequest; +import com.schematic.api.resources.entitlements.requests.ListPlanEntitlementsRequest; +import com.schematic.api.resources.entitlements.requests.UpdateCompanyOverrideRequestBody; +import com.schematic.api.resources.entitlements.requests.UpdatePlanEntitlementRequestBody; +import com.schematic.api.resources.entitlements.types.CountCompanyOverridesResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureCompaniesResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureUsageResponse; +import com.schematic.api.resources.entitlements.types.CountFeatureUsersResponse; +import com.schematic.api.resources.entitlements.types.CountPlanEntitlementsResponse; +import com.schematic.api.resources.entitlements.types.CreateCompanyOverrideRequestBodyValueType; +import com.schematic.api.resources.entitlements.types.CreateCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementRequestBodyValueType; +import com.schematic.api.resources.entitlements.types.CreatePlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.DeleteCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.DeletePlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.GetCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.GetFeatureUsageByCompanyResponse; +import com.schematic.api.resources.entitlements.types.GetPlanEntitlementResponse; +import com.schematic.api.resources.entitlements.types.ListCompanyOverridesResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureCompaniesResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureUsageResponse; +import com.schematic.api.resources.entitlements.types.ListFeatureUsersResponse; +import com.schematic.api.resources.entitlements.types.ListPlanEntitlementsResponse; +import com.schematic.api.resources.entitlements.types.UpdateCompanyOverrideRequestBodyValueType; +import com.schematic.api.resources.entitlements.types.UpdateCompanyOverrideResponse; +import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementRequestBodyValueType; +import com.schematic.api.resources.entitlements.types.UpdatePlanEntitlementResponse; +import java.util.HashMap; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class EntitlementsWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testListCompanyOverrides() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"company_id\":\"company_id\",\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"expiration_date\":\"2024-01-15T09:30:00Z\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"notes\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_bool\":true,\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"}],\"params\":{\"company_id\":\"company_id\",\"company_ids\":[\"company_ids\"],\"feature_id\":\"feature_id\",\"feature_ids\":[\"feature_ids\"],\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"without_expired\":true}}")); + ListCompanyOverridesResponse response = client.entitlements() + .listCompanyOverrides(ListCompanyOverridesRequest.builder() + .companyId("company_id") + .featureId("feature_id") + .withoutExpired(true) + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"notes\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_bool\": true,\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_ids\": [\n" + + " \"company_ids\"\n" + + " ],\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"without_expired\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateCompanyOverride() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"company_id\":\"company_id\",\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"expiration_date\":\"2024-01-15T09:30:00Z\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"notes\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_bool\":true,\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"params\":{\"key\":\"value\"}}")); + CreateCompanyOverrideResponse response = client.entitlements() + .createCompanyOverride(CreateCompanyOverrideRequestBody.builder() + .companyId("company_id") + .featureId("feature_id") + .valueType(CreateCompanyOverrideRequestBodyValueType.BOOLEAN) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"company_id\": \"company_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"value_type\": \"boolean\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"notes\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_bool\": true,\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetCompanyOverride() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"company_id\":\"company_id\",\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"expiration_date\":\"2024-01-15T09:30:00Z\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"notes\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_bool\":true,\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"params\":{\"key\":\"value\"}}")); + GetCompanyOverrideResponse response = client.entitlements().getCompanyOverride("company_override_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"notes\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_bool\": true,\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateCompanyOverride() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"company_id\":\"company_id\",\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"expiration_date\":\"2024-01-15T09:30:00Z\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"notes\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_bool\":true,\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"params\":{\"key\":\"value\"}}")); + UpdateCompanyOverrideResponse response = client.entitlements() + .updateCompanyOverride( + "company_override_id", + UpdateCompanyOverrideRequestBody.builder() + .valueType(UpdateCompanyOverrideRequestBodyValueType.BOOLEAN) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"value_type\": \"boolean\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"notes\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_bool\": true,\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteCompanyOverride() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteCompanyOverrideResponse response = client.entitlements().deleteCompanyOverride("company_override_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountCompanyOverrides() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"company_id\":\"company_id\",\"company_ids\":[\"company_ids\"],\"feature_id\":\"feature_id\",\"feature_ids\":[\"feature_ids\"],\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"without_expired\":true}}")); + CountCompanyOverridesResponse response = client.entitlements() + .countCompanyOverrides(CountCompanyOverridesRequest.builder() + .companyId("company_id") + .featureId("feature_id") + .withoutExpired(true) + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_ids\": [\n" + + " \"company_ids\"\n" + + " ],\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"without_expired\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListFeatureCompanies() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"access\":true,\"allocation\":1,\"allocation_type\":\"boolean\",\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"company_override\":{\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"notes\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"},\"credit_consumption_rate\":1.1,\"credit_grant_counts\":{\"key\":1.1},\"credit_grant_details\":[{\"grant_reason\":\"free\",\"quantity\":1.1}],\"credit_grant_reason\":\"free\",\"credit_remaining\":1.1,\"credit_total\":1.1,\"credit_type_icon\":\"credit_type_icon\",\"credit_used\":1.1,\"effective_limit\":1,\"effective_price\":1.1,\"entitlement_expiration_date\":\"2024-01-15T09:30:00Z\",\"entitlement_id\":\"entitlement_id\",\"entitlement_source\":\"entitlement_source\",\"entitlement_type\":\"entitlement_type\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"has_valid_allocation\":true,\"is_unlimited\":true,\"metric_reset_at\":\"2024-01-15T09:30:00Z\",\"month_reset\":\"month_reset\",\"monthly_usage_based_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"overuse\":1,\"percent_used\":1.1,\"period\":\"period\",\"plan\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_entitlement\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"},\"price_behavior\":\"price_behavior\",\"soft_limit\":1,\"usage\":1,\"yearly_usage_based_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}}],\"params\":{\"feature_id\":\"feature_id\",\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + ListFeatureCompaniesResponse response = client.entitlements() + .listFeatureCompanies(ListFeatureCompaniesRequest.builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation\": 1,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"company_override\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"notes\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"credit_consumption_rate\": 1.1,\n" + + " \"credit_grant_counts\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"credit_grant_details\": [\n" + + " {\n" + + " \"grant_reason\": \"free\",\n" + + " \"quantity\": 1.1\n" + + " }\n" + + " ],\n" + + " \"credit_grant_reason\": \"free\",\n" + + " \"credit_remaining\": 1.1,\n" + + " \"credit_total\": 1.1,\n" + + " \"credit_type_icon\": \"credit_type_icon\",\n" + + " \"credit_used\": 1.1,\n" + + " \"effective_limit\": 1,\n" + + " \"effective_price\": 1.1,\n" + + " \"entitlement_expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_source\": \"entitlement_source\",\n" + + " \"entitlement_type\": \"entitlement_type\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"has_valid_allocation\": true,\n" + + " \"is_unlimited\": true,\n" + + " \"metric_reset_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"monthly_usage_based_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"overuse\": 1,\n" + + " \"percent_used\": 1.1,\n" + + " \"period\": \"period\",\n" + + " \"plan\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_entitlement\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"soft_limit\": 1,\n" + + " \"usage\": 1,\n" + + " \"yearly_usage_based_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountFeatureCompanies() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"feature_id\":\"feature_id\",\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + CountFeatureCompaniesResponse response = client.entitlements() + .countFeatureCompanies(CountFeatureCompaniesRequest.builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListFeatureUsage() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"access\":true,\"allocation\":1,\"allocation_type\":\"boolean\",\"company_override\":{\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"notes\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"},\"credit_consumption_rate\":1.1,\"credit_grant_counts\":{\"key\":1.1},\"credit_grant_details\":[{\"grant_reason\":\"free\",\"quantity\":1.1}],\"credit_grant_reason\":\"free\",\"credit_remaining\":1.1,\"credit_total\":1.1,\"credit_type_icon\":\"credit_type_icon\",\"credit_used\":1.1,\"effective_limit\":1,\"effective_price\":1.1,\"entitlement_expiration_date\":\"2024-01-15T09:30:00Z\",\"entitlement_id\":\"entitlement_id\",\"entitlement_source\":\"entitlement_source\",\"entitlement_type\":\"entitlement_type\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"has_valid_allocation\":true,\"is_unlimited\":true,\"metric_reset_at\":\"2024-01-15T09:30:00Z\",\"month_reset\":\"month_reset\",\"monthly_usage_based_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"overuse\":1,\"percent_used\":1.1,\"period\":\"period\",\"plan\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_entitlement\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"},\"price_behavior\":\"price_behavior\",\"soft_limit\":1,\"usage\":1,\"yearly_usage_based_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}}],\"params\":{\"company_id\":\"company_id\",\"company_keys\":{\"key\":\"value\"},\"feature_ids\":[\"feature_ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"without_negative_entitlements\":true}}")); + ListFeatureUsageResponse response = client.entitlements() + .listFeatureUsage(ListFeatureUsageRequest.builder() + .companyId("company_id") + .q("q") + .withoutNegativeEntitlements(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation\": 1,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"company_override\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"notes\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"credit_consumption_rate\": 1.1,\n" + + " \"credit_grant_counts\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"credit_grant_details\": [\n" + + " {\n" + + " \"grant_reason\": \"free\",\n" + + " \"quantity\": 1.1\n" + + " }\n" + + " ],\n" + + " \"credit_grant_reason\": \"free\",\n" + + " \"credit_remaining\": 1.1,\n" + + " \"credit_total\": 1.1,\n" + + " \"credit_type_icon\": \"credit_type_icon\",\n" + + " \"credit_used\": 1.1,\n" + + " \"effective_limit\": 1,\n" + + " \"effective_price\": 1.1,\n" + + " \"entitlement_expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_source\": \"entitlement_source\",\n" + + " \"entitlement_type\": \"entitlement_type\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"has_valid_allocation\": true,\n" + + " \"is_unlimited\": true,\n" + + " \"metric_reset_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"monthly_usage_based_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"overuse\": 1,\n" + + " \"percent_used\": 1.1,\n" + + " \"period\": \"period\",\n" + + " \"plan\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_entitlement\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"soft_limit\": 1,\n" + + " \"usage\": 1,\n" + + " \"yearly_usage_based_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_keys\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"without_negative_entitlements\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountFeatureUsage() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"company_id\":\"company_id\",\"company_keys\":{\"key\":\"value\"},\"feature_ids\":[\"feature_ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"without_negative_entitlements\":true}}")); + CountFeatureUsageResponse response = client.entitlements() + .countFeatureUsage(CountFeatureUsageRequest.builder() + .companyId("company_id") + .q("q") + .withoutNegativeEntitlements(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"company_keys\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"without_negative_entitlements\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListFeatureUsers() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"access\":true,\"allocation\":1,\"allocation_type\":\"boolean\",\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"entitlement_id\":\"entitlement_id\",\"entitlement_type\":\"entitlement_type\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"metric_reset_at\":\"2024-01-15T09:30:00Z\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"plan\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"usage\":1,\"user\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"}}],\"params\":{\"feature_id\":\"feature_id\",\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + ListFeatureUsersResponse response = client.entitlements() + .listFeatureUsers(ListFeatureUsersRequest.builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation\": 1,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_type\": \"entitlement_type\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"metric_reset_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"plan\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"usage\": 1,\n" + + " \"user\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountFeatureUsers() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"feature_id\":\"feature_id\",\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + CountFeatureUsersResponse response = client.entitlements() + .countFeatureUsers(CountFeatureUsersRequest.builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListPlanEntitlements() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"billing_threshold\":1,\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metered_monthly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metered_yearly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"plan\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_id\":\"plan_id\",\"price_behavior\":\"price_behavior\",\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"soft_limit\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_based_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_bool\":true,\"value_credit\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"}],\"params\":{\"feature_id\":\"feature_id\",\"feature_ids\":[\"feature_ids\"],\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"plan_ids\":[\"plan_ids\"],\"q\":\"q\",\"with_metered_products\":true}}")); + ListPlanEntitlementsResponse response = client.entitlements() + .listPlanEntitlements(ListPlanEntitlementsRequest.builder() + .featureId("feature_id") + .planId("plan_id") + .q("q") + .withMeteredProducts(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"billing_threshold\": 1,\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metered_monthly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metered_yearly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"plan\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"soft_limit\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_based_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_bool\": true,\n" + + " \"value_credit\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_ids\": [\n" + + " \"plan_ids\"\n" + + " ],\n" + + " \"q\": \"q\",\n" + + " \"with_metered_products\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreatePlanEntitlement() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_threshold\":1,\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metered_monthly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metered_yearly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"plan\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_id\":\"plan_id\",\"price_behavior\":\"price_behavior\",\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"soft_limit\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_based_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_bool\":true,\"value_credit\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"params\":{\"key\":\"value\"}}")); + CreatePlanEntitlementResponse response = client.entitlements() + .createPlanEntitlement(CreatePlanEntitlementRequestBody.builder() + .featureId("feature_id") + .planId("plan_id") + .valueType(CreatePlanEntitlementRequestBodyValueType.BOOLEAN) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"value_type\": \"boolean\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_threshold\": 1,\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metered_monthly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metered_yearly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"plan\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"soft_limit\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_based_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_bool\": true,\n" + + " \"value_credit\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetPlanEntitlement() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_threshold\":1,\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metered_monthly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metered_yearly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"plan\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_id\":\"plan_id\",\"price_behavior\":\"price_behavior\",\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"soft_limit\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_based_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_bool\":true,\"value_credit\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"params\":{\"key\":\"value\"}}")); + GetPlanEntitlementResponse response = client.entitlements().getPlanEntitlement("plan_entitlement_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_threshold\": 1,\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metered_monthly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metered_yearly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"plan\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"soft_limit\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_based_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_bool\": true,\n" + + " \"value_credit\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdatePlanEntitlement() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_threshold\":1,\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metered_monthly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metered_yearly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"plan\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_id\":\"plan_id\",\"price_behavior\":\"price_behavior\",\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"soft_limit\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_based_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_bool\":true,\"value_credit\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"params\":{\"key\":\"value\"}}")); + UpdatePlanEntitlementResponse response = client.entitlements() + .updatePlanEntitlement( + "plan_entitlement_id", + UpdatePlanEntitlementRequestBody.builder() + .valueType(UpdatePlanEntitlementRequestBodyValueType.BOOLEAN) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"value_type\": \"boolean\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_threshold\": 1,\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metered_monthly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metered_yearly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"plan\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"soft_limit\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_based_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_bool\": true,\n" + + " \"value_credit\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeletePlanEntitlement() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeletePlanEntitlementResponse response = client.entitlements().deletePlanEntitlement("plan_entitlement_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountPlanEntitlements() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"feature_id\":\"feature_id\",\"feature_ids\":[\"feature_ids\"],\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_id\":\"plan_id\",\"plan_ids\":[\"plan_ids\"],\"q\":\"q\",\"with_metered_products\":true}}")); + CountPlanEntitlementsResponse response = client.entitlements() + .countPlanEntitlements(CountPlanEntitlementsRequest.builder() + .featureId("feature_id") + .planId("plan_id") + .q("q") + .withMeteredProducts(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_ids\": [\n" + + " \"plan_ids\"\n" + + " ],\n" + + " \"q\": \"q\",\n" + + " \"with_metered_products\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetFeatureUsageByCompany() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"features\":[{\"access\":true,\"allocation\":1,\"allocation_type\":\"boolean\",\"company_override\":{\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"},{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"billing_credit_balances\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1},{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"},{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[],\"conditions\":[],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true},{\"account_id\":\"account_id\",\"condition_groups\":[],\"conditions\":[],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"traits\":{\"key\":\"value\"}},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"company_id\":\"company_id\",\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"expiration_date\":\"2024-01-15T09:30:00Z\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"notes\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_bool\":true,\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"credit_consumption_rate\":1.1,\"credit_grant_counts\":{\"credit_grant_counts\":1.1},\"credit_grant_details\":[{\"credit_type_icon\":\"credit_type_icon\",\"expires_at\":\"2024-01-15T09:30:00Z\",\"grant_reason\":\"free\",\"quantity\":1.1},{\"credit_type_icon\":\"credit_type_icon\",\"expires_at\":\"2024-01-15T09:30:00Z\",\"grant_reason\":\"free\",\"quantity\":1.1}],\"credit_grant_reason\":\"free\",\"credit_remaining\":1.1,\"credit_total\":1.1,\"credit_type_icon\":\"credit_type_icon\",\"credit_used\":1.1,\"effective_limit\":1,\"effective_price\":1.1,\"entitlement_expiration_date\":\"2024-01-15T09:30:00Z\",\"entitlement_id\":\"entitlement_id\",\"entitlement_source\":\"entitlement_source\",\"entitlement_type\":\"entitlement_type\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"event_summary\":{\"company_count\":1,\"environment_id\":\"environment_id\",\"event_count\":1,\"event_subtype\":\"event_subtype\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"last_checked_at\":\"2024-01-15T09:30:00Z\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[],\"conditions\":[],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true},{\"condition_groups\":[],\"conditions\":[],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"last_checked_at\":\"2024-01-15T09:30:00Z\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[],\"conditions\":[],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true},{\"condition_groups\":[],\"conditions\":[],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plans\":[{\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\"},{\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\"}],\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"has_valid_allocation\":true,\"is_unlimited\":true,\"metric_reset_at\":\"2024-01-15T09:30:00Z\",\"month_reset\":\"month_reset\",\"monthly_usage_based_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"overuse\":1,\"percent_used\":1.1,\"period\":\"period\",\"plan\":{\"audience_type\":\"audience_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_entitlement\":{\"billing_threshold\":1,\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metered_monthly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{},{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metered_yearly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{},{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"plan\":{\"audience_type\":\"audience_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_id\":\"plan_id\",\"price_behavior\":\"price_behavior\",\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"soft_limit\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_based_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_bool\":true,\"value_credit\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"price_behavior\":\"price_behavior\",\"soft_limit\":1,\"usage\":1,\"yearly_usage_based_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}},{\"access\":true,\"allocation\":1,\"allocation_type\":\"boolean\",\"company_override\":{\"company\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"},{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"billing_credit_balances\":1.1},\"billing_subscription\":{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1},{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1},{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"id\":\"id\",\"name\":\"name\"},\"plans\":[{\"id\":\"id\",\"name\":\"name\"},{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[],\"conditions\":[],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true},{\"account_id\":\"account_id\",\"condition_groups\":[],\"conditions\":[],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"traits\":{\"key\":\"value\"}},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"company_id\":\"company_id\",\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"expiration_date\":\"2024-01-15T09:30:00Z\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"notes\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"external_user_id\":\"external_user_id\",\"external_user_name\":\"external_user_name\",\"id\":\"id\",\"note\":\"note\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_bool\":true,\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"credit_consumption_rate\":1.1,\"credit_grant_counts\":{\"credit_grant_counts\":1.1},\"credit_grant_details\":[{\"credit_type_icon\":\"credit_type_icon\",\"expires_at\":\"2024-01-15T09:30:00Z\",\"grant_reason\":\"free\",\"quantity\":1.1},{\"credit_type_icon\":\"credit_type_icon\",\"expires_at\":\"2024-01-15T09:30:00Z\",\"grant_reason\":\"free\",\"quantity\":1.1}],\"credit_grant_reason\":\"free\",\"credit_remaining\":1.1,\"credit_total\":1.1,\"credit_type_icon\":\"credit_type_icon\",\"credit_used\":1.1,\"effective_limit\":1,\"effective_price\":1.1,\"entitlement_expiration_date\":\"2024-01-15T09:30:00Z\",\"entitlement_id\":\"entitlement_id\",\"entitlement_source\":\"entitlement_source\",\"entitlement_type\":\"entitlement_type\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"event_summary\":{\"company_count\":1,\"environment_id\":\"environment_id\",\"event_count\":1,\"event_subtype\":\"event_subtype\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"last_checked_at\":\"2024-01-15T09:30:00Z\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[],\"conditions\":[],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true},{\"condition_groups\":[],\"conditions\":[],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"},{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"last_checked_at\":\"2024-01-15T09:30:00Z\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[],\"conditions\":[],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true},{\"condition_groups\":[],\"conditions\":[],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plans\":[{\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\"},{\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\"}],\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"has_valid_allocation\":true,\"is_unlimited\":true,\"metric_reset_at\":\"2024-01-15T09:30:00Z\",\"month_reset\":\"month_reset\",\"monthly_usage_based_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"overuse\":1,\"percent_used\":1.1,\"period\":\"period\",\"plan\":{\"audience_type\":\"audience_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_entitlement\":{\"billing_threshold\":1,\"consumption_rate\":1.1,\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"id\":\"id\",\"metered_monthly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{},{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metered_yearly_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{},{}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"},\"metric_period\":\"metric_period\",\"metric_period_month_reset\":\"metric_period_month_reset\",\"plan\":{\"audience_type\":\"audience_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"plan_id\":\"plan_id\",\"price_behavior\":\"price_behavior\",\"rule_id\":\"rule_id\",\"rule_id_usage_exceeded\":\"rule_id_usage_exceeded\",\"soft_limit\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_based_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_bool\":true,\"value_credit\":{\"burn_strategy\":\"burn_strategy\",\"created_at\":\"2024-01-15T09:30:00Z\",\"default_expiry_unit\":\"default_expiry_unit\",\"default_expiry_unit_count\":1,\"default_rollover_policy\":\"default_rollover_policy\",\"description\":\"description\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"product_id\":\"product_id\",\"quantity\":1.1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"singular_name\":\"singular_name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_numeric\":1,\"value_trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\",\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"value_trait_id\":\"value_trait_id\",\"value_type\":\"value_type\"},\"price_behavior\":\"price_behavior\",\"soft_limit\":1,\"usage\":1,\"yearly_usage_based_price\":{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"id\":\"id\",\"interval\":\"interval\",\"is_active\":true,\"meter_event_name\":\"meter_event_name\",\"meter_event_payload_key\":\"meter_event_payload_key\",\"meter_id\":\"meter_id\",\"package_size\":1,\"price\":1,\"price_decimal\":\"price_decimal\",\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1},{\"flat_amount\":1,\"per_unit_price\":1,\"per_unit_price_decimal\":\"per_unit_price_decimal\",\"up_to\":1}],\"product_external_id\":\"product_external_id\",\"product_id\":\"product_id\",\"product_name\":\"product_name\",\"tiers_mode\":\"tiers_mode\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}}]},\"params\":{\"keys\":{\"keys\":\"keys\"}}}")); + GetFeatureUsageByCompanyResponse response = client.entitlements() + .getFeatureUsageByCompany(GetFeatureUsageByCompanyRequest.builder() + .keys(new HashMap() { + { + put("keys", "keys"); + } + }) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"features\": [\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation\": 1,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"company_override\": {\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"billing_credit_balances\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"notes\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_bool\": true,\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"credit_consumption_rate\": 1.1,\n" + + " \"credit_grant_counts\": {\n" + + " \"credit_grant_counts\": 1.1\n" + + " },\n" + + " \"credit_grant_details\": [\n" + + " {\n" + + " \"credit_type_icon\": \"credit_type_icon\",\n" + + " \"expires_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"grant_reason\": \"free\",\n" + + " \"quantity\": 1.1\n" + + " },\n" + + " {\n" + + " \"credit_type_icon\": \"credit_type_icon\",\n" + + " \"expires_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"grant_reason\": \"free\",\n" + + " \"quantity\": 1.1\n" + + " }\n" + + " ],\n" + + " \"credit_grant_reason\": \"free\",\n" + + " \"credit_remaining\": 1.1,\n" + + " \"credit_total\": 1.1,\n" + + " \"credit_type_icon\": \"credit_type_icon\",\n" + + " \"credit_used\": 1.1,\n" + + " \"effective_limit\": 1,\n" + + " \"effective_price\": 1.1,\n" + + " \"entitlement_expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_source\": \"entitlement_source\",\n" + + " \"entitlement_type\": \"entitlement_type\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"event_summary\": {\n" + + " \"company_count\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_count\": 1,\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"last_checked_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " },\n" + + " {\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"last_checked_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " },\n" + + " {\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " {\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"has_valid_allocation\": true,\n" + + " \"is_unlimited\": true,\n" + + " \"metric_reset_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"monthly_usage_based_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"overuse\": 1,\n" + + " \"percent_used\": 1.1,\n" + + " \"period\": \"period\",\n" + + " \"plan\": {\n" + + " \"audience_type\": \"audience_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_entitlement\": {\n" + + " \"billing_threshold\": 1,\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metered_monthly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {},\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metered_yearly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {},\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"plan\": {\n" + + " \"audience_type\": \"audience_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"soft_limit\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_based_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_bool\": true,\n" + + " \"value_credit\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"soft_limit\": 1,\n" + + " \"usage\": 1,\n" + + " \"yearly_usage_based_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"access\": true,\n" + + " \"allocation\": 1,\n" + + " \"allocation_type\": \"boolean\",\n" + + " \"company_override\": {\n" + + " \"company\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"billing_credit_balances\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " },\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " },\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"notes\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"external_user_id\": \"external_user_id\",\n" + + " \"external_user_name\": \"external_user_name\",\n" + + " \"id\": \"id\",\n" + + " \"note\": \"note\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_bool\": true,\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"credit_consumption_rate\": 1.1,\n" + + " \"credit_grant_counts\": {\n" + + " \"credit_grant_counts\": 1.1\n" + + " },\n" + + " \"credit_grant_details\": [\n" + + " {\n" + + " \"credit_type_icon\": \"credit_type_icon\",\n" + + " \"expires_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"grant_reason\": \"free\",\n" + + " \"quantity\": 1.1\n" + + " },\n" + + " {\n" + + " \"credit_type_icon\": \"credit_type_icon\",\n" + + " \"expires_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"grant_reason\": \"free\",\n" + + " \"quantity\": 1.1\n" + + " }\n" + + " ],\n" + + " \"credit_grant_reason\": \"free\",\n" + + " \"credit_remaining\": 1.1,\n" + + " \"credit_total\": 1.1,\n" + + " \"credit_type_icon\": \"credit_type_icon\",\n" + + " \"credit_used\": 1.1,\n" + + " \"effective_limit\": 1,\n" + + " \"effective_price\": 1.1,\n" + + " \"entitlement_expiration_date\": \"2024-01-15T09:30:00Z\",\n" + + " \"entitlement_id\": \"entitlement_id\",\n" + + " \"entitlement_source\": \"entitlement_source\",\n" + + " \"entitlement_type\": \"entitlement_type\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"event_summary\": {\n" + + " \"company_count\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_count\": 1,\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"last_checked_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " },\n" + + " {\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"last_checked_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " },\n" + + " {\n" + + " \"condition_groups\": [],\n" + + " \"conditions\": [],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " {\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"has_valid_allocation\": true,\n" + + " \"is_unlimited\": true,\n" + + " \"metric_reset_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"monthly_usage_based_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"overuse\": 1,\n" + + " \"percent_used\": 1.1,\n" + + " \"period\": \"period\",\n" + + " \"plan\": {\n" + + " \"audience_type\": \"audience_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_entitlement\": {\n" + + " \"billing_threshold\": 1,\n" + + " \"consumption_rate\": 1.1,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"metered_monthly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {},\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metered_yearly_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {},\n" + + " {}\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " },\n" + + " \"metric_period\": \"metric_period\",\n" + + " \"metric_period_month_reset\": \"metric_period_month_reset\",\n" + + " \"plan\": {\n" + + " \"audience_type\": \"audience_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_id_usage_exceeded\": \"rule_id_usage_exceeded\",\n" + + " \"soft_limit\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_based_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_bool\": true,\n" + + " \"value_credit\": {\n" + + " \"burn_strategy\": \"burn_strategy\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_expiry_unit\": \"default_expiry_unit\",\n" + + " \"default_expiry_unit_count\": 1,\n" + + " \"default_rollover_policy\": \"default_rollover_policy\",\n" + + " \"description\": \"description\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_numeric\": 1,\n" + + " \"value_trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\",\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"value_trait_id\": \"value_trait_id\",\n" + + " \"value_type\": \"value_type\"\n" + + " },\n" + + " \"price_behavior\": \"price_behavior\",\n" + + " \"soft_limit\": 1,\n" + + " \"usage\": 1,\n" + + " \"yearly_usage_based_price\": {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"is_active\": true,\n" + + " \"meter_event_name\": \"meter_event_name\",\n" + + " \"meter_event_payload_key\": \"meter_event_payload_key\",\n" + + " \"meter_id\": \"meter_id\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " },\n" + + " {\n" + + " \"flat_amount\": 1,\n" + + " \"per_unit_price\": 1,\n" + + " \"per_unit_price_decimal\": \"per_unit_price_decimal\",\n" + + " \"up_to\": 1\n" + + " }\n" + + " ],\n" + + " \"product_external_id\": \"product_external_id\",\n" + + " \"product_id\": \"product_id\",\n" + + " \"product_name\": \"product_name\",\n" + + " \"tiers_mode\": \"tiers_mode\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"params\": {\n" + + " \"keys\": {\n" + + " \"keys\": \"keys\"\n" + + " }\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/EventsWireTest.java b/src/test/java/com/schematic/api/EventsWireTest.java new file mode 100644 index 0000000..3abd034 --- /dev/null +++ b/src/test/java/com/schematic/api/EventsWireTest.java @@ -0,0 +1,566 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.events.requests.CreateEventBatchRequestBody; +import com.schematic.api.resources.events.requests.GetEventSummariesRequest; +import com.schematic.api.resources.events.requests.ListEventsRequest; +import com.schematic.api.resources.events.types.CreateEventBatchResponse; +import com.schematic.api.resources.events.types.CreateEventResponse; +import com.schematic.api.resources.events.types.GetEventResponse; +import com.schematic.api.resources.events.types.GetEventSummariesResponse; +import com.schematic.api.resources.events.types.GetSegmentIntegrationStatusResponse; +import com.schematic.api.resources.events.types.ListEventsResponse; +import com.schematic.api.types.CreateEventRequestBody; +import com.schematic.api.types.CreateEventRequestBodyEventType; +import java.util.Arrays; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class EventsWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testCreateEventBatch() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"events\":[{\"captured_at\":\"2024-01-15T09:30:00Z\",\"remote_addr\":\"remote_addr\",\"remote_ip\":\"remote_ip\",\"user_agent\":\"user_agent\"}]},\"params\":{\"key\":\"value\"}}")); + CreateEventBatchResponse response = client.events() + .createEventBatch(CreateEventBatchRequestBody.builder() + .events(Arrays.asList(CreateEventRequestBody.builder() + .eventType(CreateEventRequestBodyEventType.IDENTIFY) + .build())) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"events\": [\n" + + " {\n" + + " \"event_type\": \"identify\"\n" + + " }\n" + + " ]\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"events\": [\n" + + " {\n" + + " \"captured_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"remote_addr\": \"remote_addr\",\n" + + " \"remote_ip\": \"remote_ip\",\n" + + " \"user_agent\": \"user_agent\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetEventSummaries() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"company_count\":1,\"environment_id\":\"environment_id\",\"event_count\":1,\"event_subtype\":\"event_subtype\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1}],\"params\":{\"event_subtypes\":[\"event_subtypes\"],\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + GetEventSummariesResponse response = client.events() + .getEventSummaries(GetEventSummariesRequest.builder() + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"company_count\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_count\": 1,\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"event_subtypes\": [\n" + + " \"event_subtypes\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListEvents() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"api_key\":\"api_key\",\"body\":{\"key\":\"value\"},\"body_preview\":\"body_preview\",\"captured_at\":\"2024-01-15T09:30:00Z\",\"company\":{\"id\":\"id\",\"name\":\"name\"},\"company_id\":\"company_id\",\"enriched_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"error_message\":\"error_message\",\"feature_ids\":[\"feature_ids\"],\"features\":[{\"id\":\"id\",\"name\":\"name\"}],\"id\":\"id\",\"loaded_at\":\"2024-01-15T09:30:00Z\",\"processed_at\":\"2024-01-15T09:30:00Z\",\"quantity\":1,\"sent_at\":\"2024-01-15T09:30:00Z\",\"status\":\"status\",\"subtype\":\"subtype\",\"type\":\"type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user\":{\"id\":\"id\",\"name\":\"name\"},\"user_id\":\"user_id\"}],\"params\":{\"company_id\":\"company_id\",\"event_subtype\":\"event_subtype\",\"event_types\":[\"identify\"],\"flag_id\":\"flag_id\",\"limit\":1,\"offset\":1,\"user_id\":\"user_id\"}}")); + ListEventsResponse response = client.events() + .listEvents(ListEventsRequest.builder() + .companyId("company_id") + .eventSubtype("event_subtype") + .flagId("flag_id") + .userId("user_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"api_key\": \"api_key\",\n" + + " \"body\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"body_preview\": \"body_preview\",\n" + + " \"captured_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"company\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"enriched_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"error_message\": \"error_message\",\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"loaded_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"processed_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"quantity\": 1,\n" + + " \"sent_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"status\": \"status\",\n" + + " \"subtype\": \"subtype\",\n" + + " \"type\": \"type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user\": {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"event_types\": [\n" + + " \"identify\"\n" + + " ],\n" + + " \"flag_id\": \"flag_id\",\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"user_id\": \"user_id\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateEvent() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"captured_at\":\"2024-01-15T09:30:00Z\",\"event_id\":\"event_id\",\"remote_addr\":\"remote_addr\",\"remote_ip\":\"remote_ip\",\"user_agent\":\"user_agent\"},\"params\":{\"key\":\"value\"}}")); + CreateEventResponse response = client.events() + .createEvent(CreateEventRequestBody.builder() + .eventType(CreateEventRequestBodyEventType.IDENTIFY) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"event_type\": \"identify\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"captured_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"event_id\": \"event_id\",\n" + + " \"remote_addr\": \"remote_addr\",\n" + + " \"remote_ip\": \"remote_ip\",\n" + + " \"user_agent\": \"user_agent\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetEvent() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"api_key\":\"api_key\",\"body\":{\"key\":\"value\"},\"body_preview\":\"body_preview\",\"captured_at\":\"2024-01-15T09:30:00Z\",\"company\":{\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\"},\"company_id\":\"company_id\",\"enriched_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"error_message\":\"error_message\",\"feature_ids\":[\"feature_ids\"],\"features\":[{\"id\":\"id\",\"name\":\"name\"}],\"id\":\"id\",\"loaded_at\":\"2024-01-15T09:30:00Z\",\"processed_at\":\"2024-01-15T09:30:00Z\",\"quantity\":1,\"sent_at\":\"2024-01-15T09:30:00Z\",\"status\":\"status\",\"subtype\":\"subtype\",\"type\":\"type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"user\":{\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\"},\"user_id\":\"user_id\"},\"params\":{\"key\":\"value\"}}")); + GetEventResponse response = client.events().getEvent("event_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"api_key\": \"api_key\",\n" + + " \"body\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"body_preview\": \"body_preview\",\n" + + " \"captured_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"company\": {\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"company_id\": \"company_id\",\n" + + " \"enriched_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"error_message\": \"error_message\",\n" + + " \"feature_ids\": [\n" + + " \"feature_ids\"\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"loaded_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"processed_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"quantity\": 1,\n" + + " \"sent_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"status\": \"status\",\n" + + " \"subtype\": \"subtype\",\n" + + " \"type\": \"type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user\": {\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\"\n" + + " },\n" + + " \"user_id\": \"user_id\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetSegmentIntegrationStatus() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"connected\":true,\"environment_id\":\"environment_id\",\"last_event_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetSegmentIntegrationStatusResponse response = client.events().getSegmentIntegrationStatus(); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"connected\": true,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"last_event_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/FeaturesWireTest.java b/src/test/java/com/schematic/api/FeaturesWireTest.java new file mode 100644 index 0000000..42626c6 --- /dev/null +++ b/src/test/java/com/schematic/api/FeaturesWireTest.java @@ -0,0 +1,2121 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.features.requests.CountFeaturesRequest; +import com.schematic.api.resources.features.requests.CountFlagsRequest; +import com.schematic.api.resources.features.requests.CreateFeatureRequestBody; +import com.schematic.api.resources.features.requests.ListFeaturesRequest; +import com.schematic.api.resources.features.requests.ListFlagsRequest; +import com.schematic.api.resources.features.requests.UpdateFeatureRequestBody; +import com.schematic.api.resources.features.requests.UpdateFlagRulesRequestBody; +import com.schematic.api.resources.features.types.CheckFlagResponse; +import com.schematic.api.resources.features.types.CheckFlagsResponse; +import com.schematic.api.resources.features.types.CountFeaturesResponse; +import com.schematic.api.resources.features.types.CountFlagsResponse; +import com.schematic.api.resources.features.types.CreateFeatureRequestBodyFeatureType; +import com.schematic.api.resources.features.types.CreateFeatureResponse; +import com.schematic.api.resources.features.types.CreateFlagResponse; +import com.schematic.api.resources.features.types.DeleteFeatureResponse; +import com.schematic.api.resources.features.types.DeleteFlagResponse; +import com.schematic.api.resources.features.types.GetFeatureResponse; +import com.schematic.api.resources.features.types.GetFlagResponse; +import com.schematic.api.resources.features.types.ListFeaturesResponse; +import com.schematic.api.resources.features.types.ListFlagsResponse; +import com.schematic.api.resources.features.types.UpdateFeatureResponse; +import com.schematic.api.resources.features.types.UpdateFlagResponse; +import com.schematic.api.resources.features.types.UpdateFlagRulesResponse; +import com.schematic.api.types.CheckFlagRequestBody; +import com.schematic.api.types.CreateFlagRequestBody; +import com.schematic.api.types.CreateOrUpdateConditionGroupRequestBody; +import com.schematic.api.types.CreateOrUpdateConditionRequestBody; +import com.schematic.api.types.CreateOrUpdateConditionRequestBodyConditionType; +import com.schematic.api.types.CreateOrUpdateConditionRequestBodyOperator; +import com.schematic.api.types.CreateOrUpdateRuleRequestBody; +import java.util.Arrays; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class FeaturesWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testListFeatures() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"event_summary\":{\"company_count\":1,\"environment_id\":\"environment_id\",\"event_count\":1,\"event_subtype\":\"event_subtype\",\"user_count\":1},\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"boolean_require_event\":true,\"feature_type\":[\"feature_type\"],\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"without_company_override_for\":\"without_company_override_for\",\"without_plan_entitlement_for\":\"without_plan_entitlement_for\"}}")); + ListFeaturesResponse response = client.features() + .listFeatures(ListFeaturesRequest.builder() + .q("q") + .withoutCompanyOverrideFor("without_company_override_for") + .withoutPlanEntitlementFor("without_plan_entitlement_for") + .booleanRequireEvent(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"event_summary\": {\n" + + " \"company_count\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_count\": 1,\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"boolean_require_event\": true,\n" + + " \"feature_type\": [\n" + + " \"feature_type\"\n" + + " ],\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"without_company_override_for\": \"without_company_override_for\",\n" + + " \"without_plan_entitlement_for\": \"without_plan_entitlement_for\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateFeature() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"event_summary\":{\"company_count\":1,\"environment_id\":\"environment_id\",\"event_count\":1,\"event_subtype\":\"event_subtype\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateFeatureResponse response = client.features() + .createFeature(CreateFeatureRequestBody.builder() + .description("description") + .featureType(CreateFeatureRequestBodyFeatureType.BOOLEAN) + .name("name") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"boolean\",\n" + + " \"name\": \"name\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"event_summary\": {\n" + + " \"company_count\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_count\": 1,\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetFeature() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"event_summary\":{\"company_count\":1,\"environment_id\":\"environment_id\",\"event_count\":1,\"event_subtype\":\"event_subtype\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetFeatureResponse response = client.features().getFeature("feature_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"event_summary\": {\n" + + " \"company_count\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_count\": 1,\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateFeature() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"event_summary\":{\"company_count\":1,\"environment_id\":\"environment_id\",\"event_count\":1,\"event_subtype\":\"event_subtype\",\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"display_name\":\"display_name\",\"entity_type\":\"entity_type\",\"hierarchy\":[\"hierarchy\"],\"id\":\"id\",\"trait_type\":\"trait_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdateFeatureResponse response = client.features() + .updateFeature("feature_id", UpdateFeatureRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"event_summary\": {\n" + + " \"company_count\": 1,\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_count\": 1,\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"display_name\": \"display_name\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"hierarchy\": [\n" + + " \"hierarchy\"\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"trait_type\": \"trait_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteFeature() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteFeatureResponse response = client.features().deleteFeature("feature_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountFeatures() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"boolean_require_event\":true,\"feature_type\":[\"feature_type\"],\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"without_company_override_for\":\"without_company_override_for\",\"without_plan_entitlement_for\":\"without_plan_entitlement_for\"}}")); + CountFeaturesResponse response = client.features() + .countFeatures(CountFeaturesRequest.builder() + .q("q") + .withoutCompanyOverrideFor("without_company_override_for") + .withoutPlanEntitlementFor("without_plan_entitlement_for") + .booleanRequireEvent(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"boolean_require_event\": true,\n" + + " \"feature_type\": [\n" + + " \"feature_type\"\n" + + " ],\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"without_company_override_for\": \"without_company_override_for\",\n" + + " \"without_plan_entitlement_for\": \"without_plan_entitlement_for\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListFlags() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"last_checked_at\":\"2024-01-15T09:30:00Z\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"params\":{\"feature_id\":\"feature_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + ListFlagsResponse response = client.features() + .listFlags(ListFlagsRequest.builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"last_checked_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateFlag() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"last_checked_at\":\"2024-01-15T09:30:00Z\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + CreateFlagResponse response = client.features() + .createFlag(CreateFlagRequestBody.builder() + .defaultValue(true) + .description("description") + .flagType("boolean") + .key("key") + .name("name") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"boolean\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"last_checked_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetFlag() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"last_checked_at\":\"2024-01-15T09:30:00Z\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + GetFlagResponse response = client.features().getFlag("flag_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"last_checked_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateFlag() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"event_subtype\":\"event_subtype\",\"feature_type\":\"feature_type\",\"icon\":\"icon\",\"id\":\"id\",\"lifecycle_phase\":\"lifecycle_phase\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"plural_name\":\"plural_name\",\"singular_name\":\"singular_name\",\"trait_id\":\"trait_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"last_checked_at\":\"2024-01-15T09:30:00Z\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"},\"params\":{\"key\":\"value\"}}")); + UpdateFlagResponse response = client.features() + .updateFlag( + "flag_id", + CreateFlagRequestBody.builder() + .defaultValue(true) + .description("description") + .flagType("boolean") + .key("key") + .name("name") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"boolean\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"lifecycle_phase\": \"lifecycle_phase\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"plural_name\": \"plural_name\",\n" + + " \"singular_name\": \"singular_name\",\n" + + " \"trait_id\": \"trait_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"last_checked_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteFlag() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteFlagResponse response = client.features().deleteFlag("flag_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateFlagRules() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"flag\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"feature_id\":\"feature_id\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"maintainer_id\":\"maintainer_id\",\"name\":\"name\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}]},\"params\":{\"key\":\"value\"}}")); + UpdateFlagRulesResponse response = client.features() + .updateFlagRules( + "flag_id", + UpdateFlagRulesRequestBody.builder() + .rules(Arrays.asList(CreateOrUpdateRuleRequestBody.builder() + .conditionGroups(Arrays.asList(CreateOrUpdateConditionGroupRequestBody.builder() + .conditions(Arrays.asList(CreateOrUpdateConditionRequestBody.builder() + .conditionType( + CreateOrUpdateConditionRequestBodyConditionType.COMPANY) + .operator(CreateOrUpdateConditionRequestBodyOperator.EQ) + .resourceIds(Arrays.asList("resource_ids")) + .build())) + .build())) + .conditions(Arrays.asList(CreateOrUpdateConditionRequestBody.builder() + .conditionType(CreateOrUpdateConditionRequestBodyConditionType.COMPANY) + .operator(CreateOrUpdateConditionRequestBodyOperator.EQ) + .resourceIds(Arrays.asList("resource_ids")) + .build())) + .name("name") + .priority(1) + .value(true) + .build())) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"company\",\n" + + " \"operator\": \"eq\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ]\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"company\",\n" + + " \"operator\": \"eq\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"value\": true\n" + + " }\n" + + " ]\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"flag\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"maintainer_id\": \"maintainer_id\",\n" + + " \"name\": \"name\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCheckFlag() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"company_id\":\"company_id\",\"error\":\"error\",\"feature_allocation\":1,\"feature_usage\":1,\"feature_usage_event\":\"feature_usage_event\",\"feature_usage_period\":\"feature_usage_period\",\"feature_usage_reset_at\":\"2024-01-15T09:30:00Z\",\"flag\":\"flag\",\"flag_id\":\"flag_id\",\"reason\":\"reason\",\"rule_id\":\"rule_id\",\"rule_type\":\"rule_type\",\"user_id\":\"user_id\",\"value\":true},\"params\":{\"key\":\"value\"}}")); + CheckFlagResponse response = client.features() + .checkFlag("key", CheckFlagRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"error\": \"error\",\n" + + " \"feature_allocation\": 1,\n" + + " \"feature_usage\": 1,\n" + + " \"feature_usage_event\": \"feature_usage_event\",\n" + + " \"feature_usage_period\": \"feature_usage_period\",\n" + + " \"feature_usage_reset_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"flag\": \"flag\",\n" + + " \"flag_id\": \"flag_id\",\n" + + " \"reason\": \"reason\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"user_id\": \"user_id\",\n" + + " \"value\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCheckFlags() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"flags\":[{\"flag\":\"flag\",\"reason\":\"reason\",\"value\":true}]},\"params\":{\"key\":\"value\"}}")); + CheckFlagsResponse response = + client.features().checkFlags(CheckFlagRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"flags\": [\n" + + " {\n" + + " \"flag\": \"flag\",\n" + + " \"reason\": \"reason\",\n" + + " \"value\": true\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountFlags() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"feature_id\":\"feature_id\",\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + CountFlagsResponse response = client.features() + .countFlags(CountFlagsRequest.builder() + .featureId("feature_id") + .q("q") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/PlangroupsWireTest.java b/src/test/java/com/schematic/api/PlangroupsWireTest.java new file mode 100644 index 0000000..1eb87fc --- /dev/null +++ b/src/test/java/com/schematic/api/PlangroupsWireTest.java @@ -0,0 +1,1506 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.plangroups.requests.CreatePlanGroupRequestBody; +import com.schematic.api.resources.plangroups.requests.UpdatePlanGroupRequestBody; +import com.schematic.api.resources.plangroups.types.CreatePlanGroupResponse; +import com.schematic.api.resources.plangroups.types.GetPlanGroupResponse; +import com.schematic.api.resources.plangroups.types.UpdatePlanGroupResponse; +import com.schematic.api.types.OrderedPlansInGroup; +import com.schematic.api.types.PlanGroupBundleOrder; +import java.util.Arrays; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PlangroupsWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testGetPlanGroup() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_ons\":[{\"charge_type\":\"charge_type\",\"company_count\":1,\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"entitlements\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"}],\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"is_custom\":true,\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"checkout_settings\":{\"collect_address\":true,\"collect_email\":true,\"collect_phone\":true},\"custom_plan_config\":{\"cta_text\":\"cta_text\",\"cta_web_site\":\"cta_web_site\",\"price_text\":\"price_text\"},\"custom_plan_id\":\"custom_plan_id\",\"default_plan\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"custom_plan_config\":{\"cta_text\":\"cta_text\",\"cta_web_site\":\"cta_web_site\",\"price_text\":\"price_text\"},\"description\":\"description\",\"entitlements\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"}],\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_custom\":true,\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}},\"fallback_plan\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"custom_plan_config\":{\"cta_text\":\"cta_text\",\"cta_web_site\":\"cta_web_site\",\"price_text\":\"price_text\"},\"description\":\"description\",\"entitlements\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"}],\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_custom\":true,\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}},\"fallback_plan_id\":\"fallback_plan_id\",\"id\":\"id\",\"initial_plan\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"custom_plan_config\":{\"cta_text\":\"cta_text\",\"cta_web_site\":\"cta_web_site\",\"price_text\":\"price_text\"},\"description\":\"description\",\"entitlements\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"}],\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_custom\":true,\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}},\"initial_plan_id\":\"initial_plan_id\",\"initial_plan_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"initial_plan_price_id\":\"initial_plan_price_id\",\"ordered_add_on_list\":[{\"plan_id\":\"plan_id\"}],\"ordered_bundle_list\":[{\"bundleId\":\"bundleId\"}],\"ordered_plan_list\":[{\"plan_id\":\"plan_id\"}],\"plans\":[{\"charge_type\":\"charge_type\",\"company_count\":1,\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"entitlements\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"}],\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"is_custom\":true,\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"name\":\"name\",\"plan_type\":\"plan_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"prevent_downgrades_when_over_limit\":true,\"show_credits\":true,\"show_period_toggle\":true,\"show_zero_price_as_free\":true,\"sync_customer_billing_details_for_tax\":true,\"tax_collection_enabled\":true,\"trial_days\":1,\"trial_expiry_plan\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"custom_plan_config\":{\"cta_text\":\"cta_text\",\"cta_web_site\":\"cta_web_site\",\"price_text\":\"price_text\"},\"description\":\"description\",\"entitlements\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"feature_id\":\"feature_id\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value_type\":\"value_type\"}],\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_custom\":true,\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}},\"trial_expiry_plan_id\":\"trial_expiry_plan_id\",\"trial_expiry_plan_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"trial_expiry_plan_price_id\":\"trial_expiry_plan_price_id\",\"trial_payment_method_required\":true},\"params\":{\"key\":\"value\"}}")); + GetPlanGroupResponse response = client.plangroups().getPlanGroup(); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"entitlements\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"is_custom\": true,\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"checkout_settings\": {\n" + + " \"collect_address\": true,\n" + + " \"collect_email\": true,\n" + + " \"collect_phone\": true\n" + + " },\n" + + " \"custom_plan_config\": {\n" + + " \"cta_text\": \"cta_text\",\n" + + " \"cta_web_site\": \"cta_web_site\",\n" + + " \"price_text\": \"price_text\"\n" + + " },\n" + + " \"custom_plan_id\": \"custom_plan_id\",\n" + + " \"default_plan\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"custom_plan_config\": {\n" + + " \"cta_text\": \"cta_text\",\n" + + " \"cta_web_site\": \"cta_web_site\",\n" + + " \"price_text\": \"price_text\"\n" + + " },\n" + + " \"description\": \"description\",\n" + + " \"entitlements\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_custom\": true,\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"fallback_plan\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"custom_plan_config\": {\n" + + " \"cta_text\": \"cta_text\",\n" + + " \"cta_web_site\": \"cta_web_site\",\n" + + " \"price_text\": \"price_text\"\n" + + " },\n" + + " \"description\": \"description\",\n" + + " \"entitlements\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_custom\": true,\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"fallback_plan_id\": \"fallback_plan_id\",\n" + + " \"id\": \"id\",\n" + + " \"initial_plan\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"custom_plan_config\": {\n" + + " \"cta_text\": \"cta_text\",\n" + + " \"cta_web_site\": \"cta_web_site\",\n" + + " \"price_text\": \"price_text\"\n" + + " },\n" + + " \"description\": \"description\",\n" + + " \"entitlements\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_custom\": true,\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"initial_plan_id\": \"initial_plan_id\",\n" + + " \"initial_plan_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"initial_plan_price_id\": \"initial_plan_price_id\",\n" + + " \"ordered_add_on_list\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"ordered_bundle_list\": [\n" + + " {\n" + + " \"bundleId\": \"bundleId\"\n" + + " }\n" + + " ],\n" + + " \"ordered_plan_list\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"plans\": [\n" + + " {\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"entitlements\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"is_custom\": true,\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"prevent_downgrades_when_over_limit\": true,\n" + + " \"show_credits\": true,\n" + + " \"show_period_toggle\": true,\n" + + " \"show_zero_price_as_free\": true,\n" + + " \"sync_customer_billing_details_for_tax\": true,\n" + + " \"tax_collection_enabled\": true,\n" + + " \"trial_days\": 1,\n" + + " \"trial_expiry_plan\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"custom_plan_config\": {\n" + + " \"cta_text\": \"cta_text\",\n" + + " \"cta_web_site\": \"cta_web_site\",\n" + + " \"price_text\": \"price_text\"\n" + + " },\n" + + " \"description\": \"description\",\n" + + " \"entitlements\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"feature_id\": \"feature_id\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value_type\": \"value_type\"\n" + + " }\n" + + " ],\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_custom\": true,\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"trial_expiry_plan_id\": \"trial_expiry_plan_id\",\n" + + " \"trial_expiry_plan_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"trial_expiry_plan_price_id\": \"trial_expiry_plan_price_id\",\n" + + " \"trial_payment_method_required\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreatePlanGroup() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_on_compatibilities\":[{\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"source_plan_id\":\"source_plan_id\"}],\"add_on_ids\":[\"add_on_ids\"],\"checkout_settings\":{\"collect_address\":true,\"collect_email\":true,\"collect_phone\":true},\"fallback_plan_id\":\"fallback_plan_id\",\"id\":\"id\",\"initial_plan_id\":\"initial_plan_id\",\"initial_plan_price_id\":\"initial_plan_price_id\",\"ordered_add_on_ids\":[{\"plan_id\":\"plan_id\"}],\"plan_ids\":[{\"plan_id\":\"plan_id\"}],\"prevent_downgrades_when_over_limit\":true,\"show_credits\":true,\"show_period_toggle\":true,\"show_zero_price_as_free\":true,\"sync_customer_billing_details_for_tax\":true,\"tax_collection_enabled\":true,\"trial_days\":1,\"trial_expiry_plan_id\":\"trial_expiry_plan_id\",\"trial_expiry_plan_price_id\":\"trial_expiry_plan_price_id\",\"trial_payment_method_required\":true},\"params\":{\"key\":\"value\"}}")); + CreatePlanGroupResponse response = client.plangroups() + .createPlanGroup(CreatePlanGroupRequestBody.builder() + .addOnIds(Arrays.asList("add_on_ids")) + .checkoutCollectAddress(true) + .checkoutCollectEmail(true) + .checkoutCollectPhone(true) + .enableTaxCollection(true) + .orderedAddOns(Arrays.asList( + OrderedPlansInGroup.builder().planId("plan_id").build())) + .orderedBundleList(Arrays.asList(PlanGroupBundleOrder.builder() + .bundleId("bundleId") + .build())) + .orderedPlans(Arrays.asList( + OrderedPlansInGroup.builder().planId("plan_id").build())) + .preventDowngradesWhenOverLimit(true) + .showCredits(true) + .showPeriodToggle(true) + .showZeroPriceAsFree(true) + .syncCustomerBillingDetailsForTax(true) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"add_on_ids\": [\n" + + " \"add_on_ids\"\n" + + " ],\n" + + " \"checkout_collect_address\": true,\n" + + " \"checkout_collect_email\": true,\n" + + " \"checkout_collect_phone\": true,\n" + + " \"enable_tax_collection\": true,\n" + + " \"ordered_add_ons\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"ordered_bundle_list\": [\n" + + " {\n" + + " \"bundleId\": \"bundleId\"\n" + + " }\n" + + " ],\n" + + " \"ordered_plans\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"prevent_downgrades_when_over_limit\": true,\n" + + " \"show_credits\": true,\n" + + " \"show_period_toggle\": true,\n" + + " \"show_zero_price_as_free\": true,\n" + + " \"sync_customer_billing_details_for_tax\": true\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_on_compatibilities\": [\n" + + " {\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"source_plan_id\": \"source_plan_id\"\n" + + " }\n" + + " ],\n" + + " \"add_on_ids\": [\n" + + " \"add_on_ids\"\n" + + " ],\n" + + " \"checkout_settings\": {\n" + + " \"collect_address\": true,\n" + + " \"collect_email\": true,\n" + + " \"collect_phone\": true\n" + + " },\n" + + " \"fallback_plan_id\": \"fallback_plan_id\",\n" + + " \"id\": \"id\",\n" + + " \"initial_plan_id\": \"initial_plan_id\",\n" + + " \"initial_plan_price_id\": \"initial_plan_price_id\",\n" + + " \"ordered_add_on_ids\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"plan_ids\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"prevent_downgrades_when_over_limit\": true,\n" + + " \"show_credits\": true,\n" + + " \"show_period_toggle\": true,\n" + + " \"show_zero_price_as_free\": true,\n" + + " \"sync_customer_billing_details_for_tax\": true,\n" + + " \"tax_collection_enabled\": true,\n" + + " \"trial_days\": 1,\n" + + " \"trial_expiry_plan_id\": \"trial_expiry_plan_id\",\n" + + " \"trial_expiry_plan_price_id\": \"trial_expiry_plan_price_id\",\n" + + " \"trial_payment_method_required\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdatePlanGroup() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_on_compatibilities\":[{\"compatible_plan_ids\":[\"compatible_plan_ids\"],\"source_plan_id\":\"source_plan_id\"}],\"add_on_ids\":[\"add_on_ids\"],\"checkout_settings\":{\"collect_address\":true,\"collect_email\":true,\"collect_phone\":true},\"fallback_plan_id\":\"fallback_plan_id\",\"id\":\"id\",\"initial_plan_id\":\"initial_plan_id\",\"initial_plan_price_id\":\"initial_plan_price_id\",\"ordered_add_on_ids\":[{\"plan_id\":\"plan_id\"}],\"plan_ids\":[{\"plan_id\":\"plan_id\"}],\"prevent_downgrades_when_over_limit\":true,\"show_credits\":true,\"show_period_toggle\":true,\"show_zero_price_as_free\":true,\"sync_customer_billing_details_for_tax\":true,\"tax_collection_enabled\":true,\"trial_days\":1,\"trial_expiry_plan_id\":\"trial_expiry_plan_id\",\"trial_expiry_plan_price_id\":\"trial_expiry_plan_price_id\",\"trial_payment_method_required\":true},\"params\":{\"key\":\"value\"}}")); + UpdatePlanGroupResponse response = client.plangroups() + .updatePlanGroup( + "plan_group_id", + UpdatePlanGroupRequestBody.builder() + .addOnIds(Arrays.asList("add_on_ids")) + .checkoutCollectAddress(true) + .checkoutCollectEmail(true) + .checkoutCollectPhone(true) + .enableTaxCollection(true) + .orderedAddOns(Arrays.asList(OrderedPlansInGroup.builder() + .planId("plan_id") + .build())) + .orderedBundleList(Arrays.asList(PlanGroupBundleOrder.builder() + .bundleId("bundleId") + .build())) + .orderedPlans(Arrays.asList(OrderedPlansInGroup.builder() + .planId("plan_id") + .build())) + .preventDowngradesWhenOverLimit(true) + .showCredits(true) + .showPeriodToggle(true) + .showZeroPriceAsFree(true) + .syncCustomerBillingDetailsForTax(true) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"add_on_ids\": [\n" + + " \"add_on_ids\"\n" + + " ],\n" + + " \"checkout_collect_address\": true,\n" + + " \"checkout_collect_email\": true,\n" + + " \"checkout_collect_phone\": true,\n" + + " \"enable_tax_collection\": true,\n" + + " \"ordered_add_ons\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"ordered_bundle_list\": [\n" + + " {\n" + + " \"bundleId\": \"bundleId\"\n" + + " }\n" + + " ],\n" + + " \"ordered_plans\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"prevent_downgrades_when_over_limit\": true,\n" + + " \"show_credits\": true,\n" + + " \"show_period_toggle\": true,\n" + + " \"show_zero_price_as_free\": true,\n" + + " \"sync_customer_billing_details_for_tax\": true\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_on_compatibilities\": [\n" + + " {\n" + + " \"compatible_plan_ids\": [\n" + + " \"compatible_plan_ids\"\n" + + " ],\n" + + " \"source_plan_id\": \"source_plan_id\"\n" + + " }\n" + + " ],\n" + + " \"add_on_ids\": [\n" + + " \"add_on_ids\"\n" + + " ],\n" + + " \"checkout_settings\": {\n" + + " \"collect_address\": true,\n" + + " \"collect_email\": true,\n" + + " \"collect_phone\": true\n" + + " },\n" + + " \"fallback_plan_id\": \"fallback_plan_id\",\n" + + " \"id\": \"id\",\n" + + " \"initial_plan_id\": \"initial_plan_id\",\n" + + " \"initial_plan_price_id\": \"initial_plan_price_id\",\n" + + " \"ordered_add_on_ids\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"plan_ids\": [\n" + + " {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + " ],\n" + + " \"prevent_downgrades_when_over_limit\": true,\n" + + " \"show_credits\": true,\n" + + " \"show_period_toggle\": true,\n" + + " \"show_zero_price_as_free\": true,\n" + + " \"sync_customer_billing_details_for_tax\": true,\n" + + " \"tax_collection_enabled\": true,\n" + + " \"trial_days\": 1,\n" + + " \"trial_expiry_plan_id\": \"trial_expiry_plan_id\",\n" + + " \"trial_expiry_plan_price_id\": \"trial_expiry_plan_price_id\",\n" + + " \"trial_payment_method_required\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/PlansWireTest.java b/src/test/java/com/schematic/api/PlansWireTest.java new file mode 100644 index 0000000..75b5f44 --- /dev/null +++ b/src/test/java/com/schematic/api/PlansWireTest.java @@ -0,0 +1,1704 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.plans.requests.CountPlansRequest; +import com.schematic.api.resources.plans.requests.CreatePlanRequestBody; +import com.schematic.api.resources.plans.requests.ListPlanIssuesRequest; +import com.schematic.api.resources.plans.requests.ListPlansRequest; +import com.schematic.api.resources.plans.requests.UpdateCompanyPlansRequestBody; +import com.schematic.api.resources.plans.requests.UpdatePlanRequestBody; +import com.schematic.api.resources.plans.requests.UpsertBillingProductRequestBody; +import com.schematic.api.resources.plans.types.CountPlansRequestPlanType; +import com.schematic.api.resources.plans.types.CountPlansResponse; +import com.schematic.api.resources.plans.types.CreatePlanRequestBodyPlanType; +import com.schematic.api.resources.plans.types.CreatePlanResponse; +import com.schematic.api.resources.plans.types.DeletePlanResponse; +import com.schematic.api.resources.plans.types.GetPlanResponse; +import com.schematic.api.resources.plans.types.ListPlanIssuesResponse; +import com.schematic.api.resources.plans.types.ListPlansRequestPlanType; +import com.schematic.api.resources.plans.types.ListPlansResponse; +import com.schematic.api.resources.plans.types.UpdateCompanyPlansResponse; +import com.schematic.api.resources.plans.types.UpdatePlanResponse; +import com.schematic.api.resources.plans.types.UpsertBillingProductPlanResponse; +import com.schematic.api.resources.plans.types.UpsertBillingProductRequestBodyChargeType; +import java.util.Arrays; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PlansWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testUpdateCompanyPlans() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"add_ons\":[{\"id\":\"id\",\"name\":\"name\"}],\"billing_credit_balances\":{\"key\":1.1},\"billing_subscription\":{\"cancel_at\":1,\"cancel_at_period_end\":true,\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"default_payment_method_id\":\"default_payment_method_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"expired_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"interval\":\"interval\",\"latest_invoice\":{\"amount_due\":1,\"amount_paid\":1,\"amount_remaining\":1,\"collection_method\":\"collection_method\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"subtotal\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"metadata\":{\"key\":\"value\"},\"payment_method\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1,\"trial_end\":1,\"trial_end_setting\":\"trial_end_setting\"},\"billing_subscriptions\":[{\"cancel_at_period_end\":true,\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"customer_external_id\":\"customer_external_id\",\"discounts\":[{\"coupon_id\":\"coupon_id\",\"coupon_name\":\"coupon_name\",\"discount_external_id\":\"discount_external_id\",\"duration\":\"duration\",\"is_active\":true,\"started_at\":\"2024-01-15T09:30:00Z\",\"subscription_external_id\":\"subscription_external_id\"}],\"id\":\"id\",\"interval\":\"interval\",\"period_end\":1,\"period_start\":1,\"products\":[{\"billing_scheme\":\"billing_scheme\",\"created_at\":\"2024-01-15T09:30:00Z\",\"currency\":\"currency\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"interval\":\"interval\",\"name\":\"name\",\"package_size\":1,\"price\":1,\"price_external_id\":\"price_external_id\",\"price_id\":\"price_id\",\"price_tier\":[{}],\"quantity\":1.1,\"subscription_id\":\"subscription_id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"usage_type\":\"usage_type\"}],\"status\":\"status\",\"subscription_external_id\":\"subscription_external_id\",\"total_price\":1}],\"created_at\":\"2024-01-15T09:30:00Z\",\"default_payment_method\":{\"account_last4\":\"account_last4\",\"account_name\":\"account_name\",\"bank_name\":\"bank_name\",\"billing_email\":\"billing_email\",\"billing_name\":\"billing_name\",\"card_brand\":\"card_brand\",\"card_exp_month\":1,\"card_exp_year\":1,\"card_last4\":\"card_last4\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"},\"entity_traits\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"keys\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"definition_id\":\"definition_id\",\"entity_id\":\"entity_id\",\"entity_type\":\"entity_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"key\":\"key\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":\"value\"}],\"last_seen_at\":\"2024-01-15T09:30:00Z\",\"logo_url\":\"logo_url\",\"metrics\":[{\"account_id\":\"account_id\",\"captured_at_max\":\"2024-01-15T09:30:00Z\",\"captured_at_min\":\"2024-01-15T09:30:00Z\",\"company_id\":\"company_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"event_subtype\":\"event_subtype\",\"month_reset\":\"month_reset\",\"period\":\"period\",\"value\":1}],\"name\":\"name\",\"payment_methods\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"customer_external_id\":\"customer_external_id\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"id\":\"id\",\"payment_method_type\":\"payment_method_type\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"plan\":{\"added_on\":\"2024-01-15T09:30:00Z\",\"billing_product_external_id\":\"billing_product_external_id\",\"billing_product_id\":\"billing_product_id\",\"description\":\"description\",\"id\":\"id\",\"image_url\":\"image_url\",\"name\":\"name\",\"plan_period\":\"plan_period\",\"plan_price\":1},\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"rules\":[{\"account_id\":\"account_id\",\"condition_groups\":[{\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}]}],\"conditions\":[{\"account_id\":\"account_id\",\"condition_type\":\"condition_type\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"trait_value\":\"trait_value\"}],\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"value\":true}],\"traits\":{\"key\":\"value\"},\"updated_at\":\"2024-01-15T09:30:00Z\",\"user_count\":1},\"params\":{\"key\":\"value\"}}")); + UpdateCompanyPlansResponse response = client.plans() + .updateCompanyPlans( + "company_plan_id", + UpdateCompanyPlansRequestBody.builder() + .addOnIds(Arrays.asList("add_on_ids")) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"add_on_ids\": [\n" + " \"add_on_ids\"\n" + " ]\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"add_ons\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"billing_credit_balances\": {\n" + + " \"key\": 1.1\n" + + " },\n" + + " \"billing_subscription\": {\n" + + " \"cancel_at\": 1,\n" + + " \"cancel_at_period_end\": true,\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"default_payment_method_id\": \"default_payment_method_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"expired_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"latest_invoice\": {\n" + + " \"amount_due\": 1,\n" + + " \"amount_paid\": 1,\n" + + " \"amount_remaining\": 1,\n" + + " \"collection_method\": \"collection_method\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"subtotal\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"metadata\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"payment_method\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1,\n" + + " \"trial_end\": 1,\n" + + " \"trial_end_setting\": \"trial_end_setting\"\n" + + " },\n" + + " \"billing_subscriptions\": [\n" + + " {\n" + + " \"cancel_at_period_end\": true,\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"discounts\": [\n" + + " {\n" + + " \"coupon_id\": \"coupon_id\",\n" + + " \"coupon_name\": \"coupon_name\",\n" + + " \"discount_external_id\": \"discount_external_id\",\n" + + " \"duration\": \"duration\",\n" + + " \"is_active\": true,\n" + + " \"started_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"subscription_external_id\": \"subscription_external_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"period_end\": 1,\n" + + " \"period_start\": 1,\n" + + " \"products\": [\n" + + " {\n" + + " \"billing_scheme\": \"billing_scheme\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"currency\": \"currency\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"name\": \"name\",\n" + + " \"package_size\": 1,\n" + + " \"price\": 1,\n" + + " \"price_external_id\": \"price_external_id\",\n" + + " \"price_id\": \"price_id\",\n" + + " \"price_tier\": [\n" + + " {}\n" + + " ],\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_id\": \"subscription_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"usage_type\": \"usage_type\"\n" + + " }\n" + + " ],\n" + + " \"status\": \"status\",\n" + + " \"subscription_external_id\": \"subscription_external_id\",\n" + + " \"total_price\": 1\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_payment_method\": {\n" + + " \"account_last4\": \"account_last4\",\n" + + " \"account_name\": \"account_name\",\n" + + " \"bank_name\": \"bank_name\",\n" + + " \"billing_email\": \"billing_email\",\n" + + " \"billing_name\": \"billing_name\",\n" + + " \"card_brand\": \"card_brand\",\n" + + " \"card_exp_month\": 1,\n" + + " \"card_exp_year\": 1,\n" + + " \"card_last4\": \"card_last4\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"entity_traits\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"keys\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"definition_id\": \"definition_id\",\n" + + " \"entity_id\": \"entity_id\",\n" + + " \"entity_type\": \"entity_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": \"value\"\n" + + " }\n" + + " ],\n" + + " \"last_seen_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"logo_url\": \"logo_url\",\n" + + " \"metrics\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"captured_at_max\": \"2024-01-15T09:30:00Z\",\n" + + " \"captured_at_min\": \"2024-01-15T09:30:00Z\",\n" + + " \"company_id\": \"company_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"event_subtype\": \"event_subtype\",\n" + + " \"month_reset\": \"month_reset\",\n" + + " \"period\": \"period\",\n" + + " \"value\": 1\n" + + " }\n" + + " ],\n" + + " \"name\": \"name\",\n" + + " \"payment_methods\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"customer_external_id\": \"customer_external_id\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"id\": \"id\",\n" + + " \"payment_method_type\": \"payment_method_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"plan\": {\n" + + " \"added_on\": \"2024-01-15T09:30:00Z\",\n" + + " \"billing_product_external_id\": \"billing_product_external_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"description\": \"description\",\n" + + " \"id\": \"id\",\n" + + " \"image_url\": \"image_url\",\n" + + " \"name\": \"name\",\n" + + " \"plan_period\": \"plan_period\",\n" + + " \"plan_price\": 1\n" + + " },\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rules\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"account_id\": \"account_id\",\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"trait_value\": \"trait_value\"\n" + + " }\n" + + " ],\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"traits\": {\n" + + " \"key\": \"value\"\n" + + " },\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"user_count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListPlans() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}}],\"params\":{\"company_id\":\"company_id\",\"for_fallback_plan\":true,\"for_initial_plan\":true,\"for_trial_expiry_plan\":true,\"has_product_id\":true,\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_type\":\"plan\",\"q\":\"q\",\"requires_payment_method\":true,\"without_entitlement_for\":\"without_entitlement_for\",\"without_paid_product_id\":true,\"without_product_id\":true}}")); + ListPlansResponse response = client.plans() + .listPlans(ListPlansRequest.builder() + .companyId("company_id") + .forFallbackPlan(true) + .forInitialPlan(true) + .forTrialExpiryPlan(true) + .hasProductId(true) + .planType(ListPlansRequestPlanType.PLAN) + .q("q") + .requiresPaymentMethod(true) + .withoutEntitlementFor("without_entitlement_for") + .withoutProductId(true) + .withoutPaidProductId(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"for_fallback_plan\": true,\n" + + " \"for_initial_plan\": true,\n" + + " \"for_trial_expiry_plan\": true,\n" + + " \"has_product_id\": true,\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_type\": \"plan\",\n" + + " \"q\": \"q\",\n" + + " \"requires_payment_method\": true,\n" + + " \"without_entitlement_for\": \"without_entitlement_for\",\n" + + " \"without_paid_product_id\": true,\n" + + " \"without_product_id\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreatePlan() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"}},\"params\":{\"key\":\"value\"}}")); + CreatePlanResponse response = client.plans() + .createPlan(CreatePlanRequestBody.builder() + .description("description") + .name("name") + .planType(CreatePlanRequestBodyPlanType.PLAN) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"description\": \"description\",\n" + + " \"name\": \"name\",\n" + + " \"plan_type\": \"plan\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetPlan() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"}},\"params\":{\"key\":\"value\"}}")); + GetPlanResponse response = client.plans().getPlan("plan_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdatePlan() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"billing_product\":{\"account_id\":\"account_id\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"external_id\":\"external_id\",\"is_active\":true,\"name\":\"name\",\"price\":1.1,\"price_decimal\":\"price_decimal\",\"prices\":[{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"scheme\":\"scheme\"}],\"product_id\":\"product_id\",\"quantity\":1.1,\"subscription_count\":1,\"updated_at\":\"2024-01-15T09:30:00Z\"},\"charge_type\":\"charge_type\",\"company_count\":1,\"controlled_by\":\"controlled_by\",\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"features\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"description\":\"description\",\"feature_type\":\"feature_type\",\"flags\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"default_value\":true,\"description\":\"description\",\"flag_type\":\"flag_type\",\"id\":\"id\",\"key\":\"key\",\"name\":\"name\",\"rules\":[{\"condition_groups\":[{\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"rule_id\":\"rule_id\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"conditions\":[{\"condition_type\":\"condition_type\",\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"operator\":\"operator\",\"resource_ids\":[\"resource_ids\"],\"resources\":[{\"id\":\"id\",\"name\":\"name\"}],\"rule_id\":\"rule_id\",\"trait_value\":\"trait_value\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"created_at\":\"2024-01-15T09:30:00Z\",\"environment_id\":\"environment_id\",\"id\":\"id\",\"name\":\"name\",\"priority\":1,\"rule_type\":\"rule_type\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"value\":true}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"name\":\"name\",\"plans\":[{\"id\":\"id\",\"name\":\"name\"}],\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"icon\":\"icon\",\"id\":\"id\",\"included_credit_grants\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_amount\":1,\"credit_id\":\"credit_id\",\"credit_name\":\"credit_name\",\"id\":\"id\",\"plan_id\":\"plan_id\",\"plan_name\":\"plan_name\",\"reset_cadence\":\"reset_cadence\",\"reset_start\":\"reset_start\",\"updated_at\":\"2024-01-15T09:30:00Z\"}],\"is_default\":true,\"is_free\":true,\"is_trialable\":true,\"monthly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"name\":\"name\",\"one_time_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"},\"plan_type\":\"plan_type\",\"trial_days\":1,\"updated_at\":\"2024-01-15T09:30:00Z\",\"yearly_price\":{\"currency\":\"currency\",\"external_price_id\":\"external_price_id\",\"id\":\"id\",\"interval\":\"interval\",\"price\":1,\"price_decimal\":\"price_decimal\",\"scheme\":\"scheme\"}},\"params\":{\"key\":\"value\"}}")); + UpdatePlanResponse response = client.plans() + .updatePlan( + "plan_id", UpdatePlanRequestBody.builder().name("name").build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{\n" + " \"name\": \"name\"\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"billing_product\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"external_id\": \"external_id\",\n" + + " \"is_active\": true,\n" + + " \"name\": \"name\",\n" + + " \"price\": 1.1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"prices\": [\n" + + " {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " ],\n" + + " \"product_id\": \"product_id\",\n" + + " \"quantity\": 1.1,\n" + + " \"subscription_count\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " },\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"company_count\": 1,\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"features\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"description\": \"description\",\n" + + " \"feature_type\": \"feature_type\",\n" + + " \"flags\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"default_value\": true,\n" + + " \"description\": \"description\",\n" + + " \"flag_type\": \"flag_type\",\n" + + " \"id\": \"id\",\n" + + " \"key\": \"key\",\n" + + " \"name\": \"name\",\n" + + " \"rules\": [\n" + + " {\n" + + " \"condition_groups\": [\n" + + " {\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"conditions\": [\n" + + " {\n" + + " \"condition_type\": \"condition_type\",\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"operator\": \"operator\",\n" + + " \"resource_ids\": [\n" + + " \"resource_ids\"\n" + + " ],\n" + + " \"resources\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"rule_id\": \"rule_id\",\n" + + " \"trait_value\": \"trait_value\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"priority\": 1,\n" + + " \"rule_type\": \"rule_type\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"value\": true\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"plans\": [\n" + + " {\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\"\n" + + " }\n" + + " ],\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"icon\": \"icon\",\n" + + " \"id\": \"id\",\n" + + " \"included_credit_grants\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_amount\": 1,\n" + + " \"credit_id\": \"credit_id\",\n" + + " \"credit_name\": \"credit_name\",\n" + + " \"id\": \"id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"plan_name\": \"plan_name\",\n" + + " \"reset_cadence\": \"reset_cadence\",\n" + + " \"reset_start\": \"reset_start\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\"\n" + + " }\n" + + " ],\n" + + " \"is_default\": true,\n" + + " \"is_free\": true,\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"name\": \"name\",\n" + + " \"one_time_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " },\n" + + " \"plan_type\": \"plan_type\",\n" + + " \"trial_days\": 1,\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"yearly_price\": {\n" + + " \"currency\": \"currency\",\n" + + " \"external_price_id\": \"external_price_id\",\n" + + " \"id\": \"id\",\n" + + " \"interval\": \"interval\",\n" + + " \"price\": 1,\n" + + " \"price_decimal\": \"price_decimal\",\n" + + " \"scheme\": \"scheme\"\n" + + " }\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeletePlan() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeletePlanResponse response = client.plans().deletePlan("plan_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpsertBillingProductPlan() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"account_id\":\"account_id\",\"billing_product_id\":\"billing_product_id\",\"charge_type\":\"charge_type\",\"controlled_by\":\"controlled_by\",\"environment_id\":\"environment_id\",\"is_trialable\":true,\"monthly_price_id\":\"monthly_price_id\",\"one_time_price_id\":\"one_time_price_id\",\"plan_id\":\"plan_id\",\"trial_days\":1,\"yearly_price_id\":\"yearly_price_id\"},\"params\":{\"key\":\"value\"}}")); + UpsertBillingProductPlanResponse response = client.plans() + .upsertBillingProductPlan( + "plan_id", + UpsertBillingProductRequestBody.builder() + .chargeType(UpsertBillingProductRequestBodyChargeType.ONE_TIME) + .isTrialable(true) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = + "" + "{\n" + " \"charge_type\": \"one_time\",\n" + " \"is_trialable\": true\n" + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"account_id\": \"account_id\",\n" + + " \"billing_product_id\": \"billing_product_id\",\n" + + " \"charge_type\": \"charge_type\",\n" + + " \"controlled_by\": \"controlled_by\",\n" + + " \"environment_id\": \"environment_id\",\n" + + " \"is_trialable\": true,\n" + + " \"monthly_price_id\": \"monthly_price_id\",\n" + + " \"one_time_price_id\": \"one_time_price_id\",\n" + + " \"plan_id\": \"plan_id\",\n" + + " \"trial_days\": 1,\n" + + " \"yearly_price_id\": \"yearly_price_id\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountPlans() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"company_id\":\"company_id\",\"for_fallback_plan\":true,\"for_initial_plan\":true,\"for_trial_expiry_plan\":true,\"has_product_id\":true,\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"plan_type\":\"plan\",\"q\":\"q\",\"requires_payment_method\":true,\"without_entitlement_for\":\"without_entitlement_for\",\"without_paid_product_id\":true,\"without_product_id\":true}}")); + CountPlansResponse response = client.plans() + .countPlans(CountPlansRequest.builder() + .companyId("company_id") + .forFallbackPlan(true) + .forInitialPlan(true) + .forTrialExpiryPlan(true) + .hasProductId(true) + .planType(CountPlansRequestPlanType.PLAN) + .q("q") + .requiresPaymentMethod(true) + .withoutEntitlementFor("without_entitlement_for") + .withoutProductId(true) + .withoutPaidProductId(true) + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"company_id\": \"company_id\",\n" + + " \"for_fallback_plan\": true,\n" + + " \"for_initial_plan\": true,\n" + + " \"for_trial_expiry_plan\": true,\n" + + " \"has_product_id\": true,\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"plan_type\": \"plan\",\n" + + " \"q\": \"q\",\n" + + " \"requires_payment_method\": true,\n" + + " \"without_entitlement_for\": \"without_entitlement_for\",\n" + + " \"without_paid_product_id\": true,\n" + + " \"without_product_id\": true\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListPlanIssues() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"code\":\"code\",\"description\":\"description\",\"detail\":\"detail\",\"id\":\"id\"}],\"params\":{\"plan_id\":\"plan_id\"}}")); + ListPlanIssuesResponse response = client.plans() + .listPlanIssues( + ListPlanIssuesRequest.builder().planId("plan_id").build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"code\": \"code\",\n" + + " \"description\": \"description\",\n" + + " \"detail\": \"detail\",\n" + + " \"id\": \"id\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"plan_id\": \"plan_id\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/ServiceWireTest.java b/src/test/java/com/schematic/api/ServiceWireTest.java new file mode 100644 index 0000000..cc589da --- /dev/null +++ b/src/test/java/com/schematic/api/ServiceWireTest.java @@ -0,0 +1,50 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ServiceWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testPutPlanAudiencesPlanAudienceId() throws Exception { + server.enqueue(new MockResponse().setResponseCode(200).setBody("{}")); + client.putPlanAudiencesPlanAudienceId("plan_audience_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + } + + @Test + public void testDeletePlanAudiencesPlanAudienceId() throws Exception { + server.enqueue(new MockResponse().setResponseCode(200).setBody("{}")); + client.deletePlanAudiencesPlanAudienceId("plan_audience_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + } +} diff --git a/src/test/java/com/schematic/api/StreamTest.java b/src/test/java/com/schematic/api/StreamTest.java new file mode 100644 index 0000000..66e7cea --- /dev/null +++ b/src/test/java/com/schematic/api/StreamTest.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api; + +import static org.junit.jupiter.api.Assertions.*; + +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.core.Stream; +import java.io.IOException; +import java.io.StringReader; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.junit.jupiter.api.Test; + +public final class StreamTest { + @Test + public void testJsonStream() { + List messages = List.of(Map.of("message", "hello"), Map.of("message", "world")); + List jsonStrings = messages.stream().map(StreamTest::mapToJson).collect(Collectors.toList()); + String input = String.join("\n", jsonStrings); + StringReader jsonInput = new StringReader(input); + Stream jsonStream = Stream.fromJson(Map.class, jsonInput); + int expectedMessages = 2; + int actualMessages = 0; + for (Map jsonObject : jsonStream) { + actualMessages++; + assertTrue(jsonObject.containsKey("message")); + } + assertEquals(expectedMessages, actualMessages); + } + + @Test + public void testSseStream() { + List events = List.of(Map.of("event", "start"), Map.of("event", "end")); + List sseStrings = events.stream().map(StreamTest::mapToSse).collect(Collectors.toList()); + String input = String.join("\n" + "\n", sseStrings); + StringReader sseInput = new StringReader(input); + Stream sseStream = Stream.fromSse(Map.class, sseInput); + int expectedEvents = 2; + int actualEvents = 0; + for (Map eventData : sseStream) { + actualEvents++; + assertTrue(eventData.containsKey("event")); + } + assertEquals(expectedEvents, actualEvents); + } + + @Test + public void testSseStreamWithTerminator() { + List events = List.of(Map.of("message", "first"), Map.of("message", "second")); + List sseStrings = events.stream().map(StreamTest::mapToSse).collect(Collectors.toList()); + sseStrings.add("data: [DONE]"); + String input = String.join("\n" + "\n", sseStrings); + StringReader sseInput = new StringReader(input); + Stream sseStream = Stream.fromSse(Map.class, sseInput, "[DONE]"); + int expectedEvents = 2; + int actualEvents = 0; + for (Map eventData : sseStream) { + actualEvents++; + assertTrue(eventData.containsKey("message")); + } + assertEquals(expectedEvents, actualEvents); + } + + @Test + public void testStreamResourceManagement() throws IOException { + StringReader testInput = new StringReader("{\"test\":\"data\"}"); + Stream testStream = Stream.fromJson(Map.class, testInput); + testStream.close(); + assertFalse(testStream.iterator().hasNext()); + } + + private static String mapToJson(Map map) { + try { + return ObjectMappers.JSON_MAPPER.writeValueAsString(map); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static String mapToSse(Map map) { + return "data: " + mapToJson(map); + } +} diff --git a/src/test/java/com/schematic/api/WebhooksWireTest.java b/src/test/java/com/schematic/api/WebhooksWireTest.java new file mode 100644 index 0000000..2e6b95b --- /dev/null +++ b/src/test/java/com/schematic/api/WebhooksWireTest.java @@ -0,0 +1,765 @@ +package com.schematic.api; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.schematic.api.core.ObjectMappers; +import com.schematic.api.resources.webhooks.requests.CountWebhookEventsRequest; +import com.schematic.api.resources.webhooks.requests.CountWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.CreateWebhookRequestBody; +import com.schematic.api.resources.webhooks.requests.ListWebhookEventsRequest; +import com.schematic.api.resources.webhooks.requests.ListWebhooksRequest; +import com.schematic.api.resources.webhooks.requests.UpdateWebhookRequestBody; +import com.schematic.api.resources.webhooks.types.CountWebhookEventsResponse; +import com.schematic.api.resources.webhooks.types.CountWebhooksResponse; +import com.schematic.api.resources.webhooks.types.CreateWebhookRequestBodyRequestTypesItem; +import com.schematic.api.resources.webhooks.types.CreateWebhookResponse; +import com.schematic.api.resources.webhooks.types.DeleteWebhookResponse; +import com.schematic.api.resources.webhooks.types.GetWebhookEventResponse; +import com.schematic.api.resources.webhooks.types.GetWebhookResponse; +import com.schematic.api.resources.webhooks.types.ListWebhookEventsResponse; +import com.schematic.api.resources.webhooks.types.ListWebhooksResponse; +import com.schematic.api.resources.webhooks.types.UpdateWebhookResponse; +import java.util.Arrays; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class WebhooksWireTest { + private MockWebServer server; + private BaseSchematic client; + private ObjectMapper objectMapper = ObjectMappers.JSON_MAPPER; + + @BeforeEach + public void setup() throws Exception { + server = new MockWebServer(); + server.start(); + client = BaseSchematic.builder() + .url(server.url("/").toString()) + .apiKey("test-api-key") + .build(); + } + + @AfterEach + public void teardown() throws Exception { + server.shutdown(); + } + + @Test + public void testListWebhookEvents() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"payload\":\"payload\",\"request_type\":\"request_type\",\"response_code\":1,\"sent_at\":\"2024-01-15T09:30:00Z\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"webhook\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"name\":\"name\",\"request_types\":[\"request_types\"],\"secret\":\"secret\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"webhook_id\":\"webhook_id\"}],\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"webhook_id\":\"webhook_id\"}}")); + ListWebhookEventsResponse response = client.webhooks() + .listWebhookEvents(ListWebhookEventsRequest.builder() + .q("q") + .webhookId("webhook_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"payload\": \"payload\",\n" + + " \"request_type\": \"request_type\",\n" + + " \"response_code\": 1,\n" + + " \"sent_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"webhook\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"request_types\": [\n" + + " \"request_types\"\n" + + " ],\n" + + " \"secret\": \"secret\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"webhook_id\": \"webhook_id\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"webhook_id\": \"webhook_id\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetWebhookEvent() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"id\":\"id\",\"payload\":\"payload\",\"request_type\":\"request_type\",\"response_code\":1,\"sent_at\":\"2024-01-15T09:30:00Z\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"webhook\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_trigger_configs\":[{\"credit_id\":\"credit_id\"}],\"entitlement_trigger_configs\":[{\"feature_id\":\"feature_id\"}],\"id\":\"id\",\"name\":\"name\",\"request_types\":[\"request_types\"],\"secret\":\"secret\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"webhook_id\":\"webhook_id\"},\"params\":{\"key\":\"value\"}}")); + GetWebhookEventResponse response = client.webhooks().getWebhookEvent("webhook_event_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"id\": \"id\",\n" + + " \"payload\": \"payload\",\n" + + " \"request_type\": \"request_type\",\n" + + " \"response_code\": 1,\n" + + " \"sent_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"webhook\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_trigger_configs\": [\n" + + " {\n" + + " \"credit_id\": \"credit_id\"\n" + + " }\n" + + " ],\n" + + " \"entitlement_trigger_configs\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"request_types\": [\n" + + " \"request_types\"\n" + + " ],\n" + + " \"secret\": \"secret\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"webhook_id\": \"webhook_id\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountWebhookEvents() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"count\":1},\"params\":{\"ids\":[\"ids\"],\"limit\":1,\"offset\":1,\"q\":\"q\",\"webhook_id\":\"webhook_id\"}}")); + CountWebhookEventsResponse response = client.webhooks() + .countWebhookEvents(CountWebhookEventsRequest.builder() + .q("q") + .webhookId("webhook_id") + .limit(1) + .offset(1) + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"ids\": [\n" + + " \"ids\"\n" + + " ],\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\",\n" + + " \"webhook_id\": \"webhook_id\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testListWebhooks() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":[{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_trigger_configs\":[{\"credit_id\":\"credit_id\"}],\"entitlement_trigger_configs\":[{\"feature_id\":\"feature_id\"}],\"id\":\"id\",\"name\":\"name\",\"request_types\":[\"request_types\"],\"secret\":\"secret\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"}],\"params\":{\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + ListWebhooksResponse response = client.webhooks() + .listWebhooks( + ListWebhooksRequest.builder().q("q").limit(1).offset(1).build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": [\n" + + " {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_trigger_configs\": [\n" + + " {\n" + + " \"credit_id\": \"credit_id\"\n" + + " }\n" + + " ],\n" + + " \"entitlement_trigger_configs\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"request_types\": [\n" + + " \"request_types\"\n" + + " ],\n" + + " \"secret\": \"secret\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " }\n" + + " ],\n" + + " \"params\": {\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCreateWebhook() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_trigger_configs\":[{\"credit_id\":\"credit_id\"}],\"entitlement_trigger_configs\":[{\"feature_id\":\"feature_id\"}],\"id\":\"id\",\"name\":\"name\",\"request_types\":[\"request_types\"],\"secret\":\"secret\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"params\":{\"key\":\"value\"}}")); + CreateWebhookResponse response = client.webhooks() + .createWebhook(CreateWebhookRequestBody.builder() + .name("name") + .requestTypes(Arrays.asList(CreateWebhookRequestBodyRequestTypesItem.COMPANY_UPDATED)) + .url("url") + .build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("POST", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + + "{\n" + + " \"name\": \"name\",\n" + + " \"request_types\": [\n" + + " \"company.updated\"\n" + + " ],\n" + + " \"url\": \"url\"\n" + + "}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_trigger_configs\": [\n" + + " {\n" + + " \"credit_id\": \"credit_id\"\n" + + " }\n" + + " ],\n" + + " \"entitlement_trigger_configs\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"request_types\": [\n" + + " \"request_types\"\n" + + " ],\n" + + " \"secret\": \"secret\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testGetWebhook() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_trigger_configs\":[{\"credit_id\":\"credit_id\"}],\"entitlement_trigger_configs\":[{\"feature_id\":\"feature_id\"}],\"id\":\"id\",\"name\":\"name\",\"request_types\":[\"request_types\"],\"secret\":\"secret\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"params\":{\"key\":\"value\"}}")); + GetWebhookResponse response = client.webhooks().getWebhook("webhook_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_trigger_configs\": [\n" + + " {\n" + + " \"credit_id\": \"credit_id\"\n" + + " }\n" + + " ],\n" + + " \"entitlement_trigger_configs\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"request_types\": [\n" + + " \"request_types\"\n" + + " ],\n" + + " \"secret\": \"secret\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testUpdateWebhook() throws Exception { + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody( + "{\"data\":{\"created_at\":\"2024-01-15T09:30:00Z\",\"credit_trigger_configs\":[{\"credit_id\":\"credit_id\"}],\"entitlement_trigger_configs\":[{\"feature_id\":\"feature_id\"}],\"id\":\"id\",\"name\":\"name\",\"request_types\":[\"request_types\"],\"secret\":\"secret\",\"status\":\"status\",\"updated_at\":\"2024-01-15T09:30:00Z\",\"url\":\"url\"},\"params\":{\"key\":\"value\"}}")); + UpdateWebhookResponse response = client.webhooks() + .updateWebhook("webhook_id", UpdateWebhookRequestBody.builder().build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("PUT", request.getMethod()); + // Validate request body + String actualRequestBody = request.getBody().readUtf8(); + String expectedRequestBody = "" + "{}"; + JsonNode actualJson = objectMapper.readTree(actualRequestBody); + JsonNode expectedJson = objectMapper.readTree(expectedRequestBody); + Assertions.assertEquals(expectedJson, actualJson, "Request body structure does not match expected"); + if (actualJson.has("type") || actualJson.has("_type") || actualJson.has("kind")) { + String discriminator = null; + if (actualJson.has("type")) discriminator = actualJson.get("type").asText(); + else if (actualJson.has("_type")) + discriminator = actualJson.get("_type").asText(); + else if (actualJson.has("kind")) + discriminator = actualJson.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualJson.isNull()) { + Assertions.assertTrue( + actualJson.isObject() || actualJson.isArray() || actualJson.isValueNode(), + "request should be a valid JSON value"); + } + + if (actualJson.isArray()) { + Assertions.assertTrue(actualJson.size() >= 0, "Array should have valid size"); + } + if (actualJson.isObject()) { + Assertions.assertTrue(actualJson.size() >= 0, "Object should have valid field count"); + } + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"created_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"credit_trigger_configs\": [\n" + + " {\n" + + " \"credit_id\": \"credit_id\"\n" + + " }\n" + + " ],\n" + + " \"entitlement_trigger_configs\": [\n" + + " {\n" + + " \"feature_id\": \"feature_id\"\n" + + " }\n" + + " ],\n" + + " \"id\": \"id\",\n" + + " \"name\": \"name\",\n" + + " \"request_types\": [\n" + + " \"request_types\"\n" + + " ],\n" + + " \"secret\": \"secret\",\n" + + " \"status\": \"status\",\n" + + " \"updated_at\": \"2024-01-15T09:30:00Z\",\n" + + " \"url\": \"url\"\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testDeleteWebhook() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"deleted\":true},\"params\":{\"key\":\"value\"}}")); + DeleteWebhookResponse response = client.webhooks().deleteWebhook("webhook_id"); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("DELETE", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"deleted\": true\n" + + " },\n" + + " \"params\": {\n" + + " \"key\": \"value\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } + + @Test + public void testCountWebhooks() throws Exception { + server.enqueue(new MockResponse() + .setResponseCode(200) + .setBody("{\"data\":{\"count\":1},\"params\":{\"limit\":1,\"offset\":1,\"q\":\"q\"}}")); + CountWebhooksResponse response = client.webhooks() + .countWebhooks( + CountWebhooksRequest.builder().q("q").limit(1).offset(1).build()); + RecordedRequest request = server.takeRequest(); + Assertions.assertNotNull(request); + Assertions.assertEquals("GET", request.getMethod()); + + // Validate response body + Assertions.assertNotNull(response, "Response should not be null"); + String actualResponseJson = objectMapper.writeValueAsString(response); + String expectedResponseBody = "" + + "{\n" + + " \"data\": {\n" + + " \"count\": 1\n" + + " },\n" + + " \"params\": {\n" + + " \"limit\": 1,\n" + + " \"offset\": 1,\n" + + " \"q\": \"q\"\n" + + " }\n" + + "}"; + JsonNode actualResponseNode = objectMapper.readTree(actualResponseJson); + JsonNode expectedResponseNode = objectMapper.readTree(expectedResponseBody); + Assertions.assertEquals( + expectedResponseNode, actualResponseNode, "Response body structure does not match expected"); + if (actualResponseNode.has("type") || actualResponseNode.has("_type") || actualResponseNode.has("kind")) { + String discriminator = null; + if (actualResponseNode.has("type")) + discriminator = actualResponseNode.get("type").asText(); + else if (actualResponseNode.has("_type")) + discriminator = actualResponseNode.get("_type").asText(); + else if (actualResponseNode.has("kind")) + discriminator = actualResponseNode.get("kind").asText(); + Assertions.assertNotNull(discriminator, "Union type should have a discriminator field"); + Assertions.assertFalse(discriminator.isEmpty(), "Union discriminator should not be empty"); + } + + if (!actualResponseNode.isNull()) { + Assertions.assertTrue( + actualResponseNode.isObject() || actualResponseNode.isArray() || actualResponseNode.isValueNode(), + "response should be a valid JSON value"); + } + + if (actualResponseNode.isArray()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Array should have valid size"); + } + if (actualResponseNode.isObject()) { + Assertions.assertTrue(actualResponseNode.size() >= 0, "Object should have valid field count"); + } + } +} diff --git a/src/test/java/com/schematic/api/core/QueryStringMapperTest.java b/src/test/java/com/schematic/api/core/QueryStringMapperTest.java new file mode 100644 index 0000000..1a94930 --- /dev/null +++ b/src/test/java/com/schematic/api/core/QueryStringMapperTest.java @@ -0,0 +1,339 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.schematic.api.core; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.HttpUrl; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public final class QueryStringMapperTest { + @Test + public void testObjectWithQuotedString_indexedArrays() { + Map map = new HashMap() { + { + put("hello", "\"world\""); + } + }; + + String expectedQueryString = "withquoted%5Bhello%5D=%22world%22"; + + String actualQueryString = queryString( + new HashMap() { + { + put("withquoted", map); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectWithQuotedString_arraysAsRepeats() { + Map map = new HashMap() { + { + put("hello", "\"world\""); + } + }; + + String expectedQueryString = "withquoted%5Bhello%5D=%22world%22"; + + String actualQueryString = queryString( + new HashMap() { + { + put("withquoted", map); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObject_indexedArrays() { + Map map = new HashMap() { + { + put("foo", "bar"); + put("baz", "qux"); + } + }; + + String expectedQueryString = "metadata%5Bfoo%5D=bar&metadata%5Bbaz%5D=qux"; + + String actualQueryString = queryString( + new HashMap() { + { + put("metadata", map); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObject_arraysAsRepeats() { + Map map = new HashMap() { + { + put("foo", "bar"); + put("baz", "qux"); + } + }; + + String expectedQueryString = "metadata%5Bfoo%5D=bar&metadata%5Bbaz%5D=qux"; + + String actualQueryString = queryString( + new HashMap() { + { + put("metadata", map); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testNestedObject_indexedArrays() { + Map> nestedMap = new HashMap>() { + { + put("mapkey1", new HashMap() { + { + put("mapkey1mapkey1", "mapkey1mapkey1value"); + put("mapkey1mapkey2", "mapkey1mapkey2value"); + } + }); + put("mapkey2", new HashMap() { + { + put("mapkey2mapkey1", "mapkey2mapkey1value"); + } + }); + } + }; + + String expectedQueryString = + "nested%5Bmapkey2%5D%5Bmapkey2mapkey1%5D=mapkey2mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey1" + + "%5D=mapkey1mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey2%5D=mapkey1mapkey2value"; + + String actualQueryString = queryString( + new HashMap() { + { + put("nested", nestedMap); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testNestedObject_arraysAsRepeats() { + Map> nestedMap = new HashMap>() { + { + put("mapkey1", new HashMap() { + { + put("mapkey1mapkey1", "mapkey1mapkey1value"); + put("mapkey1mapkey2", "mapkey1mapkey2value"); + } + }); + put("mapkey2", new HashMap() { + { + put("mapkey2mapkey1", "mapkey2mapkey1value"); + } + }); + } + }; + + String expectedQueryString = + "nested%5Bmapkey2%5D%5Bmapkey2mapkey1%5D=mapkey2mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey1" + + "%5D=mapkey1mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey2%5D=mapkey1mapkey2value"; + + String actualQueryString = queryString( + new HashMap() { + { + put("nested", nestedMap); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testDateTime_indexedArrays() { + OffsetDateTime dateTime = + OffsetDateTime.ofInstant(Instant.ofEpochSecond(1740412107L), ZoneId.of("America/New_York")); + + String expectedQueryString = "datetime=2025-02-24T10%3A48%3A27-05%3A00"; + + String actualQueryString = queryString( + new HashMap() { + { + put("datetime", dateTime); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testDateTime_arraysAsRepeats() { + OffsetDateTime dateTime = + OffsetDateTime.ofInstant(Instant.ofEpochSecond(1740412107L), ZoneId.of("America/New_York")); + + String expectedQueryString = "datetime=2025-02-24T10%3A48%3A27-05%3A00"; + + String actualQueryString = queryString( + new HashMap() { + { + put("datetime", dateTime); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectArray_indexedArrays() { + List> mapArray = new ArrayList>() { + { + add(new HashMap() { + { + put("key", "hello"); + put("value", "world"); + } + }); + add(new HashMap() { + { + put("key", "foo"); + put("value", "bar"); + } + }); + add(new HashMap<>()); + } + }; + + String expectedQueryString = "objects%5B0%5D%5Bvalue%5D=world&objects%5B0%5D%5Bkey%5D=hello&objects%5B1%5D" + + "%5Bvalue%5D=bar&objects%5B1%5D%5Bkey%5D=foo"; + + String actualQueryString = queryString( + new HashMap() { + { + put("objects", mapArray); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectArray_arraysAsRepeats() { + List> mapArray = new ArrayList>() { + { + add(new HashMap() { + { + put("key", "hello"); + put("value", "world"); + } + }); + add(new HashMap() { + { + put("key", "foo"); + put("value", "bar"); + } + }); + add(new HashMap<>()); + } + }; + + String expectedQueryString = + "objects%5Bvalue%5D=world&objects%5Bkey%5D=hello&objects%5Bvalue" + "%5D=bar&objects%5Bkey%5D=foo"; + + String actualQueryString = queryString( + new HashMap() { + { + put("objects", mapArray); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectWithArray_indexedArrays() { + Map objectWithArray = new HashMap() { + { + put("id", "abc123"); + put("contactIds", new ArrayList() { + { + add("id1"); + add("id2"); + add("id3"); + } + }); + } + }; + + String expectedQueryString = + "objectwitharray%5Bid%5D=abc123&objectwitharray%5BcontactIds%5D%5B0%5D=id1&objectwitharray" + + "%5BcontactIds%5D%5B1%5D=id2&objectwitharray%5BcontactIds%5D%5B2%5D=id3"; + + String actualQueryString = queryString( + new HashMap() { + { + put("objectwitharray", objectWithArray); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectWithArray_arraysAsRepeats() { + Map objectWithArray = new HashMap() { + { + put("id", "abc123"); + put("contactIds", new ArrayList() { + { + add("id1"); + add("id2"); + add("id3"); + } + }); + } + }; + + String expectedQueryString = "objectwitharray%5Bid%5D=abc123&objectwitharray%5BcontactIds" + + "%5D=id1&objectwitharray%5BcontactIds%5D=id2&objectwitharray%5BcontactIds%5D=id3"; + + String actualQueryString = queryString( + new HashMap() { + { + put("objectwitharray", objectWithArray); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + private static String queryString(Map params, boolean arraysAsRepeats) { + HttpUrl.Builder httpUrl = HttpUrl.parse("http://www.fakewebsite.com/").newBuilder(); + params.forEach((paramName, paramValue) -> + QueryStringMapper.addQueryParameter(httpUrl, paramName, paramValue, arraysAsRepeats)); + return httpUrl.build().encodedQuery(); + } +}