diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 1dfeb007..77ccbc1d 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: d601cdca28bb62f7d6e18e40c0b60a30 + docChecksum: dc000089a43747ca3b3d40380012db42 docVersion: 1.0.0 speakeasyVersion: 1.790.3 generationVersion: 2.918.4 - releaseVersion: 2.16.116 - configChecksum: 27c53acc4ab3dcc92a41a2eb56edad84 + releaseVersion: 2.16.117 + configChecksum: 06655f6449575fe253daba8c42ae66cd repoURL: https://github.com/gr4vy/gr4vy-java.git installationURL: https://github.com/gr4vy/gr4vy-java published: true persistentEdits: - generation_id: 7e99d61a-30e1-46a1-b261-8005f9fc8a8b - pristine_commit_hash: e023b1cf176232161d829daa45ef6d012546076f - pristine_tree_hash: 1b0145580172b58177e617d738732898cf932d25 + generation_id: 8b0cb8de-1007-4fa4-9891-bc4e550d3809 + pristine_commit_hash: 083223dbb0848221954692ef86c38741ff6d3ec4 + pristine_tree_hash: 29afd5824aaf8fda1c1f4117cc2ff86f852326bf features: java: additionalDependencies: 0.1.0 @@ -568,6 +568,10 @@ trackedFiles: id: 040d9b308398 last_write_checksum: sha1:04c217efdbd47c7fe3e110c7da0d19ccc74ca107 pristine_git_object: f22b3db40cca48b74c4d9598566460696a05d4e4 + docs/models/components/GiftCardActivationCreate.md: + id: e2ba13478fe3 + last_write_checksum: sha1:78bbf8f02cb0c8c983ceb80093a96eb7f601aba0 + pristine_git_object: a751465e2c306d612a5d1535e434b2ef512df48c docs/models/components/GiftCardBalanceRequest.md: id: c80a3eda305b last_write_checksum: sha1:c1f2778ba0fe150682aef69158b5019168d9459c @@ -1672,6 +1676,14 @@ trackedFiles: id: ec17bf2e8999 last_write_checksum: sha1:6c70e2aaec45c9b55035ed72704f250dc4edb74b pristine_git_object: aba85e9d58199b57db3cf62f509c4f33162e0a90 + docs/models/operations/ActivateGiftCardRequest.md: + id: 5de84093c9ee + last_write_checksum: sha1:bf0c4b7b2a932b8d29b035170cb90cc2e43b5943 + pristine_git_object: 832d86085fea9460572a966150f800e1b695cb2f + docs/models/operations/ActivateGiftCardResponse.md: + id: 6ce3b6123ccb + last_write_checksum: sha1:843e3b72932582e21866e6256f4a99327ff3f628 + pristine_git_object: 857555e494eeb4277829a57a0573cb7654acf52a docs/models/operations/AddBuyerRequest.md: id: 62d343203c23 last_write_checksum: sha1:7a23686582f327ee4e360dd9155e7cc85975952c @@ -2624,6 +2636,10 @@ trackedFiles: id: e229cf99e666 last_write_checksum: sha1:a82dfb47a1fe7d50dc6fbaee535c5c6b341ded6d pristine_git_object: 0f7d8fa069ab3f04c91515239d103b286359bd3d + docs/sdks/activations/README.md: + id: 5e6a3a8cf62a + last_write_checksum: sha1:df91083b2d54f4ee6fa90a29ef725a0d524e5e14 + pristine_git_object: 5ce22e0995ff775c947eb81da5617e8c5bb033dc docs/sdks/all/README.md: id: 936653be5c4b last_write_checksum: sha1:97da642dcdafbb8a8d55336d987af073423d3643 @@ -2778,8 +2794,8 @@ trackedFiles: pristine_git_object: 15c4e4642f204ccb312d8814155b69e153b4e19b gradle.properties: id: 2afbb999f001 - last_write_checksum: sha1:c98d7a695601572e3e4a74fd331b87a73ddca0a5 - pristine_git_object: 5791823b373ad66310c27e21d262a2dfe7880df2 + last_write_checksum: sha1:2203841b199a233ef51e11a05418c8239ef443fa + pristine_git_object: c4e8e8013966a2db88d290cda8ecb4296b4c2bb3 gradle/wrapper/gradle-wrapper.jar: id: ec27dae6e852 last_write_checksum: sha1:f725fb1467084142d74fd7cd8eab691ab3442611 @@ -2812,6 +2828,10 @@ trackedFiles: id: 7c86edba82fe last_write_checksum: sha1:b0773e26a4e2976a99ec46652571f52b1af78159 pristine_git_object: b86ebe2ce835d4b6e1021be71f78aa98cd5d477c + src/main/java/com/gr4vy/sdk/Activations.java: + id: f4748ece3b9b + last_write_checksum: sha1:c1c04ebcdca70f4f390b2c8dd41b0af0e05be949 + pristine_git_object: f8d575aeff5a4ae95238fca7c103c8ba03ecfac7 src/main/java/com/gr4vy/sdk/All.java: id: 234c521b6941 last_write_checksum: sha1:6ef88cfdfc33ec118f9cc83b188b69433ee939a3 @@ -2828,6 +2848,10 @@ trackedFiles: id: 6e9840fe25fe last_write_checksum: sha1:afbf98587fe590a1c4ab597503642a0ef891a3c9 pristine_git_object: 028d3696be7da66d76b84b1353133139769e2079 + src/main/java/com/gr4vy/sdk/AsyncActivations.java: + id: bd7db28e97c1 + last_write_checksum: sha1:cd8fc9c05774d534000831e440ace6114220658d + pristine_git_object: fd9f0372db00a7f0eb65b30dac091a3f799af396 src/main/java/com/gr4vy/sdk/AsyncAll.java: id: 42ccc0a41ddf last_write_checksum: sha1:7252df5451de1c20d538f2de57ef003c53c06b65 @@ -2890,8 +2914,8 @@ trackedFiles: pristine_git_object: 25aeba074772d8e62b54c2310f1e0fd2742d7df5 src/main/java/com/gr4vy/sdk/AsyncGiftCards.java: id: 371241ed7eda - last_write_checksum: sha1:d0285c69d4788d605d4d669e47ef735f7bf46fed - pristine_git_object: 16225a13ae2c2ea408f68b32ff53576e805717a8 + last_write_checksum: sha1:7aabd54717410fda2fe6f2759d65cd783fbf95db + pristine_git_object: ddacc9ff0e8b133c93a63555040881c2e7120707 src/main/java/com/gr4vy/sdk/AsyncGr4vy.java: id: ae8f21a7dc22 last_write_checksum: sha1:c5cf3f07d6e68afd6eb7d8b94085a5aedd0800e3 @@ -3034,8 +3058,8 @@ trackedFiles: pristine_git_object: d9350eeb34a6ccbcf7df500e3325782730b8d5a7 src/main/java/com/gr4vy/sdk/GiftCards.java: id: b4a553867645 - last_write_checksum: sha1:91e4ed6ad25c27d3b6ee7bfca334f359538c78f2 - pristine_git_object: c0bd05b6b21e7d3f560e27b0c3dead257db4f9ac + last_write_checksum: sha1:7e003bbc8f895ee3bf2ac7714e8aa8017f7f0c79 + pristine_git_object: 19ac3468d38478f4a13d55c7edbfc322604b6e3f src/main/java/com/gr4vy/sdk/Gr4vy.java: id: 239506d7cead last_write_checksum: sha1:2f29ae77ade0777daf380025889f80ead0fd379f @@ -3098,8 +3122,8 @@ trackedFiles: pristine_git_object: 502a7312d3dc82c102dbaf7ed5e952d0c793e26f src/main/java/com/gr4vy/sdk/SDKConfiguration.java: id: 73a7edeaca45 - last_write_checksum: sha1:d5d136e9129835dddbd64d8b8c98a901e910efc6 - pristine_git_object: f8cef02007838cdbf237e5adef295fce5de540c8 + last_write_checksum: sha1:3d16c1cf992391dde428fd59661703def5d152fc + pristine_git_object: b5cb428abc6f746389d187cfbd7d7133965cdc18 src/main/java/com/gr4vy/sdk/SecuritySource.java: id: 1b6add6b9b50 last_write_checksum: sha1:2f365cc823c6243188e83f4df618c9737fcee8bd @@ -3652,6 +3676,10 @@ trackedFiles: id: 25f48a4f3105 last_write_checksum: sha1:d3d091a3e84d03f8ab36abd85a1f329fcf2665dd pristine_git_object: 86e82602250ebfd5bb1c46be7009785dd34dd693 + src/main/java/com/gr4vy/sdk/models/components/GiftCardActivationCreate.java: + id: 888f251c8e49 + last_write_checksum: sha1:5a418c7d1d2ec2556a69929b565956227bf8f3b8 + pristine_git_object: 14f65504b8de0f60f7de854697bb76d498d6aed6 src/main/java/com/gr4vy/sdk/models/components/GiftCardBalanceRequest.java: id: 170501161b7d last_write_checksum: sha1:f742fd871283b30d36fd4a9c99d95508f71a4efd @@ -4780,6 +4808,10 @@ trackedFiles: id: abb4e6ec572d last_write_checksum: sha1:da61714aa809fd6dc83fbd51f3d897d8b2b82d08 pristine_git_object: e92369fc80631b9270d11bd68f73c5a9ba09d760 + src/main/java/com/gr4vy/sdk/models/operations//async/ActivateGiftCardRequestBuilder.java: + id: 14e5b5f14015 + last_write_checksum: sha1:123dd7529f3dd43d815f5f5e516dd7de0ee648c6 + pristine_git_object: 6b9e2d7538d2f0e0b040981731c5692058eed2d1 src/main/java/com/gr4vy/sdk/models/operations//async/AddBuyerRequestBuilder.java: id: de48d2b0098d last_write_checksum: sha1:ff03232b38a3522825d093f71b26523cde58e001 @@ -5244,6 +5276,18 @@ trackedFiles: id: d3925d992927 last_write_checksum: sha1:35027f724df5b5de0be7dd43e374548339236850 pristine_git_object: 231c23327faf1e69847e5df435a5b818431d00ff + src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardRequest.java: + id: d5a7fa9ba9a8 + last_write_checksum: sha1:39d3080734974664ebc24cc56724399dd2948384 + pristine_git_object: 345d53f87d2c5c4cf3b9c815acff0c0625ecafca + src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardRequestBuilder.java: + id: 773dd0c9e941 + last_write_checksum: sha1:557b478d5733304f6642e24604066b4b2d72f005 + pristine_git_object: be702ce68f48a7d5293083dc9102bdd042e5238b + src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardResponse.java: + id: 7089d4b32548 + last_write_checksum: sha1:8bacd1cd773487a755d29ca03b04c7a1389e468d + pristine_git_object: 1f2a840217f41a4d741381adf1eea436b0b39b2f src/main/java/com/gr4vy/sdk/models/operations/AddBuyerRequest.java: id: 2146acc3be1b last_write_checksum: sha1:1a8ad024061bca41a1c94e73f669da3095e4c28a @@ -6656,6 +6700,10 @@ trackedFiles: id: 5ea58d3e0baa last_write_checksum: sha1:07036ac66bfa8574ce5686f6d210315e363575db pristine_git_object: bcb221947062a4b08d6c037eb893b3d5e24a5632 + src/main/java/com/gr4vy/sdk/models/operations/async/ActivateGiftCardResponse.java: + id: 41bd08ddbf0b + last_write_checksum: sha1:dd357024ee7fdb4c67535508d88951958fb0f50d + pristine_git_object: 34429be8a5fcaeb22fd0a70d8d2174c4322d01a2 src/main/java/com/gr4vy/sdk/models/operations/async/AddBuyerResponse.java: id: 48afa8147434 last_write_checksum: sha1:80f83e179409c1af464ed7ae3d9f2e35511284f7 @@ -7120,6 +7168,10 @@ trackedFiles: id: 2b8a0d3e2aee last_write_checksum: sha1:8d5308d647325522c1faf76500daa4e50b9c00e5 pristine_git_object: 7c9b9291863e63386f53d03ef0940a83dbda8b53 + src/main/java/com/gr4vy/sdk/operations/ActivateGiftCard.java: + id: 27858570f002 + last_write_checksum: sha1:b64abb8851c9489ee62fc51f6d4a847053f9c64e + pristine_git_object: 9a621b2ed02dd6d24a7fe94028daf73b1ace2d63 src/main/java/com/gr4vy/sdk/operations/AddBuyer.java: id: dba293f0bbdd last_write_checksum: sha1:9d46d1c350698b9e237fe929a0450fa791da7c82 @@ -12067,35 +12119,42 @@ 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"} + activate_gift_card: + speakeasy-default-activate-gift-card: + requestBody: + application/json: {"number": "4123455541234561234"} + responses: + "201": + application/json: {"type": "gift-card", "id": "356d56e5-fe16-42ae-97ee-8d55d846ae2e", "merchant_account_id": "default", "gift_card_service": {"type": "gift-card-service", "id": "35b60feec-a7c7-4844-b503-f39b09192d81", "gift_card_service_definition_id": "valuelink-gift-card", "display_name": "Qwikcilver USA"}, "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", "usage_count": 100, "cit_usage_count": 50} + "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.buyers.list()`: `response.items[].reconciliationId` **Added** - * `gr4vy.buyers.create()`: `response.reconciliationId` **Added** - * `gr4vy.buyers.get()`: `response.reconciliationId` **Added** - * `gr4vy.buyers.update()`: `response.reconciliationId` **Added** - * `gr4vy.paymentMethods.list()`: `response.items[].buyer.reconciliationId` **Added** - * `gr4vy.paymentMethods.create()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.paymentMethods.get()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.paymentMethods.update()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.giftCards.get()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.giftCards.create()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.giftCards.list()`: `response.items[].buyer.reconciliationId` **Added** - * `gr4vy.transactions.list()`: `response.items[].buyer.reconciliationId` **Added** - * `gr4vy.transactions.create()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.transactions.get()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.transactions.update()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.transactions.capture()`: `response.union(Transaction).buyer.reconciliationId` **Added** - * `gr4vy.transactions.void()`: `response.union(Transaction).buyer.reconciliationId` **Added** - * `gr4vy.transactions.cancel()`: `response.transaction.buyer.reconciliationId` **Added** - * `gr4vy.transactions.sync()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.payouts.list()`: `response.items[].buyer.reconciliationId` **Added** - * `gr4vy.payouts.create()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.payouts.get()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.paymentLinks.create()`: `response.buyer.reconciliationId` **Added** - * `gr4vy.paymentLinks.list()`: `response.items[].buyer.reconciliationId` **Added** - * `gr4vy.paymentLinks.get()`: `response.buyer.reconciliationId` **Added** + * `gr4vy.giftCards.activations.create()`: **Added** generatedFiles: - .gitattributes - USAGE.md diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index da72d9c1..ff2efc51 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -30,7 +30,7 @@ generation: generateNewTests: false skipResponseBodyAssertions: false java: - version: 2.16.116 + version: 2.16.117 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 cdc4b08c..507fd991 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -9,8 +9,8 @@ sources: - 1.0.0 openapi: sourceNamespace: openapi - sourceRevisionDigest: sha256:31393f02113c5e92ea647f66d99014eef6982274aa7b1c11d075a465adcb675b - sourceBlobDigest: sha256:fdbb3d6eaeda0a2af66bb2bfd1a068a92472c4eb3f390eab352c4bd8927e7615 + sourceRevisionDigest: sha256:e1ade4025d5ca249627a418d5cdb630a45e65ba5a50082dfaea088c79923bf89 + sourceBlobDigest: sha256:86dd6182eaf8bae046076e3f83f7da0e9556994bd38314fdaae2b7cdceea4d73 tags: - latest - 1.0.0 @@ -25,10 +25,10 @@ targets: java: source: openapi sourceNamespace: openapi - sourceRevisionDigest: sha256:31393f02113c5e92ea647f66d99014eef6982274aa7b1c11d075a465adcb675b - sourceBlobDigest: sha256:fdbb3d6eaeda0a2af66bb2bfd1a068a92472c4eb3f390eab352c4bd8927e7615 + sourceRevisionDigest: sha256:e1ade4025d5ca249627a418d5cdb630a45e65ba5a50082dfaea088c79923bf89 + sourceBlobDigest: sha256:86dd6182eaf8bae046076e3f83f7da0e9556994bd38314fdaae2b7cdceea4d73 codeSamplesNamespace: openapi-java-code-samples - codeSamplesRevisionDigest: sha256:444e71574e626d70170ffb6f40cdf81561428268dc0e367cdb6801bbf711a205 + codeSamplesRevisionDigest: sha256:61983efb0ff06168b55a295d8ae3e43caa720be1988b58eea727b7362533325a workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 3213ed31..b87c4c0f 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.16.116' +implementation 'com.gr4vy:sdk:2.16.117' ``` Maven: @@ -67,7 +67,7 @@ Maven: com.gr4vy sdk - 2.16.116 + 2.16.117 ``` @@ -411,6 +411,10 @@ Async support is available for: * [create](docs/sdks/giftcards/README.md#create) - Create gift card * [list](docs/sdks/giftcards/README.md#list) - List gift cards +#### [GiftCards.Activations](docs/sdks/activations/README.md) + +* [create](docs/sdks/activations/README.md#create) - Activate a gift card + #### [GiftCards.Balances](docs/sdks/balances/README.md) * [list](docs/sdks/balances/README.md#list) - List gift card balances diff --git a/RELEASES.md b/RELEASES.md index a7918bf9..fabc6248 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1998,4 +1998,14 @@ Based on: ### Generated - [java v2.16.116] . ### Releases -- [Maven Central v2.16.116] https://central.sonatype.com/artifact/com.gr4vy/sdk/2.16.116 - . \ No newline at end of file +- [Maven Central v2.16.116] https://central.sonatype.com/artifact/com.gr4vy/sdk/2.16.116 - . + +## 2026-07-23 14:22:26 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.790.3 (2.918.4) https://github.com/speakeasy-api/speakeasy +### Generated +- [java v2.16.117] . +### Releases +- [Maven Central v2.16.117] https://central.sonatype.com/artifact/com.gr4vy/sdk/2.16.117 - . \ No newline at end of file diff --git a/docs/models/components/GiftCardActivationCreate.md b/docs/models/components/GiftCardActivationCreate.md new file mode 100644 index 00000000..a751465e --- /dev/null +++ b/docs/models/components/GiftCardActivationCreate.md @@ -0,0 +1,14 @@ +# GiftCardActivationCreate + +The details used to activate a physical gift card. + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| `number` | *String* | :heavy_check_mark: | The 16-19 digit number for the gift card. | 4123455541234561234 | +| `pin` | *JsonNullable\* | :heavy_minus_sign: | The PIN for this gift card. | 1234 | +| `amount` | *JsonNullable\* | :heavy_minus_sign: | The amount to load onto the gift card, in the smallest denomination for the currency. Required if `currency` is provided. | 5000 | +| `currency` | *JsonNullable\* | :heavy_minus_sign: | The ISO-4217 currency code for the `amount`. Required if `amount` is provided. | USD | +| `externalIdentifier` | *JsonNullable\* | :heavy_minus_sign: | An optional external identifier for this activation. | order-12345 | \ No newline at end of file diff --git a/docs/models/operations/ActivateGiftCardRequest.md b/docs/models/operations/ActivateGiftCardRequest.md new file mode 100644 index 00000000..832d8608 --- /dev/null +++ b/docs/models/operations/ActivateGiftCardRequest.md @@ -0,0 +1,10 @@ +# ActivateGiftCardRequest + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `idempotencyKey` | *JsonNullable\* | :heavy_minus_sign: | A unique key that identifies this request. If supported by the gift card service, the value will be forwarded to make the activation idempotent. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. | +| `merchantAccountId` | *JsonNullable\* | :heavy_minus_sign: | The ID of the merchant account to use for this request. | +| `giftCardActivationCreate` | [GiftCardActivationCreate](../../models/components/GiftCardActivationCreate.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/ActivateGiftCardResponse.md b/docs/models/operations/ActivateGiftCardResponse.md new file mode 100644 index 00000000..857555e4 --- /dev/null +++ b/docs/models/operations/ActivateGiftCardResponse.md @@ -0,0 +1,11 @@ +# ActivateGiftCardResponse + + +## 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 | +| `giftCard` | [Optional\](../../models/components/GiftCard.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file diff --git a/docs/sdks/activations/README.md b/docs/sdks/activations/README.md new file mode 100644 index 00000000..5ce22e09 --- /dev/null +++ b/docs/sdks/activations/README.md @@ -0,0 +1,75 @@ +# GiftCards.Activations + +## Overview + +### Available Operations + +* [create](#create) - Activate a gift card + +## create + +Activate a physical gift card through the primary gift card service. + +### Example Usage + + +```java +package hello.world; + +import com.gr4vy.sdk.Gr4vy; +import com.gr4vy.sdk.models.components.GiftCardActivationCreate; +import com.gr4vy.sdk.models.errors.*; +import com.gr4vy.sdk.models.operations.ActivateGiftCardResponse; +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(); + + ActivateGiftCardResponse res = sdk.giftCards().activations().create() + .giftCardActivationCreate(GiftCardActivationCreate.builder() + .number("4123455541234561234") + .build()) + .call(); + + if (res.giftCard().isPresent()) { + System.out.println(res.giftCard().get()); + } + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `idempotencyKey` | *JsonNullable\* | :heavy_minus_sign: | A unique key that identifies this request. If supported by the gift card service, the value will be forwarded to make the activation idempotent. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. | +| `merchantAccountId` | *JsonNullable\* | :heavy_minus_sign: | The ID of the merchant account to use for this request. | +| `giftCardActivationCreate` | [GiftCardActivationCreate](../../models/components/GiftCardActivationCreate.md) | :heavy_check_mark: | N/A | + +### Response + +**[ActivateGiftCardResponse](../../models/operations/ActivateGiftCardResponse.md)** + +### 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 | \*/\* | \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 5791823b..c4e8e801 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ groupId=com.gr4vy artifactId=sdk -version=2.16.116 +version=2.16.117 org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g diff --git a/src/main/java/com/gr4vy/sdk/Activations.java b/src/main/java/com/gr4vy/sdk/Activations.java new file mode 100644 index 00000000..f8d575ae --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/Activations.java @@ -0,0 +1,87 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk; + +import static com.gr4vy.sdk.operations.Operations.RequestOperation; + +import com.gr4vy.sdk.models.components.GiftCardActivationCreate; +import com.gr4vy.sdk.models.operations.ActivateGiftCardRequest; +import com.gr4vy.sdk.models.operations.ActivateGiftCardRequestBuilder; +import com.gr4vy.sdk.models.operations.ActivateGiftCardResponse; +import com.gr4vy.sdk.operations.ActivateGiftCard; +import com.gr4vy.sdk.utils.Headers; +import java.lang.String; +import org.openapitools.jackson.nullable.JsonNullable; + + +public class Activations { + private static final Headers _headers = Headers.EMPTY; + private final SDKConfiguration sdkConfiguration; + private final AsyncActivations asyncSDK; + + Activations(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.asyncSDK = new AsyncActivations(this, sdkConfiguration); + } + + /** + * Switches to the async SDK. + * + * @return The async SDK + */ + public AsyncActivations async() { + return asyncSDK; + } + + /** + * Activate a gift card + * + *

Activate a physical gift card through the primary gift card service. + * + * @return The call builder + */ + public ActivateGiftCardRequestBuilder create() { + return new ActivateGiftCardRequestBuilder(sdkConfiguration); + } + + /** + * Activate a gift card + * + *

Activate a physical gift card through the primary gift card service. + * + * @param giftCardActivationCreate The details used to activate a physical gift card. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public ActivateGiftCardResponse create(GiftCardActivationCreate giftCardActivationCreate) { + return create(JsonNullable.undefined(), JsonNullable.undefined(), giftCardActivationCreate); + } + + /** + * Activate a gift card + * + *

Activate a physical gift card through the primary gift card service. + * + * @param idempotencyKey A unique key that identifies this request. If supported by the gift card service, the value will be forwarded to make the activation idempotent. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. + * @param merchantAccountId + * @param giftCardActivationCreate The details used to activate a physical gift card. + * @return The response from the API call + * @throws RuntimeException subclass if the API call fails + */ + public ActivateGiftCardResponse create( + JsonNullable idempotencyKey, JsonNullable merchantAccountId, + GiftCardActivationCreate giftCardActivationCreate) { + ActivateGiftCardRequest request = + ActivateGiftCardRequest + .builder() + .idempotencyKey(idempotencyKey) + .merchantAccountId(merchantAccountId) + .giftCardActivationCreate(giftCardActivationCreate) + .build(); + RequestOperation operation + = new ActivateGiftCard.Sync(sdkConfiguration, _headers); + return operation.handleResponse(operation.doRequest(request)); + } + +} diff --git a/src/main/java/com/gr4vy/sdk/AsyncActivations.java b/src/main/java/com/gr4vy/sdk/AsyncActivations.java new file mode 100644 index 00000000..fd9f0372 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/AsyncActivations.java @@ -0,0 +1,88 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.gr4vy.sdk; + +import static com.gr4vy.sdk.operations.Operations.AsyncRequestOperation; + +import com.gr4vy.sdk.models.components.GiftCardActivationCreate; +import com.gr4vy.sdk.models.operations.ActivateGiftCardRequest; +import com.gr4vy.sdk.models.operations.async.ActivateGiftCardRequestBuilder; +import com.gr4vy.sdk.models.operations.async.ActivateGiftCardResponse; +import com.gr4vy.sdk.operations.ActivateGiftCard; +import com.gr4vy.sdk.utils.Headers; +import java.lang.String; +import java.util.concurrent.CompletableFuture; +import org.openapitools.jackson.nullable.JsonNullable; + + +public class AsyncActivations { + private static final Headers _headers = Headers.EMPTY; + private final SDKConfiguration sdkConfiguration; + private final Activations syncSDK; + + AsyncActivations(Activations syncSDK, SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + this.syncSDK = syncSDK; + } + + /** + * Switches to the sync SDK. + * + * @return The sync SDK + */ + public Activations sync() { + return syncSDK; + } + + + /** + * Activate a gift card + * + *

Activate a physical gift card through the primary gift card service. + * + * @return The async call builder + */ + public ActivateGiftCardRequestBuilder create() { + return new ActivateGiftCardRequestBuilder(sdkConfiguration); + } + + /** + * Activate a gift card + * + *

Activate a physical gift card through the primary gift card service. + * + * @param giftCardActivationCreate The details used to activate a physical gift card. + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture create(GiftCardActivationCreate giftCardActivationCreate) { + return create(JsonNullable.undefined(), JsonNullable.undefined(), giftCardActivationCreate); + } + + /** + * Activate a gift card + * + *

Activate a physical gift card through the primary gift card service. + * + * @param idempotencyKey A unique key that identifies this request. If supported by the gift card service, the value will be forwarded to make the activation idempotent. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. + * @param merchantAccountId + * @param giftCardActivationCreate The details used to activate a physical gift card. + * @return {@code CompletableFuture} - The async response + */ + public CompletableFuture create( + JsonNullable idempotencyKey, JsonNullable merchantAccountId, + GiftCardActivationCreate giftCardActivationCreate) { + ActivateGiftCardRequest request = + ActivateGiftCardRequest + .builder() + .idempotencyKey(idempotencyKey) + .merchantAccountId(merchantAccountId) + .giftCardActivationCreate(giftCardActivationCreate) + .build(); + AsyncRequestOperation operation + = new ActivateGiftCard.Async(sdkConfiguration, _headers); + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } + +} diff --git a/src/main/java/com/gr4vy/sdk/AsyncGiftCards.java b/src/main/java/com/gr4vy/sdk/AsyncGiftCards.java index 16225a13..ddacc9ff 100644 --- a/src/main/java/com/gr4vy/sdk/AsyncGiftCards.java +++ b/src/main/java/com/gr4vy/sdk/AsyncGiftCards.java @@ -34,11 +34,13 @@ public class AsyncGiftCards { private static final Headers _headers = Headers.EMPTY; private final SDKConfiguration sdkConfiguration; private final AsyncBalances balances; + private final AsyncActivations activations; private final GiftCards syncSDK; AsyncGiftCards(GiftCards syncSDK, SDKConfiguration sdkConfiguration) { this.sdkConfiguration = sdkConfiguration; this.balances = new AsyncBalances(syncSDK.balances(), this.sdkConfiguration); + this.activations = new AsyncActivations(syncSDK.activations(), this.sdkConfiguration); this.syncSDK = syncSDK; } @@ -46,6 +48,10 @@ public final AsyncBalances balances() { return balances; } + public final AsyncActivations activations() { + return activations; + } + /** * Switches to the sync SDK. * diff --git a/src/main/java/com/gr4vy/sdk/GiftCards.java b/src/main/java/com/gr4vy/sdk/GiftCards.java index c0bd05b6..19ac3468 100644 --- a/src/main/java/com/gr4vy/sdk/GiftCards.java +++ b/src/main/java/com/gr4vy/sdk/GiftCards.java @@ -34,10 +34,12 @@ public class GiftCards { private final SDKConfiguration sdkConfiguration; private final AsyncGiftCards asyncSDK; private final Balances balances; + private final Activations activations; GiftCards(SDKConfiguration sdkConfiguration) { this.sdkConfiguration = sdkConfiguration; this.balances = new Balances(this.sdkConfiguration); + this.activations = new Activations(this.sdkConfiguration); this.asyncSDK = new AsyncGiftCards(this, sdkConfiguration); } @@ -45,6 +47,10 @@ public final Balances balances() { return balances; } + public final Activations activations() { + return activations; + } + /** * Switches to the async SDK. * diff --git a/src/main/java/com/gr4vy/sdk/SDKConfiguration.java b/src/main/java/com/gr4vy/sdk/SDKConfiguration.java index f8cef020..b5cb428a 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.16.116"; + public static final String SDK_VERSION = "2.16.117"; public static final String GEN_VERSION = "2.918.4"; private static final String BASE_PACKAGE = "com.gr4vy.sdk"; public static final String USER_AGENT = diff --git a/src/main/java/com/gr4vy/sdk/models/components/GiftCardActivationCreate.java b/src/main/java/com/gr4vy/sdk/models/components/GiftCardActivationCreate.java new file mode 100644 index 00000000..14f65504 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/components/GiftCardActivationCreate.java @@ -0,0 +1,359 @@ +/* + * 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.gr4vy.sdk.utils.Utils; +import java.lang.Long; +import java.lang.Override; +import java.lang.String; +import org.openapitools.jackson.nullable.JsonNullable; + +/** + * GiftCardActivationCreate + * + *

The details used to activate a physical gift card. + */ +public class GiftCardActivationCreate { + /** + * The 16-19 digit number for the gift card. + */ + @JsonProperty("number") + private String number; + + /** + * The PIN for this gift card. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("pin") + private JsonNullable pin; + + /** + * The amount to load onto the gift card, in the smallest denomination for the currency. Required if + * `currency` is provided. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("amount") + private JsonNullable amount; + + /** + * The ISO-4217 currency code for the `amount`. Required if `amount` is provided. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("currency") + private JsonNullable currency; + + /** + * An optional external identifier for this activation. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("external_identifier") + private JsonNullable externalIdentifier; + + @JsonCreator + public GiftCardActivationCreate( + @JsonProperty("number") String number, + @JsonProperty("pin") JsonNullable pin, + @JsonProperty("amount") JsonNullable amount, + @JsonProperty("currency") JsonNullable currency, + @JsonProperty("external_identifier") JsonNullable externalIdentifier) { + Utils.checkNotNull(number, "number"); + Utils.checkNotNull(pin, "pin"); + Utils.checkNotNull(amount, "amount"); + Utils.checkNotNull(currency, "currency"); + Utils.checkNotNull(externalIdentifier, "externalIdentifier"); + this.number = number; + this.pin = pin; + this.amount = amount; + this.currency = currency; + this.externalIdentifier = externalIdentifier; + } + + public GiftCardActivationCreate( + String number) { + this(number, JsonNullable.undefined(), JsonNullable.undefined(), + JsonNullable.undefined(), JsonNullable.undefined()); + } + + /** + * The 16-19 digit number for the gift card. + */ + @JsonIgnore + public String number() { + return number; + } + + /** + * The PIN for this gift card. + */ + @JsonIgnore + public JsonNullable pin() { + return pin; + } + + /** + * The amount to load onto the gift card, in the smallest denomination for the currency. Required if + * `currency` is provided. + */ + @JsonIgnore + public JsonNullable amount() { + return amount; + } + + /** + * The ISO-4217 currency code for the `amount`. Required if `amount` is provided. + */ + @JsonIgnore + public JsonNullable currency() { + return currency; + } + + /** + * An optional external identifier for this activation. + */ + @JsonIgnore + public JsonNullable externalIdentifier() { + return externalIdentifier; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * The 16-19 digit number for the gift card. + */ + public GiftCardActivationCreate withNumber(String number) { + Utils.checkNotNull(number, "number"); + this.number = number; + return this; + } + + /** + * The PIN for this gift card. + */ + public GiftCardActivationCreate withPin(String pin) { + Utils.checkNotNull(pin, "pin"); + this.pin = JsonNullable.of(pin); + return this; + } + + /** + * The PIN for this gift card. + */ + public GiftCardActivationCreate withPin(JsonNullable pin) { + Utils.checkNotNull(pin, "pin"); + this.pin = pin; + return this; + } + + /** + * The amount to load onto the gift card, in the smallest denomination for the currency. Required if + * `currency` is provided. + */ + public GiftCardActivationCreate withAmount(long amount) { + Utils.checkNotNull(amount, "amount"); + this.amount = JsonNullable.of(amount); + return this; + } + + /** + * The amount to load onto the gift card, in the smallest denomination for the currency. Required if + * `currency` is provided. + */ + public GiftCardActivationCreate withAmount(JsonNullable amount) { + Utils.checkNotNull(amount, "amount"); + this.amount = amount; + return this; + } + + /** + * The ISO-4217 currency code for the `amount`. Required if `amount` is provided. + */ + public GiftCardActivationCreate withCurrency(String currency) { + Utils.checkNotNull(currency, "currency"); + this.currency = JsonNullable.of(currency); + return this; + } + + /** + * The ISO-4217 currency code for the `amount`. Required if `amount` is provided. + */ + public GiftCardActivationCreate withCurrency(JsonNullable currency) { + Utils.checkNotNull(currency, "currency"); + this.currency = currency; + return this; + } + + /** + * An optional external identifier for this activation. + */ + public GiftCardActivationCreate withExternalIdentifier(String externalIdentifier) { + Utils.checkNotNull(externalIdentifier, "externalIdentifier"); + this.externalIdentifier = JsonNullable.of(externalIdentifier); + return this; + } + + /** + * An optional external identifier for this activation. + */ + public GiftCardActivationCreate withExternalIdentifier(JsonNullable externalIdentifier) { + Utils.checkNotNull(externalIdentifier, "externalIdentifier"); + this.externalIdentifier = externalIdentifier; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GiftCardActivationCreate other = (GiftCardActivationCreate) o; + return + Utils.enhancedDeepEquals(this.number, other.number) && + Utils.enhancedDeepEquals(this.pin, other.pin) && + Utils.enhancedDeepEquals(this.amount, other.amount) && + Utils.enhancedDeepEquals(this.currency, other.currency) && + Utils.enhancedDeepEquals(this.externalIdentifier, other.externalIdentifier); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + number, pin, amount, + currency, externalIdentifier); + } + + @Override + public String toString() { + return Utils.toString(GiftCardActivationCreate.class, + "number", number, + "pin", pin, + "amount", amount, + "currency", currency, + "externalIdentifier", externalIdentifier); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String number; + + private JsonNullable pin = JsonNullable.undefined(); + + private JsonNullable amount = JsonNullable.undefined(); + + private JsonNullable currency = JsonNullable.undefined(); + + private JsonNullable externalIdentifier = JsonNullable.undefined(); + + private Builder() { + // force use of static builder() method + } + + + /** + * The 16-19 digit number for the gift card. + */ + public Builder number(String number) { + Utils.checkNotNull(number, "number"); + this.number = number; + return this; + } + + + /** + * The PIN for this gift card. + */ + public Builder pin(String pin) { + Utils.checkNotNull(pin, "pin"); + this.pin = JsonNullable.of(pin); + return this; + } + + /** + * The PIN for this gift card. + */ + public Builder pin(JsonNullable pin) { + Utils.checkNotNull(pin, "pin"); + this.pin = pin; + return this; + } + + + /** + * The amount to load onto the gift card, in the smallest denomination for the currency. Required if + * `currency` is provided. + */ + public Builder amount(long amount) { + Utils.checkNotNull(amount, "amount"); + this.amount = JsonNullable.of(amount); + return this; + } + + /** + * The amount to load onto the gift card, in the smallest denomination for the currency. Required if + * `currency` is provided. + */ + public Builder amount(JsonNullable amount) { + Utils.checkNotNull(amount, "amount"); + this.amount = amount; + return this; + } + + + /** + * The ISO-4217 currency code for the `amount`. Required if `amount` is provided. + */ + public Builder currency(String currency) { + Utils.checkNotNull(currency, "currency"); + this.currency = JsonNullable.of(currency); + return this; + } + + /** + * The ISO-4217 currency code for the `amount`. Required if `amount` is provided. + */ + public Builder currency(JsonNullable currency) { + Utils.checkNotNull(currency, "currency"); + this.currency = currency; + return this; + } + + + /** + * An optional external identifier for this activation. + */ + public Builder externalIdentifier(String externalIdentifier) { + Utils.checkNotNull(externalIdentifier, "externalIdentifier"); + this.externalIdentifier = JsonNullable.of(externalIdentifier); + return this; + } + + /** + * An optional external identifier for this activation. + */ + public Builder externalIdentifier(JsonNullable externalIdentifier) { + Utils.checkNotNull(externalIdentifier, "externalIdentifier"); + this.externalIdentifier = externalIdentifier; + return this; + } + + public GiftCardActivationCreate build() { + + return new GiftCardActivationCreate( + number, pin, amount, + currency, externalIdentifier); + } + + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardRequest.java b/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardRequest.java new file mode 100644 index 00000000..345d53f8 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardRequest.java @@ -0,0 +1,225 @@ +/* + * 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.GiftCardActivationCreate; +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 ActivateGiftCardRequest { + /** + * A unique key that identifies this request. If supported by the gift card service, the value will be + * forwarded to make the activation idempotent. 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; + + /** + * 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; + + + @SpeakeasyMetadata("request:mediaType=application/json") + private GiftCardActivationCreate giftCardActivationCreate; + + @JsonCreator + public ActivateGiftCardRequest( + JsonNullable idempotencyKey, + JsonNullable merchantAccountId, + GiftCardActivationCreate giftCardActivationCreate) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + Utils.checkNotNull(giftCardActivationCreate, "giftCardActivationCreate"); + this.idempotencyKey = idempotencyKey; + this.merchantAccountId = merchantAccountId; + this.giftCardActivationCreate = giftCardActivationCreate; + } + + public ActivateGiftCardRequest( + GiftCardActivationCreate giftCardActivationCreate) { + this(JsonNullable.undefined(), JsonNullable.undefined(), giftCardActivationCreate); + } + + /** + * A unique key that identifies this request. If supported by the gift card service, the value will be + * forwarded to make the activation idempotent. We recommend using V4 UUIDs, or another random string + * with enough entropy to avoid collisions. + */ + @JsonIgnore + public JsonNullable idempotencyKey() { + return idempotencyKey; + } + + /** + * The ID of the merchant account to use for this request. + */ + @JsonIgnore + public JsonNullable merchantAccountId() { + return merchantAccountId; + } + + @JsonIgnore + public GiftCardActivationCreate giftCardActivationCreate() { + return giftCardActivationCreate; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * A unique key that identifies this request. If supported by the gift card service, the value will be + * forwarded to make the activation idempotent. We recommend using V4 UUIDs, or another random string + * with enough entropy to avoid collisions. + */ + public ActivateGiftCardRequest withIdempotencyKey(String idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = JsonNullable.of(idempotencyKey); + return this; + } + + /** + * A unique key that identifies this request. If supported by the gift card service, the value will be + * forwarded to make the activation idempotent. We recommend using V4 UUIDs, or another random string + * with enough entropy to avoid collisions. + */ + public ActivateGiftCardRequest withIdempotencyKey(JsonNullable idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = idempotencyKey; + return this; + } + + /** + * The ID of the merchant account to use for this request. + */ + public ActivateGiftCardRequest 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 ActivateGiftCardRequest withMerchantAccountId(JsonNullable merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = merchantAccountId; + return this; + } + + public ActivateGiftCardRequest withGiftCardActivationCreate(GiftCardActivationCreate giftCardActivationCreate) { + Utils.checkNotNull(giftCardActivationCreate, "giftCardActivationCreate"); + this.giftCardActivationCreate = giftCardActivationCreate; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActivateGiftCardRequest other = (ActivateGiftCardRequest) o; + return + Utils.enhancedDeepEquals(this.idempotencyKey, other.idempotencyKey) && + Utils.enhancedDeepEquals(this.merchantAccountId, other.merchantAccountId) && + Utils.enhancedDeepEquals(this.giftCardActivationCreate, other.giftCardActivationCreate); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + idempotencyKey, merchantAccountId, giftCardActivationCreate); + } + + @Override + public String toString() { + return Utils.toString(ActivateGiftCardRequest.class, + "idempotencyKey", idempotencyKey, + "merchantAccountId", merchantAccountId, + "giftCardActivationCreate", giftCardActivationCreate); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private JsonNullable idempotencyKey = JsonNullable.undefined(); + + private JsonNullable merchantAccountId = JsonNullable.undefined(); + + private GiftCardActivationCreate giftCardActivationCreate; + + private Builder() { + // force use of static builder() method + } + + + /** + * A unique key that identifies this request. If supported by the gift card service, the value will be + * forwarded to make the activation idempotent. 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. If supported by the gift card service, the value will be + * forwarded to make the activation idempotent. 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; + } + + + /** + * 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; + } + + + public Builder giftCardActivationCreate(GiftCardActivationCreate giftCardActivationCreate) { + Utils.checkNotNull(giftCardActivationCreate, "giftCardActivationCreate"); + this.giftCardActivationCreate = giftCardActivationCreate; + return this; + } + + public ActivateGiftCardRequest build() { + + return new ActivateGiftCardRequest( + idempotencyKey, merchantAccountId, giftCardActivationCreate); + } + + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardRequestBuilder.java b/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardRequestBuilder.java new file mode 100644 index 00000000..be702ce6 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardRequestBuilder.java @@ -0,0 +1,76 @@ +/* + * 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.GiftCardActivationCreate; +import com.gr4vy.sdk.operations.ActivateGiftCard; +import com.gr4vy.sdk.utils.Headers; +import com.gr4vy.sdk.utils.Utils; +import java.lang.String; +import org.openapitools.jackson.nullable.JsonNullable; + +public class ActivateGiftCardRequestBuilder { + + private JsonNullable idempotencyKey = JsonNullable.undefined(); + private JsonNullable merchantAccountId = JsonNullable.undefined(); + private GiftCardActivationCreate giftCardActivationCreate; + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public ActivateGiftCardRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public ActivateGiftCardRequestBuilder idempotencyKey(String idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = JsonNullable.of(idempotencyKey); + return this; + } + + public ActivateGiftCardRequestBuilder idempotencyKey(JsonNullable idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = idempotencyKey; + return this; + } + + public ActivateGiftCardRequestBuilder merchantAccountId(String merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = JsonNullable.of(merchantAccountId); + return this; + } + + public ActivateGiftCardRequestBuilder merchantAccountId(JsonNullable merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = merchantAccountId; + return this; + } + + public ActivateGiftCardRequestBuilder giftCardActivationCreate(GiftCardActivationCreate giftCardActivationCreate) { + Utils.checkNotNull(giftCardActivationCreate, "giftCardActivationCreate"); + this.giftCardActivationCreate = giftCardActivationCreate; + return this; + } + + + private ActivateGiftCardRequest buildRequest() { + + ActivateGiftCardRequest request = new ActivateGiftCardRequest(idempotencyKey, + merchantAccountId, + giftCardActivationCreate); + + return request; + } + + public ActivateGiftCardResponse call() { + + RequestOperation operation + = new ActivateGiftCard.Sync(sdkConfiguration, _headers); + ActivateGiftCardRequest request = buildRequest(); + + return operation.handleResponse(operation.doRequest(request)); + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardResponse.java b/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardResponse.java new file mode 100644 index 00000000..1f2a8402 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/ActivateGiftCardResponse.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.GiftCard; +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 ActivateGiftCardResponse 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 giftCard; + + @JsonCreator + public ActivateGiftCardResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional giftCard) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(giftCard, "giftCard"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.giftCard = giftCard; + } + + public ActivateGiftCardResponse( + 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 giftCard() { + return (Optional) giftCard; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public ActivateGiftCardResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public ActivateGiftCardResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public ActivateGiftCardResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful Response + */ + public ActivateGiftCardResponse withGiftCard(GiftCard giftCard) { + Utils.checkNotNull(giftCard, "giftCard"); + this.giftCard = Optional.ofNullable(giftCard); + return this; + } + + + /** + * Successful Response + */ + public ActivateGiftCardResponse withGiftCard(Optional giftCard) { + Utils.checkNotNull(giftCard, "giftCard"); + this.giftCard = giftCard; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActivateGiftCardResponse other = (ActivateGiftCardResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.giftCard, other.giftCard); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + giftCard); + } + + @Override + public String toString() { + return Utils.toString(ActivateGiftCardResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "giftCard", giftCard); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional giftCard = 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 giftCard(GiftCard giftCard) { + Utils.checkNotNull(giftCard, "giftCard"); + this.giftCard = Optional.ofNullable(giftCard); + return this; + } + + /** + * Successful Response + */ + public Builder giftCard(Optional giftCard) { + Utils.checkNotNull(giftCard, "giftCard"); + this.giftCard = giftCard; + return this; + } + + public ActivateGiftCardResponse build() { + + return new ActivateGiftCardResponse( + contentType, statusCode, rawResponse, + giftCard); + } + + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/async/ActivateGiftCardRequestBuilder.java b/src/main/java/com/gr4vy/sdk/models/operations/async/ActivateGiftCardRequestBuilder.java new file mode 100644 index 00000000..6b9e2d75 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/async/ActivateGiftCardRequestBuilder.java @@ -0,0 +1,79 @@ +/* + * 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.GiftCardActivationCreate; +import com.gr4vy.sdk.models.operations.ActivateGiftCardRequest; +import com.gr4vy.sdk.operations.ActivateGiftCard; +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 ActivateGiftCardRequestBuilder { + + private JsonNullable idempotencyKey = JsonNullable.undefined(); + private JsonNullable merchantAccountId = JsonNullable.undefined(); + private GiftCardActivationCreate giftCardActivationCreate; + private final SDKConfiguration sdkConfiguration; + private final Headers _headers = new Headers(); + + public ActivateGiftCardRequestBuilder(SDKConfiguration sdkConfiguration) { + this.sdkConfiguration = sdkConfiguration; + } + + public ActivateGiftCardRequestBuilder idempotencyKey(String idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = JsonNullable.of(idempotencyKey); + return this; + } + + public ActivateGiftCardRequestBuilder idempotencyKey(JsonNullable idempotencyKey) { + Utils.checkNotNull(idempotencyKey, "idempotencyKey"); + this.idempotencyKey = idempotencyKey; + return this; + } + + public ActivateGiftCardRequestBuilder merchantAccountId(String merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = JsonNullable.of(merchantAccountId); + return this; + } + + public ActivateGiftCardRequestBuilder merchantAccountId(JsonNullable merchantAccountId) { + Utils.checkNotNull(merchantAccountId, "merchantAccountId"); + this.merchantAccountId = merchantAccountId; + return this; + } + + public ActivateGiftCardRequestBuilder giftCardActivationCreate(GiftCardActivationCreate giftCardActivationCreate) { + Utils.checkNotNull(giftCardActivationCreate, "giftCardActivationCreate"); + this.giftCardActivationCreate = giftCardActivationCreate; + return this; + } + + + private ActivateGiftCardRequest buildRequest() { + + ActivateGiftCardRequest request = new ActivateGiftCardRequest(idempotencyKey, + merchantAccountId, + giftCardActivationCreate); + + return request; + } + + public CompletableFuture call() { + + AsyncRequestOperation operation + = new ActivateGiftCard.Async(sdkConfiguration, _headers); + ActivateGiftCardRequest request = buildRequest(); + + return operation.doRequest(request) + .thenCompose(operation::handleResponse); + } +} diff --git a/src/main/java/com/gr4vy/sdk/models/operations/async/ActivateGiftCardResponse.java b/src/main/java/com/gr4vy/sdk/models/operations/async/ActivateGiftCardResponse.java new file mode 100644 index 00000000..34429be8 --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/models/operations/async/ActivateGiftCardResponse.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.GiftCard; +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 ActivateGiftCardResponse 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 giftCard; + + @JsonCreator + public ActivateGiftCardResponse( + String contentType, + int statusCode, + HttpResponse rawResponse, + Optional giftCard) { + Utils.checkNotNull(contentType, "contentType"); + Utils.checkNotNull(statusCode, "statusCode"); + Utils.checkNotNull(rawResponse, "rawResponse"); + Utils.checkNotNull(giftCard, "giftCard"); + this.contentType = contentType; + this.statusCode = statusCode; + this.rawResponse = rawResponse; + this.giftCard = giftCard; + } + + public ActivateGiftCardResponse( + 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 giftCard() { + return (Optional) giftCard; + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * HTTP response content type for this operation + */ + public ActivateGiftCardResponse withContentType(String contentType) { + Utils.checkNotNull(contentType, "contentType"); + this.contentType = contentType; + return this; + } + + /** + * HTTP response status code for this operation + */ + public ActivateGiftCardResponse withStatusCode(int statusCode) { + Utils.checkNotNull(statusCode, "statusCode"); + this.statusCode = statusCode; + return this; + } + + /** + * Raw HTTP response; suitable for custom response parsing + */ + public ActivateGiftCardResponse withRawResponse(HttpResponse rawResponse) { + Utils.checkNotNull(rawResponse, "rawResponse"); + this.rawResponse = rawResponse; + return this; + } + + /** + * Successful Response + */ + public ActivateGiftCardResponse withGiftCard(GiftCard giftCard) { + Utils.checkNotNull(giftCard, "giftCard"); + this.giftCard = Optional.ofNullable(giftCard); + return this; + } + + + /** + * Successful Response + */ + public ActivateGiftCardResponse withGiftCard(Optional giftCard) { + Utils.checkNotNull(giftCard, "giftCard"); + this.giftCard = giftCard; + return this; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActivateGiftCardResponse other = (ActivateGiftCardResponse) o; + return + Utils.enhancedDeepEquals(this.contentType, other.contentType) && + Utils.enhancedDeepEquals(this.statusCode, other.statusCode) && + Utils.enhancedDeepEquals(this.rawResponse, other.rawResponse) && + Utils.enhancedDeepEquals(this.giftCard, other.giftCard); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + contentType, statusCode, rawResponse, + giftCard); + } + + @Override + public String toString() { + return Utils.toString(ActivateGiftCardResponse.class, + "contentType", contentType, + "statusCode", statusCode, + "rawResponse", rawResponse, + "giftCard", giftCard); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String contentType; + + private Integer statusCode; + + private HttpResponse rawResponse; + + private Optional giftCard = 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 giftCard(GiftCard giftCard) { + Utils.checkNotNull(giftCard, "giftCard"); + this.giftCard = Optional.ofNullable(giftCard); + return this; + } + + /** + * Successful Response + */ + public Builder giftCard(Optional giftCard) { + Utils.checkNotNull(giftCard, "giftCard"); + this.giftCard = giftCard; + return this; + } + + public ActivateGiftCardResponse build() { + + return new ActivateGiftCardResponse( + contentType, statusCode, rawResponse, + giftCard); + } + + } +} diff --git a/src/main/java/com/gr4vy/sdk/operations/ActivateGiftCard.java b/src/main/java/com/gr4vy/sdk/operations/ActivateGiftCard.java new file mode 100644 index 00000000..9a621b2e --- /dev/null +++ b/src/main/java/com/gr4vy/sdk/operations/ActivateGiftCard.java @@ -0,0 +1,458 @@ +/* + * 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.GiftCard; +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.ActivateGiftCardRequest; +import com.gr4vy.sdk.models.operations.ActivateGiftCardResponse; +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 ActivateGiftCard { + + 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, + "activate_gift_card", + java.util.Optional.empty(), + securitySource()); + } + + AfterSuccessContextImpl createAfterSuccessContext() { + return new AfterSuccessContextImpl( + this.sdkConfiguration, + this.baseUrl, + "activate_gift_card", + java.util.Optional.empty(), + securitySource()); + } + + AfterErrorContextImpl createAfterErrorContext() { + return new AfterErrorContextImpl( + this.sdkConfiguration, + this.baseUrl, + "activate_gift_card", + java.util.Optional.empty(), + securitySource()); + } + HttpRequest buildRequest(T request, TypeReference typeReference) throws Exception { + String url = Utils.generateURL( + this.baseUrl, + "/gift-cards/activations"); + HTTPRequest req = new HTTPRequest(url, "POST"); + Object convertedRequest = Utils.convertToShape( + request, + JsonShape.DEFAULT, + typeReference); + SerializedBody serializedRequestBody = Utils.serializeRequestBody( + convertedRequest, + "giftCardActivationCreate", + "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(ActivateGiftCardRequest request) throws Exception { + HttpRequest req = buildRequest(request, 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(ActivateGiftCardRequest 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 ActivateGiftCardResponse handleResponse(HttpResponse response) { + String contentType = response + .headers() + .firstValue("Content-Type") + .orElse("application/octet-stream"); + ActivateGiftCardResponse.Builder resBuilder = + ActivateGiftCardResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + ActivateGiftCardResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "201")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return res.withGiftCard(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(ActivateGiftCardRequest request) throws Exception { + HttpRequest req = buildRequest(request, 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(ActivateGiftCardRequest 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.ActivateGiftCardResponse.Builder resBuilder = + com.gr4vy.sdk.models.operations.async.ActivateGiftCardResponse + .builder() + .contentType(contentType) + .statusCode(response.statusCode()) + .rawResponse(response); + + com.gr4vy.sdk.models.operations.async.ActivateGiftCardResponse res = resBuilder.build(); + + if (Utils.statusCodeMatches(response.statusCode(), "201")) { + if (Utils.contentTypeMatches(contentType, "application/json")) { + return Utils.unmarshalAsync(response, new TypeReference() {}) + .thenApply(res::withGiftCard); + } 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()); + } + } +}