diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 7108e3f5..0bca5c39 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: 2.0.0 id: 5bbaa3a9-baa0-471b-ba6a-13fd88e8c119 management: - docChecksum: eb80d376bd87555fc332c244429360fd + docChecksum: d337c2891c3414a6e389fbab08fdef6f docVersion: 1.0.0 speakeasyVersion: 1.791.1 generationVersion: 2.926.2 - releaseVersion: 2.18.4 - configChecksum: 5fcc0225b237efa59dfd4fd2f869bd0e + releaseVersion: 2.18.5 + configChecksum: dab92c79f11878efd6e99699554f6a16 repoURL: https://github.com/gr4vy/gr4vy-java.git installationURL: https://github.com/gr4vy/gr4vy-java published: true persistentEdits: - generation_id: 1941317d-d61b-4703-831c-bd8376504e73 - pristine_commit_hash: bdc687d1421979a32ed1f529300e239852249ad0 - pristine_tree_hash: 20d96cb21630f300a22928926e73171b40c0cdcf + generation_id: 136c16eb-f946-4643-a3c9-ac154f379672 + pristine_commit_hash: a46071629cd72fe38d8837cf196e8c990f3138a6 + pristine_tree_hash: e94ff9b84d3db933b37f2df7314ad0b5e4af61ea features: java: additionalDependencies: 0.1.0 @@ -681,6 +681,10 @@ trackedFiles: id: 5d1129bbb687 last_write_checksum: sha1:ee2297e780a0d4cc8285c964fa193195d357ac10 pristine_git_object: 59b5a4c4b7d4b4da787d6841159cce291e0f6463 + docs/models/components/IncrementalAuthorizationStatus.md: + id: 0806d533899e + last_write_checksum: sha1:256aa4edf34686640548b3c0d6e52fb059546c73 + pristine_git_object: ee63b5761caf29e28d952bacc4105251a465e83a docs/models/components/InstrumentType.md: id: 35df1be925d2 last_write_checksum: sha1:e7db9590ce768778626b6eeed4e19913fdd1a62c @@ -1473,6 +1477,14 @@ trackedFiles: id: 40a8e069c73a last_write_checksum: sha1:88bb082afe8dd221f3c6e69e57fe9bef6ab58ead pristine_git_object: b57f6dff53780c04e40354cbf0ff2c9b0f4d00c4 + docs/models/components/TransactionAuthorizationIncrement.md: + id: f31fecf8ccba + last_write_checksum: sha1:dbbe8b4c920e54957e5dbf7fe8f86288ed753d72 + pristine_git_object: 9247393fdb33406feca1fcd4e7fa084e63ebd354 + docs/models/components/TransactionAuthorizationIncrementCreate.md: + id: b98664eafadc + last_write_checksum: sha1:0deebbf842c185b182036ecf6a3fb177a7409fcf + pristine_git_object: b7efc6ab4486870b3c2a18138323199574b67e30 docs/models/components/TransactionBuyer.md: id: 31b4c412193a last_write_checksum: sha1:9dd6d124261f8feeba70ef68dbca4907bc672e4b @@ -2225,6 +2237,14 @@ trackedFiles: id: df23cbe2e74c last_write_checksum: sha1:7bc6821ae8804e5cb0ea50309f2dbfba6b999240 pristine_git_object: d89db579cce99d0a41390f45e56e2599771c9ed0 + docs/models/operations/IncrementTransactionAuthorizationRequest.md: + id: bac37e8d5f21 + last_write_checksum: sha1:1e6e5555fb8bb1c3212993090643e0349e53fa35 + pristine_git_object: eb0c7c1aa03a61b74f62c6a62ca7fe9d0abaaadc + docs/models/operations/IncrementTransactionAuthorizationResponse.md: + id: 4f46afdf4122 + last_write_checksum: sha1:aa65de5bc7338737079f1e107b551dc954aa09a6 + pristine_git_object: 1de978730945ddbd6936e5056ced6dfba74e942c docs/models/operations/IssueGiftCardRequest.md: id: 69523bcdefd8 last_write_checksum: sha1:8e88a13a0b4aa2c1882f73e0ac29ef92054d12ac @@ -2807,8 +2827,8 @@ trackedFiles: pristine_git_object: ffde19082a6d584ec7b3244cd0045dfc6bf95e37 docs/sdks/transactions/README.md: id: 85592abe3c6b - last_write_checksum: sha1:3068513e02b61c90a97a111e30eee9464a4065cd - pristine_git_object: 6d3f1cb8e157f20af48844982f135eca1c5bb1bc + last_write_checksum: sha1:56bd39137e499a18c9db2173d8c817f64c2111b5 + pristine_git_object: 1a53e6a86f398ecb811c3428ee5e0630a772bebc docs/sdks/transactionsrefunds/README.md: id: c6a0400f5020 last_write_checksum: sha1:6d1efac19c5e2ea43ed416ef4cc1a3a883db9f0b @@ -2819,8 +2839,8 @@ trackedFiles: pristine_git_object: 15c4e4642f204ccb312d8814155b69e153b4e19b gradle.properties: id: 2afbb999f001 - last_write_checksum: sha1:1b98a272863f97a9cd5768fc6bd96ee1c0321407 - pristine_git_object: 57d533d139ba535b23d5cbe91e1b3646c3b6a974 + last_write_checksum: sha1:5abea2eca219b40b3f0554cae855235c694ab205 + pristine_git_object: c8ea59f8c54ad2415704e0398766c09c254302b2 gradle/wrapper/gradle-wrapper.jar: id: ec27dae6e852 last_write_checksum: sha1:f725fb1467084142d74fd7cd8eab691ab3442611 @@ -3027,8 +3047,8 @@ trackedFiles: pristine_git_object: a6bbf0fbc29524b348fd7cc9e00047ec46275401 src/main/java/com/gr4vy/sdk/AsyncTransactions.java: id: bf9640b12cf9 - last_write_checksum: sha1:4f4b0bc624f2d3589391b318846193d7385609d1 - pristine_git_object: 431d73315bcd6315ec3fa24bb2ccb319d368993c + last_write_checksum: sha1:0dda664221d31851060d674c8c96509db74f96ff + pristine_git_object: 521f6d4fa6fcda2f7e0f472a53a8e2932c8d68ca src/main/java/com/gr4vy/sdk/AsyncTransactionsRefunds.java: id: 25e32812684e last_write_checksum: sha1:dc1b6a43809efd702627e0fb1b8bb768bce94a87 @@ -3155,8 +3175,8 @@ trackedFiles: pristine_git_object: 502a7312d3dc82c102dbaf7ed5e952d0c793e26f src/main/java/com/gr4vy/sdk/SDKConfiguration.java: id: 73a7edeaca45 - last_write_checksum: sha1:30ce9ad8e288ed3ddce5f74a694803afd0694c30 - pristine_git_object: a68d33ed864fcb2df39dd16568aa5f5f1d47bc57 + last_write_checksum: sha1:b55ab663b429e02a276e13bd2406249b77d58d08 + pristine_git_object: 03ea0ed55f3fcd78a8056e35c19dd00006bda540 src/main/java/com/gr4vy/sdk/SecuritySource.java: id: 1b6add6b9b50 last_write_checksum: sha1:2f365cc823c6243188e83f4df618c9737fcee8bd @@ -3183,8 +3203,8 @@ trackedFiles: pristine_git_object: c2607f8627fe389c7931efa78da82d0d695d18ac src/main/java/com/gr4vy/sdk/Transactions.java: id: 3cf11cff6a7f - last_write_checksum: sha1:55cef1e5392e131296219a904dbb2479a8045075 - pristine_git_object: fa86c63af6bda0025e42f092763efc1b45d6b000 + last_write_checksum: sha1:a67b8925612a4cea0b8d4ca5e4728d08576494dd + pristine_git_object: fb956274d4a9e9dfbfb9859908fbac2845784c31 src/main/java/com/gr4vy/sdk/TransactionsRefunds.java: id: cf62b811d59f last_write_checksum: sha1:50c365428eec86db114bd293148371e32d558554 @@ -3821,6 +3841,10 @@ trackedFiles: id: c9d5d35d7f74 last_write_checksum: sha1:0f75f9462a25fcba22c8af920e7e9bb46274e481 pristine_git_object: 286a3dfae9406bfc0f775f9f5e4594fd0b0abe49 + src/main/java/com/gr4vy/sdk/models/components/IncrementalAuthorizationStatus.java: + id: 3c0bdd7e4610 + last_write_checksum: sha1:301025db3f7c00387cbdeddcf2000feb12328bf9 + pristine_git_object: 76b3892bb2ddf16a7b35eb87f1500de8c5f6fd6f src/main/java/com/gr4vy/sdk/models/components/InstrumentType.java: id: f17c5bdc0d7d last_write_checksum: sha1:ccdc010b740282bee65f6b04e135ad290eb0042e @@ -4617,6 +4641,14 @@ trackedFiles: id: 6046e429eb14 last_write_checksum: sha1:ed325ea0de8479a18191964326342440080d3d40 pristine_git_object: 8e5f4ed945fcb918649ebad09496b8834b963076 + src/main/java/com/gr4vy/sdk/models/components/TransactionAuthorizationIncrement.java: + id: a871803b5779 + last_write_checksum: sha1:089bbda9d723da90a7b854313df94022727f1d9d + pristine_git_object: 20171ff59ac1ecbb6945db28b11e69ca8739035d + src/main/java/com/gr4vy/sdk/models/components/TransactionAuthorizationIncrementCreate.java: + id: b52f856f9457 + last_write_checksum: sha1:251e68819ce313c80c8000226a45cb6392b20915 + pristine_git_object: f1c2975cfa2276f7c229e0a759305c2b23338222 src/main/java/com/gr4vy/sdk/models/components/TransactionBuyer.java: id: 6a241140748c last_write_checksum: sha1:1d1368233b0b4b3c88c0467d1ff5a77f1a3fc5aa @@ -5125,6 +5157,10 @@ trackedFiles: id: cfbfd7ca05cc last_write_checksum: sha1:c1522cf91cdfe69f524f2a1f19afa47f14e5f559 pristine_git_object: e60793ba22a9f2c358f5fa3bcfde32ed3c93cc3b + src/main/java/com/gr4vy/sdk/models/operations//async/IncrementTransactionAuthorizationRequestBuilder.java: + id: 40087ec51f94 + last_write_checksum: sha1:4b367105071d99e65bdb8cce4325071d1fedbed6 + pristine_git_object: 591fa059dcb9b79f3b33740fc6a44122164db343 src/main/java/com/gr4vy/sdk/models/operations//async/IssueGiftCardRequestBuilder.java: id: b23613242f4a last_write_checksum: sha1:1f9bdfba1d445eca4f9491894c30d8879e43e9a0 @@ -6133,6 +6169,18 @@ trackedFiles: id: d7e80b94a23d last_write_checksum: sha1:372e790fa978b6a9db593cadf7e48e9738616572 pristine_git_object: 561b619fa38fdf01ae4320767184bae2fa4f28d5 + src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationRequest.java: + id: c864bab98ae4 + last_write_checksum: sha1:753bf67e4dbf1e23b6976a42f310b9595b4bdfe3 + pristine_git_object: b1c92a27fdea9ef62e5d632406cf0f0f1abc5edf + src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationRequestBuilder.java: + id: a1191ada2eed + last_write_checksum: sha1:26db444acbc0a2471e3242230b9e586182d6d377 + pristine_git_object: 2495aff564a76a2dd7906fa1cc3c6c81a987495e + src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationResponse.java: + id: dfe47f28c37c + last_write_checksum: sha1:3249d6ab63aeee7f9ee6786c1aaea54e3943c5d3 + pristine_git_object: 0e3cf1897da70a4d0dc5cd40642ed286ed59fad8 src/main/java/com/gr4vy/sdk/models/operations/IssueGiftCardRequest.java: id: 8cab21d431bd last_write_checksum: sha1:99a7222d2a29edaeba918797eb2016ebe5f709aa @@ -7033,6 +7081,10 @@ trackedFiles: id: fd6664f1af7a last_write_checksum: sha1:251b54d67fc3c0abd22a56db2323d8049628d002 pristine_git_object: 3049894fdaef1d5a7e73df68af1d7eba82baf295 + src/main/java/com/gr4vy/sdk/models/operations/async/IncrementTransactionAuthorizationResponse.java: + id: 5d6f7626c260 + last_write_checksum: sha1:8eb5d624131b7f5d4669de009a52d51856e2be0f + pristine_git_object: 8c4d85637b4c9705baab8eb4f90f128bcc96b3a5 src/main/java/com/gr4vy/sdk/models/operations/async/IssueGiftCardResponse.java: id: a1082a1f3e74 last_write_checksum: sha1:f2d6c02b3bfb8cf8d52a864794761fa05c254dfc @@ -7505,6 +7557,10 @@ trackedFiles: id: b34eab46d29a last_write_checksum: sha1:d21dc9eed30cb6f140ca0755805c803eb0f72fc6 pristine_git_object: 79e114f8745e84dc46ba425c11a04ed416082b95 + src/main/java/com/gr4vy/sdk/operations/IncrementTransactionAuthorization.java: + id: 11a38b5b8b57 + last_write_checksum: sha1:e5f6f4a7d292f3cf32dcfac88e8619cd8160346b + pristine_git_object: f82708b01f9bea545ef5bdcb3c445ce62f5a798e src/main/java/com/gr4vy/sdk/operations/IssueGiftCard.java: id: 6191e5b29ddb last_write_checksum: sha1:f723bf260549f8aa5809d4c5655ef07c3791c77b @@ -12250,14 +12306,45 @@ examples: application/json: {"type": "error", "code": "bad_gateway", "status": 502, "message": "Request could not be processed"} "504": application/json: {"type": "error", "code": "gateway_timeout", "status": 504, "message": "Request could not be processed"} + increment_transaction_authorization: + speakeasy-default-increment-transaction-authorization: + parameters: + path: + transaction_id: "7099948d-7286-47e4-aad8-b68f7eb44591" + requestBody: + application/json: {"amount": 1299} + responses: + "200": + application/json: {"type": "transaction-authorization-increment", "status": "succeeded", "code": "service_error", "raw_response_code": "E104", "raw_response_description": "Internal error", "transaction": {"type": "transaction", "id": "7099948d-7286-47e4-aad8-b68f7eb44591", "reconciliation_id": "default", "merchant_account_id": "default", "currency": "EUR", "amount": 1299, "status": "authorization_declined", "authorized_amount": 1299, "captured_amount": 1299, "refunded_amount": 1299, "settled_amount": 1100, "settled": true, "intent": "authorize", "pending_review": false, "gift_card_redemptions": [{"type": "gift-card-redemption", "id": "31e65fb1-9c67-432e-9c06-83300b9d4059", "status": "skipped", "amount": 100, "refunded_amount": 50, "gift_card": {"type": "gift-card", "bin": "412345", "sub_bin": "554", "last4": "1234"}}], "created_at": "2013-07-16T19:23:00.000+00:00", "updated_at": "2013-07-16T19:23:00.000+00:00", "disputed": true, "payment_source": "moto", "merchant_initiated": true, "is_subsequent_payment": false, "intent_outcome": "pending", "multi_tender": true, "account_funding_transaction": true}} + "400": + application/json: {"type": "error", "code": "bad_request", "status": 400, "message": "Request failed validation"} + "401": + application/json: {"type": "error", "code": "unauthorized", "status": 401, "message": "No valid API authentication found"} + "403": + application/json: {"type": "error", "code": "forbidden", "status": 403, "message": "Request failed validation"} + "404": + application/json: {"type": "error", "code": "not_found", "status": 404, "message": "The resource could not be found"} + "405": + application/json: {"type": "error", "code": "method_not_allowed", "status": 405, "message": "Method Not Allowed"} + "409": + application/json: {"type": "error", "code": "duplicate_record", "status": 409, "message": "Request failed validation"} + "422": + application/json: {} + "425": + application/json: {"type": "error", "code": "too_early", "status": 425, "message": "Request failed validation"} + "429": + application/json: {"type": "error", "code": "too_many_requests", "status": 429, "message": "Request failed validation"} + "500": + application/json: {"type": "error", "code": "server_error", "status": 500, "message": "Request could not be processed"} + "502": + application/json: {"type": "error", "code": "bad_gateway", "status": 502, "message": "Request could not be processed"} + "504": + application/json: {"type": "error", "code": "gateway_timeout", "status": 504, "message": "Request could not be processed"} examplesVersion: 1.0.2 generatedTests: {} releaseNotes: | ## Java SDK Changes: - * `gr4vy.apiKeyPairs.list()`: `response.items[].lastUsedAt` **Added** - * `gr4vy.apiKeyPairs.create()`: `response.lastUsedAt` **Added** - * `gr4vy.apiKeyPairs.get()`: `response.lastUsedAt` **Added** - * `gr4vy.apiKeyPairs.update()`: `response.lastUsedAt` **Added** + * `gr4vy.transactions.incrementAuthorization()`: **Added** generatedFiles: - .gitattributes - USAGE.md diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index a82b82c1..96455645 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -30,7 +30,7 @@ generation: generateNewTests: false skipResponseBodyAssertions: false java: - version: 2.18.4 + version: 2.18.5 additionalDependencies: - testImplementation:org.junit.jupiter:junit-jupiter:5.10.0 - implementation:com.auth0:java-jwt:4.5.0 diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index aa93a3c4..be99d799 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -9,8 +9,8 @@ sources: - 1.0.0 openapi: sourceNamespace: openapi - sourceRevisionDigest: sha256:029d9232a22d61eeb54626473fd91cafd91a0245bac8e9da4b5eff0b4dd544c3 - sourceBlobDigest: sha256:bf6bbdd5f9e6a685242b0934013ea3e3cd456ec61d22a0ac1349c199c04394b5 + sourceRevisionDigest: sha256:cf77c0db1050c554c105ef90625703caee01dbb9f3f36e19cdd55eb048bb06c5 + sourceBlobDigest: sha256:e25c8fdf66c85680017f8f94ab247ba44603c78cb61f0dced9c9afd84b1e2375 tags: - latest - 1.0.0 @@ -25,10 +25,10 @@ targets: java: source: openapi sourceNamespace: openapi - sourceRevisionDigest: sha256:029d9232a22d61eeb54626473fd91cafd91a0245bac8e9da4b5eff0b4dd544c3 - sourceBlobDigest: sha256:bf6bbdd5f9e6a685242b0934013ea3e3cd456ec61d22a0ac1349c199c04394b5 + sourceRevisionDigest: sha256:cf77c0db1050c554c105ef90625703caee01dbb9f3f36e19cdd55eb048bb06c5 + sourceBlobDigest: sha256:e25c8fdf66c85680017f8f94ab247ba44603c78cb61f0dced9c9afd84b1e2375 codeSamplesNamespace: openapi-java-code-samples - codeSamplesRevisionDigest: sha256:4d46f0fcfa68da4453bf7ed6e1249564b638b7555b12accd1fcdbb9d0157b14f + codeSamplesRevisionDigest: sha256:d2c07781108d704bfbab72cdf51d538511e8289a23b4b40810f2c0ff54384387 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 7c40a8f8..9b0dd6bc 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The samples below show how a published SDK artifact is used: Gradle: ```groovy -implementation 'com.gr4vy:sdk:2.18.4' +implementation 'com.gr4vy:sdk:2.18.5' ``` Maven: @@ -67,7 +67,7 @@ Maven: com.gr4vy sdk - 2.18.4 + 2.18.5 ``` @@ -534,6 +534,7 @@ Async support is available for: * [void_](docs/sdks/transactions/README.md#void_) - Void transaction * [cancel](docs/sdks/transactions/README.md#cancel) - Cancel transaction * [sync](docs/sdks/transactions/README.md#sync) - Sync transaction +* [incrementAuthorization](docs/sdks/transactions/README.md#incrementauthorization) - Increment transaction authorization #### [Transactions.Actions](docs/sdks/actions/README.md) diff --git a/RELEASES.md b/RELEASES.md index 1dca36ec..dcc30667 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2068,4 +2068,14 @@ Based on: ### Generated - [java v2.18.4] . ### Releases -- [Maven Central v2.18.4] https://central.sonatype.com/artifact/com.gr4vy/sdk/2.18.4 - . \ No newline at end of file +- [Maven Central v2.18.4] https://central.sonatype.com/artifact/com.gr4vy/sdk/2.18.4 - . + +## 2026-08-03 18:22:17 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.791.1 (2.926.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [java v2.18.5] . +### Releases +- [Maven Central v2.18.5] https://central.sonatype.com/artifact/com.gr4vy/sdk/2.18.5 - . \ No newline at end of file diff --git a/docs/models/components/IncrementalAuthorizationStatus.md b/docs/models/components/IncrementalAuthorizationStatus.md new file mode 100644 index 00000000..ee63b576 --- /dev/null +++ b/docs/models/components/IncrementalAuthorizationStatus.md @@ -0,0 +1,20 @@ +# IncrementalAuthorizationStatus + +## Example Usage + +```java +import com.gr4vy.sdk.models.components.IncrementalAuthorizationStatus; + +IncrementalAuthorizationStatus value = IncrementalAuthorizationStatus.SUCCEEDED; + +// Open enum: use .of() to create instances from custom string values +IncrementalAuthorizationStatus custom = IncrementalAuthorizationStatus.of("custom_value"); +``` + + +## Values + +| Name | Value | +| ----------- | ----------- | +| `SUCCEEDED` | succeeded | +| `FAILED` | failed | \ No newline at end of file diff --git a/docs/models/components/TransactionAuthorizationIncrement.md b/docs/models/components/TransactionAuthorizationIncrement.md new file mode 100644 index 00000000..9247393f --- /dev/null +++ b/docs/models/components/TransactionAuthorizationIncrement.md @@ -0,0 +1,13 @@ +# TransactionAuthorizationIncrement + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `type` | *Optional\* | :heavy_minus_sign: | Always `transaction-authorization-increment`. | transaction-authorization-increment | +| `status` | [IncrementalAuthorizationStatus](../../models/components/IncrementalAuthorizationStatus.md) | :heavy_check_mark: | N/A | | +| `code` | *Optional\* | :heavy_check_mark: | The standardized error code set by Gr4vy. | service_error | +| `rawResponseCode` | *Optional\* | :heavy_check_mark: | This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services. | E104 | +| `rawResponseDescription` | *Optional\* | :heavy_check_mark: | This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services. | Internal error | +| `transaction` | [Transaction](../../models/components/Transaction.md) | :heavy_check_mark: | A full transaction resource. | | \ No newline at end of file diff --git a/docs/models/components/TransactionAuthorizationIncrementCreate.md b/docs/models/components/TransactionAuthorizationIncrementCreate.md new file mode 100644 index 00000000..b7efc6ab --- /dev/null +++ b/docs/models/components/TransactionAuthorizationIncrementCreate.md @@ -0,0 +1,8 @@ +# TransactionAuthorizationIncrementCreate + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `amount` | *long* | :heavy_check_mark: | The amount by which to increment the authorization, in the smallest currency unit of the transaction's currency. For example, `1299` cents to increment the authorization by `$12.99`. | 1299 | \ No newline at end of file diff --git a/docs/models/operations/IncrementTransactionAuthorizationRequest.md b/docs/models/operations/IncrementTransactionAuthorizationRequest.md new file mode 100644 index 00000000..eb0c7c1a --- /dev/null +++ b/docs/models/operations/IncrementTransactionAuthorizationRequest.md @@ -0,0 +1,11 @@ +# IncrementTransactionAuthorizationRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `transactionId` | *String* | :heavy_check_mark: | The unique identifier of the transaction. | 7099948d-7286-47e4-aad8-b68f7eb44591 | +| `merchantAccountId` | *JsonNullable\* | :heavy_minus_sign: | The ID of the merchant account to use for this request. | | +| `idempotencyKey` | *JsonNullable\* | :heavy_minus_sign: | A unique key that identifies this request. Providing this header will make this an idempotent request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. | request-12345 | +| `transactionAuthorizationIncrementCreate` | [TransactionAuthorizationIncrementCreate](../../models/components/TransactionAuthorizationIncrementCreate.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/docs/models/operations/IncrementTransactionAuthorizationResponse.md b/docs/models/operations/IncrementTransactionAuthorizationResponse.md new file mode 100644 index 00000000..1de97873 --- /dev/null +++ b/docs/models/operations/IncrementTransactionAuthorizationResponse.md @@ -0,0 +1,11 @@ +# IncrementTransactionAuthorizationResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | +| `contentType` | *String* | :heavy_check_mark: | HTTP response content type for this operation | +| `statusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `rawResponse` | [HttpResponse\](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpResponse.html) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `transactionAuthorizationIncrement` | [Optional\](../../models/components/TransactionAuthorizationIncrement.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file diff --git a/docs/sdks/transactions/README.md b/docs/sdks/transactions/README.md index 6d3f1cb8..1a53e6a8 100644 --- a/docs/sdks/transactions/README.md +++ b/docs/sdks/transactions/README.md @@ -12,6 +12,7 @@ * [void_](#void_) - Void transaction * [cancel](#cancel) - Cancel transaction * [sync](#sync) - Sync transaction +* [incrementAuthorization](#incrementauthorization) - Increment transaction authorization ## list @@ -627,6 +628,76 @@ public class Application { ### Errors +| Error Type | Status Code | Content Type | +| --------------------------------- | --------------------------------- | --------------------------------- | +| models/errors/Error400 | 400 | application/json | +| models/errors/Error401 | 401 | application/json | +| models/errors/Error403 | 403 | application/json | +| models/errors/Error404 | 404 | application/json | +| models/errors/Error405 | 405 | application/json | +| models/errors/Error409 | 409 | application/json | +| models/errors/HTTPValidationError | 422 | application/json | +| models/errors/Error425 | 425 | application/json | +| models/errors/Error429 | 429 | application/json | +| models/errors/Error500 | 500 | application/json | +| models/errors/Error502 | 502 | application/json | +| models/errors/Error504 | 504 | application/json | +| models/errors/APIException | 4XX, 5XX | \*/\* | + +## incrementAuthorization + +Increment the transaction authorization amount of a given transaction_id. + +### Example Usage + + +```java +package hello.world; + +import com.gr4vy.sdk.Gr4vy; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrementCreate; +import com.gr4vy.sdk.models.errors.*; +import com.gr4vy.sdk.models.operations.IncrementTransactionAuthorizationResponse; +import java.lang.Exception; + +public class Application { + + public static void main(String[] args) throws Exception { + + Gr4vy sdk = Gr4vy.builder() + .merchantAccountId("") + .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", "")) + .build(); + + IncrementTransactionAuthorizationResponse res = sdk.transactions().incrementAuthorization() + .transactionId("7099948d-7286-47e4-aad8-b68f7eb44591") + .transactionAuthorizationIncrementCreate(TransactionAuthorizationIncrementCreate.builder() + .amount(1299L) + .build()) + .call(); + + if (res.transactionAuthorizationIncrement().isPresent()) { + System.out.println(res.transactionAuthorizationIncrement().get()); + } + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `transactionId` | *String* | :heavy_check_mark: | The unique identifier of the transaction. | 7099948d-7286-47e4-aad8-b68f7eb44591 | +| `merchantAccountId` | *JsonNullable\* | :heavy_minus_sign: | The ID of the merchant account to use for this request. | | +| `idempotencyKey` | *JsonNullable\* | :heavy_minus_sign: | A unique key that identifies this request. Providing this header will make this an idempotent request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. | request-12345 | +| `transactionAuthorizationIncrementCreate` | [TransactionAuthorizationIncrementCreate](../../models/components/TransactionAuthorizationIncrementCreate.md) | :heavy_check_mark: | N/A | | + +### Response + +**[IncrementTransactionAuthorizationResponse](../../models/operations/IncrementTransactionAuthorizationResponse.md)** + +### Errors + | Error Type | Status Code | Content Type | | --------------------------------- | --------------------------------- | --------------------------------- | | models/errors/Error400 | 400 | application/json | diff --git a/gradle.properties b/gradle.properties index 57d533d1..c8ea59f8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ groupId=com.gr4vy artifactId=sdk -version=2.18.4 +version=2.18.5 org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g diff --git a/src/main/java/com/gr4vy/sdk/AsyncTransactions.java b/src/main/java/com/gr4vy/sdk/AsyncTransactions.java index 431d7331..521f6d4f 100644 --- a/src/main/java/com/gr4vy/sdk/AsyncTransactions.java +++ b/src/main/java/com/gr4vy/sdk/AsyncTransactions.java @@ -5,12 +5,14 @@ import static com.gr4vy.sdk.operations.Operations.AsyncRequestOperation; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrementCreate; import com.gr4vy.sdk.models.components.TransactionCreate; import com.gr4vy.sdk.models.components.TransactionUpdate; import com.gr4vy.sdk.models.operations.CancelTransactionRequest; import com.gr4vy.sdk.models.operations.CaptureTransactionRequest; import com.gr4vy.sdk.models.operations.CreateTransactionRequest; import com.gr4vy.sdk.models.operations.GetTransactionRequest; +import com.gr4vy.sdk.models.operations.IncrementTransactionAuthorizationRequest; import com.gr4vy.sdk.models.operations.ListTransactionsRequest; import com.gr4vy.sdk.models.operations.SyncTransactionRequest; import com.gr4vy.sdk.models.operations.UpdateTransactionRequest; @@ -23,6 +25,8 @@ import com.gr4vy.sdk.models.operations.async.CreateTransactionResponse; import com.gr4vy.sdk.models.operations.async.GetTransactionRequestBuilder; import com.gr4vy.sdk.models.operations.async.GetTransactionResponse; +import com.gr4vy.sdk.models.operations.async.IncrementTransactionAuthorizationRequestBuilder; +import com.gr4vy.sdk.models.operations.async.IncrementTransactionAuthorizationResponse; import com.gr4vy.sdk.models.operations.async.ListTransactionsRequestBuilder; import com.gr4vy.sdk.models.operations.async.ListTransactionsResponse; import com.gr4vy.sdk.models.operations.async.SyncTransactionRequestBuilder; @@ -35,6 +39,7 @@ import com.gr4vy.sdk.operations.CaptureTransaction; import com.gr4vy.sdk.operations.CreateTransaction; import com.gr4vy.sdk.operations.GetTransaction; +import com.gr4vy.sdk.operations.IncrementTransactionAuthorization; import com.gr4vy.sdk.operations.ListTransactions; import com.gr4vy.sdk.operations.SyncTransaction; import com.gr4vy.sdk.operations.UpdateTransaction; @@ -505,4 +510,59 @@ public CompletableFuture sync(String transactionId, Jso .thenCompose(operation::handleResponse); } + + /** + * Increment transaction authorization + * + *

Increment the transaction authorization amount of a given transaction_id. + * + * @return The async call builder + */ + public IncrementTransactionAuthorizationRequestBuilder incrementAuthorization() { + return new IncrementTransactionAuthorizationRequestBuilder(sdkConfiguration); + } + + /** + * Increment transaction authorization + * + *

Increment the transaction authorization amount of a given transaction_id. + * + * @param transactionId The unique identifier of the transaction. + * @param transactionAuthorizationIncrementCreate + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture incrementAuthorization(String transactionId, TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + return incrementAuthorization( + transactionId, JsonNullable.undefined(), JsonNullable.undefined(), + transactionAuthorizationIncrementCreate); + } + + /** + * Increment transaction authorization + * + *

Increment the transaction authorization amount of a given transaction_id. + * + * @param transactionId The unique identifier of the transaction. + * @param merchantAccountId + * @param idempotencyKey A unique key that identifies this request. Providing this header will make this an idempotent request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. + * @param transactionAuthorizationIncrementCreate + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture incrementAuthorization( + String transactionId, JsonNullable merchantAccountId, + JsonNullable idempotencyKey, TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + IncrementTransactionAuthorizationRequest request = + IncrementTransactionAuthorizationRequest + .builder() + .transactionId(transactionId) + .merchantAccountId(merchantAccountId) + .idempotencyKey(idempotencyKey) + .transactionAuthorizationIncrementCreate(transactionAuthorizationIncrementCreate) + .build(); + AsyncRequestOperation operation + = new IncrementTransactionAuthorization.Async(sdkConfiguration, _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + } diff --git a/src/main/java/com/gr4vy/sdk/SDKConfiguration.java b/src/main/java/com/gr4vy/sdk/SDKConfiguration.java index a68d33ed..03ea0ed5 100644 --- a/src/main/java/com/gr4vy/sdk/SDKConfiguration.java +++ b/src/main/java/com/gr4vy/sdk/SDKConfiguration.java @@ -22,7 +22,7 @@ public class SDKConfiguration { private static final String LANGUAGE = "java"; public static final String OPENAPI_DOC_VERSION = "1.0.0"; - public static final String SDK_VERSION = "2.18.4"; + public static final String SDK_VERSION = "2.18.5"; public static final String GEN_VERSION = "2.926.2"; private static final String BASE_PACKAGE = "com.gr4vy.sdk"; public static final String USER_AGENT = diff --git a/src/main/java/com/gr4vy/sdk/Transactions.java b/src/main/java/com/gr4vy/sdk/Transactions.java index fa86c63a..fb956274 100644 --- a/src/main/java/com/gr4vy/sdk/Transactions.java +++ b/src/main/java/com/gr4vy/sdk/Transactions.java @@ -5,6 +5,7 @@ import static com.gr4vy.sdk.operations.Operations.RequestOperation; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrementCreate; import com.gr4vy.sdk.models.components.TransactionCreate; import com.gr4vy.sdk.models.components.TransactionUpdate; import com.gr4vy.sdk.models.operations.CancelTransactionRequest; @@ -19,6 +20,9 @@ import com.gr4vy.sdk.models.operations.GetTransactionRequest; import com.gr4vy.sdk.models.operations.GetTransactionRequestBuilder; import com.gr4vy.sdk.models.operations.GetTransactionResponse; +import com.gr4vy.sdk.models.operations.IncrementTransactionAuthorizationRequest; +import com.gr4vy.sdk.models.operations.IncrementTransactionAuthorizationRequestBuilder; +import com.gr4vy.sdk.models.operations.IncrementTransactionAuthorizationResponse; import com.gr4vy.sdk.models.operations.ListTransactionsRequest; import com.gr4vy.sdk.models.operations.ListTransactionsRequestBuilder; import com.gr4vy.sdk.models.operations.ListTransactionsResponse; @@ -35,6 +39,7 @@ import com.gr4vy.sdk.operations.CaptureTransaction; import com.gr4vy.sdk.operations.CreateTransaction; import com.gr4vy.sdk.operations.GetTransaction; +import com.gr4vy.sdk.operations.IncrementTransactionAuthorization; import com.gr4vy.sdk.operations.ListTransactions; import com.gr4vy.sdk.operations.SyncTransaction; import com.gr4vy.sdk.operations.UpdateTransaction; @@ -497,4 +502,58 @@ public SyncTransactionResponse sync(String transactionId, JsonNullable m return operation.handleResponse(operation.doRequest(request)); } + /** + * Increment transaction authorization + * + *

Increment the transaction authorization amount of a given transaction_id. + * + * @return The call builder + */ + public IncrementTransactionAuthorizationRequestBuilder incrementAuthorization() { + return new IncrementTransactionAuthorizationRequestBuilder(sdkConfiguration); + } + + /** + * Increment transaction authorization + * + *

Increment the transaction authorization amount of a given transaction_id. + * + * @param transactionId The unique identifier of the transaction. + * @param transactionAuthorizationIncrementCreate + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public IncrementTransactionAuthorizationResponse incrementAuthorization(String transactionId, TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + return incrementAuthorization(transactionId, JsonNullable.undefined(), JsonNullable.undefined(), + transactionAuthorizationIncrementCreate); + } + + /** + * Increment transaction authorization + * + *

Increment the transaction authorization amount of a given transaction_id. + * + * @param transactionId The unique identifier of the transaction. + * @param merchantAccountId + * @param idempotencyKey A unique key that identifies this request. Providing this header will make this an idempotent request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. + * @param transactionAuthorizationIncrementCreate + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public IncrementTransactionAuthorizationResponse incrementAuthorization( + String transactionId, JsonNullable merchantAccountId, + JsonNullable idempotencyKey, TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + IncrementTransactionAuthorizationRequest request = + IncrementTransactionAuthorizationRequest + .builder() + .transactionId(transactionId) + .merchantAccountId(merchantAccountId) + .idempotencyKey(idempotencyKey) + .transactionAuthorizationIncrementCreate(transactionAuthorizationIncrementCreate) + .build(); + RequestOperation operation + = new IncrementTransactionAuthorization.Sync(sdkConfiguration, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + } diff --git a/src/main/java/com/gr4vy/sdk/models/components/IncrementalAuthorizationStatus.java b/src/main/java/com/gr4vy/sdk/models/components/IncrementalAuthorizationStatus.java new file mode 100644 index 00000000..76b3892b --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/components/IncrementalAuthorizationStatus.java @@ -0,0 +1,127 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.models.components; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.Override; +import java.lang.String; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Wrapper for an "open" enum that can handle unknown values from API responses + * without runtime errors. Instances are immutable singletons with reference equality. + * Use {@code asEnum()} for switch expressions. + */ +public class IncrementalAuthorizationStatus { + + public static final IncrementalAuthorizationStatus SUCCEEDED = new IncrementalAuthorizationStatus("succeeded"); + public static final IncrementalAuthorizationStatus FAILED = new IncrementalAuthorizationStatus("failed"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); + + private final String value; + + private IncrementalAuthorizationStatus(String value) { + this.value = value; + } + + /** + * Returns a IncrementalAuthorizationStatus with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as IncrementalAuthorizationStatus + */ + @JsonCreator + public static IncrementalAuthorizationStatus of(String value) { + synchronized (IncrementalAuthorizationStatus.class) { + return values.computeIfAbsent(value, v -> new IncrementalAuthorizationStatus(v)); + } + } + + @JsonValue + public String value() { + return value; + } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + IncrementalAuthorizationStatus other = (IncrementalAuthorizationStatus) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "IncrementalAuthorizationStatus [value=" + value + "]"; + } + + // return an array just like an enum + public static IncrementalAuthorizationStatus[] values() { + synchronized (IncrementalAuthorizationStatus.class) { + return values.values().toArray(new IncrementalAuthorizationStatus[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("succeeded", SUCCEEDED); + map.put("failed", FAILED); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("succeeded", IncrementalAuthorizationStatusEnum.SUCCEEDED); + map.put("failed", IncrementalAuthorizationStatusEnum.FAILED); + return map; + } + + + public enum IncrementalAuthorizationStatusEnum { + + SUCCEEDED("succeeded"), + FAILED("failed"),; + + private final String value; + + private IncrementalAuthorizationStatusEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } +} + diff --git a/src/main/java/com/gr4vy/sdk/models/components/TransactionAuthorizationIncrement.java b/src/main/java/com/gr4vy/sdk/models/components/TransactionAuthorizationIncrement.java new file mode 100644 index 00000000..20171ff5 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/components/TransactionAuthorizationIncrement.java @@ -0,0 +1,360 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.models.components; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.gr4vy.sdk.utils.LazySingletonValue; +import com.gr4vy.sdk.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +public class TransactionAuthorizationIncrement { + /** + * Always `transaction-authorization-increment`. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("type") + private Optional type; + + + @JsonProperty("status") + private IncrementalAuthorizationStatus status; + + /** + * The standardized error code set by Gr4vy. + */ + @JsonInclude(Include.ALWAYS) + @JsonProperty("code") + private Optional code; + + /** + * This is the response code received from the payment service. This can be set to any value and is not + * standardized across different payment services. + */ + @JsonInclude(Include.ALWAYS) + @JsonProperty("raw_response_code") + private Optional rawResponseCode; + + /** + * This is the response description received from the payment service. This can be set to any value and + * is not standardized across different payment services. + */ + @JsonInclude(Include.ALWAYS) + @JsonProperty("raw_response_description") + private Optional rawResponseDescription; + + /** + * A full transaction resource. + */ + @JsonProperty("transaction") + private Transaction transaction; + + @JsonCreator + public TransactionAuthorizationIncrement( + @JsonProperty("status") IncrementalAuthorizationStatus status, + @JsonProperty("code") Optional code, + @JsonProperty("raw_response_code") Optional rawResponseCode, + @JsonProperty("raw_response_description") Optional rawResponseDescription, + @JsonProperty("transaction") Transaction transaction) { + Utils.checkNotNull(status, "status"); + Utils.checkNotNull(code, "code"); + Utils.checkNotNull(rawResponseCode, "rawResponseCode"); + Utils.checkNotNull(rawResponseDescription, "rawResponseDescription"); + Utils.checkNotNull(transaction, "transaction"); + this.type = Builder._SINGLETON_VALUE_Type.value(); + this.status = status; + this.code = code; + this.rawResponseCode = rawResponseCode; + this.rawResponseDescription = rawResponseDescription; + this.transaction = transaction; + } + + public TransactionAuthorizationIncrement( + IncrementalAuthorizationStatus status, + Transaction transaction) { + this(status, Optional.empty(), Optional.empty(), + Optional.empty(), transaction); + } + + /** + * Always `transaction-authorization-increment`. + */ + @JsonIgnore + public Optional type() { + return type; + } + + @JsonIgnore + public IncrementalAuthorizationStatus status() { + return status; + } + + /** + * The standardized error code set by Gr4vy. + */ + @JsonIgnore + public Optional code() { + return code; + } + + /** + * This is the response code received from the payment service. This can be set to any value and is not + * standardized across different payment services. + */ + @JsonIgnore + public Optional rawResponseCode() { + return rawResponseCode; + } + + /** + * This is the response description received from the payment service. This can be set to any value and + * is not standardized across different payment services. + */ + @JsonIgnore + public Optional rawResponseDescription() { + return rawResponseDescription; + } + + /** + * A full transaction resource. + */ + @JsonIgnore + public Transaction transaction() { + return transaction; + } + + public static Builder builder() { + return new Builder(); + } + + + public TransactionAuthorizationIncrement withStatus(IncrementalAuthorizationStatus status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + /** + * The standardized error code set by Gr4vy. + */ + public TransactionAuthorizationIncrement withCode(String code) { + Utils.checkNotNull(code, "code"); + this.code = Optional.ofNullable(code); + return this; + } + + + /** + * The standardized error code set by Gr4vy. + */ + public TransactionAuthorizationIncrement withCode(Optional code) { + Utils.checkNotNull(code, "code"); + this.code = code; + return this; + } + + /** + * This is the response code received from the payment service. This can be set to any value and is not + * standardized across different payment services. + */ + public TransactionAuthorizationIncrement withRawResponseCode(String rawResponseCode) { + Utils.checkNotNull(rawResponseCode, "rawResponseCode"); + this.rawResponseCode = Optional.ofNullable(rawResponseCode); + return this; + } + + + /** + * This is the response code received from the payment service. This can be set to any value and is not + * standardized across different payment services. + */ + public TransactionAuthorizationIncrement withRawResponseCode(Optional rawResponseCode) { + Utils.checkNotNull(rawResponseCode, "rawResponseCode"); + this.rawResponseCode = rawResponseCode; + return this; + } + + /** + * This is the response description received from the payment service. This can be set to any value and + * is not standardized across different payment services. + */ + public TransactionAuthorizationIncrement withRawResponseDescription(String rawResponseDescription) { + Utils.checkNotNull(rawResponseDescription, "rawResponseDescription"); + this.rawResponseDescription = Optional.ofNullable(rawResponseDescription); + return this; + } + + + /** + * This is the response description received from the payment service. This can be set to any value and + * is not standardized across different payment services. + */ + public TransactionAuthorizationIncrement withRawResponseDescription(Optional rawResponseDescription) { + Utils.checkNotNull(rawResponseDescription, "rawResponseDescription"); + this.rawResponseDescription = rawResponseDescription; + return this; + } + + /** + * A full transaction resource. + */ + public TransactionAuthorizationIncrement withTransaction(Transaction transaction) { + Utils.checkNotNull(transaction, "transaction"); + this.transaction = transaction; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransactionAuthorizationIncrement other = (TransactionAuthorizationIncrement) o; + return + Utils.enhancedDeepEquals(this.type, other.type) && + Utils.enhancedDeepEquals(this.status, other.status) && + Utils.enhancedDeepEquals(this.code, other.code) && + Utils.enhancedDeepEquals(this.rawResponseCode, other.rawResponseCode) && + Utils.enhancedDeepEquals(this.rawResponseDescription, other.rawResponseDescription) && + Utils.enhancedDeepEquals(this.transaction, other.transaction); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + type, status, code, + rawResponseCode, rawResponseDescription, transaction); + } + + @Override + public String toString() { + return Utils.toString(TransactionAuthorizationIncrement.class, + "type", type, + "status", status, + "code", code, + "rawResponseCode", rawResponseCode, + "rawResponseDescription", rawResponseDescription, + "transaction", transaction); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private IncrementalAuthorizationStatus status; + + private Optional code = Optional.empty(); + + private Optional rawResponseCode = Optional.empty(); + + private Optional rawResponseDescription = Optional.empty(); + + private Transaction transaction; + + private Builder() { + // force use of static builder() method + } + + + public Builder status(IncrementalAuthorizationStatus status) { + Utils.checkNotNull(status, "status"); + this.status = status; + return this; + } + + + /** + * The standardized error code set by Gr4vy. + */ + public Builder code(String code) { + Utils.checkNotNull(code, "code"); + this.code = Optional.ofNullable(code); + return this; + } + + /** + * The standardized error code set by Gr4vy. + */ + public Builder code(Optional code) { + Utils.checkNotNull(code, "code"); + this.code = code; + return this; + } + + + /** + * This is the response code received from the payment service. This can be set to any value and is not + * standardized across different payment services. + */ + public Builder rawResponseCode(String rawResponseCode) { + Utils.checkNotNull(rawResponseCode, "rawResponseCode"); + this.rawResponseCode = Optional.ofNullable(rawResponseCode); + return this; + } + + /** + * This is the response code received from the payment service. This can be set to any value and is not + * standardized across different payment services. + */ + public Builder rawResponseCode(Optional rawResponseCode) { + Utils.checkNotNull(rawResponseCode, "rawResponseCode"); + this.rawResponseCode = rawResponseCode; + return this; + } + + + /** + * This is the response description received from the payment service. This can be set to any value and + * is not standardized across different payment services. + */ + public Builder rawResponseDescription(String rawResponseDescription) { + Utils.checkNotNull(rawResponseDescription, "rawResponseDescription"); + this.rawResponseDescription = Optional.ofNullable(rawResponseDescription); + return this; + } + + /** + * This is the response description received from the payment service. This can be set to any value and + * is not standardized across different payment services. + */ + public Builder rawResponseDescription(Optional rawResponseDescription) { + Utils.checkNotNull(rawResponseDescription, "rawResponseDescription"); + this.rawResponseDescription = rawResponseDescription; + return this; + } + + + /** + * A full transaction resource. + */ + public Builder transaction(Transaction transaction) { + Utils.checkNotNull(transaction, "transaction"); + this.transaction = transaction; + return this; + } + + public TransactionAuthorizationIncrement build() { + + return new TransactionAuthorizationIncrement( + status, code, rawResponseCode, + rawResponseDescription, transaction); + } + + + private static final LazySingletonValue> _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"transaction-authorization-increment\"", + new TypeReference>() {}); + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/components/TransactionAuthorizationIncrementCreate.java b/src/main/java/com/gr4vy/sdk/models/components/TransactionAuthorizationIncrementCreate.java new file mode 100644 index 00000000..f1c2975c --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/components/TransactionAuthorizationIncrementCreate.java @@ -0,0 +1,106 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.models.components; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.gr4vy.sdk.utils.Utils; +import java.lang.Long; +import java.lang.Override; +import java.lang.String; + + +public class TransactionAuthorizationIncrementCreate { + /** + * The amount by which to increment the authorization, in the smallest currency unit of the + * transaction's currency. For example, `1299` cents to increment the authorization by `$12.99`. + */ + @JsonProperty("amount") + private long amount; + + @JsonCreator + public TransactionAuthorizationIncrementCreate( + @JsonProperty("amount") long amount) { + Utils.checkNotNull(amount, "amount"); + this.amount = amount; + } + + /** + * The amount by which to increment the authorization, in the smallest currency unit of the + * transaction's currency. For example, `1299` cents to increment the authorization by `$12.99`. + */ + @JsonIgnore + public long amount() { + return amount; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The amount by which to increment the authorization, in the smallest currency unit of the + * transaction's currency. For example, `1299` cents to increment the authorization by `$12.99`. + */ + public TransactionAuthorizationIncrementCreate withAmount(long amount) { + Utils.checkNotNull(amount, "amount"); + this.amount = amount; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransactionAuthorizationIncrementCreate other = (TransactionAuthorizationIncrementCreate) o; + return + Utils.enhancedDeepEquals(this.amount, other.amount); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + amount); + } + + @Override + public String toString() { + return Utils.toString(TransactionAuthorizationIncrementCreate.class, + "amount", amount); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private Long amount; + + private Builder() { + // force use of static builder() method + } + + + /** + * The amount by which to increment the authorization, in the smallest currency unit of the + * transaction's currency. For example, `1299` cents to increment the authorization by `$12.99`. + */ + public Builder amount(long amount) { + Utils.checkNotNull(amount, "amount"); + this.amount = amount; + return this; + } + + public TransactionAuthorizationIncrementCreate build() { + + return new TransactionAuthorizationIncrementCreate( + amount); + } + + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationRequest.java b/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationRequest.java new file mode 100644 index 00000000..b1c92a27 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationRequest.java @@ -0,0 +1,269 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.models.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrementCreate; +import com.gr4vy.sdk.utils.SpeakeasyMetadata; +import com.gr4vy.sdk.utils.Utils; +import java.lang.Override; +import java.lang.String; +import org.openapitools.jackson.nullable.JsonNullable; + + +public class IncrementTransactionAuthorizationRequest { + /** + * The unique identifier of the transaction. + */ + @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=transaction_id") + private String transactionId; + + /** + * The ID of the merchant account to use for this request. + */ + @SpeakeasyMetadata("header:style=simple,explode=false,name=x-gr4vy-merchant-account-id") + private JsonNullable merchantAccountId; + + /** + * A unique key that identifies this request. Providing this header will make this an idempotent + * request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid + * collisions. + */ + @SpeakeasyMetadata("header:style=simple,explode=false,name=idempotency-key") + private JsonNullable idempotencyKey; + + + @SpeakeasyMetadata("request:mediaType=application/json") + private TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate; + + @JsonCreator + public IncrementTransactionAuthorizationRequest( + String transactionId, + JsonNullable merchantAccountId, + JsonNullable idempotencyKey, + TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + Utils.checkNotNull(transactionId, "transactionId"); + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + Utils.checkNotNull(transactionAuthorizationIncrementCreate, "transactionAuthorizationIncrementCreate"); + this.transactionId = transactionId; + this.merchantAccountId = merchantAccountId; + this.idempotencyKey = idempotencyKey; + this.transactionAuthorizationIncrementCreate = transactionAuthorizationIncrementCreate; + } + + public IncrementTransactionAuthorizationRequest( + String transactionId, + TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + this(transactionId, JsonNullable.undefined(), JsonNullable.undefined(), + transactionAuthorizationIncrementCreate); + } + + /** + * The unique identifier of the transaction. + */ + @JsonIgnore + public String transactionId() { + return transactionId; + } + + /** + * The ID of the merchant account to use for this request. + */ + @JsonIgnore + public JsonNullable merchantAccountId() { + return merchantAccountId; + } + + /** + * A unique key that identifies this request. Providing this header will make this an idempotent + * request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid + * collisions. + */ + @JsonIgnore + public JsonNullable idempotencyKey() { + return idempotencyKey; + } + + @JsonIgnore + public TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate() { + return transactionAuthorizationIncrementCreate; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The unique identifier of the transaction. + */ + public IncrementTransactionAuthorizationRequest withTransactionId(String transactionId) { + Utils.checkNotNull(transactionId, "transactionId"); + this.transactionId = transactionId; + return this; + } + + /** + * The ID of the merchant account to use for this request. + */ + public IncrementTransactionAuthorizationRequest withMerchantAccountId(String merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = JsonNullable.of(merchantAccountId); + return this; + } + + /** + * The ID of the merchant account to use for this request. + */ + public IncrementTransactionAuthorizationRequest withMerchantAccountId(JsonNullable merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = merchantAccountId; + return this; + } + + /** + * A unique key that identifies this request. Providing this header will make this an idempotent + * request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid + * collisions. + */ + public IncrementTransactionAuthorizationRequest withIdempotencyKey(String idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = JsonNullable.of(idempotencyKey); + return this; + } + + /** + * A unique key that identifies this request. Providing this header will make this an idempotent + * request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid + * collisions. + */ + public IncrementTransactionAuthorizationRequest withIdempotencyKey(JsonNullable idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = idempotencyKey; + return this; + } + + public IncrementTransactionAuthorizationRequest withTransactionAuthorizationIncrementCreate(TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + Utils.checkNotNull(transactionAuthorizationIncrementCreate, "transactionAuthorizationIncrementCreate"); + this.transactionAuthorizationIncrementCreate = transactionAuthorizationIncrementCreate; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IncrementTransactionAuthorizationRequest other = (IncrementTransactionAuthorizationRequest) o; + return + Utils.enhancedDeepEquals(this.transactionId, other.transactionId) && + Utils.enhancedDeepEquals(this.merchantAccountId, other.merchantAccountId) && + Utils.enhancedDeepEquals(this.idempotencyKey, other.idempotencyKey) && + Utils.enhancedDeepEquals(this.transactionAuthorizationIncrementCreate, other.transactionAuthorizationIncrementCreate); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + transactionId, merchantAccountId, idempotencyKey, + transactionAuthorizationIncrementCreate); + } + + @Override + public String toString() { + return Utils.toString(IncrementTransactionAuthorizationRequest.class, + "transactionId", transactionId, + "merchantAccountId", merchantAccountId, + "idempotencyKey", idempotencyKey, + "transactionAuthorizationIncrementCreate", transactionAuthorizationIncrementCreate); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String transactionId; + + private JsonNullable merchantAccountId = JsonNullable.undefined(); + + private JsonNullable idempotencyKey = JsonNullable.undefined(); + + private TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate; + + private Builder() { + // force use of static builder() method + } + + + /** + * The unique identifier of the transaction. + */ + public Builder transactionId(String transactionId) { + Utils.checkNotNull(transactionId, "transactionId"); + this.transactionId = transactionId; + return this; + } + + + /** + * The ID of the merchant account to use for this request. + */ + public Builder merchantAccountId(String merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = JsonNullable.of(merchantAccountId); + return this; + } + + /** + * The ID of the merchant account to use for this request. + */ + public Builder merchantAccountId(JsonNullable merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = merchantAccountId; + return this; + } + + + /** + * A unique key that identifies this request. Providing this header will make this an idempotent + * request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid + * collisions. + */ + public Builder idempotencyKey(String idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = JsonNullable.of(idempotencyKey); + return this; + } + + /** + * A unique key that identifies this request. Providing this header will make this an idempotent + * request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid + * collisions. + */ + public Builder idempotencyKey(JsonNullable idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = idempotencyKey; + return this; + } + + + public Builder transactionAuthorizationIncrementCreate(TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + Utils.checkNotNull(transactionAuthorizationIncrementCreate, "transactionAuthorizationIncrementCreate"); + this.transactionAuthorizationIncrementCreate = transactionAuthorizationIncrementCreate; + return this; + } + + public IncrementTransactionAuthorizationRequest build() { + + return new IncrementTransactionAuthorizationRequest( + transactionId, merchantAccountId, idempotencyKey, + transactionAuthorizationIncrementCreate); + } + + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationRequestBuilder.java b/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationRequestBuilder.java new file mode 100644 index 00000000..2495aff5 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationRequestBuilder.java @@ -0,0 +1,84 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.models.operations; + +import static com.gr4vy.sdk.operations.Operations.RequestOperation; + +import com.gr4vy.sdk.SDKConfiguration; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrementCreate; +import com.gr4vy.sdk.operations.IncrementTransactionAuthorization; +import com.gr4vy.sdk.utils.Headers; +import com.gr4vy.sdk.utils.Utils; +import java.lang.String; +import org.openapitools.jackson.nullable.JsonNullable; + +public class IncrementTransactionAuthorizationRequestBuilder { + + private String transactionId; + private JsonNullable merchantAccountId = JsonNullable.undefined(); + private JsonNullable idempotencyKey = JsonNullable.undefined(); + private TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate; + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public IncrementTransactionAuthorizationRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public IncrementTransactionAuthorizationRequestBuilder transactionId(String transactionId) { + Utils.checkNotNull(transactionId, "transactionId"); + this.transactionId = transactionId; + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder merchantAccountId(String merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = JsonNullable.of(merchantAccountId); + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder merchantAccountId(JsonNullable merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = merchantAccountId; + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder idempotencyKey(String idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = JsonNullable.of(idempotencyKey); + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder idempotencyKey(JsonNullable idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = idempotencyKey; + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder transactionAuthorizationIncrementCreate(TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + Utils.checkNotNull(transactionAuthorizationIncrementCreate, "transactionAuthorizationIncrementCreate"); + this.transactionAuthorizationIncrementCreate = transactionAuthorizationIncrementCreate; + return this; + } + + + private IncrementTransactionAuthorizationRequest buildRequest() { + + IncrementTransactionAuthorizationRequest request = new IncrementTransactionAuthorizationRequest(transactionId, + merchantAccountId, + idempotencyKey, + transactionAuthorizationIncrementCreate); + + return request; + } + + public IncrementTransactionAuthorizationResponse call() { + + RequestOperation operation + = new IncrementTransactionAuthorization.Sync(sdkConfiguration, _headers); + IncrementTransactionAuthorizationRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationResponse.java b/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationResponse.java new file mode 100644 index 00000000..0e3cf189 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/IncrementTransactionAuthorizationResponse.java @@ -0,0 +1,253 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.models.operations; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrement; +import com.gr4vy.sdk.utils.Response; +import com.gr4vy.sdk.utils.Utils; +import java.io.InputStream; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +public class IncrementTransactionAuthorizationResponse implements Response { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful Response + */ + private Optional transactionAuthorizationIncrement; + + @JsonCreator + public IncrementTransactionAuthorizationResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional transactionAuthorizationIncrement) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.transactionAuthorizationIncrement = transactionAuthorizationIncrement; + } + + public IncrementTransactionAuthorizationResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful Response + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional transactionAuthorizationIncrement() { + return (Optional) transactionAuthorizationIncrement; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public IncrementTransactionAuthorizationResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public IncrementTransactionAuthorizationResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public IncrementTransactionAuthorizationResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful Response + */ + public IncrementTransactionAuthorizationResponse withTransactionAuthorizationIncrement(TransactionAuthorizationIncrement transactionAuthorizationIncrement) { + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.transactionAuthorizationIncrement = Optional.ofNullable(transactionAuthorizationIncrement); + return this; + } + + + /** + * Successful Response + */ + public IncrementTransactionAuthorizationResponse withTransactionAuthorizationIncrement(Optional transactionAuthorizationIncrement) { + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.transactionAuthorizationIncrement = transactionAuthorizationIncrement; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IncrementTransactionAuthorizationResponse other = (IncrementTransactionAuthorizationResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.transactionAuthorizationIncrement, other.transactionAuthorizationIncrement); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + transactionAuthorizationIncrement); + } + + @Override + public String toString() { + return Utils.toString(IncrementTransactionAuthorizationResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "transactionAuthorizationIncrement", transactionAuthorizationIncrement); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional transactionAuthorizationIncrement = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful Response + */ + public Builder transactionAuthorizationIncrement(TransactionAuthorizationIncrement transactionAuthorizationIncrement) { + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.transactionAuthorizationIncrement = Optional.ofNullable(transactionAuthorizationIncrement); + return this; + } + + /** + * Successful Response + */ + public Builder transactionAuthorizationIncrement(Optional transactionAuthorizationIncrement) { + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.transactionAuthorizationIncrement = transactionAuthorizationIncrement; + return this; + } + + public IncrementTransactionAuthorizationResponse build() { + + return new IncrementTransactionAuthorizationResponse( + contentType, statusCode, rawResponse, + transactionAuthorizationIncrement); + } + + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/async/IncrementTransactionAuthorizationRequestBuilder.java b/src/main/java/com/gr4vy/sdk/models/operations/async/IncrementTransactionAuthorizationRequestBuilder.java new file mode 100644 index 00000000..591fa059 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/async/IncrementTransactionAuthorizationRequestBuilder.java @@ -0,0 +1,87 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.models.operations.async; + +import static com.gr4vy.sdk.operations.Operations.AsyncRequestOperation; + +import com.gr4vy.sdk.SDKConfiguration; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrementCreate; +import com.gr4vy.sdk.models.operations.IncrementTransactionAuthorizationRequest; +import com.gr4vy.sdk.operations.IncrementTransactionAuthorization; +import com.gr4vy.sdk.utils.Headers; +import com.gr4vy.sdk.utils.Utils; +import java.lang.String; +import java.util.concurrent.CompletableFuture; +import org.openapitools.jackson.nullable.JsonNullable; + +public class IncrementTransactionAuthorizationRequestBuilder { + + private String transactionId; + private JsonNullable merchantAccountId = JsonNullable.undefined(); + private JsonNullable idempotencyKey = JsonNullable.undefined(); + private TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate; + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public IncrementTransactionAuthorizationRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public IncrementTransactionAuthorizationRequestBuilder transactionId(String transactionId) { + Utils.checkNotNull(transactionId, "transactionId"); + this.transactionId = transactionId; + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder merchantAccountId(String merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = JsonNullable.of(merchantAccountId); + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder merchantAccountId(JsonNullable merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = merchantAccountId; + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder idempotencyKey(String idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = JsonNullable.of(idempotencyKey); + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder idempotencyKey(JsonNullable idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = idempotencyKey; + return this; + } + + public IncrementTransactionAuthorizationRequestBuilder transactionAuthorizationIncrementCreate(TransactionAuthorizationIncrementCreate transactionAuthorizationIncrementCreate) { + Utils.checkNotNull(transactionAuthorizationIncrementCreate, "transactionAuthorizationIncrementCreate"); + this.transactionAuthorizationIncrementCreate = transactionAuthorizationIncrementCreate; + return this; + } + + + private IncrementTransactionAuthorizationRequest buildRequest() { + + IncrementTransactionAuthorizationRequest request = new IncrementTransactionAuthorizationRequest(transactionId, + merchantAccountId, + idempotencyKey, + transactionAuthorizationIncrementCreate); + + return request; + } + + public CompletableFuture call() { + + AsyncRequestOperation operation + = new IncrementTransactionAuthorization.Async(sdkConfiguration, _headers); + IncrementTransactionAuthorizationRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/async/IncrementTransactionAuthorizationResponse.java b/src/main/java/com/gr4vy/sdk/models/operations/async/IncrementTransactionAuthorizationResponse.java new file mode 100644 index 00000000..8c4d8563 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/async/IncrementTransactionAuthorizationResponse.java @@ -0,0 +1,253 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.models.operations.async; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrement; +import com.gr4vy.sdk.utils.AsyncResponse; +import com.gr4vy.sdk.utils.Blob; +import com.gr4vy.sdk.utils.Utils; +import java.lang.Integer; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.net.http.HttpResponse; +import java.util.Optional; + + +public class IncrementTransactionAuthorizationResponse implements AsyncResponse { + /** + * HTTP response content type for this operation + */ + private String contentType; + + /** + * HTTP response status code for this operation + */ + private int statusCode; + + /** + * Raw HTTP response; suitable for custom response parsing + */ + private HttpResponse rawResponse; + + /** + * Successful Response + */ + private Optional transactionAuthorizationIncrement; + + @JsonCreator + public IncrementTransactionAuthorizationResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional transactionAuthorizationIncrement) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.transactionAuthorizationIncrement = transactionAuthorizationIncrement; + } + + public IncrementTransactionAuthorizationResponse( + String contentType, + int statusCode, + HttpResponse rawResponse) { + this(contentType, statusCode, rawResponse, + Optional.empty()); + } + + /** + * HTTP response content type for this operation + */ + @JsonIgnore + public String contentType() { + return contentType; + } + + /** + * HTTP response status code for this operation + */ + @JsonIgnore + public int statusCode() { + return statusCode; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + @JsonIgnore + public HttpResponse rawResponse() { + return rawResponse; + } + + /** + * Successful Response + */ + @SuppressWarnings("unchecked") + @JsonIgnore + public Optional transactionAuthorizationIncrement() { + return (Optional) transactionAuthorizationIncrement; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public IncrementTransactionAuthorizationResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public IncrementTransactionAuthorizationResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public IncrementTransactionAuthorizationResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful Response + */ + public IncrementTransactionAuthorizationResponse withTransactionAuthorizationIncrement(TransactionAuthorizationIncrement transactionAuthorizationIncrement) { + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.transactionAuthorizationIncrement = Optional.ofNullable(transactionAuthorizationIncrement); + return this; + } + + + /** + * Successful Response + */ + public IncrementTransactionAuthorizationResponse withTransactionAuthorizationIncrement(Optional transactionAuthorizationIncrement) { + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.transactionAuthorizationIncrement = transactionAuthorizationIncrement; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IncrementTransactionAuthorizationResponse other = (IncrementTransactionAuthorizationResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.transactionAuthorizationIncrement, other.transactionAuthorizationIncrement); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + transactionAuthorizationIncrement); + } + + @Override + public String toString() { + return Utils.toString(IncrementTransactionAuthorizationResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "transactionAuthorizationIncrement", transactionAuthorizationIncrement); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional transactionAuthorizationIncrement = Optional.empty(); + + private Builder() { + // force use of static builder() method + } + + + /** + * HTTP response content type for this operation + */ + public Builder contentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + + /** + * HTTP response status code for this operation + */ + public Builder statusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public Builder rawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + + /** + * Successful Response + */ + public Builder transactionAuthorizationIncrement(TransactionAuthorizationIncrement transactionAuthorizationIncrement) { + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.transactionAuthorizationIncrement = Optional.ofNullable(transactionAuthorizationIncrement); + return this; + } + + /** + * Successful Response + */ + public Builder transactionAuthorizationIncrement(Optional transactionAuthorizationIncrement) { + Utils.checkNotNull(transactionAuthorizationIncrement, "transactionAuthorizationIncrement"); + this.transactionAuthorizationIncrement = transactionAuthorizationIncrement; + return this; + } + + public IncrementTransactionAuthorizationResponse build() { + + return new IncrementTransactionAuthorizationResponse( + contentType, statusCode, rawResponse, + transactionAuthorizationIncrement); + } + + } +} diff --git a/src/main/java/com/gr4vy/sdk/operations/IncrementTransactionAuthorization.java b/src/main/java/com/gr4vy/sdk/operations/IncrementTransactionAuthorization.java new file mode 100644 index 00000000..f82708b0 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/operations/IncrementTransactionAuthorization.java @@ -0,0 +1,460 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk.operations; + +import static com.gr4vy.sdk.operations.Operations.RequestOperation; +import static com.gr4vy.sdk.utils.Exceptions.unchecked; +import static com.gr4vy.sdk.operations.Operations.AsyncRequestOperation; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.gr4vy.sdk.SDKConfiguration; +import com.gr4vy.sdk.SecuritySource; +import com.gr4vy.sdk.models.components.TransactionAuthorizationIncrement; +import com.gr4vy.sdk.models.errors.APIException; +import com.gr4vy.sdk.models.errors.Error400; +import com.gr4vy.sdk.models.errors.Error401; +import com.gr4vy.sdk.models.errors.Error403; +import com.gr4vy.sdk.models.errors.Error404; +import com.gr4vy.sdk.models.errors.Error405; +import com.gr4vy.sdk.models.errors.Error409; +import com.gr4vy.sdk.models.errors.Error425; +import com.gr4vy.sdk.models.errors.Error429; +import com.gr4vy.sdk.models.errors.Error500; +import com.gr4vy.sdk.models.errors.Error502; +import com.gr4vy.sdk.models.errors.Error504; +import com.gr4vy.sdk.models.errors.HTTPValidationError; +import com.gr4vy.sdk.models.operations.IncrementTransactionAuthorizationRequest; +import com.gr4vy.sdk.models.operations.IncrementTransactionAuthorizationResponse; +import com.gr4vy.sdk.utils.Blob; +import com.gr4vy.sdk.utils.Globals; +import com.gr4vy.sdk.utils.HTTPClient; +import com.gr4vy.sdk.utils.HTTPRequest; +import com.gr4vy.sdk.utils.Headers; +import com.gr4vy.sdk.utils.Hook.AfterErrorContextImpl; +import com.gr4vy.sdk.utils.Hook.AfterSuccessContextImpl; +import com.gr4vy.sdk.utils.Hook.BeforeRequestContextImpl; +import com.gr4vy.sdk.utils.SerializedBody; +import com.gr4vy.sdk.utils.Utils.JsonShape; +import com.gr4vy.sdk.utils.Utils; +import java.io.InputStream; +import java.lang.Exception; +import java.lang.IllegalArgumentException; +import java.lang.Object; +import java.lang.String; +import java.lang.Throwable; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; + + +public class IncrementTransactionAuthorization { + + static abstract class Base { + final SDKConfiguration sdkConfiguration; + final String baseUrl; + final SecuritySource securitySource; + final HTTPClient client; + final Headers _headers; + final Globals operationGlobals; + + public Base(SDKConfiguration sdkConfiguration, Headers _headers) { + this.sdkConfiguration = sdkConfiguration; + this._headers =_headers; + this.baseUrl = Utils.templateUrl( + this.sdkConfiguration.serverUrl(), this.sdkConfiguration.getServerVariableDefaults()); + this.securitySource = this.sdkConfiguration.securitySource(); + this.client = this.sdkConfiguration.client(); + this.operationGlobals = new Globals(); + this.sdkConfiguration.globals.getParam("header", "x-gr4vy-merchant-account-id") + .ifPresent(param -> operationGlobals.putParam("header", "x-gr4vy-merchant-account-id", param)); + } + + Optional securitySource() { + return Optional.ofNullable(this.securitySource); + } + + BeforeRequestContextImpl createBeforeRequestContext() { + return new BeforeRequestContextImpl( + this.sdkConfiguration, + this.baseUrl, + "increment_transaction_authorization", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "increment_transaction_authorization", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "increment_transaction_authorization", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, Class klass, TypeReference typeReference) throws Exception { + String url = Utils.generateURL( + klass, + this.baseUrl, + "/transactions/{transaction_id}/authorization/increment", + request, this.operationGlobals); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + typeReference); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "transactionAuthorizationIncrementCreate", + "json", + false); + if (serializedRequestBody == null) { + throw new IllegalArgumentException("Request body is required"); + } + req.setBody(Optional.ofNullable(serializedRequestBody)); + req.addHeader("Accept", "application/json") + .addHeader("user-agent", SDKConfiguration.USER_AGENT); + _headers.forEach((k, list) -> list.forEach(v -> req.addHeader(k, v))); + req.addHeaders(Utils.getHeadersFromMetadata(request, this.operationGlobals)); + Utils.configureSecurity(req, this.sdkConfiguration.securitySource().getSecurity()); + + return req.build(); + } + } + + public static class Sync extends Base + implements RequestOperation { + public Sync(SDKConfiguration sdkConfiguration, Headers _headers) { + super(sdkConfiguration, _headers); + } + + private HttpRequest onBuildRequest(IncrementTransactionAuthorizationRequest request) throws Exception { + HttpRequest req = buildRequest(request, IncrementTransactionAuthorizationRequest.class, new TypeReference() {}); + return sdkConfiguration.hooks().beforeRequest(createBeforeRequestContext(), req); + } + + private HttpResponse onError(HttpResponse response, Exception error) throws Exception { + return sdkConfiguration.hooks().afterError( + createAfterErrorContext(), + Optional.ofNullable(response), + Optional.ofNullable(error)); + } + + private HttpResponse onSuccess(HttpResponse response) throws Exception { + return sdkConfiguration.hooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public HttpResponse doRequest(IncrementTransactionAuthorizationRequest request) { + HttpRequest r = unchecked(() -> onBuildRequest(request)).get(); + HttpResponse httpRes; + try { + httpRes = client.send(r); + if (Utils.statusCodeMatches(httpRes.statusCode(), "4XX", "5XX")) { + httpRes = onError(httpRes, null); + } else { + httpRes = onSuccess(httpRes); + } + } catch (Exception e) { + httpRes = unchecked(() -> onError(null, e)).get(); + } + + return httpRes; + } + + + @Override + public IncrementTransactionAuthorizationResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + IncrementTransactionAuthorizationResponse.Builder resBuilder = + IncrementTransactionAuthorizationResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + IncrementTransactionAuthorizationResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return res.withTransactionAuthorizationIncrement(Utils.unmarshal(response, new TypeReference() {})); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "400")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error400.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "401")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error401.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "403")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error403.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "404")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error404.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "405")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error405.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "409")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error409.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "422")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw HTTPValidationError.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "425")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error425.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "429")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error429.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "500")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error500.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "502")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error502.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "504")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + throw Error504.from(response); + } else { + throw APIException.from("Unexpected content-type received: " + contentType, response); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + throw APIException.from("API error occurred", response); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + throw APIException.from("API error occurred", response); + } + throw APIException.from("Unexpected status code received: " + response.statusCode(), response); + } + } + public static class Async extends Base + implements AsyncRequestOperation { + + public Async(SDKConfiguration sdkConfiguration, Headers _headers) { + super(sdkConfiguration, _headers); + } + + private CompletableFuture onBuildRequest(IncrementTransactionAuthorizationRequest request) throws Exception { + HttpRequest req = buildRequest(request, IncrementTransactionAuthorizationRequest.class, new TypeReference() {}); + return this.sdkConfiguration.asyncHooks().beforeRequest(createBeforeRequestContext(), req); + } + + private CompletableFuture> onError(HttpResponse response, Throwable error) { + return this.sdkConfiguration.asyncHooks().afterError(createAfterErrorContext(), response, error); + } + + private CompletableFuture> onSuccess(HttpResponse response) { + return this.sdkConfiguration.asyncHooks().afterSuccess(createAfterSuccessContext(), response); + } + + @Override + public CompletableFuture> doRequest(IncrementTransactionAuthorizationRequest request) { + return unchecked(() -> onBuildRequest(request)).get().thenCompose(client::sendAsync) + .handle((resp, err) -> { + if (err != null) { + return onError(null, err); + } + if (Utils.statusCodeMatches(resp.statusCode(), "4XX", "5XX")) { + return onError(resp, null); + } + return CompletableFuture.completedFuture(resp); + }) + .thenCompose(Function.identity()) + .thenCompose(this::onSuccess); + } + + @Override + public CompletableFuture handleResponse( + HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + com.gr4vy.sdk.models.operations.async.IncrementTransactionAuthorizationResponse.Builder resBuilder = + com.gr4vy.sdk.models.operations.async.IncrementTransactionAuthorizationResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.gr4vy.sdk.models.operations.async.IncrementTransactionAuthorizationResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "200")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withTransactionAuthorizationIncrement); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "400")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error400.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "401")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error401.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "403")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error403.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "404")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error404.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "405")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error405.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "409")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error409.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "422")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return HTTPValidationError.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "425")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error425.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "429")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error429.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "500")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error500.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "502")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error502.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "504")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Error504.fromAsync(response) + .thenCompose(CompletableFuture::failedFuture); + } else { + return Utils.createAsyncApiError(response, "Unexpected content-type received: " + contentType); + } + } + if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { + // no content + return Utils.createAsyncApiError(response, "API error occurred"); + } + return Utils.createAsyncApiError(response, "Unexpected status code received: " + response.statusCode()); + } + } +}