diff --git a/.gitignore b/.gitignore index a530464..64fb462 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ hs_err_pid* target .gradle build + +.DS_Store diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b291156 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# Contributing to Our Project's SDK + +We value your input and contributions! We use the [OpenAPI Generator tool](https://openapi-generator.tech) to generate our SDK based on an OpenAPI YAML specification. + +If you find an issue with our SDK and want to contribute a fix, follow the guidelines mentioned below: + +## Reporting an Issue + +1. Notice an issue while using the SDK? Try to determine what's causing it. Was it a particular endpoint, operation, or datatype? + +2. Check the YAML specification: Once you've identified the issue, refer to the corresponding definition in the OpenAPI YAML specification file that is included in the SDK. This could be a specific path, operation, parameter, or schema. + +3. Describe the current behavior and desired correct behavior. + +4. Describe the steps to reproduce this issue. + +Please note that due to our open-source process, we don't have a direct way to accept code contributions for the SDK. The SDK is directly generated from our OpenAPI YAML specification file. Hence, you don't need to manually update the SDK. Instead, identify the modifications needed in the OpenAPI YAML specification. + +## Submitting a Suggestion + +If there's something in the SDK that isn't broken but could be better, you're welcome to share suggestions. Constructive feedback is always appreciated! + +When submitting a suggestion: + +1. Be clear and concise in your description of the suggestion. + +2. Explain why it would be beneficial. Real-life examples, if applicable, can help to illustrate your point. + +3. Be patient. Not all suggestions can be incorporated immediately, and it may be necessary for us to research your idea before we can implement it. + +Remember, contributions come in many forms, not just in code! Identifying areas for improvement or bringing up issues helps us make the SDK better for everyone. + +Thank you for your contributions! \ No newline at end of file diff --git a/README.md b/README.md index 492a2a1..293d57c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ -# Java API client for grabfood +# Java API client for GrabFood - API version: 1.1.3 -- Build date: 2024-09-10T06:13:57.715918Z[Etc/UTC] - -- Generator version: 7.6.0 +- Generator version: 7.8.0 For more information, please visit [https://developer.grab.com](https://developer.grab.com) @@ -78,6 +76,15 @@ Then manually install the following JARs: Please follow the [installation](#installation) instruction and execute the following Java code: +In the example below, we start by acquiring an OAuth2 access token. In your applications, it's important to handle OAuth2 tokens efficiently. This means: +- Store the received access token once it's obtained. +- Use this stored access token for as long as it's valid. +- Only request a new access token when the current one has expired. + +By following these practices, you minimize the number of requests to the server, making your application more efficient and responsive. + +You can usually determine the validity of a token by the `expires_in` attribute in the OAuth2 token response. + ```java import com.grabfood.client.ApiClient; import com.grabfood.client.ApiException; @@ -101,18 +108,18 @@ public class Example { req.setGrantType("client_credentials"); req.setScope("food.partner_api"); - String accessToken = ""; - try { GrabOauthResponse authResp = authInstance.postOauthGrab(contentType, req); - accessToken = authResp.getAccessToken(); + // Request a new token only when the previous one has expired. + // Can utilize the `expires_in` from authResp.getExpiresIn() to determine the validity of the token. + ACCESS_TOKEN = authResp.getAccessToken(); } catch (ApiException e) { System.err.println("Exception when calling GetOauthGrabApi#postOauthGrab"); e.printStackTrace(); } GetStoreHourApi apiInstance = new GetStoreHourApi(client); - String authorization = "Bearer " + accessToken; + String authorization = "Bearer " + ACCESS_TOKEN; String merchantID = "1-CYNGRUNGSBCCC"; try { StoreHourResponse result = apiInstance.getStoreHour(authorization, merchantID); @@ -125,9 +132,12 @@ public class Example { } ``` +For handling webhook requests, we provide dedicated models for both requests and responses. Please refer to the list of available models provided below for more details. + ## Documentation for API Endpoints -All URIs are relative to *https://partner-api.stg-myteksi.com/grabfood-sandbox* +The base URL for OAuth2 URIs is https://api.grab.com +For other GrabFood partner API endpoints, URIs are relative to https://partner-api.grab.com/grabfood Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- @@ -164,40 +174,29 @@ Class | Method | HTTP request | Description - [AcceptOrderRequest](docs/AcceptOrderRequest.md) - [Address](docs/Address.md) - [AdvancedPricing](docs/AdvancedPricing.md) - - [BatchUpdateMenuErrorMessage](docs/BatchUpdateMenuErrorMessage.md) - - [BatchUpdateMenuErrorMessageErrorsInner](docs/BatchUpdateMenuErrorMessageErrorsInner.md) - [BatchUpdateMenuItem](docs/BatchUpdateMenuItem.md) - - [BatchUpdateMenuItemMenuEntitiesInner](docs/BatchUpdateMenuItemMenuEntitiesInner.md) + - [BatchUpdateMenuResponse](docs/BatchUpdateMenuResponse.md) - [BindMembershipNativeRequest](docs/BindMembershipNativeRequest.md) - [BindMembershipNativeResponse](docs/BindMembershipNativeResponse.md) - - [Campaigns](docs/Campaigns.md) + - [Campaign](docs/Campaign.md) + - [CampaignConditions](docs/CampaignConditions.md) + - [CampaignDiscount](docs/CampaignDiscount.md) + - [CampaignQuotas](docs/CampaignQuotas.md) + - [CampaignScope](docs/CampaignScope.md) - [CancelCode](docs/CancelCode.md) - - [CancelOrderFail](docs/CancelOrderFail.md) - - [CancelOrderFail403](docs/CancelOrderFail403.md) + - [CancelOrderLimitType](docs/CancelOrderLimitType.md) - [CancelOrderRequest](docs/CancelOrderRequest.md) - [CancelOrderResponse](docs/CancelOrderResponse.md) - - [CancelReasonsInner](docs/CancelReasonsInner.md) - - [CategoriesInner](docs/CategoriesInner.md) - - [CategoriesInnerNameTranslation](docs/CategoriesInnerNameTranslation.md) + - [CancelReason](docs/CancelReason.md) - [CheckOrderCancelableResponse](docs/CheckOrderCancelableResponse.md) - - [Conditions](docs/Conditions.md) - [Coordinates](docs/Coordinates.md) - - [CreateCampaignFail](docs/CreateCampaignFail.md) - [CreateCampaignRequest](docs/CreateCampaignRequest.md) - [CreateCampaignResponse](docs/CreateCampaignResponse.md) - [Currency](docs/Currency.md) - - [DayHours](docs/DayHours.md) - [DineIn](docs/DineIn.md) - - [DineInVoucher400Fail](docs/DineInVoucher400Fail.md) - - [DineInVoucher404Fail](docs/DineInVoucher404Fail.md) - - [Discount](docs/Discount.md) + - [EditOrderItem](docs/EditOrderItem.md) - [EditOrderRequest](docs/EditOrderRequest.md) - - [EditOrderRequestItemsInner](docs/EditOrderRequestItemsInner.md) - - [Error404](docs/Error404.md) - - [Error409](docs/Error409.md) - - [Error500](docs/Error500.md) - - [FeatureFlags](docs/FeatureFlags.md) - - [FreeItem](docs/FreeItem.md) + - [Error](docs/Error.md) - [GetDineInVoucherResponse](docs/GetDineInVoucherResponse.md) - [GetMembershipNativeResponse](docs/GetMembershipNativeResponse.md) - [GetMembershipNativeResponsePointInfo](docs/GetMembershipNativeResponsePointInfo.md) @@ -206,97 +205,84 @@ Class | Method | HTTP request | Description - [GetMenuNewResponse](docs/GetMenuNewResponse.md) - [GetMenuOldResponse](docs/GetMenuOldResponse.md) - [GetRewardNativeRequest](docs/GetRewardNativeRequest.md) - - [GetRewardNativeRequestItemsInner](docs/GetRewardNativeRequestItemsInner.md) - [GetRewardNativeResponse](docs/GetRewardNativeResponse.md) - [GrabOauthRequest](docs/GrabOauthRequest.md) - [GrabOauthResponse](docs/GrabOauthResponse.md) - - [LimitType](docs/LimitType.md) - [ListCampaignResponse](docs/ListCampaignResponse.md) - [ListOrdersResponse](docs/ListOrdersResponse.md) - - [MarkOrderFail](docs/MarkOrderFail.md) - [MarkOrderRequest](docs/MarkOrderRequest.md) - - [MenuItemsInner](docs/MenuItemsInner.md) - - [MenuItemsInnerDescriptionTranslation](docs/MenuItemsInnerDescriptionTranslation.md) - - [MenuModifiersInner](docs/MenuModifiersInner.md) - - [MenuModifiersInnerNameTranslation](docs/MenuModifiersInnerNameTranslation.md) + - [MenuCategory](docs/MenuCategory.md) + - [MenuEntity](docs/MenuEntity.md) + - [MenuEntityError](docs/MenuEntityError.md) + - [MenuItem](docs/MenuItem.md) + - [MenuModifier](docs/MenuModifier.md) + - [MenuSection](docs/MenuSection.md) + - [MenuSectionCategory](docs/MenuSectionCategory.md) + - [MenuSectionCategoryItem](docs/MenuSectionCategoryItem.md) - [MenuSyncFail](docs/MenuSyncFail.md) - - [MenuSyncSuccess](docs/MenuSyncSuccess.md) + - [MenuSyncFailCategory](docs/MenuSyncFailCategory.md) + - [MenuSyncFailItem](docs/MenuSyncFailItem.md) + - [MenuSyncFailModifier](docs/MenuSyncFailModifier.md) + - [MenuSyncFailModifierGroup](docs/MenuSyncFailModifierGroup.md) + - [MenuSyncFailServiceHours](docs/MenuSyncFailServiceHours.md) + - [MenuSyncResponse](docs/MenuSyncResponse.md) - [MenuSyncWebhookRequest](docs/MenuSyncWebhookRequest.md) - - [ModifierGroupsInner](docs/ModifierGroupsInner.md) - - [ModifierGroupsInnerNameTranslation](docs/ModifierGroupsInnerNameTranslation.md) + - [ModifierGroup](docs/ModifierGroup.md) - [NewOrderTimeRequest](docs/NewOrderTimeRequest.md) - - [NewReadyTimeFail](docs/NewReadyTimeFail.md) - [NotifyMembershipWebviewRequest](docs/NotifyMembershipWebviewRequest.md) - - [OldMenuSectionCategoryItemsInner](docs/OldMenuSectionCategoryItemsInner.md) - - [OldMenuSectionCategoryItemsInnerDescriptionTranslation](docs/OldMenuSectionCategoryItemsInnerDescriptionTranslation.md) - - [OldMenuSectionCategoryItemsInnerNameTranslation](docs/OldMenuSectionCategoryItemsInnerNameTranslation.md) - [OpenPeriod](docs/OpenPeriod.md) - - [OrderCampaignsInner](docs/OrderCampaignsInner.md) + - [Order](docs/Order.md) + - [OrderCampaign](docs/OrderCampaign.md) - [OrderDeliveryRequest](docs/OrderDeliveryRequest.md) - - [OrderItemsInner](docs/OrderItemsInner.md) - - [OrderModifiersInner](docs/OrderModifiersInner.md) + - [OrderFeatureFlags](docs/OrderFeatureFlags.md) + - [OrderFreeItem](docs/OrderFreeItem.md) + - [OrderItem](docs/OrderItem.md) + - [OrderItemModifier](docs/OrderItemModifier.md) - [OrderPrice](docs/OrderPrice.md) + - [OrderPromo](docs/OrderPromo.md) - [OrderReadyEstimation](docs/OrderReadyEstimation.md) - [OrderStateRequest](docs/OrderStateRequest.md) - - [Orders](docs/Orders.md) - [OutOfStockInstruction](docs/OutOfStockInstruction.md) - [PartnerOauthRequest](docs/PartnerOauthRequest.md) - [PartnerOauthResponse](docs/PartnerOauthResponse.md) - [PauseStoreRequest](docs/PauseStoreRequest.md) - - [PromosInner](docs/PromosInner.md) - [Purchasability](docs/Purchasability.md) - - [Quotas](docs/Quotas.md) - [Receiver](docs/Receiver.md) - [RedeemDineInVoucherRequest](docs/RedeemDineInVoucherRequest.md) - [RedeemDineInVoucherResponse](docs/RedeemDineInVoucherResponse.md) - - [RedeemDineinVoucher500Response](docs/RedeemDineinVoucher500Response.md) - [RedeemResult](docs/RedeemResult.md) - [RegisterMembershipNativeRequest](docs/RegisterMembershipNativeRequest.md) - [RegisterMembershipNativeResponse](docs/RegisterMembershipNativeResponse.md) - - [Scope](docs/Scope.md) - - [SectionsInner](docs/SectionsInner.md) - - [SectionsInnerCategoriesInner](docs/SectionsInnerCategoriesInner.md) - - [SellingTimesInner](docs/SellingTimesInner.md) + - [RewardItem](docs/RewardItem.md) + - [SellingTime](docs/SellingTime.md) + - [ServiceHour](docs/ServiceHour.md) - [ServiceHours](docs/ServiceHours.md) - [SpecialOpeningHour](docs/SpecialOpeningHour.md) - [SpecialOpeningHourMetadata](docs/SpecialOpeningHourMetadata.md) - [SpecialOpeningHourOpeningHours](docs/SpecialOpeningHourOpeningHours.md) - [StoreHour](docs/StoreHour.md) - [StoreHourResponse](docs/StoreHourResponse.md) - - [StoreHourStatusError](docs/StoreHourStatusError.md) - [StoreStatusResponse](docs/StoreStatusResponse.md) - [SubmitOrderRequest](docs/SubmitOrderRequest.md) - - [SyncFail](docs/SyncFail.md) - - [SyncFailCategoriesInner](docs/SyncFailCategoriesInner.md) - - [SyncFailCategoryItemsInner](docs/SyncFailCategoryItemsInner.md) - - [SyncFailCategoryItemsInnerModifierGroupsInner](docs/SyncFailCategoryItemsInnerModifierGroupsInner.md) - - [SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner](docs/SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.md) - - [SyncFailServiceHours](docs/SyncFailServiceHours.md) - [UnbindMembershipNativeRequest](docs/UnbindMembershipNativeRequest.md) - [UnlinkMembershipWebviewRequest](docs/UnlinkMembershipWebviewRequest.md) + - [UpdateAdvancedPricing](docs/UpdateAdvancedPricing.md) - [UpdateCampaignRequest](docs/UpdateCampaignRequest.md) - [UpdateDeliveryHourRequest](docs/UpdateDeliveryHourRequest.md) - [UpdateDeliveryHourResponse](docs/UpdateDeliveryHourResponse.md) - [UpdateDineInHourRequest](docs/UpdateDineInHourRequest.md) - [UpdateDineInHourResponse](docs/UpdateDineInHourResponse.md) - [UpdateMenuItem](docs/UpdateMenuItem.md) - - [UpdateMenuItemAdvancedPricingsInner](docs/UpdateMenuItemAdvancedPricingsInner.md) - - [UpdateMenuItemPurchasabilitiesInner](docs/UpdateMenuItemPurchasabilitiesInner.md) - [UpdateMenuModifier](docs/UpdateMenuModifier.md) - - [UpdateMenuNotiRequest](docs/UpdateMenuNotiRequest.md) + - [UpdateMenuNotifRequest](docs/UpdateMenuNotifRequest.md) - [UpdateMenuRequest](docs/UpdateMenuRequest.md) + - [UpdatePurchasability](docs/UpdatePurchasability.md) - [UpdateSpecialHourRequest](docs/UpdateSpecialHourRequest.md) - [UpdateSpecialHourResponse](docs/UpdateSpecialHourResponse.md) - [Voucher](docs/Voucher.md) - [VoucherDescriptionInfo](docs/VoucherDescriptionInfo.md) - [WorkingHour](docs/WorkingHour.md) - - [WorkingHourFri](docs/WorkingHourFri.md) - - [WorkingHourMon](docs/WorkingHourMon.md) - - [WorkingHourSat](docs/WorkingHourSat.md) - - [WorkingHourSun](docs/WorkingHourSun.md) - - [WorkingHourThu](docs/WorkingHourThu.md) - - [WorkingHourTue](docs/WorkingHourTue.md) - - [WorkingHourWed](docs/WorkingHourWed.md) + - [WorkingHourDay](docs/WorkingHourDay.md) ## Recommendation diff --git a/api/openapi.yaml b/api/openapi.yaml index 410709e..1603b6e 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -428,7 +428,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/StoreHour-StatusError' + $ref: '#/components/schemas/Error' description: All other unexpected errors. summary: Get Store Status tags: @@ -476,7 +476,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/StoreHour-StatusError' + $ref: '#/components/schemas/Error' description: All other unexpected errors. summary: Get Store Hours tags: @@ -666,7 +666,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/BatchUpdateMenuErrorMessage' + $ref: '#/components/schemas/BatchUpdateMenuResponse' description: The API request is successfully processed. Refer to status and errors for more info. "400": @@ -752,7 +752,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/UpdateMenuNotiRequest' + $ref: '#/components/schemas/UpdateMenuNotifRequest' description: "" required: true responses: @@ -811,14 +811,14 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/MenuSyncSuccess' - description: Sync success + $ref: '#/components/schemas/MenuSyncResponse' + description: Sync success or fail "4xx": content: application/json: schema: - $ref: '#/components/schemas/MenuSyncFail' - description: Sync fail + $ref: '#/components/schemas/Error' + description: Common error summary: Trace menu sync tags: - trace-menu-sync @@ -981,7 +981,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CancelOrderFail' + $ref: '#/components/schemas/Error' description: "invalid_argument Fail example with code and reason.\n| Code\ \ | Reason | Message |\n| ------| ------| ------ |\n| 400 | invalid_argument\ \ | nothing changed |\n| 400 | invalid_argument | can't remove all items\ @@ -1068,7 +1068,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/MarkOrderFail' + $ref: '#/components/schemas/Error' description: "invalid_argument\n| Code | Reason | Message |\n| ----- | ------\ \ | ------- |\n| 400 | invalid_argument | invalid order state |\n| 400\ \ | invalid_argument\t| order already marked ready|\n| 400 | invalid_argument\ @@ -1177,7 +1177,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/NewReadyTimeFail' + $ref: '#/components/schemas/Error' description: | invalid_argument | Code | Reason | Message | @@ -1288,13 +1288,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CancelOrderFail' + $ref: '#/components/schemas/Error' description: invalid_argument "403": content: application/json: schema: - $ref: '#/components/schemas/CancelOrderFail-403' + $ref: '#/components/schemas/Error' description: | This request is forbidden. @@ -1317,19 +1317,19 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error-404' + $ref: '#/components/schemas/Error' description: not_found "409": content: application/json: schema: - $ref: '#/components/schemas/Error-409' + $ref: '#/components/schemas/Error' description: conflict "500": content: application/json: schema: - $ref: '#/components/schemas/Error-500' + $ref: '#/components/schemas/Error' description: | 5XX error codes are rare and indicate that GrabFood is facing an internal server error. This type of error is applicable to all HTTP response codes in the 500 range, e.g. 500, 504. Retry the operation at a later time with a unique ID. Use an exponential backoff retry mechanism to resend the requests at an increasingly slower interval. It is also a good practice to use a randomized delay (jitter) in your retry schedule. @@ -1484,7 +1484,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CreateCampaignFail' + $ref: '#/components/schemas/Error' description: | invalid_argument | Code | Reason | Message | @@ -1635,7 +1635,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/DineInVoucher400Fail' + $ref: '#/components/schemas/Error' description: "invalid_argument\n| Code | Reason | Message \ \ | Description \ \ | \n| ----\ @@ -1649,7 +1649,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/DineInVoucher404Fail' + $ref: '#/components/schemas/Error' description: "not_found\n| Code | Reason | Message \ \ | Description \ \ | \n| -----| ----------- | ----------------------------\ @@ -1710,7 +1710,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/DineInVoucher400Fail' + $ref: '#/components/schemas/Error' description: "invalid_argument\n| Code | Reason | Message \ \ | Description \ \ \ @@ -1726,7 +1726,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/DineInVoucher404Fail' + $ref: '#/components/schemas/Error' description: "not_found\n| Code | Reason | Message \ \ | Description \ \ | \n| -----| ----------- | ----------------------------\ @@ -1740,7 +1740,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/redeem_dinein_voucher_500_response' + $ref: '#/components/schemas/Error' description: "internal\n| Code | Reason | Message \ \ | Description \ \ | \n| -----| ----------- | ----------------------------\ @@ -1927,7 +1927,7 @@ components: description: "An array of sellingTimes JSON objects. Max 20 allowed. Refer\ \ to [Selling Times](#selling-times) for more information." items: - $ref: '#/components/schemas/sellingTimes_inner' + $ref: '#/components/schemas/SellingTime' required: - endTime - id @@ -1940,7 +1940,7 @@ components: description: "An array of category JSON objects. Max 100 allowed per section.\ \ Refer to [Categories](#categories) for more information." items: - $ref: '#/components/schemas/categories_inner' + $ref: '#/components/schemas/MenuCategory' title: categories type: array required: @@ -1968,7 +1968,7 @@ components: description: "An array of section JSON objects. Max 7 allowed. Refer to\ \ [Sections](#sections) for more information." items: - $ref: '#/components/schemas/sections_inner' + $ref: '#/components/schemas/MenuSection' title: sections type: array required: @@ -2208,7 +2208,6 @@ components: orderTime: description: "The UTC time that a consumer places the order, based on ISO_8601/RFC3339." example: 2019-05-24T05:06:00Z - format: date-time type: string submitTime: description: "The order submit time, based on ISO_8601/RFC3339. Only present\ @@ -2226,7 +2225,6 @@ components: description: "The order scheduled time, based on ISO_8601/RFC3339. Empty\ \ for non-scheduled orders." example: 2019-05-24T08:26:00Z - format: date-time type: string orderState: description: "The state of the order. Only present in the [List Orders](#tag/list-order)\ @@ -2236,19 +2234,19 @@ components: currency: $ref: '#/components/schemas/currency' featureFlags: - $ref: '#/components/schemas/featureFlags' + $ref: '#/components/schemas/orderFeatureFlags' items: description: "The items in an array of JSON Object. Refer to [Items](#items)\ \ for more information." items: - $ref: '#/components/schemas/orderItems_inner' + $ref: '#/components/schemas/OrderItem' title: orderItems type: array campaigns: description: | The campaigns that are applicable for the order.`null` when there is no campaign applied. items: - $ref: '#/components/schemas/orderCampaigns_inner' + $ref: '#/components/schemas/OrderCampaign' nullable: true title: campaigns type: array @@ -2256,7 +2254,7 @@ components: description: An array of promotion objects. Only promotions that are funded by merchants will be sent. items: - $ref: '#/components/schemas/promos_inner' + $ref: '#/components/schemas/OrderPromo' title: promos type: array price: @@ -2482,7 +2480,7 @@ components: type: string items: items: - $ref: '#/components/schemas/GetRewardNativeRequest_items_inner' + $ref: '#/components/schemas/RewardItem' type: array orderValue: description: The post-discount order value. @@ -2535,6 +2533,8 @@ components: items: $ref: '#/components/schemas/specialOpeningHour' type: array + required: + - specialOpeningHours title: UpdateSpecialHourRequest type: object UpdateSpecialHourResponse: @@ -2762,19 +2762,23 @@ components: - isOpen title: StoreStatusResponse type: object - StoreHour-StatusError: - description: Example error returned for invalid request + Error: example: - reason: not_found - message: failed to get store info + reason: error_reason + message: error detail + target: "" properties: + target: + description: Target of error + example: "" + type: string reason: - description: Reason of invalid request. - example: not_found + description: The type of error. + example: error_reason type: string message: - description: Readable error message. - example: failed to get store info + description: The details of the error. + example: error detail type: string title: Error type: object @@ -2990,13 +2994,13 @@ components: description: | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. items: - $ref: '#/components/schemas/UpdateMenuItem_advancedPricings_inner' + $ref: '#/components/schemas/UpdateAdvancedPricing' type: array purchasabilities: description: | Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. items: - $ref: '#/components/schemas/UpdateMenuItem_purchasabilities_inner' + $ref: '#/components/schemas/UpdatePurchasability' type: array required: - field @@ -3053,7 +3057,7 @@ components: description: | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. items: - $ref: '#/components/schemas/UpdateMenuItem_advancedPricings_inner' + $ref: '#/components/schemas/UpdateAdvancedPricing' type: array required: - field @@ -3113,14 +3117,14 @@ components: description: | The items in an array of JSON Object. items: - $ref: '#/components/schemas/BatchUpdateMenuItem_menuEntities_inner' + $ref: '#/components/schemas/MenuEntity' type: array required: - field - merchantID title: Batch Update Item type: object - BatchUpdateMenuErrorMessage: + BatchUpdateMenuResponse: example: merchantID: 1-CYNGRUNGSBCCC errors: @@ -3147,12 +3151,12 @@ components: description: The error messages when batch update menu record was partial success/fail. `null` when the request was success. items: - $ref: '#/components/schemas/BatchUpdateMenuErrorMessage_errors_inner' + $ref: '#/components/schemas/MenuEntityError' nullable: true type: array title: Batch Update Menu Record Response type: object - UpdateMenuNotiRequest: + UpdateMenuNotifRequest: description: | This request notifies GrabFood about the partner's updated food menu. example: @@ -3165,9 +3169,9 @@ components: type: string required: - merchantID - title: UpdateMenuNotiRequest + title: UpdateMenuNotifRequest type: object - MenuSyncSuccess: + MenuSyncResponse: description: "" example: updatedTime: 2020-07-09T09:54:01.423512013Z @@ -3494,7 +3498,7 @@ components: example: null sections: items: - $ref: '#/components/schemas/syncFail' + $ref: '#/components/schemas/menuSyncFail' nullable: true type: array example: null @@ -3504,333 +3508,6 @@ components: - updatedTime title: MenuSyncSuccess type: object - MenuSyncFail: - description: "" - example: - updatedTime: 2020-07-09T09:54:01.423512013Z - code: Failed - createdTime: 2020-07-09T09:53:59.783632615Z - errors: - - error message 1 - - error message 1 - sections: - - serviceHours: - errors: - - error 1 - - error 1 - id: section_externalID1 - categories: - - id: category_externalID1 - items: - - id: item_externalID1 - errors: - - error 1 - - error 1 - modifierGroups: - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: item_externalID1 - errors: - - error 1 - - error 1 - modifierGroups: - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - errors: - - error 2 - - error 2 - - id: category_externalID1 - items: - - id: item_externalID1 - errors: - - error 1 - - error 1 - modifierGroups: - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: item_externalID1 - errors: - - error 1 - - error 1 - modifierGroups: - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - errors: - - error 2 - - error 2 - errors: - - error 1 - - error 1 - - serviceHours: - errors: - - error 1 - - error 1 - id: section_externalID1 - categories: - - id: category_externalID1 - items: - - id: item_externalID1 - errors: - - error 1 - - error 1 - modifierGroups: - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: item_externalID1 - errors: - - error 1 - - error 1 - modifierGroups: - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - errors: - - error 2 - - error 2 - - id: category_externalID1 - items: - - id: item_externalID1 - errors: - - error 1 - - error 1 - modifierGroups: - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: item_externalID1 - errors: - - error 1 - - error 1 - modifierGroups: - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - - id: modifierGroup_externalID1 - modifiers: - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - - id: modifier_externalID1 - errors: - - error 1 - - error 1 - errors: - - error 2 - - error 2 - errors: - - error 2 - - error 2 - errors: - - error 1 - - error 1 - properties: - createdTime: - description: The Unix time the specified menu was created in GrabFood's - database. - example: 2020-07-09T09:53:59.783632615Z - format: date-time - type: string - updatedTime: - description: The Unix time the specified menu was created in GrabFood's - database. - example: 2020-07-09T09:54:01.423512013Z - format: date-time - type: string - code: - description: "The status code for this request. See [Menu sync response\ - \ statuses](#section/Menu-sync-response-statuses) for more information." - enum: - - Failed - type: string - errors: - description: An array of strings of error message. - items: - example: error message 1 - type: string - type: array - sections: - items: - $ref: '#/components/schemas/syncFail' - type: array - title: MenuSyncFail - type: object AcceptOrderRequest: description: | The manual acceptance or rejection of an order on GrabFood. @@ -4158,7 +3835,7 @@ components: type: boolean orders: items: - $ref: '#/components/schemas/orders' + $ref: '#/components/schemas/order' type: array title: ListOrdersResponse type: object @@ -4194,7 +3871,7 @@ components: description: "Specify the array of all items in the order, including deleted,\ \ added, updated and unchanged items." items: - $ref: '#/components/schemas/EditOrderRequest_items_inner' + $ref: '#/components/schemas/EditOrderItem' type: array onlyRecalculate: description: | @@ -4206,27 +3883,6 @@ components: - orderID title: EditOrderRequest type: object - CancelOrderFail: - description: "" - example: - reason: error_reason - message: error_detail - target: "" - properties: - target: - description: Target of error - example: "" - type: string - reason: - description: The type of error. - example: error_reason - type: string - message: - description: The details of the error. - example: error_detail - type: string - title: CancelOrderFail - type: object MarkOrderRequest: description: | This request marks an order as ready for delivery or completed on GrabFood. @@ -4253,27 +3909,6 @@ components: - orderID title: MarkOrderRequest type: object - MarkOrderFail: - description: "" - example: - reason: invalid_argument - message: invalid order state - target: "" - properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: invalid_argument - type: string - message: - description: The details of the error. - example: invalid order state - type: string - title: MarkOrderFail - type: object OrderDeliveryRequest: description: | This request marks an order as delivered on GrabFood. @@ -4333,27 +3968,6 @@ components: - orderID title: NewOrderTimeRequest type: object - NewReadyTimeFail: - description: "" - example: - reason: invalid_argument - message: invalid new order ready time - target: "" - properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: invalid_argument - type: string - message: - description: The details of the error. - example: invalid new order ready time - type: string - title: NewReadyTimeFail - type: object CheckOrderCancelableResponse: description: "" example: @@ -4389,17 +4003,17 @@ components: type: string example: null limitType: - $ref: '#/components/schemas/limitType' + $ref: '#/components/schemas/cancelOrderLimitType' limitTimes: description: "The remaining cancellation quota for the merchant. A value\ \ is only returned when the nearest remaining cancellation limit is approaching,\ \ else it returns 0." - title: limitTimes + title: cancelOrderLimitTimes type: integer cancelReasons: description: An array of cancel order reasons JSON objects. items: - $ref: '#/components/schemas/cancelReasons_inner' + $ref: '#/components/schemas/CancelReason' title: cancelReasons type: array title: CheckOrderCancelableResponse @@ -4423,118 +4037,29 @@ components: example: 1-CYNGRUNGSBCCC title: merchantID type: string - cancelCode: - $ref: '#/components/schemas/cancelCode' - required: - - cancelCode - - merchantID - - orderID - title: CancelOrderRequest - type: object - CancelOrderResponse: - description: "" - example: - limitTimes: 0 - limitType: not approaching limit - properties: - limitType: - $ref: '#/components/schemas/limitType' - limitTimes: - description: "The remaining cancellation quota for the merchant. A value\ - \ is only returned when the nearest remaining cancellation limit is approaching,\ - \ else it returns 0." - title: limitTimes - type: integer - title: CancelOrderResponse - type: object - CancelOrderFail-403: - description: "" - example: - reason: forbidden - message: Order cannot be cancelled via this endpoint as the order has not - been allocated yet. Please contact Grab Support for further assistance. - target: "" - properties: - target: - description: Target of error - example: "" - type: string - reason: - description: The type of error. - example: forbidden - type: string - message: - description: The details of the error. - example: Order cannot be cancelled via this endpoint as the order has not - been allocated yet. Please contact Grab Support for further assistance. - type: string - title: CancelOrderFail-403 - type: object - Error-404: - description: The specified resource does not exist. - example: - reason: not_found - message: Order not found. - target: "" - properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: not_found - type: string - message: - description: The details of the error. - example: Order not found. - type: string - title: Error - type: object - Error-409: - description: "Common error, probably due to a process failure. The reason for\ - \ the failure is usually indicated in the response." - example: - reason: conflict - message: The current status of the order does not allow cancellation. - target: "" - properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: conflict - type: string - message: - description: The details of the error. - example: The current status of the order does not allow cancellation. - type: string - title: Error + cancelCode: + $ref: '#/components/schemas/cancelCode' + required: + - cancelCode + - merchantID + - orderID + title: CancelOrderRequest type: object - Error-500: - description: "A system or application error occurred. Although the client appears\ - \ to provide a correct request, there may be something unexpected on the server.\ - \ You may retry the request in this case." + CancelOrderResponse: + description: "" example: - reason: conflict - message: Cancel order failed - target: "" + limitTimes: 0 + limitType: not approaching limit properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: conflict - type: string - message: - description: The details of the error. - example: Cancel order failed - type: string - title: Error + limitType: + $ref: '#/components/schemas/cancelOrderLimitType' + limitTimes: + description: "The remaining cancellation quota for the merchant. A value\ + \ is only returned when the nearest remaining cancellation limit is approaching,\ + \ else it returns 0." + title: cancelOrderLimitTimes + type: integer + title: CancelOrderResponse type: object PauseStoreRequest: description: | @@ -4836,11 +4361,11 @@ components: properties: ongoing: items: - $ref: '#/components/schemas/campaigns' + $ref: '#/components/schemas/campaign' type: array upcoming: items: - $ref: '#/components/schemas/campaigns' + $ref: '#/components/schemas/campaign' type: array title: ListCampaignResponse type: object @@ -4924,11 +4449,11 @@ components: title: name type: string quotas: - $ref: '#/components/schemas/quotas' + $ref: '#/components/schemas/campaignQuotas' conditions: - $ref: '#/components/schemas/conditions' + $ref: '#/components/schemas/campaignConditions' discount: - $ref: '#/components/schemas/discount' + $ref: '#/components/schemas/campaignDiscount' customTag: description: Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. @@ -4955,27 +4480,6 @@ components: type: string title: CreateCampaignResponse type: object - CreateCampaignFail: - description: "" - example: - reason: invalid_argument - message: items not found - target: "" - properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: invalid_argument - type: string - message: - description: The details of the error. - example: items not found - type: string - title: CreateCampaignFail - type: object campaignId: description: The campaign's ID. example: 4-CY4VMFMANYBYJ6-CZNZFFL1G8KKLX-94794295 @@ -5061,11 +4565,11 @@ components: title: name type: string quotas: - $ref: '#/components/schemas/quotas' + $ref: '#/components/schemas/campaignQuotas' conditions: - $ref: '#/components/schemas/conditions' + $ref: '#/components/schemas/campaignConditions' discount: - $ref: '#/components/schemas/discount' + $ref: '#/components/schemas/campaignDiscount' customTag: description: Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. @@ -5144,48 +4648,6 @@ components: type: string title: GetDineInVoucherResponse type: object - DineInVoucher400Fail: - description: The failed example with code and reason. - example: - reason: invalid_argument - message: invalid certificateID - target: "" - properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: invalid_argument - type: string - message: - description: The details of the error. - example: invalid certificateID - type: string - title: 400 Error - type: object - DineInVoucher404Fail: - description: The specified resource does not exist. - example: - reason: not_found - message: voucher not found - target: "" - properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: not_found - type: string - message: - description: The details of the error. - example: voucher not found - type: string - title: 404 Error - type: object RedeemDineInVoucherRequest: description: | Dine in voucher redemption @@ -5286,7 +4748,7 @@ components: type: string title: Register Membership Request type: object - orders: + order: description: | A JSON object containing the order information. example: @@ -5469,7 +4931,6 @@ components: orderTime: description: "The UTC time that a consumer places the order, based on ISO_8601/RFC3339." example: 2019-05-24T05:06:00Z - format: date-time type: string submitTime: description: "The order submit time, based on ISO_8601/RFC3339. Only present\ @@ -5487,7 +4948,6 @@ components: description: "The order scheduled time, based on ISO_8601/RFC3339. Empty\ \ for non-scheduled orders." example: 2019-05-24T08:26:00Z - format: date-time type: string orderState: description: "The state of the order. Only present in the [List Orders](#tag/list-order)\ @@ -5497,19 +4957,19 @@ components: currency: $ref: '#/components/schemas/currency' featureFlags: - $ref: '#/components/schemas/featureFlags' + $ref: '#/components/schemas/orderFeatureFlags' items: description: "The items in an array of JSON Object. Refer to [Items](#items)\ \ for more information." items: - $ref: '#/components/schemas/orderItems_inner' + $ref: '#/components/schemas/OrderItem' title: orderItems type: array campaigns: description: | The campaigns that are applicable for the order.`null` when there is no campaign applied. items: - $ref: '#/components/schemas/orderCampaigns_inner' + $ref: '#/components/schemas/OrderCampaign' nullable: true title: campaigns type: array @@ -5517,7 +4977,7 @@ components: description: An array of promotion objects. Only promotions that are funded by merchants will be sent. items: - $ref: '#/components/schemas/promos_inner' + $ref: '#/components/schemas/OrderPromo' title: promos type: array price: @@ -5664,7 +5124,7 @@ components: - wed title: storeHour type: object - syncFail: + menuSyncFail: example: serviceHours: errors: @@ -5820,13 +5280,13 @@ components: type: string type: array serviceHours: - $ref: '#/components/schemas/syncFail_serviceHours' + $ref: '#/components/schemas/menuSyncFail_serviceHours' categories: items: - $ref: '#/components/schemas/syncFail_categories_inner' + $ref: '#/components/schemas/MenuSyncFailCategory' type: array type: object - limitType: + cancelOrderLimitType: description: The type of the order cancellation limit. enum: - not approaching limit @@ -5834,18 +5294,18 @@ components: - approaching the weekly limit - approaching the monthly limit - "" - title: limitType + title: cancelOrderLimitType type: string - limitTimes: + cancelOrderLimitTimes: description: "The remaining cancellation quota for the merchant. A value is\ \ only returned when the nearest remaining cancellation limit is approaching,\ \ else it returns 0." - title: limitTimes + title: cancelOrderLimitTimes type: integer cancelReasons: description: An array of cancel order reasons JSON objects. items: - $ref: '#/components/schemas/cancelReasons_inner' + $ref: '#/components/schemas/CancelReason' title: cancelReasons type: array cancelCode: @@ -5857,7 +5317,7 @@ components: - 1004 title: cancelCode type: integer - campaigns: + campaign: description: A JSON object containing the campaign details for a merchant. Only campaigns that are funded by merchants will be sent. example: @@ -5953,11 +5413,11 @@ components: title: name type: string quotas: - $ref: '#/components/schemas/quotas' + $ref: '#/components/schemas/campaignQuotas' conditions: - $ref: '#/components/schemas/conditions' + $ref: '#/components/schemas/campaignConditions' discount: - $ref: '#/components/schemas/discount' + $ref: '#/components/schemas/campaignDiscount' customTag: description: Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. @@ -5970,14 +5430,14 @@ components: - id - merchantID - name - title: campaigns + title: campaign type: object campaignName: description: The campaign's name. example: $4 off with min $10 order for all users within weekday title: name type: string - quotas: + campaignQuotas: description: The quotas/limits for a particular campaign. example: totalCountPerUser: 2 @@ -5993,9 +5453,9 @@ components: if unspecified. example: 2 type: integer - title: quotas + title: campaignQuotas type: object - conditions: + campaignConditions: description: The conditions to apply to a campaign. example: eaterType: all @@ -6084,9 +5544,9 @@ components: - eaterType - endTime - startTime - title: conditions + title: campaignConditions type: object - discount: + campaignDiscount: description: The discount detail for a particular campaign when conditions are satisfied. example: @@ -6140,11 +5600,11 @@ components: format: double type: number scope: - $ref: '#/components/schemas/scope' + $ref: '#/components/schemas/campaignScope' required: - scope - type - title: discount + title: campaignDiscount type: object customTag: description: Specify the tag for custom bundle offer campaign. Only whitelisted @@ -6274,7 +5734,7 @@ components: description: "An array of sellingTimes JSON objects. Max 20 allowed. Refer to\ \ [Selling Times](#selling-times) for more information." items: - $ref: '#/components/schemas/sellingTimes_inner' + $ref: '#/components/schemas/SellingTime' required: - endTime - id @@ -6287,17 +5747,17 @@ components: description: "An array of category JSON objects. Max 100 allowed per section.\ \ Refer to [Categories](#categories) for more information." items: - $ref: '#/components/schemas/categories_inner' + $ref: '#/components/schemas/MenuCategory' title: categories type: array sections: description: "An array of section JSON objects. Max 7 allowed. Refer to [Sections](#sections)\ \ for more information." items: - $ref: '#/components/schemas/sections_inner' + $ref: '#/components/schemas/MenuSection' title: sections type: array - featureFlags: + orderFeatureFlags: description: The featureFlag JSON object containing an order's feature related information. example: @@ -6330,20 +5790,20 @@ components: required: - orderAcceptedType - orderType - title: featureFlags + title: orderFeatureFlags type: object orderItems: description: "The items in an array of JSON Object. Refer to [Items](#items)\ \ for more information." items: - $ref: '#/components/schemas/orderItems_inner' + $ref: '#/components/schemas/OrderItem' title: orderItems type: array orderCampaigns: description: | The campaigns that are applicable for the order.`null` when there is no campaign applied. items: - $ref: '#/components/schemas/orderCampaigns_inner' + $ref: '#/components/schemas/OrderCampaign' nullable: true title: campaigns type: array @@ -6351,7 +5811,7 @@ components: description: An array of promotion objects. Only promotions that are funded by merchants will be sent. items: - $ref: '#/components/schemas/promos_inner' + $ref: '#/components/schemas/OrderPromo' title: promos type: array orderPrice: @@ -6560,22 +6020,22 @@ components: endTime: 21:30 properties: sun: - $ref: '#/components/schemas/workingHour_sun' + $ref: '#/components/schemas/workingHourDay' mon: - $ref: '#/components/schemas/workingHour_mon' + $ref: '#/components/schemas/workingHourDay' tue: - $ref: '#/components/schemas/workingHour_tue' + $ref: '#/components/schemas/workingHourDay' wed: - $ref: '#/components/schemas/workingHour_wed' + $ref: '#/components/schemas/workingHourDay' thu: - $ref: '#/components/schemas/workingHour_thu' + $ref: '#/components/schemas/workingHourDay' fri: - $ref: '#/components/schemas/workingHour_fri' + $ref: '#/components/schemas/workingHourDay' sat: - $ref: '#/components/schemas/workingHour_sat' + $ref: '#/components/schemas/workingHourDay' title: workingHour type: object - scope: + campaignScope: description: The scope level for a particular campaign. example: type: items @@ -6613,25 +6073,25 @@ components: type: array required: - type - title: scope + title: campaignScope type: object serviceHours: description: A JSON object with serviceHours for each day of the week. properties: mon: - $ref: '#/components/schemas/dayHours' + $ref: '#/components/schemas/serviceHour' tue: - $ref: '#/components/schemas/dayHours' + $ref: '#/components/schemas/serviceHour' wed: - $ref: '#/components/schemas/dayHours' + $ref: '#/components/schemas/serviceHour' thu: - $ref: '#/components/schemas/dayHours' + $ref: '#/components/schemas/serviceHour' fri: - $ref: '#/components/schemas/dayHours' + $ref: '#/components/schemas/serviceHour' sat: - $ref: '#/components/schemas/dayHours' + $ref: '#/components/schemas/serviceHour' sun: - $ref: '#/components/schemas/dayHours' + $ref: '#/components/schemas/serviceHour' required: - fri - mon @@ -6642,11 +6102,17 @@ components: - wed title: serviceHours type: object + menuTranslation: + description: | + The translated name or description. The property key represents the language code (e.g., `en`, `th`, `ms`, `zh`, `vi`, `id`, `km`, `my`), and the value is the translated text. \ + Example: { "en": "english translation" } + example: translation + type: string menuItems: description: "An array of item JSON objects. Max 300 allowed per category. Refer\ \ to [Items](#items) for more information." items: - $ref: '#/components/schemas/menuItems_inner' + $ref: '#/components/schemas/MenuItem' title: menuItems type: array advancedPricing: @@ -6713,7 +6179,7 @@ components: description: "An array of the modifierGroup JSON objects. Max 30 allowed per\ \ item. Refer to [Modifier groups](#modifier-groups) for more information." items: - $ref: '#/components/schemas/modifierGroups_inner' + $ref: '#/components/schemas/ModifierGroup' title: modifierGroups type: array outOfStockInstruction: @@ -6757,7 +6223,7 @@ components: description: "An array of JSON objects modifiers. Read [this](#categories) for\ \ more information." items: - $ref: '#/components/schemas/orderModifiers_inner' + $ref: '#/components/schemas/OrderItemModifier' required: - id - price @@ -6765,7 +6231,7 @@ components: - tax title: modifiers type: array - freeItem: + orderFreeItem: description: Free item information for `freeItem` campaign. example: quantity: 1 @@ -6790,7 +6256,7 @@ components: description: The item's price in minor unit format. example: 10 type: integer - title: freeItem + title: orderFreeItem type: object address: description: A JSON object containing the receiver’s location information. @@ -6836,16 +6302,26 @@ components: $ref: '#/components/schemas/coordinates' title: address type: object - campaignPeriods: - description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ - \ response if the campaign is available all day." - items: - $ref: '#/components/schemas/openPeriod' - nullable: true - title: periods - type: array - dayHours: - description: A JSON object serviceHours for each day. + workingHourDay: + description: A JSON object for workingHour for a day. + example: + periods: + - startTime: 11:30 + endTime: 21:30 + - startTime: 11:30 + endTime: 21:30 + properties: + periods: + description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ + \ response if the campaign is available all day." + items: + $ref: '#/components/schemas/openPeriod' + nullable: true + title: periods + type: array + type: object + serviceHour: + description: A JSON object serviceHour for each day. properties: openPeriodType: description: | @@ -6871,14 +6347,13 @@ components: type: array required: - openPeriodType - - periods - title: dayHours + title: serviceHour type: object menuModifiers: description: "An array of modifier JSON objects. Max 100 per modifierGroup.\ \ Refer to [Modifiers](#modifiers) for more information." items: - $ref: '#/components/schemas/menuModifiers_inner' + $ref: '#/components/schemas/MenuModifier' title: modifiers type: array coordinates: @@ -6900,6 +6375,14 @@ components: type: number title: coordinates type: object + campaignPeriods: + description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ + \ response if the campaign is available all day." + items: + $ref: '#/components/schemas/openPeriod' + nullable: true + title: periods + type: array periods: description: An array of open periods. Only required when `openPeriodType` is **OpenPeriod** @@ -6914,25 +6397,6 @@ components: oneOf: - $ref: '#/components/schemas/UpdateMenuItem' - $ref: '#/components/schemas/UpdateMenuModifier' - redeem_dinein_voucher_500_response: - example: - reason: conflict - message: redeem failed - target: "" - properties: - target: - description: The target of error. - example: "" - type: string - reason: - description: The type of error. - example: conflict - type: string - message: - description: The details of the error. - example: redeem failed - type: string - type: object GetMembershipNativeResponse_pointInfo: description: Obtain contains user's point details. properties: @@ -6949,7 +6413,7 @@ components: example: 20 type: integer type: object - GetRewardNativeRequest_items_inner: + RewardItem: properties: itemID: description: The item's ID in partner system. @@ -6959,8 +6423,9 @@ components: description: The item's quantity. example: 1 type: integer + title: RewardItem type: object - UpdateMenuItem_advancedPricings_inner: + UpdateAdvancedPricing: example: price: 100 key: Delivery_OnDemand_GrabApp @@ -6981,8 +6446,9 @@ components: description: Price in minor unit. example: 100 type: integer + title: UpdateAdvancedPricing type: object - UpdateMenuItem_purchasabilities_inner: + UpdatePurchasability: example: purchasable: true key: Delivery_OnDemand_GrabApp @@ -7001,8 +6467,9 @@ components: type: string purchasable: type: boolean + title: UpdatePurchasability type: object - BatchUpdateMenuItem_menuEntities_inner: + MenuEntity: example: availableStatus: AVAILABLE advancedPricings: @@ -7049,16 +6516,17 @@ components: description: | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. items: - $ref: '#/components/schemas/UpdateMenuItem_advancedPricings_inner' + $ref: '#/components/schemas/UpdateAdvancedPricing' type: array purchasabilities: description: | Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. items: - $ref: '#/components/schemas/UpdateMenuItem_purchasabilities_inner' + $ref: '#/components/schemas/UpdatePurchasability' type: array + title: MenuEntity type: object - BatchUpdateMenuErrorMessage_errors_inner: + MenuEntityError: example: errMsg: get food item fail entityID: ITEM-1 @@ -7071,8 +6539,9 @@ components: description: The error message. example: get food item fail type: string + title: MenuEntityError type: object - EditOrderRequest_items_inner: + EditOrderItem: example: isExternalItemID: false itemID: IDGFSTI000004qy1490868132306763533 @@ -7115,6 +6584,7 @@ components: required: - itemID - status + title: EditOrderItem type: object specialOpeningHour_metadata: description: Contains special opening hour info. @@ -7150,7 +6620,7 @@ components: $ref: '#/components/schemas/openPeriod' type: array type: object - syncFail_serviceHours: + menuSyncFail_serviceHours: example: errors: - error 1 @@ -7163,7 +6633,7 @@ components: type: string type: array type: object - syncFailCategoryItems_inner_modifierGroups_inner_modifiers_inner: + MenuSyncFailModifier: example: id: modifier_externalID1 errors: @@ -7179,8 +6649,9 @@ components: example: error 1 type: string type: array + title: MenuSyncFailModifier type: object - syncFailCategoryItems_inner_modifierGroups_inner: + MenuSyncFailModifierGroup: example: id: modifierGroup_externalID1 modifiers: @@ -7207,10 +6678,11 @@ components: type: array modifiers: items: - $ref: '#/components/schemas/syncFailCategoryItems_inner_modifierGroups_inner_modifiers_inner' + $ref: '#/components/schemas/MenuSyncFailModifier' type: array + title: MenuSyncFailModifierGroup type: object - syncFailCategoryItems_inner: + MenuSyncFailItem: example: id: item_externalID1 errors: @@ -7258,10 +6730,11 @@ components: type: array modifierGroups: items: - $ref: '#/components/schemas/syncFailCategoryItems_inner_modifierGroups_inner' + $ref: '#/components/schemas/MenuSyncFailModifierGroup' type: array + title: MenuSyncFailItem type: object - syncFail_categories_inner: + MenuSyncFailCategory: example: id: category_externalID1 items: @@ -7347,11 +6820,12 @@ components: description: "An array of item JSON objects. Max 300 allowed per category.\ \ Refer to [Items](#items) for more information." items: - $ref: '#/components/schemas/syncFailCategoryItems_inner' + $ref: '#/components/schemas/MenuSyncFailItem' title: syncFailCategoryItems type: array + title: MenuSyncFailCategory type: object - cancelReasons_inner: + CancelReason: example: reason: Items are unavailable code: 6 @@ -7367,6 +6841,7 @@ components: - My shop is closing soon example: Items are unavailable type: string + title: CancelReason type: object voucher_descriptionInfo: description: A JSON object containing dine-in voucher's description information. @@ -7378,7 +6853,7 @@ components: example: Dine-in cash voucher for use in a transaction. type: string type: object - sellingTimes_inner: + SellingTime: properties: startTime: description: | @@ -7403,19 +6878,9 @@ components: type: string serviceHours: $ref: '#/components/schemas/serviceHours' + title: SellingTime type: object - categories_inner_nameTranslation: - description: "Translation of the category name. Only support up to 1 translated\ - \ language. Refer [Menu Translation](#section/Menu-Translation)." - properties: - en: - description: | - The English translation of the name. - Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - example: name_translation - type: string - type: object - categories_inner: + MenuCategory: properties: id: description: The category's ID that is on the partner system. This ID should @@ -7429,7 +6894,11 @@ components: maxLength: 60 type: string nameTranslation: - $ref: '#/components/schemas/categories_inner_nameTranslation' + additionalProperties: + $ref: '#/components/schemas/menuTranslation' + description: "Translation of the category name. Only support up to 1 translated\ + \ language. Refer [Menu Translation](#section/Menu-Translation)." + type: object availableStatus: description: "The status for the category. Refer to FAQs for more details\ \ about [availableStatus](#section/Menu/What-is-availableStatus)." @@ -7448,7 +6917,7 @@ components: description: "An array of item JSON objects. Max 300 allowed per category.\ \ Refer to [Items](#items) for more information." items: - $ref: '#/components/schemas/menuItems_inner' + $ref: '#/components/schemas/MenuItem' title: menuItems type: array required: @@ -7457,30 +6926,9 @@ components: - items - name - sellingTimeID + title: MenuCategory type: object - oldMenuSectionCategoryItems_inner_nameTranslation: - description: "Translation of the item name. Only support up to 1 translated\ - \ language. Refer [Menu Translation](#section/Menu-Translation)." - properties: - en: - description: | - The English translation of the name. - Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - example: name_translation - type: string - type: object - oldMenuSectionCategoryItems_inner_descriptionTranslation: - description: "Translation of the item description. Only support up to 1 translated\ - \ language. Refer [Menu Translation](#section/Menu-Translation)." - properties: - en: - description: | - The English translation of the description. - Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my`. - example: description_translation - type: string - type: object - oldMenuSectionCategoryItems_inner: + MenuSectionCategoryItem: properties: id: description: | @@ -7494,7 +6942,11 @@ components: maxLength: 80 type: string nameTranslation: - $ref: '#/components/schemas/oldMenuSectionCategoryItems_inner_nameTranslation' + additionalProperties: + $ref: '#/components/schemas/menuTranslation' + description: "Translation of the item name. Only support up to 1 translated\ + \ language. Refer [Menu Translation](#section/Menu-Translation)." + type: object availableStatus: description: | The status for the item that is in the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). @@ -7515,7 +6967,11 @@ components: maxLength: 300 type: string descriptionTranslation: - $ref: '#/components/schemas/oldMenuSectionCategoryItems_inner_descriptionTranslation' + additionalProperties: + $ref: '#/components/schemas/menuTranslation' + description: "Translation of the item description. Only support up to 1\ + \ translated language. Refer [Menu Translation](#section/Menu-Translation)." + type: object price: description: | The item's price (excluding tax) in minor format. For example: 1900 means $19 with `currency.exponent` as 2. Refer to [FAQ](#section/Menu/Is-the-item-price-with-or-without-tax) for more details. @@ -7562,7 +7018,7 @@ components: description: "An array of the modifierGroup JSON objects. Max 30 allowed\ \ per item. Refer to [Modifier groups](#modifier-groups) for more information." items: - $ref: '#/components/schemas/modifierGroups_inner' + $ref: '#/components/schemas/ModifierGroup' title: modifierGroups type: array required: @@ -7570,8 +7026,9 @@ components: - id - name - price + title: MenuSectionCategoryItem type: object - sections_inner_categories_inner: + MenuSectionCategory: properties: id: description: The category's ID that is on the partner system. This ID should @@ -7585,7 +7042,11 @@ components: maxLength: 60 type: string nameTranslation: - $ref: '#/components/schemas/categories_inner_nameTranslation' + additionalProperties: + $ref: '#/components/schemas/menuTranslation' + description: "Translation of the category name. Only support up to 1 translated\ + \ language. Refer [Menu Translation](#section/Menu-Translation)." + type: object availableStatus: description: "The status for the category. Refer to FAQs for more details\ \ about [availableStatus](#section/Menu/What-is-availableStatus)." @@ -7599,7 +7060,7 @@ components: description: "An array of item JSON objects. Max 300 allowed per category.\ \ Refer to [Items](#items) for more information." items: - $ref: '#/components/schemas/oldMenuSectionCategoryItems_inner' + $ref: '#/components/schemas/MenuSectionCategoryItem' title: oldMenuSectionCategoryItems type: array required: @@ -7607,8 +7068,9 @@ components: - id - items - name + title: MenuSectionCategory type: object - sections_inner: + MenuSection: properties: id: description: | @@ -7627,15 +7089,16 @@ components: description: "An array of category JSON objects. Max 100 allowed per section.\ \ Refer to [Categories](#categories) for more information." items: - $ref: '#/components/schemas/sections_inner_categories_inner' + $ref: '#/components/schemas/MenuSectionCategory' type: array required: - categories - id - name - serviceHours + title: MenuSection type: object - orderItems_inner: + OrderItem: example: quantity: 1 grabItemID: IDGFSTI000004qy1490868132306763533 @@ -7695,7 +7158,7 @@ components: description: "An array of JSON objects modifiers. Read [this](#categories)\ \ for more information." items: - $ref: '#/components/schemas/orderModifiers_inner' + $ref: '#/components/schemas/OrderItemModifier' required: - id - price @@ -7708,8 +7171,9 @@ components: - id - price - quantity + title: OrderItem type: object - orderCampaigns_inner: + OrderCampaign: example: level: item deductedAmount: 475 @@ -7795,9 +7259,10 @@ components: nullable: true type: array freeItem: - $ref: '#/components/schemas/freeItem' + $ref: '#/components/schemas/orderFreeItem' + title: OrderCampaign type: object - promos_inner: + OrderPromo: example: promoAmountInMin: 300 code: promo_code @@ -7842,145 +7307,9 @@ components: description: Promo amount applied in the order in minor unit. example: 300 type: integer + title: OrderPromo type: object - workingHour_sun: - description: A JSON object for workingHour for Sunday. - example: - periods: - - startTime: 11:30 - endTime: 21:30 - - startTime: 11:30 - endTime: 21:30 - properties: - periods: - description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ - \ response if the campaign is available all day." - items: - $ref: '#/components/schemas/openPeriod' - nullable: true - title: periods - type: array - type: object - workingHour_mon: - description: A JSON object for workingHour for Monday. - example: - periods: - - startTime: 11:30 - endTime: 21:30 - - startTime: 11:30 - endTime: 21:30 - properties: - periods: - description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ - \ response if the campaign is available all day." - items: - $ref: '#/components/schemas/openPeriod' - nullable: true - title: periods - type: array - type: object - workingHour_tue: - description: A JSON object for workingHour for Tuesday. - example: - periods: - - startTime: 11:30 - endTime: 21:30 - - startTime: 11:30 - endTime: 21:30 - properties: - periods: - description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ - \ response if the campaign is available all day." - items: - $ref: '#/components/schemas/openPeriod' - nullable: true - title: periods - type: array - type: object - workingHour_wed: - description: A JSON object for workingHour for Wednesday. - example: - periods: - - startTime: 11:30 - endTime: 21:30 - - startTime: 11:30 - endTime: 21:30 - properties: - periods: - description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ - \ response if the campaign is available all day." - items: - $ref: '#/components/schemas/openPeriod' - nullable: true - title: periods - type: array - type: object - workingHour_thu: - description: A JSON object for workingHour for Thursday. - example: - periods: - - startTime: 11:30 - endTime: 21:30 - - startTime: 11:30 - endTime: 21:30 - properties: - periods: - description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ - \ response if the campaign is available all day." - items: - $ref: '#/components/schemas/openPeriod' - nullable: true - title: periods - type: array - type: object - workingHour_fri: - description: A JSON object for workingHour for Friday. - example: - periods: - - startTime: 11:30 - endTime: 21:30 - - startTime: 11:30 - endTime: 21:30 - properties: - periods: - description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ - \ response if the campaign is available all day." - items: - $ref: '#/components/schemas/openPeriod' - nullable: true - title: periods - type: array - type: object - workingHour_sat: - description: A JSON object for workingHour for Saturday. - example: - periods: - - startTime: 11:30 - endTime: 21:30 - - startTime: 11:30 - endTime: 21:30 - properties: - periods: - description: "An array of open periods. `null` in [ListCampaign](#tag/list-campaign)\ - \ response if the campaign is available all day." - items: - $ref: '#/components/schemas/openPeriod' - nullable: true - title: periods - type: array - type: object - menuItems_inner_descriptionTranslation: - description: "Translation of the item description. Only support up to 1 translated\ - \ language. Refer [Menu Translation](#section/Menu-Translation)." - properties: - en: - description: | - The English translation of the description. - Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - example: description_translation - type: string - type: object - menuItems_inner: + MenuItem: properties: id: description: | @@ -7994,7 +7323,11 @@ components: maxLength: 80 type: string nameTranslation: - $ref: '#/components/schemas/oldMenuSectionCategoryItems_inner_nameTranslation' + additionalProperties: + $ref: '#/components/schemas/menuTranslation' + description: "Translation of the item name. Only support up to 1 translated\ + \ language. Refer [Menu Translation](#section/Menu-Translation)." + type: object availableStatus: description: | The status for the item that is in the category. @@ -8015,7 +7348,11 @@ components: maxLength: 300 type: string descriptionTranslation: - $ref: '#/components/schemas/menuItems_inner_descriptionTranslation' + additionalProperties: + $ref: '#/components/schemas/menuTranslation' + description: "Translation of the item description. Only support up to 1\ + \ translated language. Refer [Menu Translation](#section/Menu-Translation)." + type: object price: description: | The item's price (excluding tax) in minor format. For example: 1900 means $19 with `currency.exponent` as 2. Refer to [FAQ](#section/Menu/Is-the-item-price-with-or-without-tax) for more details. @@ -8067,7 +7404,7 @@ components: description: "An array of the modifierGroup JSON objects. Max 30 allowed\ \ per item. Refer to [Modifier groups](#modifier-groups) for more information." items: - $ref: '#/components/schemas/modifierGroups_inner' + $ref: '#/components/schemas/ModifierGroup' title: modifierGroups type: array required: @@ -8075,19 +7412,9 @@ components: - id - name - price + title: MenuItem type: object - modifierGroups_inner_nameTranslation: - description: "Translation of the modifier group name. Only support up to 1 translated\ - \ language. Refer [Menu Translation](#section/Menu-Translation)." - properties: - en: - description: | - The English translation of the name. - Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - example: name_translation - type: string - type: object - modifierGroups_inner: + ModifierGroup: properties: id: description: The ModifierGroup's ID that is on the partner system. This @@ -8102,7 +7429,11 @@ components: maxLength: 50 type: string nameTranslation: - $ref: '#/components/schemas/modifierGroups_inner_nameTranslation' + additionalProperties: + $ref: '#/components/schemas/menuTranslation' + description: "Translation of the modifier group name. Only support up to\ + \ 1 translated language. Refer [Menu Translation](#section/Menu-Translation)." + type: object availableStatus: description: The status for the ModifierGroup that is in the item. enum: @@ -8125,7 +7456,7 @@ components: description: "An array of modifier JSON objects. Max 100 per modifierGroup.\ \ Refer to [Modifiers](#modifiers) for more information." items: - $ref: '#/components/schemas/menuModifiers_inner' + $ref: '#/components/schemas/MenuModifier' title: modifiers type: array required: @@ -8133,8 +7464,9 @@ components: - id - name - selectionRangeMax + title: ModifierGroup type: object - orderModifiers_inner: + OrderItemModifier: example: quantity: 0 price: 175 @@ -8161,19 +7493,9 @@ components: enum: - 1 type: integer + title: OrderItemModifier type: object - menuModifiers_inner_nameTranslation: - description: "Translation of the modifier name. Only support up to 1 translated\ - \ language. Refer [Menu Translation](#section/Menu-Translation)." - properties: - en: - description: | - The English translation of the name. - Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - example: name_translation - type: string - type: object - menuModifiers_inner: + MenuModifier: properties: id: description: The modifier's ID that is on the partner's system. This ID @@ -8187,7 +7509,11 @@ components: maxLength: 40 type: string nameTranslation: - $ref: '#/components/schemas/menuModifiers_inner_nameTranslation' + additionalProperties: + $ref: '#/components/schemas/menuTranslation' + description: "Translation of the modifier name. Only support up to 1 translated\ + \ language. Refer [Menu Translation](#section/Menu-Translation)." + type: object availableStatus: description: The status for the modifier that is in the ModifierGroup. enum: @@ -8213,6 +7539,7 @@ components: - availableStatus - id - name + title: MenuModifier type: object x-tagGroups: - name: Authorisation diff --git a/build.gradle b/build.gradle index 149e6bf..eb275ff 100644 --- a/build.gradle +++ b/build.gradle @@ -112,14 +112,13 @@ dependencies { implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' implementation 'com.google.code.gson:gson:2.9.1' implementation 'io.gsonfire:gson-fire:1.9.0' - implementation 'javax.ws.rs:jsr311-api:1.1.1' - implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' + implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6' implementation 'org.openapitools:jackson-databind-nullable:0.2.6' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' testImplementation 'org.mockito:mockito-core:3.12.4' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' } javadoc { diff --git a/build.sbt b/build.sbt index 212c7ba..775e102 100644 --- a/build.sbt +++ b/build.sbt @@ -14,14 +14,13 @@ lazy val root = (project in file(".")). "com.squareup.okhttp3" % "logging-interceptor" % "4.12.0", "com.google.code.gson" % "gson" % "2.9.1", "org.apache.commons" % "commons-lang3" % "3.12.0", - "javax.ws.rs" % "jsr311-api" % "1.1.1", - "javax.ws.rs" % "javax.ws.rs-api" % "2.1.1", + "jakarta.ws.rs" % "jakarta.ws.rs-api" % "2.1.6", "org.openapitools" % "jackson-databind-nullable" % "0.2.6", "io.gsonfire" % "gson-fire" % "1.9.0" % "compile", "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", "com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile", "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile", - "org.junit.jupiter" % "junit-jupiter-api" % "5.10.2" % "test", + "org.junit.jupiter" % "junit-jupiter-api" % "5.10.3" % "test", "com.novocode" % "junit-interface" % "0.10" % "test", "org.mockito" % "mockito-core" % "3.12.4" % "test" ) diff --git a/docs/AcceptOrderRequest.md b/docs/AcceptOrderRequest.md index a008759..536e3cb 100644 --- a/docs/AcceptOrderRequest.md +++ b/docs/AcceptOrderRequest.md @@ -19,6 +19,7 @@ The manual acceptance or rejection of an order on GrabFood. |---- | -----| | ACCEPTED | "Accepted" | | REJECTED | "Rejected" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/Address.md b/docs/Address.md index b5598d7..e8afb00 100644 --- a/docs/Address.md +++ b/docs/Address.md @@ -24,6 +24,7 @@ A JSON object containing the receiver’s location information. |---- | -----| | GRAB | "GRAB" | | GOOGLE | "GOOGLE" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/BatchUpdateMenuItem.md b/docs/BatchUpdateMenuItem.md index de13edb..13f2e34 100644 --- a/docs/BatchUpdateMenuItem.md +++ b/docs/BatchUpdateMenuItem.md @@ -10,7 +10,7 @@ Information about the GrabFood client updating their food menu. |------------ | ------------- | ------------- | -------------| |**merchantID** | **String** | The merchant's ID that is in GrabFood's database. | | |**field** | [**FieldEnum**](#FieldEnum) | The record type that you want to update. | | -|**menuEntities** | [**List<BatchUpdateMenuItemMenuEntitiesInner>**](BatchUpdateMenuItemMenuEntitiesInner.md) | The items in an array of JSON Object. | [optional] | +|**menuEntities** | [**List<MenuEntity>**](MenuEntity.md) | The items in an array of JSON Object. | [optional] | @@ -19,6 +19,7 @@ Information about the GrabFood client updating their food menu. | Name | Value | |---- | -----| | ITEM | "ITEM" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/BatchUpdateMenuErrorMessage.md b/docs/BatchUpdateMenuResponse.md similarity index 61% rename from docs/BatchUpdateMenuErrorMessage.md rename to docs/BatchUpdateMenuResponse.md index b6a7992..6024ebe 100644 --- a/docs/BatchUpdateMenuErrorMessage.md +++ b/docs/BatchUpdateMenuResponse.md @@ -1,6 +1,6 @@ -# BatchUpdateMenuErrorMessage +# BatchUpdateMenuResponse ## Properties @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**merchantID** | **String** | The merchant's ID that is in GrabFood's database. | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | The status of this request. | [optional] | -|**errors** | [**List<BatchUpdateMenuErrorMessageErrorsInner>**](BatchUpdateMenuErrorMessageErrorsInner.md) | The error messages when batch update menu record was partial success/fail. `null` when the request was success. | [optional] | +|**errors** | [**List<MenuEntityError>**](MenuEntityError.md) | The error messages when batch update menu record was partial success/fail. `null` when the request was success. | [optional] | @@ -20,6 +20,7 @@ | SUCCESS | "success" | | PARTIAL_SUCCESS | "partial success" | | FAIL | "fail" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/Campaigns.md b/docs/Campaign.md similarity index 74% rename from docs/Campaigns.md rename to docs/Campaign.md index e0b32e3..f51942c 100644 --- a/docs/Campaigns.md +++ b/docs/Campaign.md @@ -1,6 +1,6 @@ -# Campaigns +# Campaign A JSON object containing the campaign details for a merchant. Only campaigns that are funded by merchants will be sent. @@ -12,9 +12,9 @@ A JSON object containing the campaign details for a merchant. Only campaigns tha |**createdBy** | [**CreatedByEnum**](#CreatedByEnum) | The party who created the campaign. Can be created by partners via API, merchants via the merchant app or Grab. | | |**merchantID** | **String** | The merchant's ID that is in GrabFood's database. | | |**name** | **String** | The campaign's name. | | -|**quotas** | [**Quotas**](Quotas.md) | | [optional] | -|**conditions** | [**Conditions**](Conditions.md) | | [optional] | -|**discount** | [**Discount**](Discount.md) | | [optional] | +|**quotas** | [**CampaignQuotas**](CampaignQuotas.md) | | [optional] | +|**conditions** | [**CampaignConditions**](CampaignConditions.md) | | [optional] | +|**discount** | [**CampaignDiscount**](CampaignDiscount.md) | | [optional] | |**customTag** | **String** | Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. | [optional] | @@ -26,6 +26,7 @@ A JSON object containing the campaign details for a merchant. Only campaigns tha | GRAB | "Grab" | | MERCHANT | "Merchant" | | PARTNER | "Partner" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/Conditions.md b/docs/CampaignConditions.md similarity index 93% rename from docs/Conditions.md rename to docs/CampaignConditions.md index 8f902e1..20d87d5 100644 --- a/docs/Conditions.md +++ b/docs/CampaignConditions.md @@ -1,6 +1,6 @@ -# Conditions +# CampaignConditions The conditions to apply to a campaign. @@ -23,6 +23,7 @@ The conditions to apply to a campaign. |---- | -----| | ALL | "all" | | NEW | "new" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/Discount.md b/docs/CampaignDiscount.md similarity index 73% rename from docs/Discount.md rename to docs/CampaignDiscount.md index 189d6f1..76216e2 100644 --- a/docs/Discount.md +++ b/docs/CampaignDiscount.md @@ -1,6 +1,6 @@ -# Discount +# CampaignDiscount The discount detail for a particular campaign when conditions are satisfied. @@ -11,7 +11,7 @@ The discount detail for a particular campaign when conditions are satisfied. |**type** | [**TypeEnum**](#TypeEnum) | The type of discount | | |**cap** | **Double** | The maximum discount dollar amount. It is **not required** and will be ignored when the `discount.type` is: - `net` - `delivery` - `freeItem` - `bundleSameNet` - `bundleSamePercentage` - `bundleSameFixPrice` - `bundleDiffNet` - `bundleDiffPercentage` - `bundleDiffFixPrice` | [optional] | |**value** | **Double** | Specify the discount amount. Decimal number is not supported For VN, ID and TH. For example, `10.5` is not allowed and it should be `10.0`. * Dollar amount value when `discount.type` is `net`, `delivery`, `bundleSameNet`, `bundleSameFixPrice`, `bundleDiffNet`, `bundleDiffFixPrice`. * Percentage value (0-100) when `discount.type` is `percentage`, `bundleSamePercentage`, `bundleDiffPercentage`. * **Not required** when `discount.type` is `freeItem`. | [optional] | -|**scope** | [**Scope**](Scope.md) | | | +|**scope** | [**CampaignScope**](CampaignScope.md) | | | @@ -22,13 +22,14 @@ The discount detail for a particular campaign when conditions are satisfied. | NET | "net" | | PERCENTAGE | "percentage" | | DELIVERY | "delivery" | -| FREEITEM | "freeItem" | -| BUNDLESAMENET | "bundleSameNet" | -| BUNDLESAMEPERCENTAGE | "bundleSamePercentage" | -| BUNDLESAMEFIXPRICE | "bundleSameFixPrice" | -| BUNDLEDIFFNET | "bundleDiffNet" | -| BUNDLEDIFFPERCENTAGE | "bundleDiffPercentage" | -| BUNDLEDIFFFIXPRICE | "bundleDiffFixPrice" | +| FREE_ITEM | "freeItem" | +| BUNDLE_SAME_NET | "bundleSameNet" | +| BUNDLE_SAME_PERCENTAGE | "bundleSamePercentage" | +| BUNDLE_SAME_FIX_PRICE | "bundleSameFixPrice" | +| BUNDLE_DIFF_NET | "bundleDiffNet" | +| BUNDLE_DIFF_PERCENTAGE | "bundleDiffPercentage" | +| BUNDLE_DIFF_FIX_PRICE | "bundleDiffFixPrice" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/Quotas.md b/docs/CampaignQuotas.md similarity index 96% rename from docs/Quotas.md rename to docs/CampaignQuotas.md index c30300c..6444b2b 100644 --- a/docs/Quotas.md +++ b/docs/CampaignQuotas.md @@ -1,6 +1,6 @@ -# Quotas +# CampaignQuotas The quotas/limits for a particular campaign. diff --git a/docs/Scope.md b/docs/CampaignScope.md similarity index 93% rename from docs/Scope.md rename to docs/CampaignScope.md index 3f2a8e7..24f18cd 100644 --- a/docs/Scope.md +++ b/docs/CampaignScope.md @@ -1,6 +1,6 @@ -# Scope +# CampaignScope The scope level for a particular campaign. @@ -20,6 +20,7 @@ The scope level for a particular campaign. | ORDER | "order" | | ITEMS | "items" | | CATEGORY | "category" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/CancelCode.md b/docs/CancelCode.md index 9679dfc..6be5fc0 100644 --- a/docs/CancelCode.md +++ b/docs/CancelCode.md @@ -13,5 +13,7 @@ * `NUMBER_1004` (value: `1004`) +* `NUMBER_unknown_default_open_api` (value: `11184809`) + diff --git a/docs/CancelOrderFail403.md b/docs/CancelOrderFail403.md deleted file mode 100644 index 78443ff..0000000 --- a/docs/CancelOrderFail403.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# CancelOrderFail403 - - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | Target of error | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/LimitType.md b/docs/CancelOrderLimitType.md similarity index 78% rename from docs/LimitType.md rename to docs/CancelOrderLimitType.md index ea837a6..a6f4bc0 100644 --- a/docs/LimitType.md +++ b/docs/CancelOrderLimitType.md @@ -1,6 +1,6 @@ -# LimitType +# CancelOrderLimitType ## Enum @@ -15,5 +15,7 @@ * `EMPTY` (value: `""`) +* `UNKNOWN_DEFAULT_OPEN_API` (value: `"unknown_default_open_api"`) + diff --git a/docs/CancelOrderResponse.md b/docs/CancelOrderResponse.md index 0ffde1f..8f6f598 100644 --- a/docs/CancelOrderResponse.md +++ b/docs/CancelOrderResponse.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**limitType** | **LimitType** | | [optional] | +|**limitType** | **CancelOrderLimitType** | | [optional] | |**limitTimes** | **Integer** | The remaining cancellation quota for the merchant. A value is only returned when the nearest remaining cancellation limit is approaching, else it returns 0. | [optional] | diff --git a/docs/CancelReasonsInner.md b/docs/CancelReason.md similarity index 95% rename from docs/CancelReasonsInner.md rename to docs/CancelReason.md index 1859df2..4987e54 100644 --- a/docs/CancelReasonsInner.md +++ b/docs/CancelReason.md @@ -1,6 +1,6 @@ -# CancelReasonsInner +# CancelReason ## Properties diff --git a/docs/CategoriesInnerNameTranslation.md b/docs/CategoriesInnerNameTranslation.md deleted file mode 100644 index 8298cb8..0000000 --- a/docs/CategoriesInnerNameTranslation.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# CategoriesInnerNameTranslation - -Translation of the category name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**en** | **String** | The English translation of the name. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` | [optional] | - - - diff --git a/docs/CheckOrderCancelableResponse.md b/docs/CheckOrderCancelableResponse.md index 94ab829..3831a42 100644 --- a/docs/CheckOrderCancelableResponse.md +++ b/docs/CheckOrderCancelableResponse.md @@ -10,9 +10,9 @@ |------------ | ------------- | ------------- | -------------| |**cancelAble** | **Boolean** | The boolean value to indicate whether an order can be cancelled. | [optional] | |**nonCancellationReason** | [**NonCancellationReasonEnum**](#NonCancellationReasonEnum) | The reason for the order to be non-cancelable. | [optional] | -|**limitType** | **LimitType** | | [optional] | +|**limitType** | **CancelOrderLimitType** | | [optional] | |**limitTimes** | **Integer** | The remaining cancellation quota for the merchant. A value is only returned when the nearest remaining cancellation limit is approaching, else it returns 0. | [optional] | -|**cancelReasons** | [**List<CancelReasonsInner>**](CancelReasonsInner.md) | An array of cancel order reasons JSON objects. | [optional] | +|**cancelReasons** | [**List<CancelReason>**](CancelReason.md) | An array of cancel order reasons JSON objects. | [optional] | @@ -32,6 +32,7 @@ | THE_CURRENT_STATUS_OF_THE_ORDER_DOES_NOT_ALLOW_CANCELLATION | "The current status of the order does not allow cancellation" | | DEFAULT_ERROR | "Default Error" | | EMPTY | "" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/CreateCampaignFail.md b/docs/CreateCampaignFail.md deleted file mode 100644 index b0a3ede..0000000 --- a/docs/CreateCampaignFail.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# CreateCampaignFail - - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/CreateCampaignRequest.md b/docs/CreateCampaignRequest.md index 45c432b..22e26e7 100644 --- a/docs/CreateCampaignRequest.md +++ b/docs/CreateCampaignRequest.md @@ -10,9 +10,9 @@ This request creates a campaign for your GrabFood store. |------------ | ------------- | ------------- | -------------| |**merchantID** | **String** | The merchant's ID that is in GrabFood's database. | | |**name** | **String** | The campaign's name. | | -|**quotas** | [**Quotas**](Quotas.md) | | [optional] | -|**conditions** | [**Conditions**](Conditions.md) | | | -|**discount** | [**Discount**](Discount.md) | | | +|**quotas** | [**CampaignQuotas**](CampaignQuotas.md) | | [optional] | +|**conditions** | [**CampaignConditions**](CampaignConditions.md) | | | +|**discount** | [**CampaignDiscount**](CampaignDiscount.md) | | | |**customTag** | **String** | Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. | [optional] | diff --git a/docs/Currency.md b/docs/Currency.md index 043066b..0731bd5 100644 --- a/docs/Currency.md +++ b/docs/Currency.md @@ -24,6 +24,7 @@ A JSON object containing code, symbol, and exponent for a given currency. Refer | SGD | "SGD" | | THB | "THB" | | VND | "VND" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -37,6 +38,7 @@ A JSON object containing code, symbol, and exponent for a given currency. Refer | S_ | "S$" | | u2 | "฿" | | u3 | "₫" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/DineInVoucher400Fail.md b/docs/DineInVoucher400Fail.md deleted file mode 100644 index ad104c5..0000000 --- a/docs/DineInVoucher400Fail.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# DineInVoucher400Fail - -The failed example with code and reason. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/DineInVoucher404Fail.md b/docs/DineInVoucher404Fail.md deleted file mode 100644 index 5febe6d..0000000 --- a/docs/DineInVoucher404Fail.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# DineInVoucher404Fail - -The specified resource does not exist. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/EditOrderRequestItemsInner.md b/docs/EditOrderItem.md similarity index 94% rename from docs/EditOrderRequestItemsInner.md rename to docs/EditOrderItem.md index 4608025..9424fbf 100644 --- a/docs/EditOrderRequestItemsInner.md +++ b/docs/EditOrderItem.md @@ -1,6 +1,6 @@ -# EditOrderRequestItemsInner +# EditOrderItem ## Properties @@ -22,6 +22,7 @@ | UPDATED | "UPDATED" | | ADDED | "ADDED" | | EMPTY | "" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/EditOrderRequest.md b/docs/EditOrderRequest.md index bab709a..05ca514 100644 --- a/docs/EditOrderRequest.md +++ b/docs/EditOrderRequest.md @@ -9,7 +9,7 @@ Information about editing an existing order on GrabFood. | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**orderID** | **String** | The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). | | -|**items** | [**List<EditOrderRequestItemsInner>**](EditOrderRequestItemsInner.md) | Specify the array of all items in the order, including deleted, added, updated and unchanged items. | | +|**items** | [**List<EditOrderItem>**](EditOrderItem.md) | Specify the array of all items in the order, including deleted, added, updated and unchanged items. | | |**onlyRecalculate** | **Boolean** | This parameter specifies whether to recalculate the edited order without submitting it. It is intended for testing purposes only. This parameter is set to false by default, which means the edited order will be recalculated and re-submitted to partners. | [optional] | diff --git a/docs/CancelOrderFail.md b/docs/Error.md similarity index 94% rename from docs/CancelOrderFail.md rename to docs/Error.md index 920150c..2be9a41 100644 --- a/docs/CancelOrderFail.md +++ b/docs/Error.md @@ -1,7 +1,6 @@ -# CancelOrderFail - +# Error ## Properties diff --git a/docs/Error404.md b/docs/Error404.md deleted file mode 100644 index bf615ff..0000000 --- a/docs/Error404.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Error404 - -The specified resource does not exist. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/Error409.md b/docs/Error409.md deleted file mode 100644 index f93ff2a..0000000 --- a/docs/Error409.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Error409 - -Common error, probably due to a process failure. The reason for the failure is usually indicated in the response. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/Error500.md b/docs/Error500.md deleted file mode 100644 index 5c99f71..0000000 --- a/docs/Error500.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Error500 - -A system or application error occurred. Although the client appears to provide a correct request, there may be something unexpected on the server. You may retry the request in this case. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/GetDineInVoucherResponse.md b/docs/GetDineInVoucherResponse.md index 432774d..fab7d8f 100644 --- a/docs/GetDineInVoucherResponse.md +++ b/docs/GetDineInVoucherResponse.md @@ -25,6 +25,7 @@ | REDEEMED | "REDEEMED" | | EXPIRED | "EXPIRED" | | REFUNDED | "REFUNDED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/GetMembershipNativeResponse.md b/docs/GetMembershipNativeResponse.md index 1df2b4b..9b87472 100644 --- a/docs/GetMembershipNativeResponse.md +++ b/docs/GetMembershipNativeResponse.md @@ -20,6 +20,7 @@ This response returns membership detail. |---- | -----| | VALID | "VALID" | | INVALID | "INVALID" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/GetMembershipWebviewResponse.md b/docs/GetMembershipWebviewResponse.md index a7b1f19..58757eb 100644 --- a/docs/GetMembershipWebviewResponse.md +++ b/docs/GetMembershipWebviewResponse.md @@ -18,6 +18,7 @@ This response returns membership detail. |---- | -----| | VALID | "VALID" | | INVALID | "INVALID" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/GetMenuNewResponse.md b/docs/GetMenuNewResponse.md index 786a229..fe0dacc 100644 --- a/docs/GetMenuNewResponse.md +++ b/docs/GetMenuNewResponse.md @@ -11,8 +11,8 @@ |**merchantID** | **String** | The merchant's ID that is in GrabFood's database. | [optional] | |**partnerMerchantID** | **String** | The merchant's ID that is on the partner's database. | [optional] | |**currency** | [**Currency**](Currency.md) | | | -|**sellingTimes** | [**List<SellingTimesInner>**](SellingTimesInner.md) | An array of sellingTimes JSON objects. Max 20 allowed. Refer to [Selling Times](#selling-times) for more information. | | -|**categories** | [**List<CategoriesInner>**](CategoriesInner.md) | An array of category JSON objects. Max 100 allowed per section. Refer to [Categories](#categories) for more information. | | +|**sellingTimes** | [**List<SellingTime>**](SellingTime.md) | An array of sellingTimes JSON objects. Max 20 allowed. Refer to [Selling Times](#selling-times) for more information. | | +|**categories** | [**List<MenuCategory>**](MenuCategory.md) | An array of category JSON objects. Max 100 allowed per section. Refer to [Categories](#categories) for more information. | | diff --git a/docs/GetMenuOldResponse.md b/docs/GetMenuOldResponse.md index 87ca199..56d14af 100644 --- a/docs/GetMenuOldResponse.md +++ b/docs/GetMenuOldResponse.md @@ -11,7 +11,7 @@ |**merchantID** | **String** | The merchant's ID that is in GrabFood's database. | [optional] | |**partnerMerchantID** | **String** | The merchant's ID that is on the partner's database. | [optional] | |**currency** | [**Currency**](Currency.md) | | | -|**sections** | [**List<SectionsInner>**](SectionsInner.md) | An array of section JSON objects. Max 7 allowed. Refer to [Sections](#sections) for more information. | | +|**sections** | [**List<MenuSection>**](MenuSection.md) | An array of section JSON objects. Max 7 allowed. Refer to [Sections](#sections) for more information. | | diff --git a/docs/GetRewardNativeRequest.md b/docs/GetRewardNativeRequest.md index 1145911..1150dfc 100644 --- a/docs/GetRewardNativeRequest.md +++ b/docs/GetRewardNativeRequest.md @@ -10,7 +10,7 @@ This request submits membership detail and order value to get reward calculation |------------ | ------------- | ------------- | -------------| |**memberID** | **String** | The unique member ID on the partner's database. | [optional] | |**merchantID** | **String** | Grab merchant's ID. | [optional] | -|**items** | [**List<GetRewardNativeRequestItemsInner>**](GetRewardNativeRequestItemsInner.md) | | [optional] | +|**items** | [**List<RewardItem>**](RewardItem.md) | | [optional] | |**orderValue** | **Integer** | The post-discount order value. | [optional] | diff --git a/docs/ListCampaignResponse.md b/docs/ListCampaignResponse.md index e0ece6b..a950709 100644 --- a/docs/ListCampaignResponse.md +++ b/docs/ListCampaignResponse.md @@ -8,8 +8,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**ongoing** | [**List<Campaigns>**](Campaigns.md) | | [optional] | -|**upcoming** | [**List<Campaigns>**](Campaigns.md) | | [optional] | +|**ongoing** | [**List<Campaign>**](Campaign.md) | | [optional] | +|**upcoming** | [**List<Campaign>**](Campaign.md) | | [optional] | diff --git a/docs/ListOrdersResponse.md b/docs/ListOrdersResponse.md index eae5d43..2b17f5f 100644 --- a/docs/ListOrdersResponse.md +++ b/docs/ListOrdersResponse.md @@ -9,7 +9,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**more** | **Boolean** | The boolean value to indicate if there is more order data. If `true`, you can continue requesting with page+1. | [optional] | -|**orders** | [**List<Orders>**](Orders.md) | | [optional] | +|**orders** | [**List<Order>**](Order.md) | | [optional] | diff --git a/docs/MarkOrderFail.md b/docs/MarkOrderFail.md deleted file mode 100644 index 350a3b4..0000000 --- a/docs/MarkOrderFail.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# MarkOrderFail - - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/MarkOrderRequest.md b/docs/MarkOrderRequest.md index fbbc2f7..16e9647 100644 --- a/docs/MarkOrderRequest.md +++ b/docs/MarkOrderRequest.md @@ -19,6 +19,7 @@ This request marks an order as ready for delivery or completed on GrabFood. |---- | -----| | NUMBER_1 | 1 | | NUMBER_2 | 2 | +| NUMBER_unknown_default_open_api | 11184809 | diff --git a/docs/CategoriesInner.md b/docs/MenuCategory.md similarity index 66% rename from docs/CategoriesInner.md rename to docs/MenuCategory.md index a07a0ce..29f98d0 100644 --- a/docs/CategoriesInner.md +++ b/docs/MenuCategory.md @@ -1,6 +1,6 @@ -# CategoriesInner +# MenuCategory ## Properties @@ -9,10 +9,10 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | The category's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. | | |**name** | **String** | The name of the category. | | -|**nameTranslation** | [**CategoriesInnerNameTranslation**](CategoriesInnerNameTranslation.md) | | [optional] | +|**nameTranslation** | **Map<String, String>** | Translation of the category name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The status for the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). | | |**sellingTimeID** | **String** | The selling time's ID for the category. All items within the category will apply the same selling time unless there is another selling time specified for the item. | | -|**items** | [**List<MenuItemsInner>**](MenuItemsInner.md) | An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. | | +|**items** | [**List<MenuItem>**](MenuItem.md) | An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. | | @@ -23,6 +23,7 @@ | AVAILABLE | "AVAILABLE" | | UNAVAILABLE | "UNAVAILABLE" | | HIDE | "HIDE" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/BatchUpdateMenuItemMenuEntitiesInner.md b/docs/MenuEntity.md similarity index 65% rename from docs/BatchUpdateMenuItemMenuEntitiesInner.md rename to docs/MenuEntity.md index 73e743f..834312e 100644 --- a/docs/BatchUpdateMenuItemMenuEntitiesInner.md +++ b/docs/MenuEntity.md @@ -1,6 +1,6 @@ -# BatchUpdateMenuItemMenuEntitiesInner +# MenuEntity ## Properties @@ -11,8 +11,8 @@ |**price** | **Integer** | The record's price in minor unit format. | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The record's availableStatus. Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. | [optional] | |**maxStock** | **Integer** | Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. | [optional] | -|**advancedPricings** | [**List<UpdateMenuItemAdvancedPricingsInner>**](UpdateMenuItemAdvancedPricingsInner.md) | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. | [optional] | -|**purchasabilities** | [**List<UpdateMenuItemPurchasabilitiesInner>**](UpdateMenuItemPurchasabilitiesInner.md) | Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. | [optional] | +|**advancedPricings** | [**List<UpdateAdvancedPricing>**](UpdateAdvancedPricing.md) | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. | [optional] | +|**purchasabilities** | [**List<UpdatePurchasability>**](UpdatePurchasability.md) | Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. | [optional] | @@ -23,6 +23,7 @@ | AVAILABLE | "AVAILABLE" | | UNAVAILABLE | "UNAVAILABLE" | | UNAVAILABLETODAY | "UNAVAILABLETODAY" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/BatchUpdateMenuErrorMessageErrorsInner.md b/docs/MenuEntityError.md similarity index 85% rename from docs/BatchUpdateMenuErrorMessageErrorsInner.md rename to docs/MenuEntityError.md index fd82db0..b02b81a 100644 --- a/docs/BatchUpdateMenuErrorMessageErrorsInner.md +++ b/docs/MenuEntityError.md @@ -1,6 +1,6 @@ -# BatchUpdateMenuErrorMessageErrorsInner +# MenuEntityError ## Properties diff --git a/docs/MenuItemsInner.md b/docs/MenuItem.md similarity index 78% rename from docs/MenuItemsInner.md rename to docs/MenuItem.md index f051bb2..41545da 100644 --- a/docs/MenuItemsInner.md +++ b/docs/MenuItem.md @@ -1,6 +1,6 @@ -# MenuItemsInner +# MenuItem ## Properties @@ -9,10 +9,10 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | The item's ID in the partner system. | | |**name** | **String** | The name of the item. | | -|**nameTranslation** | [**OldMenuSectionCategoryItemsInnerNameTranslation**](OldMenuSectionCategoryItemsInnerNameTranslation.md) | | [optional] | +|**nameTranslation** | **Map<String, String>** | Translation of the item name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The status for the item that is in the category. Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. | | |**description** | **String** | The description of the item. There is a custom length limit of 2000 for `VN`. | [optional] | -|**descriptionTranslation** | [**MenuItemsInnerDescriptionTranslation**](MenuItemsInnerDescriptionTranslation.md) | | [optional] | +|**descriptionTranslation** | **Map<String, String>** | Translation of the item description. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). | [optional] | |**price** | **Integer** | The item's price (excluding tax) in minor format. For example: 1900 means $19 with `currency.exponent` as 2. Refer to [FAQ](#section/Menu/Is-the-item-price-with-or-without-tax) for more details. | | |**photos** | **List<String>** | An array string for the item’s image URL links. Refer to FAQs for more details about [images](#section/Menu/What-are-the-recommended-formats-for-an-item-image). | [optional] | |**specialType** | [**SpecialTypeEnum**](#SpecialTypeEnum) | The item's special Tag. Refer to FAQs for more details about [specialType](#section/Menu/What's-specialType). | [optional] | @@ -22,7 +22,7 @@ |**maxStock** | **Integer** | Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Empty value implies no limit. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. | [optional] | |**advancedPricing** | [**AdvancedPricing**](AdvancedPricing.md) | | [optional] | |**purchasability** | [**Purchasability**](Purchasability.md) | | [optional] | -|**modifierGroups** | [**List<ModifierGroupsInner>**](ModifierGroupsInner.md) | An array of the modifierGroup JSON objects. Max 30 allowed per item. Refer to [Modifier groups](#modifier-groups) for more information. | [optional] | +|**modifierGroups** | [**List<ModifierGroup>**](ModifierGroup.md) | An array of the modifierGroup JSON objects. Max 30 allowed per item. Refer to [Modifier groups](#modifier-groups) for more information. | [optional] | @@ -34,6 +34,7 @@ | UNAVAILABLE | "UNAVAILABLE" | | HIDE | "HIDE" | | UNAVAILABLETODAY | "UNAVAILABLETODAY" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -43,6 +44,7 @@ |---- | -----| | ALCOHOL | "alcohol" | | EMPTY | "" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/MenuItemsInnerDescriptionTranslation.md b/docs/MenuItemsInnerDescriptionTranslation.md deleted file mode 100644 index 45f4b56..0000000 --- a/docs/MenuItemsInnerDescriptionTranslation.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# MenuItemsInnerDescriptionTranslation - -Translation of the item description. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**en** | **String** | The English translation of the description. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` | [optional] | - - - diff --git a/docs/MenuModifiersInner.md b/docs/MenuModifier.md similarity index 79% rename from docs/MenuModifiersInner.md rename to docs/MenuModifier.md index 811a3a5..dbd41e5 100644 --- a/docs/MenuModifiersInner.md +++ b/docs/MenuModifier.md @@ -1,6 +1,6 @@ -# MenuModifiersInner +# MenuModifier ## Properties @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | The modifier's ID that is on the partner's system. This ID should be unique with a min length of 1 and max of 64. | | |**name** | **String** | The name of the modifier. | | -|**nameTranslation** | [**MenuModifiersInnerNameTranslation**](MenuModifiersInnerNameTranslation.md) | | [optional] | +|**nameTranslation** | **Map<String, String>** | Translation of the modifier name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The status for the modifier that is in the ModifierGroup. | | |**price** | **Integer** | The modifier's price (excluding tax) in minor format. Refer to FAQs for more details about [tax](#section/Order/How-is-tax-calculated). | [optional] | |**barcode** | **String** | The barcode Number (GTIN). GTIN must be 8, 12, 13, 14 numeric digits. | [optional] | @@ -25,6 +25,7 @@ | UNAVAILABLE | "UNAVAILABLE" | | UNAVAILABLETODAY | "UNAVAILABLETODAY" | | HIDE | "HIDE" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/MenuModifiersInnerNameTranslation.md b/docs/MenuModifiersInnerNameTranslation.md deleted file mode 100644 index ffa7638..0000000 --- a/docs/MenuModifiersInnerNameTranslation.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# MenuModifiersInnerNameTranslation - -Translation of the modifier name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**en** | **String** | The English translation of the name. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` | [optional] | - - - diff --git a/docs/SectionsInner.md b/docs/MenuSection.md similarity index 56% rename from docs/SectionsInner.md rename to docs/MenuSection.md index 276fb4e..88b4ba9 100644 --- a/docs/SectionsInner.md +++ b/docs/MenuSection.md @@ -1,6 +1,6 @@ -# SectionsInner +# MenuSection ## Properties @@ -10,7 +10,7 @@ |**id** | **String** | The section's ID in the partner system. | | |**name** | **String** | The name of the section. | | |**serviceHours** | [**ServiceHours**](ServiceHours.md) | | | -|**categories** | [**List<SectionsInnerCategoriesInner>**](SectionsInnerCategoriesInner.md) | An array of category JSON objects. Max 100 allowed per section. Refer to [Categories](#categories) for more information. | | +|**categories** | [**List<MenuSectionCategory>**](MenuSectionCategory.md) | An array of category JSON objects. Max 100 allowed per section. Refer to [Categories](#categories) for more information. | | diff --git a/docs/SectionsInnerCategoriesInner.md b/docs/MenuSectionCategory.md similarity index 58% rename from docs/SectionsInnerCategoriesInner.md rename to docs/MenuSectionCategory.md index ee60233..d131bd4 100644 --- a/docs/SectionsInnerCategoriesInner.md +++ b/docs/MenuSectionCategory.md @@ -1,6 +1,6 @@ -# SectionsInnerCategoriesInner +# MenuSectionCategory ## Properties @@ -9,9 +9,9 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | The category's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. | | |**name** | **String** | The name of the category. | | -|**nameTranslation** | [**CategoriesInnerNameTranslation**](CategoriesInnerNameTranslation.md) | | [optional] | +|**nameTranslation** | **Map<String, String>** | Translation of the category name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The status for the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). | | -|**items** | [**List<OldMenuSectionCategoryItemsInner>**](OldMenuSectionCategoryItemsInner.md) | An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. | | +|**items** | [**List<MenuSectionCategoryItem>**](MenuSectionCategoryItem.md) | An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. | | @@ -22,6 +22,7 @@ | AVAILABLE | "AVAILABLE" | | UNAVAILABLE | "UNAVAILABLE" | | HIDE | "HIDE" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/OldMenuSectionCategoryItemsInner.md b/docs/MenuSectionCategoryItem.md similarity index 77% rename from docs/OldMenuSectionCategoryItemsInner.md rename to docs/MenuSectionCategoryItem.md index 1301b4e..1ef8e2f 100644 --- a/docs/OldMenuSectionCategoryItemsInner.md +++ b/docs/MenuSectionCategoryItem.md @@ -1,6 +1,6 @@ -# OldMenuSectionCategoryItemsInner +# MenuSectionCategoryItem ## Properties @@ -9,10 +9,10 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | The item's ID in the partner system. | | |**name** | **String** | The name of the item. | | -|**nameTranslation** | [**OldMenuSectionCategoryItemsInnerNameTranslation**](OldMenuSectionCategoryItemsInnerNameTranslation.md) | | [optional] | +|**nameTranslation** | **Map<String, String>** | Translation of the item name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The status for the item that is in the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. | | |**description** | **String** | The description of the item. There is a custom length limit of 2000 for `VN`. | [optional] | -|**descriptionTranslation** | [**OldMenuSectionCategoryItemsInnerDescriptionTranslation**](OldMenuSectionCategoryItemsInnerDescriptionTranslation.md) | | [optional] | +|**descriptionTranslation** | **Map<String, String>** | Translation of the item description. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). | [optional] | |**price** | **Integer** | The item's price (excluding tax) in minor format. For example: 1900 means $19 with `currency.exponent` as 2. Refer to [FAQ](#section/Menu/Is-the-item-price-with-or-without-tax) for more details. | | |**photos** | **List<String>** | An array string for the item’s image URL links. Refer to FAQs for more details about [images](#section/Menu/What-are-the-recommended-formats-for-an-item-image). | [optional] | |**specialType** | [**SpecialTypeEnum**](#SpecialTypeEnum) | The item's special Tag. Refer to FAQs for more details about [specialType](#section/Menu/What's-specialType). | [optional] | @@ -21,7 +21,7 @@ |**maxStock** | **Integer** | Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Empty value implies no limit. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. | [optional] | |**advancedPricing** | [**AdvancedPricing**](AdvancedPricing.md) | | [optional] | |**purchasability** | [**Purchasability**](Purchasability.md) | | [optional] | -|**modifierGroups** | [**List<ModifierGroupsInner>**](ModifierGroupsInner.md) | An array of the modifierGroup JSON objects. Max 30 allowed per item. Refer to [Modifier groups](#modifier-groups) for more information. | [optional] | +|**modifierGroups** | [**List<ModifierGroup>**](ModifierGroup.md) | An array of the modifierGroup JSON objects. Max 30 allowed per item. Refer to [Modifier groups](#modifier-groups) for more information. | [optional] | @@ -33,6 +33,7 @@ | UNAVAILABLE | "UNAVAILABLE" | | HIDE | "HIDE" | | UNAVAILABLETODAY | "UNAVAILABLETODAY" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -42,6 +43,7 @@ |---- | -----| | ALCOHOL | "alcohol" | | EMPTY | "" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/MenuSyncFail.md b/docs/MenuSyncFail.md index 28ffe0f..1bc56c3 100644 --- a/docs/MenuSyncFail.md +++ b/docs/MenuSyncFail.md @@ -3,24 +3,14 @@ # MenuSyncFail - ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**createdTime** | **OffsetDateTime** | The Unix time the specified menu was created in GrabFood's database. | [optional] | -|**updatedTime** | **OffsetDateTime** | The Unix time the specified menu was created in GrabFood's database. | [optional] | -|**code** | [**CodeEnum**](#CodeEnum) | The status code for this request. See [Menu sync response statuses](#section/Menu-sync-response-statuses) for more information. | [optional] | +|**id** | **String** | | [optional] | |**errors** | **List<String>** | An array of strings of error message. | [optional] | -|**sections** | [**List<SyncFail>**](SyncFail.md) | | [optional] | - - - -## Enum: CodeEnum - -| Name | Value | -|---- | -----| -| FAILED | "Failed" | +|**serviceHours** | [**MenuSyncFailServiceHours**](MenuSyncFailServiceHours.md) | | [optional] | +|**categories** | [**List<MenuSyncFailCategory>**](MenuSyncFailCategory.md) | | [optional] | diff --git a/docs/SyncFailCategoriesInner.md b/docs/MenuSyncFailCategory.md similarity index 60% rename from docs/SyncFailCategoriesInner.md rename to docs/MenuSyncFailCategory.md index 8ee186d..8b486f2 100644 --- a/docs/SyncFailCategoriesInner.md +++ b/docs/MenuSyncFailCategory.md @@ -1,6 +1,6 @@ -# SyncFailCategoriesInner +# MenuSyncFailCategory ## Properties @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | The category's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. | [optional] | |**errors** | **List<String>** | An array of strings of error message. | [optional] | -|**items** | [**List<SyncFailCategoryItemsInner>**](SyncFailCategoryItemsInner.md) | An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. | [optional] | +|**items** | [**List<MenuSyncFailItem>**](MenuSyncFailItem.md) | An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. | [optional] | diff --git a/docs/SyncFailCategoryItemsInner.md b/docs/MenuSyncFailItem.md similarity index 61% rename from docs/SyncFailCategoryItemsInner.md rename to docs/MenuSyncFailItem.md index 0f2b099..f402fcb 100644 --- a/docs/SyncFailCategoryItemsInner.md +++ b/docs/MenuSyncFailItem.md @@ -1,6 +1,6 @@ -# SyncFailCategoryItemsInner +# MenuSyncFailItem ## Properties @@ -9,7 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | The item's ID in the partner system. | [optional] | |**errors** | **List<String>** | An array of strings of error message. | [optional] | -|**modifierGroups** | [**List<SyncFailCategoryItemsInnerModifierGroupsInner>**](SyncFailCategoryItemsInnerModifierGroupsInner.md) | | [optional] | +|**modifierGroups** | [**List<MenuSyncFailModifierGroup>**](MenuSyncFailModifierGroup.md) | | [optional] | diff --git a/docs/SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.md b/docs/MenuSyncFailModifier.md similarity index 80% rename from docs/SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.md rename to docs/MenuSyncFailModifier.md index bd40074..6b541fe 100644 --- a/docs/SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.md +++ b/docs/MenuSyncFailModifier.md @@ -1,6 +1,6 @@ -# SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner +# MenuSyncFailModifier ## Properties diff --git a/docs/SyncFail.md b/docs/MenuSyncFailModifierGroup.md similarity index 55% rename from docs/SyncFail.md rename to docs/MenuSyncFailModifierGroup.md index 6a1fbd2..f598106 100644 --- a/docs/SyncFail.md +++ b/docs/MenuSyncFailModifierGroup.md @@ -1,6 +1,6 @@ -# SyncFail +# MenuSyncFailModifierGroup ## Properties @@ -9,8 +9,7 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | | [optional] | |**errors** | **List<String>** | An array of strings of error message. | [optional] | -|**serviceHours** | [**SyncFailServiceHours**](SyncFailServiceHours.md) | | [optional] | -|**categories** | [**List<SyncFailCategoriesInner>**](SyncFailCategoriesInner.md) | | [optional] | +|**modifiers** | [**List<MenuSyncFailModifier>**](MenuSyncFailModifier.md) | | [optional] | diff --git a/docs/SyncFailServiceHours.md b/docs/MenuSyncFailServiceHours.md similarity index 88% rename from docs/SyncFailServiceHours.md rename to docs/MenuSyncFailServiceHours.md index 0d37ec7..28b164d 100644 --- a/docs/SyncFailServiceHours.md +++ b/docs/MenuSyncFailServiceHours.md @@ -1,6 +1,6 @@ -# SyncFailServiceHours +# MenuSyncFailServiceHours ## Properties diff --git a/docs/MenuSyncSuccess.md b/docs/MenuSyncResponse.md similarity index 73% rename from docs/MenuSyncSuccess.md rename to docs/MenuSyncResponse.md index 28a9348..e4d0827 100644 --- a/docs/MenuSyncSuccess.md +++ b/docs/MenuSyncResponse.md @@ -1,6 +1,6 @@ -# MenuSyncSuccess +# MenuSyncResponse @@ -12,7 +12,7 @@ |**updatedTime** | **OffsetDateTime** | The Unix time the specified menu was created in GrabFood's database. | | |**code** | [**CodeEnum**](#CodeEnum) | The status code for this request. See [Menu sync response statuses](#section/Menu-sync-response-statuses) for more information. | | |**errors** | **List<String>** | An array of strings of error message. | [optional] | -|**sections** | [**List<SyncFail>**](SyncFail.md) | | [optional] | +|**sections** | [**List<MenuSyncFail>**](MenuSyncFail.md) | | [optional] | @@ -21,8 +21,9 @@ | Name | Value | |---- | -----| | SUCCESS | "Success" | -| PARTIALSUCCESS | "PartialSuccess" | -| INQUEUING | "InQueuing" | +| PARTIAL_SUCCESS | "PartialSuccess" | +| IN_QUEUING | "InQueuing" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/MenuSyncWebhookRequest.md b/docs/MenuSyncWebhookRequest.md index 4415dfb..716de99 100644 --- a/docs/MenuSyncWebhookRequest.md +++ b/docs/MenuSyncWebhookRequest.md @@ -26,6 +26,7 @@ This request pushes the state of a menu sync operation. | PROCESSING | "PROCESSING" | | SUCCESS | "SUCCESS" | | FAILED | "FAILED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/ModifierGroupsInner.md b/docs/ModifierGroup.md similarity index 69% rename from docs/ModifierGroupsInner.md rename to docs/ModifierGroup.md index d624703..8eded6d 100644 --- a/docs/ModifierGroupsInner.md +++ b/docs/ModifierGroup.md @@ -1,6 +1,6 @@ -# ModifierGroupsInner +# ModifierGroup ## Properties @@ -9,11 +9,11 @@ |------------ | ------------- | ------------- | -------------| |**id** | **String** | The ModifierGroup's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. | | |**name** | **String** | The name of the ModifierGroup for the item that is in the parent category and section. | | -|**nameTranslation** | [**ModifierGroupsInnerNameTranslation**](ModifierGroupsInnerNameTranslation.md) | | [optional] | +|**nameTranslation** | **Map<String, String>** | Translation of the modifier group name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The status for the ModifierGroup that is in the item. | | |**selectionRangeMin** | **Integer** | The minimum quantity of the attribute. Refer to FAQs for more details about [selection range](#section/Menu/What-does-the-selection-range-do). | [optional] | |**selectionRangeMax** | **Integer** | The maximum quantity of the attribute. Refer to FAQs for more details about [selection range](#section/Menu/What-does-the-selection-range-do). | | -|**modifiers** | [**List<MenuModifiersInner>**](MenuModifiersInner.md) | An array of modifier JSON objects. Max 100 per modifierGroup. Refer to [Modifiers](#modifiers) for more information. | [optional] | +|**modifiers** | [**List<MenuModifier>**](MenuModifier.md) | An array of modifier JSON objects. Max 100 per modifierGroup. Refer to [Modifiers](#modifiers) for more information. | [optional] | @@ -25,6 +25,7 @@ | UNAVAILABLE | "UNAVAILABLE" | | UNAVAILABLETODAY | "UNAVAILABLETODAY" | | HIDE | "HIDE" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/ModifierGroupsInnerNameTranslation.md b/docs/ModifierGroupsInnerNameTranslation.md deleted file mode 100644 index 54c2469..0000000 --- a/docs/ModifierGroupsInnerNameTranslation.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# ModifierGroupsInnerNameTranslation - -Translation of the modifier group name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**en** | **String** | The English translation of the name. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` | [optional] | - - - diff --git a/docs/NewReadyTimeFail.md b/docs/NewReadyTimeFail.md deleted file mode 100644 index ee89f48..0000000 --- a/docs/NewReadyTimeFail.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# NewReadyTimeFail - - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/NotifyMembershipWebviewRequest.md b/docs/NotifyMembershipWebviewRequest.md index 38914a0..75dbcac 100644 --- a/docs/NotifyMembershipWebviewRequest.md +++ b/docs/NotifyMembershipWebviewRequest.md @@ -22,6 +22,7 @@ This request submits membership registration request to partner. | LINK | "LINK" | | REGISTER | "REGISTER" | | UNLINK | "UNLINK" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/OldMenuSectionCategoryItemsInnerDescriptionTranslation.md b/docs/OldMenuSectionCategoryItemsInnerDescriptionTranslation.md deleted file mode 100644 index 11a84db..0000000 --- a/docs/OldMenuSectionCategoryItemsInnerDescriptionTranslation.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# OldMenuSectionCategoryItemsInnerDescriptionTranslation - -Translation of the item description. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**en** | **String** | The English translation of the description. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my`. | [optional] | - - - diff --git a/docs/OldMenuSectionCategoryItemsInnerNameTranslation.md b/docs/OldMenuSectionCategoryItemsInnerNameTranslation.md deleted file mode 100644 index d00f4d9..0000000 --- a/docs/OldMenuSectionCategoryItemsInnerNameTranslation.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# OldMenuSectionCategoryItemsInnerNameTranslation - -Translation of the item name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**en** | **String** | The English translation of the name. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` | [optional] | - - - diff --git a/docs/Orders.md b/docs/Order.md similarity index 72% rename from docs/Orders.md rename to docs/Order.md index 0a07325..d82317a 100644 --- a/docs/Orders.md +++ b/docs/Order.md @@ -1,6 +1,6 @@ -# Orders +# Order A JSON object containing the order information. @@ -14,16 +14,16 @@ A JSON object containing the order information. |**partnerMerchantID** | **String** | The merchant's ID that is on the partner's database. | [optional] | |**paymentType** | [**PaymentTypeEnum**](#PaymentTypeEnum) | The payment method used. Refer to FAQs for more details about [paymentType](#section/Order/Does-the-paymentType-affect-partners). | | |**cutlery** | **Boolean** | The boolean value to indicate whether cutlery are needed or not. Refer to FAQs for more details about [cutlery](#section/Order/What-do-the-true-or-false-values-mean-for-cutlery). | | -|**orderTime** | **OffsetDateTime** | The UTC time that a consumer places the order, based on ISO_8601/RFC3339. | | +|**orderTime** | **String** | The UTC time that a consumer places the order, based on ISO_8601/RFC3339. | | |**submitTime** | **OffsetDateTime** | The order submit time, based on ISO_8601/RFC3339. Only present in the [List Orders](#tag/list-order) response. | [optional] | |**completeTime** | **OffsetDateTime** | The order complete time, based on ISO_8601/RFC3339. Only present in the [List Orders](#tag/list-order) response. | [optional] | -|**scheduledTime** | **OffsetDateTime** | The order scheduled time, based on ISO_8601/RFC3339. Empty for non-scheduled orders. | [optional] | +|**scheduledTime** | **String** | The order scheduled time, based on ISO_8601/RFC3339. Empty for non-scheduled orders. | [optional] | |**orderState** | **String** | The state of the order. Only present in the [List Orders](#tag/list-order) response. Refer to [Order States](#section/Order-states). | [optional] | |**currency** | [**Currency**](Currency.md) | | | -|**featureFlags** | [**FeatureFlags**](FeatureFlags.md) | | | -|**items** | [**List<OrderItemsInner>**](OrderItemsInner.md) | The items in an array of JSON Object. Refer to [Items](#items) for more information. | | -|**campaigns** | [**List<OrderCampaignsInner>**](OrderCampaignsInner.md) | The campaigns that are applicable for the order.`null` when there is no campaign applied. | [optional] | -|**promos** | [**List<PromosInner>**](PromosInner.md) | An array of promotion objects. Only promotions that are funded by merchants will be sent. | [optional] | +|**featureFlags** | [**OrderFeatureFlags**](OrderFeatureFlags.md) | | | +|**items** | [**List<OrderItem>**](OrderItem.md) | The items in an array of JSON Object. Refer to [Items](#items) for more information. | | +|**campaigns** | [**List<OrderCampaign>**](OrderCampaign.md) | The campaigns that are applicable for the order.`null` when there is no campaign applied. | [optional] | +|**promos** | [**List<OrderPromo>**](OrderPromo.md) | An array of promotion objects. Only promotions that are funded by merchants will be sent. | [optional] | |**price** | [**OrderPrice**](OrderPrice.md) | | | |**dineIn** | [**DineIn**](DineIn.md) | | [optional] | |**receiver** | [**Receiver**](Receiver.md) | | [optional] | @@ -38,6 +38,7 @@ A JSON object containing the order information. |---- | -----| | CASH | "CASH" | | CASHLESS | "CASHLESS" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/OrderCampaignsInner.md b/docs/OrderCampaign.md similarity index 79% rename from docs/OrderCampaignsInner.md rename to docs/OrderCampaign.md index a2d0723..d052760 100644 --- a/docs/OrderCampaignsInner.md +++ b/docs/OrderCampaign.md @@ -1,6 +1,6 @@ -# OrderCampaignsInner +# OrderCampaign ## Properties @@ -17,7 +17,7 @@ |**deductedAmount** | **Integer** | The deducted amount in minor unit format. `Item price(tax inclusive) * 20% discount | 2375*0.2` | [optional] | |**deductedPart** | [**DeductedPartEnum**](#DeductedPartEnum) | The part that the campaign is applied. | [optional] | |**appliedItemIDs** | **List<String>** | An array of item IDs that get discount under this campaign. `null` if no item applied in this campaign. | [optional] | -|**freeItem** | [**FreeItem**](FreeItem.md) | | [optional] | +|**freeItem** | [**OrderFreeItem**](OrderFreeItem.md) | | [optional] | @@ -30,6 +30,7 @@ | ORDER | "order" | | DELIVERY_FEE | "delivery_fee" | | BUNDLE | "bundle" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -40,10 +41,11 @@ | PERCENTAGE | "percentage" | | NET | "net" | | DELIVERY | "delivery" | -| FREEITEM | "freeItem" | -| BUNDLESAMENET | "bundleSameNet" | -| BUNDLESAMEPERCENTAGE | "bundleSamePercentage" | -| BUNDLESAMEFIXPRICE | "bundleSameFixPrice" | +| FREE_ITEM | "freeItem" | +| BUNDLE_SAME_NET | "bundleSameNet" | +| BUNDLE_SAME_PERCENTAGE | "bundleSamePercentage" | +| BUNDLE_SAME_FIX_PRICE | "bundleSameFixPrice" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -53,6 +55,7 @@ |---- | -----| | BASKET_AMOUNT | "basket_amount" | | DELIVERY_FEE | "delivery_fee" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/OrderDeliveryRequest.md b/docs/OrderDeliveryRequest.md index 2c804f0..138e20b 100644 --- a/docs/OrderDeliveryRequest.md +++ b/docs/OrderDeliveryRequest.md @@ -19,8 +19,9 @@ This request marks an order as delivered on GrabFood. | Name | Value | |---- | -----| | ACCEPTED | "Accepted" | -| FINDDRIVER | "FindDriver" | +| FIND_DRIVER | "FindDriver" | | COLLECTED | "Collected" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -28,9 +29,10 @@ This request marks an order as delivered on GrabFood. | Name | Value | |---- | -----| -| FINDDRIVER | "FindDriver" | +| FIND_DRIVER | "FindDriver" | | COLLECTED | "Collected" | | DELIVERED | "Delivered" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/FeatureFlags.md b/docs/OrderFeatureFlags.md similarity index 71% rename from docs/FeatureFlags.md rename to docs/OrderFeatureFlags.md index 6d79d31..203c8bb 100644 --- a/docs/FeatureFlags.md +++ b/docs/OrderFeatureFlags.md @@ -1,6 +1,6 @@ -# FeatureFlags +# OrderFeatureFlags The featureFlag JSON object containing an order's feature related information. @@ -20,6 +20,7 @@ The featureFlag JSON object containing an order's feature related information. |---- | -----| | AUTO | "AUTO" | | MANUAL | "MANUAL" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -27,10 +28,11 @@ The featureFlag JSON object containing an order's feature related information. | Name | Value | |---- | -----| -| TAKEAWAY | "TakeAway" | -| DELIVEREDBYGRAB | "DeliveredByGrab" | -| DELIVEREDBYRESTAURANT | "DeliveredByRestaurant" | -| DINEIN | "DineIn" | +| TAKE_AWAY | "TakeAway" | +| DELIVERED_BY_GRAB | "DeliveredByGrab" | +| DELIVERED_BY_RESTAURANT | "DeliveredByRestaurant" | +| DINE_IN | "DineIn" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/FreeItem.md b/docs/OrderFreeItem.md similarity index 96% rename from docs/FreeItem.md rename to docs/OrderFreeItem.md index 9bfa40e..eac7064 100644 --- a/docs/FreeItem.md +++ b/docs/OrderFreeItem.md @@ -1,6 +1,6 @@ -# FreeItem +# OrderFreeItem Free item information for `freeItem` campaign. diff --git a/docs/OrderItemsInner.md b/docs/OrderItem.md similarity index 85% rename from docs/OrderItemsInner.md rename to docs/OrderItem.md index b416bb8..6786d97 100644 --- a/docs/OrderItemsInner.md +++ b/docs/OrderItem.md @@ -1,6 +1,6 @@ -# OrderItemsInner +# OrderItem ## Properties @@ -14,7 +14,7 @@ |**tax** | **Integer** | Tax in minor format for 1 item and all modifiers under it. `0` if tax configuration is absent. `Item tax + Modifier tax | (2241*0.06)+(165*0.06)=144`. Refer to FAQs for more details about [tax](#section/Order/How-is-tax-calculated). | [optional] | |**specifications** | **String** | An extra note for the merchant. `Blank` if no note from consumer. | [optional] | |**outOfStockInstruction** | [**OutOfStockInstruction**](OutOfStockInstruction.md) | | [optional] | -|**modifiers** | [**List<OrderModifiersInner>**](OrderModifiersInner.md) | An array of JSON objects modifiers. Read [this](#categories) for more information. | [optional] | +|**modifiers** | [**List<OrderItemModifier>**](OrderItemModifier.md) | An array of JSON objects modifiers. Read [this](#categories) for more information. | [optional] | diff --git a/docs/OrderModifiersInner.md b/docs/OrderItemModifier.md similarity index 91% rename from docs/OrderModifiersInner.md rename to docs/OrderItemModifier.md index a8be1f8..3d19d68 100644 --- a/docs/OrderModifiersInner.md +++ b/docs/OrderItemModifier.md @@ -1,6 +1,6 @@ -# OrderModifiersInner +# OrderItemModifier ## Properties @@ -19,6 +19,7 @@ | Name | Value | |---- | -----| | NUMBER_1 | 1 | +| NUMBER_unknown_default_open_api | 11184809 | diff --git a/docs/PromosInner.md b/docs/OrderPromo.md similarity index 98% rename from docs/PromosInner.md rename to docs/OrderPromo.md index 7f86189..3baa8a4 100644 --- a/docs/PromosInner.md +++ b/docs/OrderPromo.md @@ -1,6 +1,6 @@ -# PromosInner +# OrderPromo ## Properties diff --git a/docs/OrderStateRequest.md b/docs/OrderStateRequest.md index 74f1292..2decc6b 100644 --- a/docs/OrderStateRequest.md +++ b/docs/OrderStateRequest.md @@ -28,6 +28,7 @@ This request pushes the state of an order on GrabFood. | DELIVERED | "DELIVERED" | | FAILED | "FAILED" | | CANCELLED | "CANCELLED" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/OutOfStockInstruction.md b/docs/OutOfStockInstruction.md index 9d47bb2..24d8be7 100644 --- a/docs/OutOfStockInstruction.md +++ b/docs/OutOfStockInstruction.md @@ -23,6 +23,7 @@ An JSON object that indicates the instructions to be taken by the merchant when | CANCEL | "CANCEL" | | SPECIFIC_ITEM | "SPECIFIC_ITEM" | | CONTACT | "CONTACT" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/PartnerOauthResponse.md b/docs/PartnerOauthResponse.md index fa24567..0e3c222 100644 --- a/docs/PartnerOauthResponse.md +++ b/docs/PartnerOauthResponse.md @@ -18,6 +18,7 @@ | Name | Value | |---- | -----| | BEARER | "Bearer" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/PauseStoreRequest.md b/docs/PauseStoreRequest.md index cf2863a..73a5797 100644 --- a/docs/PauseStoreRequest.md +++ b/docs/PauseStoreRequest.md @@ -21,6 +21,7 @@ This request pauses a store temporarily for (30 minutes/1 hour/24 hours) or unpa | _30M | "30m" | | _1H | "1h" | | _24H | "24h" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/RedeemDineinVoucher500Response.md b/docs/RedeemDineinVoucher500Response.md deleted file mode 100644 index c292708..0000000 --- a/docs/RedeemDineinVoucher500Response.md +++ /dev/null @@ -1,15 +0,0 @@ - - -# RedeemDineinVoucher500Response - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**target** | **String** | The target of error. | [optional] | -|**reason** | **String** | The type of error. | [optional] | -|**message** | **String** | The details of the error. | [optional] | - - - diff --git a/docs/RedeemResult.md b/docs/RedeemResult.md index ad2ca7c..739c46d 100644 --- a/docs/RedeemResult.md +++ b/docs/RedeemResult.md @@ -23,6 +23,7 @@ A JSON object containing dine-in voucher details. | INVALID_MERCHANT | "INVALID_MERCHANT" | | INVALID_ID | "INVALID_ID" | | EMPTY | "" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/GetRewardNativeRequestItemsInner.md b/docs/RewardItem.md similarity index 88% rename from docs/GetRewardNativeRequestItemsInner.md rename to docs/RewardItem.md index 8f2ae16..a522094 100644 --- a/docs/GetRewardNativeRequestItemsInner.md +++ b/docs/RewardItem.md @@ -1,6 +1,6 @@ -# GetRewardNativeRequestItemsInner +# RewardItem ## Properties diff --git a/docs/SellingTimesInner.md b/docs/SellingTime.md similarity index 96% rename from docs/SellingTimesInner.md rename to docs/SellingTime.md index dfc6d2c..0311a7f 100644 --- a/docs/SellingTimesInner.md +++ b/docs/SellingTime.md @@ -1,6 +1,6 @@ -# SellingTimesInner +# SellingTime ## Properties diff --git a/docs/DayHours.md b/docs/ServiceHour.md similarity index 65% rename from docs/DayHours.md rename to docs/ServiceHour.md index 250c559..bf8ff66 100644 --- a/docs/DayHours.md +++ b/docs/ServiceHour.md @@ -1,15 +1,15 @@ -# DayHours +# ServiceHour -A JSON object serviceHours for each day. +A JSON object serviceHour for each day. ## Properties | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**openPeriodType** | [**OpenPeriodTypeEnum**](#OpenPeriodTypeEnum) | The period type for when the outlet is open. - OpenPeriod = open only in given periods - OpenAllDay = open 24 hours - CloseAllDay = closed 24 hours | | -|**periods** | [**List<OpenPeriod>**](OpenPeriod.md) | An array of open periods. Only required when `openPeriodType` is **OpenPeriod** | | +|**periods** | [**List<OpenPeriod>**](OpenPeriod.md) | An array of open periods. Only required when `openPeriodType` is **OpenPeriod** | [optional] | @@ -17,9 +17,10 @@ A JSON object serviceHours for each day. | Name | Value | |---- | -----| -| OPENPERIOD | "OpenPeriod" | -| OPENALLDAY | "OpenAllDay" | -| CLOSEALLDAY | "CloseAllDay" | +| OPEN_PERIOD | "OpenPeriod" | +| OPEN_ALL_DAY | "OpenAllDay" | +| CLOSE_ALL_DAY | "CloseAllDay" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/ServiceHours.md b/docs/ServiceHours.md index 9e06e97..242909f 100644 --- a/docs/ServiceHours.md +++ b/docs/ServiceHours.md @@ -8,13 +8,13 @@ A JSON object with serviceHours for each day of the week. | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**mon** | [**DayHours**](DayHours.md) | | | -|**tue** | [**DayHours**](DayHours.md) | | | -|**wed** | [**DayHours**](DayHours.md) | | | -|**thu** | [**DayHours**](DayHours.md) | | | -|**fri** | [**DayHours**](DayHours.md) | | | -|**sat** | [**DayHours**](DayHours.md) | | | -|**sun** | [**DayHours**](DayHours.md) | | | +|**mon** | [**ServiceHour**](ServiceHour.md) | | | +|**tue** | [**ServiceHour**](ServiceHour.md) | | | +|**wed** | [**ServiceHour**](ServiceHour.md) | | | +|**thu** | [**ServiceHour**](ServiceHour.md) | | | +|**fri** | [**ServiceHour**](ServiceHour.md) | | | +|**sat** | [**ServiceHour**](ServiceHour.md) | | | +|**sun** | [**ServiceHour**](ServiceHour.md) | | | diff --git a/docs/SpecialOpeningHourOpeningHours.md b/docs/SpecialOpeningHourOpeningHours.md index 4dd3912..a6ce6e0 100644 --- a/docs/SpecialOpeningHourOpeningHours.md +++ b/docs/SpecialOpeningHourOpeningHours.md @@ -18,8 +18,9 @@ Store special opening hour period. | Name | Value | |---- | -----| | PERIOD | "Period" | -| OPENALLDAY | "OpenAllDay" | -| CLOSEDALLDAY | "ClosedAllDay" | +| OPEN_ALL_DAY | "OpenAllDay" | +| CLOSED_ALL_DAY | "ClosedAllDay" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/StoreHourStatusError.md b/docs/StoreHourStatusError.md deleted file mode 100644 index 1faf60c..0000000 --- a/docs/StoreHourStatusError.md +++ /dev/null @@ -1,15 +0,0 @@ - - -# StoreHourStatusError - -Example error returned for invalid request - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**reason** | **String** | Reason of invalid request. | [optional] | -|**message** | **String** | Readable error message. | [optional] | - - - diff --git a/docs/StoreStatusResponse.md b/docs/StoreStatusResponse.md index ec6669f..d8690ff 100644 --- a/docs/StoreStatusResponse.md +++ b/docs/StoreStatusResponse.md @@ -28,6 +28,7 @@ Object contains store status info | SUSPENDED | "suspended" | | PARSE_DATA_FAIL | "parse_data_fail" | | EMPTY | "" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/SubmitOrderRequest.md b/docs/SubmitOrderRequest.md index 82553fd..a536d4b 100644 --- a/docs/SubmitOrderRequest.md +++ b/docs/SubmitOrderRequest.md @@ -14,16 +14,16 @@ A JSON object containing the order information. |**partnerMerchantID** | **String** | The merchant's ID that is on the partner's database. | [optional] | |**paymentType** | [**PaymentTypeEnum**](#PaymentTypeEnum) | The payment method used. Refer to FAQs for more details about [paymentType](#section/Order/Does-the-paymentType-affect-partners). | | |**cutlery** | **Boolean** | The boolean value to indicate whether cutlery are needed or not. Refer to FAQs for more details about [cutlery](#section/Order/What-do-the-true-or-false-values-mean-for-cutlery). | | -|**orderTime** | **OffsetDateTime** | The UTC time that a consumer places the order, based on ISO_8601/RFC3339. | | +|**orderTime** | **String** | The UTC time that a consumer places the order, based on ISO_8601/RFC3339. | | |**submitTime** | **OffsetDateTime** | The order submit time, based on ISO_8601/RFC3339. Only present in the [List Orders](#tag/list-order) response. | [optional] | |**completeTime** | **OffsetDateTime** | The order complete time, based on ISO_8601/RFC3339. Only present in the [List Orders](#tag/list-order) response. | [optional] | -|**scheduledTime** | **OffsetDateTime** | The order scheduled time, based on ISO_8601/RFC3339. Empty for non-scheduled orders. | [optional] | +|**scheduledTime** | **String** | The order scheduled time, based on ISO_8601/RFC3339. Empty for non-scheduled orders. | [optional] | |**orderState** | **String** | The state of the order. Only present in the [List Orders](#tag/list-order) response. Refer to [Order States](#section/Order-states). | [optional] | |**currency** | [**Currency**](Currency.md) | | | -|**featureFlags** | [**FeatureFlags**](FeatureFlags.md) | | | -|**items** | [**List<OrderItemsInner>**](OrderItemsInner.md) | The items in an array of JSON Object. Refer to [Items](#items) for more information. | | -|**campaigns** | [**List<OrderCampaignsInner>**](OrderCampaignsInner.md) | The campaigns that are applicable for the order.`null` when there is no campaign applied. | [optional] | -|**promos** | [**List<PromosInner>**](PromosInner.md) | An array of promotion objects. Only promotions that are funded by merchants will be sent. | [optional] | +|**featureFlags** | [**OrderFeatureFlags**](OrderFeatureFlags.md) | | | +|**items** | [**List<OrderItem>**](OrderItem.md) | The items in an array of JSON Object. Refer to [Items](#items) for more information. | | +|**campaigns** | [**List<OrderCampaign>**](OrderCampaign.md) | The campaigns that are applicable for the order.`null` when there is no campaign applied. | [optional] | +|**promos** | [**List<OrderPromo>**](OrderPromo.md) | An array of promotion objects. Only promotions that are funded by merchants will be sent. | [optional] | |**price** | [**OrderPrice**](OrderPrice.md) | | | |**dineIn** | [**DineIn**](DineIn.md) | | [optional] | |**receiver** | [**Receiver**](Receiver.md) | | [optional] | @@ -38,6 +38,7 @@ A JSON object containing the order information. |---- | -----| | CASH | "CASH" | | CASHLESS | "CASHLESS" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/SyncFailCategoryItemsInnerModifierGroupsInner.md b/docs/SyncFailCategoryItemsInnerModifierGroupsInner.md deleted file mode 100644 index fd694dd..0000000 --- a/docs/SyncFailCategoryItemsInnerModifierGroupsInner.md +++ /dev/null @@ -1,15 +0,0 @@ - - -# SyncFailCategoryItemsInnerModifierGroupsInner - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**id** | **String** | | [optional] | -|**errors** | **List<String>** | An array of strings of error message. | [optional] | -|**modifiers** | [**List<SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner>**](SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.md) | | [optional] | - - - diff --git a/docs/TraceMenuSyncApi.md b/docs/TraceMenuSyncApi.md index 1261829..775e7a4 100644 --- a/docs/TraceMenuSyncApi.md +++ b/docs/TraceMenuSyncApi.md @@ -9,7 +9,7 @@ All URIs are relative to *https://partner-api.stg-myteksi.com/grabfood-sandbox* # **traceMenuSync** -> MenuSyncSuccess traceMenuSync(authorization, merchantID) +> MenuSyncResponse traceMenuSync(authorization, merchantID) Trace menu sync @@ -31,7 +31,7 @@ public class Example { String authorization = "Bearer "; // String | Specify the generated authorization token of the bearer type. String merchantID = "1-CYNGRUNGSBCCC"; // String | The merchant's ID that is in GrabFood's database. try { - MenuSyncSuccess result = apiInstance.traceMenuSync(authorization, merchantID); + MenuSyncResponse result = apiInstance.traceMenuSync(authorization, merchantID); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling TraceMenuSyncApi#traceMenuSync"); @@ -53,7 +53,7 @@ public class Example { ### Return type -[**MenuSyncSuccess**](MenuSyncSuccess.md) +[**MenuSyncResponse**](MenuSyncResponse.md) ### Authorization @@ -67,6 +67,6 @@ No authorization required ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -| **200** | Sync success | - | -| **4xx** | Sync fail | - | +| **200** | Sync success or fail | - | +| **4xx** | Common error | - | diff --git a/docs/UpdateAdvancedPricing.md b/docs/UpdateAdvancedPricing.md new file mode 100644 index 0000000..61e7593 --- /dev/null +++ b/docs/UpdateAdvancedPricing.md @@ -0,0 +1,29 @@ + + +# UpdateAdvancedPricing + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**key** | [**KeyEnum**](#KeyEnum) | Available service type. | [optional] | +|**price** | **Integer** | Price in minor unit. | [optional] | + + + +## Enum: KeyEnum + +| Name | Value | +|---- | -----| +| DELIVERY_ON_DEMAND_GRAB_APP | "Delivery_OnDemand_GrabApp" | +| DELIVERY_SCHEDULED_GRAB_APP | "Delivery_Scheduled_GrabApp" | +| SELF_PICK_UP_ON_DEMAND_GRAB_APP | "SelfPickUp_OnDemand_GrabApp" | +| DINE_IN_ON_DEMAND_GRAB_APP | "DineIn_OnDemand_GrabApp" | +| DELIVERY_ON_DEMAND_STORE_FRONT | "Delivery_OnDemand_StoreFront" | +| DELIVERY_SCHEDULED_STORE_FRONT | "Delivery_Scheduled_StoreFront" | +| SELF_PICK_UP_ON_DEMAND_STORE_FRONT | "SelfPickUp_OnDemand_StoreFront" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/UpdateCampaignRequest.md b/docs/UpdateCampaignRequest.md index cb210db..0808f6a 100644 --- a/docs/UpdateCampaignRequest.md +++ b/docs/UpdateCampaignRequest.md @@ -10,9 +10,9 @@ This request updates a campaign for your GrabFood store. |------------ | ------------- | ------------- | -------------| |**merchantID** | **String** | The merchant's ID that is in GrabFood's database. | [optional] | |**name** | **String** | The campaign's name. | [optional] | -|**quotas** | [**Quotas**](Quotas.md) | | [optional] | -|**conditions** | [**Conditions**](Conditions.md) | | [optional] | -|**discount** | [**Discount**](Discount.md) | | [optional] | +|**quotas** | [**CampaignQuotas**](CampaignQuotas.md) | | [optional] | +|**conditions** | [**CampaignConditions**](CampaignConditions.md) | | [optional] | +|**discount** | [**CampaignDiscount**](CampaignDiscount.md) | | [optional] | |**customTag** | **String** | Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. | [optional] | diff --git a/docs/UpdateDeliveryHourResponse.md b/docs/UpdateDeliveryHourResponse.md index 2341cc1..81d9436 100644 --- a/docs/UpdateDeliveryHourResponse.md +++ b/docs/UpdateDeliveryHourResponse.md @@ -19,10 +19,11 @@ Object contain update store delivery hour response | Name | Value | |---- | -----| -| CLOSINGHOURSINEFFECTIVE | "ClosingHoursIneffective" | -| FORCEUPDATED | "ForceUpdated" | -| PENDINGSCHEDULEDORDERS | "PendingScheduledOrders" | -| PENDINGORDERS | "PendingOrders" | +| CLOSING_HOURS_INEFFECTIVE | "ClosingHoursIneffective" | +| FORCE_UPDATED | "ForceUpdated" | +| PENDING_SCHEDULED_ORDERS | "PendingScheduledOrders" | +| PENDING_ORDERS | "PendingOrders" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/UpdateMenuItem.md b/docs/UpdateMenuItem.md index 5930a84..e9a993b 100644 --- a/docs/UpdateMenuItem.md +++ b/docs/UpdateMenuItem.md @@ -14,8 +14,8 @@ Information about the GrabFood client updating their food menu. |**price** | **Integer** | The record's price in minor unit format. | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The record's availableStatus. Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. | [optional] | |**maxStock** | **Integer** | Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. | [optional] | -|**advancedPricings** | [**List<UpdateMenuItemAdvancedPricingsInner>**](UpdateMenuItemAdvancedPricingsInner.md) | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. | [optional] | -|**purchasabilities** | [**List<UpdateMenuItemPurchasabilitiesInner>**](UpdateMenuItemPurchasabilitiesInner.md) | Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. | [optional] | +|**advancedPricings** | [**List<UpdateAdvancedPricing>**](UpdateAdvancedPricing.md) | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. | [optional] | +|**purchasabilities** | [**List<UpdatePurchasability>**](UpdatePurchasability.md) | Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. | [optional] | @@ -24,6 +24,7 @@ Information about the GrabFood client updating their food menu. | Name | Value | |---- | -----| | ITEM | "ITEM" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -34,6 +35,7 @@ Information about the GrabFood client updating their food menu. | AVAILABLE | "AVAILABLE" | | UNAVAILABLE | "UNAVAILABLE" | | UNAVAILABLETODAY | "UNAVAILABLETODAY" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/UpdateMenuItemAdvancedPricingsInner.md b/docs/UpdateMenuItemAdvancedPricingsInner.md deleted file mode 100644 index 4e2eb53..0000000 --- a/docs/UpdateMenuItemAdvancedPricingsInner.md +++ /dev/null @@ -1,28 +0,0 @@ - - -# UpdateMenuItemAdvancedPricingsInner - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**key** | [**KeyEnum**](#KeyEnum) | Available service type. | [optional] | -|**price** | **Integer** | Price in minor unit. | [optional] | - - - -## Enum: KeyEnum - -| Name | Value | -|---- | -----| -| DELIVERY_ONDEMAND_GRABAPP | "Delivery_OnDemand_GrabApp" | -| DELIVERY_SCHEDULED_GRABAPP | "Delivery_Scheduled_GrabApp" | -| SELFPICKUP_ONDEMAND_GRABAPP | "SelfPickUp_OnDemand_GrabApp" | -| DINEIN_ONDEMAND_GRABAPP | "DineIn_OnDemand_GrabApp" | -| DELIVERY_ONDEMAND_STOREFRONT | "Delivery_OnDemand_StoreFront" | -| DELIVERY_SCHEDULED_STOREFRONT | "Delivery_Scheduled_StoreFront" | -| SELFPICKUP_ONDEMAND_STOREFRONT | "SelfPickUp_OnDemand_StoreFront" | - - - diff --git a/docs/UpdateMenuItemPurchasabilitiesInner.md b/docs/UpdateMenuItemPurchasabilitiesInner.md deleted file mode 100644 index a9661ca..0000000 --- a/docs/UpdateMenuItemPurchasabilitiesInner.md +++ /dev/null @@ -1,28 +0,0 @@ - - -# UpdateMenuItemPurchasabilitiesInner - - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**key** | [**KeyEnum**](#KeyEnum) | Available service type. | [optional] | -|**purchasable** | **Boolean** | | [optional] | - - - -## Enum: KeyEnum - -| Name | Value | -|---- | -----| -| DELIVERY_ONDEMAND_GRABAPP | "Delivery_OnDemand_GrabApp" | -| DELIVERY_SCHEDULED_GRABAPP | "Delivery_Scheduled_GrabApp" | -| SELFPICKUP_ONDEMAND_GRABAPP | "SelfPickUp_OnDemand_GrabApp" | -| DINEIN_ONDEMAND_GRABAPP | "DineIn_OnDemand_GrabApp" | -| DELIVERY_ONDEMAND_STOREFRONT | "Delivery_OnDemand_StoreFront" | -| DELIVERY_SCHEDULED_STOREFRONT | "Delivery_Scheduled_StoreFront" | -| SELFPICKUP_ONDEMAND_STOREFRONT | "SelfPickUp_OnDemand_StoreFront" | - - - diff --git a/docs/UpdateMenuModifier.md b/docs/UpdateMenuModifier.md index dc8ffdd..f534d8c 100644 --- a/docs/UpdateMenuModifier.md +++ b/docs/UpdateMenuModifier.md @@ -15,7 +15,7 @@ Information about the GrabFood client updating their food menu. |**name** | **String** | **Only required when updating modifiers.** The record's name. Used as identifier to locate the correct record. | | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The record's availableStatus. | [optional] | |**isFree** | **Boolean** | Allows the modifier's price to be explicitly set as zero. Possible values are as follows: * `isFree` && `price == 0` sets the modifier's price to zero. * `isFree` && `price > 0` returns an error message that \"price cannot be set to > 0, if modifier is free”. * `!isFree` && `price > 0` sets the modifier's price to the defined price. * `!isFree` && `price == 0` does not update the modifier's price and reuses the existing price. | [optional] | -|**advancedPricings** | [**List<UpdateMenuItemAdvancedPricingsInner>**](UpdateMenuItemAdvancedPricingsInner.md) | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. | [optional] | +|**advancedPricings** | [**List<UpdateAdvancedPricing>**](UpdateAdvancedPricing.md) | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. | [optional] | @@ -24,6 +24,7 @@ Information about the GrabFood client updating their food menu. | Name | Value | |---- | -----| | MODIFIER | "MODIFIER" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -34,6 +35,7 @@ Information about the GrabFood client updating their food menu. | AVAILABLE | "AVAILABLE" | | UNAVAILABLE | "UNAVAILABLE" | | UNAVAILABLETODAY | "UNAVAILABLETODAY" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/UpdateMenuNotiApi.md b/docs/UpdateMenuNotiApi.md index 0d2ebe5..45ad47b 100644 --- a/docs/UpdateMenuNotiApi.md +++ b/docs/UpdateMenuNotiApi.md @@ -9,7 +9,7 @@ All URIs are relative to *https://partner-api.stg-myteksi.com/grabfood-sandbox* # **updateMenuNotification** -> updateMenuNotification(contentType, authorization, updateMenuNotiRequest) +> updateMenuNotification(contentType, authorization, updateMenuNotifRequest) Notify Grab of updated menu @@ -30,9 +30,9 @@ public class Example { UpdateMenuNotiApi apiInstance = new UpdateMenuNotiApi(defaultClient); String contentType = "application/json"; // String | The content type of the request body. You must use `application/json` for this header as GrabFood API currently does not support other formats. String authorization = "Bearer "; // String | Specify the generated authorization token of the bearer type. - UpdateMenuNotiRequest updateMenuNotiRequest = new UpdateMenuNotiRequest(); // UpdateMenuNotiRequest | + UpdateMenuNotifRequest updateMenuNotifRequest = new UpdateMenuNotifRequest(); // UpdateMenuNotifRequest | try { - apiInstance.updateMenuNotification(contentType, authorization, updateMenuNotiRequest); + apiInstance.updateMenuNotification(contentType, authorization, updateMenuNotifRequest); } catch (ApiException e) { System.err.println("Exception when calling UpdateMenuNotiApi#updateMenuNotification"); System.err.println("Status code: " + e.getCode()); @@ -50,7 +50,7 @@ public class Example { |------------- | ------------- | ------------- | -------------| | **contentType** | **String**| The content type of the request body. You must use `application/json` for this header as GrabFood API currently does not support other formats. | | | **authorization** | **String**| Specify the generated authorization token of the bearer type. | | -| **updateMenuNotiRequest** | [**UpdateMenuNotiRequest**](UpdateMenuNotiRequest.md)| | | +| **updateMenuNotifRequest** | [**UpdateMenuNotifRequest**](UpdateMenuNotifRequest.md)| | | ### Return type diff --git a/docs/UpdateMenuNotiRequest.md b/docs/UpdateMenuNotifRequest.md similarity index 92% rename from docs/UpdateMenuNotiRequest.md rename to docs/UpdateMenuNotifRequest.md index c0be083..f835de6 100644 --- a/docs/UpdateMenuNotiRequest.md +++ b/docs/UpdateMenuNotifRequest.md @@ -1,6 +1,6 @@ -# UpdateMenuNotiRequest +# UpdateMenuNotifRequest This request notifies GrabFood about the partner's updated food menu. diff --git a/docs/UpdateMenuRecordApi.md b/docs/UpdateMenuRecordApi.md index 9deaf5e..3526e44 100644 --- a/docs/UpdateMenuRecordApi.md +++ b/docs/UpdateMenuRecordApi.md @@ -10,7 +10,7 @@ All URIs are relative to *https://partner-api.stg-myteksi.com/grabfood-sandbox* # **batchUpdateMenuRecord** -> BatchUpdateMenuErrorMessage batchUpdateMenuRecord(contentType, authorization, batchUpdateMenuItem) +> BatchUpdateMenuResponse batchUpdateMenuRecord(contentType, authorization, batchUpdateMenuItem) Batch Update Menu @@ -33,7 +33,7 @@ public class Example { String authorization = "Bearer "; // String | Specify the generated authorization token of the bearer type. BatchUpdateMenuItem batchUpdateMenuItem = new BatchUpdateMenuItem(); // BatchUpdateMenuItem | try { - BatchUpdateMenuErrorMessage result = apiInstance.batchUpdateMenuRecord(contentType, authorization, batchUpdateMenuItem); + BatchUpdateMenuResponse result = apiInstance.batchUpdateMenuRecord(contentType, authorization, batchUpdateMenuItem); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling UpdateMenuRecordApi#batchUpdateMenuRecord"); @@ -56,7 +56,7 @@ public class Example { ### Return type -[**BatchUpdateMenuErrorMessage**](BatchUpdateMenuErrorMessage.md) +[**BatchUpdateMenuResponse**](BatchUpdateMenuResponse.md) ### Authorization diff --git a/docs/UpdateMenuRequest.md b/docs/UpdateMenuRequest.md index 5691dee..34470cb 100644 --- a/docs/UpdateMenuRequest.md +++ b/docs/UpdateMenuRequest.md @@ -13,8 +13,8 @@ |**price** | **Integer** | The record's price in minor unit format. | [optional] | |**availableStatus** | [**AvailableStatusEnum**](#AvailableStatusEnum) | The record's availableStatus. | [optional] | |**maxStock** | **Integer** | Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. | [optional] | -|**advancedPricings** | [**List<UpdateMenuItemAdvancedPricingsInner>**](UpdateMenuItemAdvancedPricingsInner.md) | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. | [optional] | -|**purchasabilities** | [**List<UpdateMenuItemPurchasabilitiesInner>**](UpdateMenuItemPurchasabilitiesInner.md) | Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. | [optional] | +|**advancedPricings** | [**List<UpdateAdvancedPricing>**](UpdateAdvancedPricing.md) | Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. | [optional] | +|**purchasabilities** | [**List<UpdatePurchasability>**](UpdatePurchasability.md) | Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. | [optional] | |**name** | **String** | **Only required when updating modifiers.** The record's name. Used as identifier to locate the correct record. | | |**isFree** | **Boolean** | Allows the modifier's price to be explicitly set as zero. Possible values are as follows: * `isFree` && `price == 0` sets the modifier's price to zero. * `isFree` && `price > 0` returns an error message that \"price cannot be set to > 0, if modifier is free”. * `!isFree` && `price > 0` sets the modifier's price to the defined price. * `!isFree` && `price == 0` does not update the modifier's price and reuses the existing price. | [optional] | @@ -25,6 +25,7 @@ | Name | Value | |---- | -----| | MODIFIER | "MODIFIER" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | @@ -35,6 +36,7 @@ | AVAILABLE | "AVAILABLE" | | UNAVAILABLE | "UNAVAILABLE" | | UNAVAILABLETODAY | "UNAVAILABLETODAY" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/UpdatePurchasability.md b/docs/UpdatePurchasability.md new file mode 100644 index 0000000..c35ad72 --- /dev/null +++ b/docs/UpdatePurchasability.md @@ -0,0 +1,29 @@ + + +# UpdatePurchasability + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**key** | [**KeyEnum**](#KeyEnum) | Available service type. | [optional] | +|**purchasable** | **Boolean** | | [optional] | + + + +## Enum: KeyEnum + +| Name | Value | +|---- | -----| +| DELIVERY_ON_DEMAND_GRAB_APP | "Delivery_OnDemand_GrabApp" | +| DELIVERY_SCHEDULED_GRAB_APP | "Delivery_Scheduled_GrabApp" | +| SELF_PICK_UP_ON_DEMAND_GRAB_APP | "SelfPickUp_OnDemand_GrabApp" | +| DINE_IN_ON_DEMAND_GRAB_APP | "DineIn_OnDemand_GrabApp" | +| DELIVERY_ON_DEMAND_STORE_FRONT | "Delivery_OnDemand_StoreFront" | +| DELIVERY_SCHEDULED_STORE_FRONT | "Delivery_Scheduled_StoreFront" | +| SELF_PICK_UP_ON_DEMAND_STORE_FRONT | "SelfPickUp_OnDemand_StoreFront" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | + + + diff --git a/docs/UpdateSpecialHourRequest.md b/docs/UpdateSpecialHourRequest.md index 4af9010..7a6c8e2 100644 --- a/docs/UpdateSpecialHourRequest.md +++ b/docs/UpdateSpecialHourRequest.md @@ -8,7 +8,7 @@ Object contains store special hours. | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**specialOpeningHours** | [**List<SpecialOpeningHour>**](SpecialOpeningHour.md) | An array of objects contain store special hours. Max. 3 array elements. | [optional] | +|**specialOpeningHours** | [**List<SpecialOpeningHour>**](SpecialOpeningHour.md) | An array of objects contain store special hours. Max. 3 array elements. | | diff --git a/docs/UpdateSpecialHourResponse.md b/docs/UpdateSpecialHourResponse.md index 586993a..b86a4e8 100644 --- a/docs/UpdateSpecialHourResponse.md +++ b/docs/UpdateSpecialHourResponse.md @@ -19,7 +19,8 @@ Object contain update store special hour response | Name | Value | |---- | -----| -| PENDINGORDERS | "PendingOrders" | +| PENDING_ORDERS | "PendingOrders" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/Voucher.md b/docs/Voucher.md index 15dd285..3820c93 100644 --- a/docs/Voucher.md +++ b/docs/Voucher.md @@ -22,6 +22,7 @@ A JSON object containing dine-in voucher details. |---- | -----| | CASH | "CASH" | | ITEM | "ITEM" | +| UNKNOWN_DEFAULT_OPEN_API | "unknown_default_open_api" | diff --git a/docs/WorkingHour.md b/docs/WorkingHour.md index 6867574..02d9bf9 100644 --- a/docs/WorkingHour.md +++ b/docs/WorkingHour.md @@ -8,13 +8,13 @@ A JSON object that describes the workingHour for each day. | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**sun** | [**WorkingHourSun**](WorkingHourSun.md) | | [optional] | -|**mon** | [**WorkingHourMon**](WorkingHourMon.md) | | [optional] | -|**tue** | [**WorkingHourTue**](WorkingHourTue.md) | | [optional] | -|**wed** | [**WorkingHourWed**](WorkingHourWed.md) | | [optional] | -|**thu** | [**WorkingHourThu**](WorkingHourThu.md) | | [optional] | -|**fri** | [**WorkingHourFri**](WorkingHourFri.md) | | [optional] | -|**sat** | [**WorkingHourSat**](WorkingHourSat.md) | | [optional] | +|**sun** | [**WorkingHourDay**](WorkingHourDay.md) | | [optional] | +|**mon** | [**WorkingHourDay**](WorkingHourDay.md) | | [optional] | +|**tue** | [**WorkingHourDay**](WorkingHourDay.md) | | [optional] | +|**wed** | [**WorkingHourDay**](WorkingHourDay.md) | | [optional] | +|**thu** | [**WorkingHourDay**](WorkingHourDay.md) | | [optional] | +|**fri** | [**WorkingHourDay**](WorkingHourDay.md) | | [optional] | +|**sat** | [**WorkingHourDay**](WorkingHourDay.md) | | [optional] | diff --git a/docs/WorkingHourFri.md b/docs/WorkingHourDay.md similarity index 84% rename from docs/WorkingHourFri.md rename to docs/WorkingHourDay.md index e672970..1f3cee1 100644 --- a/docs/WorkingHourFri.md +++ b/docs/WorkingHourDay.md @@ -1,8 +1,8 @@ -# WorkingHourFri +# WorkingHourDay -A JSON object for workingHour for Friday. +A JSON object for workingHour for a day. ## Properties diff --git a/docs/WorkingHourMon.md b/docs/WorkingHourMon.md deleted file mode 100644 index ce55cdd..0000000 --- a/docs/WorkingHourMon.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# WorkingHourMon - -A JSON object for workingHour for Monday. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**periods** | [**List<OpenPeriod>**](OpenPeriod.md) | An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. | [optional] | - - - diff --git a/docs/WorkingHourSat.md b/docs/WorkingHourSat.md deleted file mode 100644 index 961a36f..0000000 --- a/docs/WorkingHourSat.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# WorkingHourSat - -A JSON object for workingHour for Saturday. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**periods** | [**List<OpenPeriod>**](OpenPeriod.md) | An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. | [optional] | - - - diff --git a/docs/WorkingHourSun.md b/docs/WorkingHourSun.md deleted file mode 100644 index 25c3bd1..0000000 --- a/docs/WorkingHourSun.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# WorkingHourSun - -A JSON object for workingHour for Sunday. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**periods** | [**List<OpenPeriod>**](OpenPeriod.md) | An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. | [optional] | - - - diff --git a/docs/WorkingHourThu.md b/docs/WorkingHourThu.md deleted file mode 100644 index f7c39d5..0000000 --- a/docs/WorkingHourThu.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# WorkingHourThu - -A JSON object for workingHour for Thursday. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**periods** | [**List<OpenPeriod>**](OpenPeriod.md) | An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. | [optional] | - - - diff --git a/docs/WorkingHourTue.md b/docs/WorkingHourTue.md deleted file mode 100644 index a4eae4f..0000000 --- a/docs/WorkingHourTue.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# WorkingHourTue - -A JSON object for workingHour for Tuesday. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**periods** | [**List<OpenPeriod>**](OpenPeriod.md) | An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. | [optional] | - - - diff --git a/docs/WorkingHourWed.md b/docs/WorkingHourWed.md deleted file mode 100644 index 82c8906..0000000 --- a/docs/WorkingHourWed.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# WorkingHourWed - -A JSON object for workingHour for Wednesday. - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| -|**periods** | [**List<OpenPeriod>**](OpenPeriod.md) | An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. | [optional] | - - - diff --git a/pom.xml b/pom.xml index f3cfa06..bab0bc3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ jar grabfood-java-client 1.0.0 - + https://github.com/grab/grabfood-api-sdk-java OpenAPI Java scm:git:git@github.com:openapitools/openapi-generator.git @@ -301,14 +301,9 @@ ${jackson-databind-nullable-version} - javax.ws.rs - jsr311-api - ${jsr311-api-version} - - - javax.ws.rs - javax.ws.rs-api - ${javax.ws.rs-api-version} + jakarta.ws.rs + jakarta.ws.rs-api + ${jakarta.ws.rs-api-version} @@ -329,14 +324,14 @@ ${java.version} ${java.version} 1.9.0 - 4.11.0 + 4.12.0 2.10.1 3.14.0 0.2.6 1.3.5 - 5.10.2 + 5.10.3 1.10.0 - 2.1.1 + 2.1.6 1.1.1 UTF-8 2.43.0 diff --git a/src/main/java/com/grabfood/client/ApiClient.java b/src/main/java/com/grabfood/client/ApiClient.java index 4569917..fa2dae5 100644 --- a/src/main/java/com/grabfood/client/ApiClient.java +++ b/src/main/java/com/grabfood/client/ApiClient.java @@ -746,6 +746,30 @@ public List parameterToPairs(String collectionFormat, String name, Collect return params; } + /** + * Formats the specified free-form query parameters to a list of {@code Pair} objects. + * + * @param value The free-form query parameters. + * @return A list of {@code Pair} objects. + */ + public List freeFormParameterToPairs(Object value) { + List params = new ArrayList<>(); + + // preconditions + if (value == null || !(value instanceof Map )) { + return params; + } + + final Map valuesMap = (Map) value; + + for (Map.Entry entry : valuesMap.entrySet()) { + params.add(new Pair(entry.getKey(), parameterToString(entry.getValue()))); + } + + return params; + } + + /** * Formats the specified collection path parameter to a string value. * @@ -1184,10 +1208,6 @@ public Call buildCall(String baseUrl, String path, String method, List que * @throws com.grabfood.client.ApiException If fail to serialize the request body object */ public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { - // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams - List allQueryParams = new ArrayList(queryParams); - allQueryParams.addAll(collectionQueryParams); - final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); // prepare HTTP request body @@ -1215,10 +1235,12 @@ public Request buildRequest(String baseUrl, String path, String method, List updatedQueryParams = new ArrayList<>(queryParams); + // update parameters with authentication settings - updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + updateParamsForAuth(authNames, updatedQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); - final Request.Builder reqBuilder = new Request.Builder().url(url); + final Request.Builder reqBuilder = new Request.Builder().url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams)); processHeaderParams(headerParams, reqBuilder); processCookieParams(cookieParams, reqBuilder); diff --git a/src/main/java/com/grabfood/client/ApiException.java b/src/main/java/com/grabfood/client/ApiException.java index b3cf2d9..9406ef9 100644 --- a/src/main/java/com/grabfood/client/ApiException.java +++ b/src/main/java/com/grabfood/client/ApiException.java @@ -24,7 +24,7 @@ *

ApiException class.

*/ @SuppressWarnings("serial") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class ApiException extends Exception { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/grabfood/client/Configuration.java b/src/main/java/com/grabfood/client/Configuration.java index eca538c..7cc8c79 100644 --- a/src/main/java/com/grabfood/client/Configuration.java +++ b/src/main/java/com/grabfood/client/Configuration.java @@ -16,7 +16,7 @@ package com.grabfood.client; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class Configuration { public static final String VERSION = "1.0.0"; diff --git a/src/main/java/com/grabfood/client/JSON.java b/src/main/java/com/grabfood/client/JSON.java index d2cab12..e733a78 100644 --- a/src/main/java/com/grabfood/client/JSON.java +++ b/src/main/java/com/grabfood/client/JSON.java @@ -16,11 +16,11 @@ package com.grabfood.client; -import com.fasterxml.jackson.databind.util.StdDateFormat; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonParseException; import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.google.gson.JsonElement; @@ -34,16 +34,14 @@ import java.lang.reflect.Type; import java.text.DateFormat; import java.text.ParseException; +import java.text.ParsePosition; import java.time.LocalDate; import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.Locale; import java.util.Map; import java.util.HashMap; -import java.util.TimeZone; /* * A JSON utility class @@ -60,11 +58,6 @@ public class JSON { private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); - private static final StdDateFormat sdf = new StdDateFormat() - .withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())) - .withColonInTimeZone(true); - private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME; - @SuppressWarnings("unchecked") public static GsonBuilder createGson() { GsonFireBuilder fireBuilder = new GsonFireBuilder() @@ -106,39 +99,27 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.AcceptOrderRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Address.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.AdvancedPricing.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.BatchUpdateMenuErrorMessage.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.BatchUpdateMenuErrorMessageErrorsInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.BatchUpdateMenuItem.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.BatchUpdateMenuItemMenuEntitiesInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.BatchUpdateMenuResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.BindMembershipNativeRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.BindMembershipNativeResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Campaigns.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CancelOrderFail.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CancelOrderFail403.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Campaign.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CampaignConditions.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CampaignDiscount.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CampaignQuotas.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CampaignScope.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CancelOrderRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CancelOrderResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CancelReasonsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CategoriesInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CategoriesInnerNameTranslation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CancelReason.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CheckOrderCancelableResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Conditions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Coordinates.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CreateCampaignFail.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CreateCampaignRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.CreateCampaignResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Currency.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.DayHours.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.DineIn.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.DineInVoucher400Fail.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.DineInVoucher404Fail.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Discount.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.EditOrderItem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.EditOrderRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.EditOrderRequestItemsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Error404.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Error409.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Error500.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.FeatureFlags.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.FreeItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Error.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GetDineInVoucherResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GetMembershipNativeResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GetMembershipNativeResponsePointInfo.CustomTypeAdapterFactory()); @@ -147,96 +128,84 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GetMenuNewResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GetMenuOldResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GetRewardNativeRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GetRewardNativeRequestItemsInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GetRewardNativeResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GrabOauthRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.GrabOauthResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.ListCampaignResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.ListOrdersResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MarkOrderFail.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MarkOrderRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuItemsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuItemsInnerDescriptionTranslation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuModifiersInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuModifiersInnerNameTranslation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuCategory.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuEntity.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuEntityError.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuModifier.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSection.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSectionCategory.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSectionCategoryItem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncFail.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncSuccess.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncFailCategory.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncFailItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncFailModifier.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncFailModifierGroup.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncFailServiceHours.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.MenuSyncWebhookRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.ModifierGroupsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.ModifierGroupsInnerNameTranslation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.ModifierGroup.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.NewOrderTimeRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.NewReadyTimeFail.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.NotifyMembershipWebviewRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OldMenuSectionCategoryItemsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OldMenuSectionCategoryItemsInnerDescriptionTranslation.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OldMenuSectionCategoryItemsInnerNameTranslation.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OpenPeriod.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderCampaignsInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Order.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderCampaign.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderDeliveryRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderItemsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderModifiersInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderFeatureFlags.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderFreeItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderItemModifier.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderPrice.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderPromo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderReadyEstimation.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OrderStateRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Orders.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.OutOfStockInstruction.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.PartnerOauthRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.PartnerOauthResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.PauseStoreRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.PromosInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Purchasability.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Quotas.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Receiver.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.RedeemDineInVoucherRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.RedeemDineInVoucherResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.RedeemDineinVoucher500Response.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.RedeemResult.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.RegisterMembershipNativeRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.RegisterMembershipNativeResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Scope.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SectionsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SectionsInnerCategoriesInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SellingTimesInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.RewardItem.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SellingTime.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.ServiceHour.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.ServiceHours.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SpecialOpeningHour.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SpecialOpeningHourMetadata.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SpecialOpeningHourOpeningHours.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.StoreHour.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.StoreHourResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.StoreHourStatusError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.StoreStatusResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SubmitOrderRequest.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SyncFail.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SyncFailCategoriesInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SyncFailCategoryItemsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SyncFailCategoryItemsInnerModifierGroupsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.SyncFailServiceHours.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UnbindMembershipNativeRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UnlinkMembershipWebviewRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateAdvancedPricing.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateCampaignRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateDeliveryHourRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateDeliveryHourResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateDineInHourRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateDineInHourResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateMenuItem.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateMenuItemAdvancedPricingsInner.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateMenuItemPurchasabilitiesInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateMenuModifier.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateMenuNotiRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateMenuNotifRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateMenuRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdatePurchasability.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateSpecialHourRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.UpdateSpecialHourResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.Voucher.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.VoucherDescriptionInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHour.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHourFri.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHourMon.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHourSat.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHourSun.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHourThu.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHourTue.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHourWed.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.grabfood.client.model.WorkingHourDay.CustomTypeAdapterFactory()); gson = gsonBuilder.create(); } @@ -469,7 +438,7 @@ public java.sql.Date read(JsonReader in) throws IOException { if (dateFormat != null) { return new java.sql.Date(dateFormat.parse(date).getTime()); } - return new java.sql.Date(sdf.parse(date).getTime()); + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); } catch (ParseException e) { throw new JsonParseException(e); } @@ -479,7 +448,7 @@ public java.sql.Date read(JsonReader in) throws IOException { /** * Gson TypeAdapter for java.util.Date type - * If the dateFormat is null, DateTimeFormatter will be used. + * If the dateFormat is null, ISO8601Utils will be used. */ public static class DateTypeAdapter extends TypeAdapter { @@ -504,7 +473,7 @@ public void write(JsonWriter out, Date date) throws IOException { if (dateFormat != null) { value = dateFormat.format(date); } else { - value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf); + value = ISO8601Utils.format(date, true); } out.value(value); } @@ -523,7 +492,7 @@ public Date read(JsonReader in) throws IOException { if (dateFormat != null) { return dateFormat.parse(date); } - return sdf.parse(date); + return ISO8601Utils.parse(date, new ParsePosition(0)); } catch (ParseException e) { throw new JsonParseException(e); } diff --git a/src/main/java/com/grabfood/client/Pair.java b/src/main/java/com/grabfood/client/Pair.java index 1cf7bbe..55b3219 100644 --- a/src/main/java/com/grabfood/client/Pair.java +++ b/src/main/java/com/grabfood/client/Pair.java @@ -16,7 +16,7 @@ package com.grabfood.client; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class Pair { private String name = ""; private String value = ""; diff --git a/src/main/java/com/grabfood/client/ServerConfiguration.java b/src/main/java/com/grabfood/client/ServerConfiguration.java index 014c271..8dd1f57 100644 --- a/src/main/java/com/grabfood/client/ServerConfiguration.java +++ b/src/main/java/com/grabfood/client/ServerConfiguration.java @@ -1,3 +1,19 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + package com.grabfood.client; import java.util.Map; @@ -5,7 +21,7 @@ /** * Representing a Server configuration. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class ServerConfiguration { public String URL; public String description; diff --git a/src/main/java/com/grabfood/client/ServerVariable.java b/src/main/java/com/grabfood/client/ServerVariable.java index d45dd4e..96117db 100644 --- a/src/main/java/com/grabfood/client/ServerVariable.java +++ b/src/main/java/com/grabfood/client/ServerVariable.java @@ -1,3 +1,19 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + package com.grabfood.client; import java.util.HashSet; @@ -5,7 +21,7 @@ /** * Representing a Server Variable for server URL template substitution. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class ServerVariable { public String description; public String defaultValue; diff --git a/src/main/java/com/grabfood/client/StringUtil.java b/src/main/java/com/grabfood/client/StringUtil.java index c9ca1d1..bd8a312 100644 --- a/src/main/java/com/grabfood/client/StringUtil.java +++ b/src/main/java/com/grabfood/client/StringUtil.java @@ -19,7 +19,7 @@ import java.util.Collection; import java.util.Iterator; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/src/main/java/com/grabfood/client/api/CancelOrderApi.java b/src/main/java/com/grabfood/client/api/CancelOrderApi.java index 6ad0bc7..119b28b 100644 --- a/src/main/java/com/grabfood/client/api/CancelOrderApi.java +++ b/src/main/java/com/grabfood/client/api/CancelOrderApi.java @@ -30,13 +30,9 @@ import java.io.IOException; -import com.grabfood.client.model.CancelOrderFail; -import com.grabfood.client.model.CancelOrderFail403; import com.grabfood.client.model.CancelOrderRequest; import com.grabfood.client.model.CancelOrderResponse; -import com.grabfood.client.model.Error404; -import com.grabfood.client.model.Error409; -import com.grabfood.client.model.Error500; +import com.grabfood.client.model.Error; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/src/main/java/com/grabfood/client/api/CreateCampaignApi.java b/src/main/java/com/grabfood/client/api/CreateCampaignApi.java index 4238742..b8a3e24 100644 --- a/src/main/java/com/grabfood/client/api/CreateCampaignApi.java +++ b/src/main/java/com/grabfood/client/api/CreateCampaignApi.java @@ -30,9 +30,9 @@ import java.io.IOException; -import com.grabfood.client.model.CreateCampaignFail; import com.grabfood.client.model.CreateCampaignRequest; import com.grabfood.client.model.CreateCampaignResponse; +import com.grabfood.client.model.Error; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/src/main/java/com/grabfood/client/api/EditOrderApi.java b/src/main/java/com/grabfood/client/api/EditOrderApi.java index 820efef..13b76e2 100644 --- a/src/main/java/com/grabfood/client/api/EditOrderApi.java +++ b/src/main/java/com/grabfood/client/api/EditOrderApi.java @@ -30,8 +30,8 @@ import java.io.IOException; -import com.grabfood.client.model.CancelOrderFail; import com.grabfood.client.model.EditOrderRequest; +import com.grabfood.client.model.Error; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/src/main/java/com/grabfood/client/api/GetDineinVoucherApi.java b/src/main/java/com/grabfood/client/api/GetDineinVoucherApi.java index 545e3dc..9494467 100644 --- a/src/main/java/com/grabfood/client/api/GetDineinVoucherApi.java +++ b/src/main/java/com/grabfood/client/api/GetDineinVoucherApi.java @@ -30,8 +30,7 @@ import java.io.IOException; -import com.grabfood.client.model.DineInVoucher400Fail; -import com.grabfood.client.model.DineInVoucher404Fail; +import com.grabfood.client.model.Error; import com.grabfood.client.model.GetDineInVoucherResponse; import java.lang.reflect.Type; diff --git a/src/main/java/com/grabfood/client/api/GetStoreHourApi.java b/src/main/java/com/grabfood/client/api/GetStoreHourApi.java index 239fe43..3745c0c 100644 --- a/src/main/java/com/grabfood/client/api/GetStoreHourApi.java +++ b/src/main/java/com/grabfood/client/api/GetStoreHourApi.java @@ -30,8 +30,8 @@ import java.io.IOException; +import com.grabfood.client.model.Error; import com.grabfood.client.model.StoreHourResponse; -import com.grabfood.client.model.StoreHourStatusError; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/src/main/java/com/grabfood/client/api/GetStoreStatusApi.java b/src/main/java/com/grabfood/client/api/GetStoreStatusApi.java index b4b9534..eb7688e 100644 --- a/src/main/java/com/grabfood/client/api/GetStoreStatusApi.java +++ b/src/main/java/com/grabfood/client/api/GetStoreStatusApi.java @@ -30,7 +30,7 @@ import java.io.IOException; -import com.grabfood.client.model.StoreHourStatusError; +import com.grabfood.client.model.Error; import com.grabfood.client.model.StoreStatusResponse; import java.lang.reflect.Type; diff --git a/src/main/java/com/grabfood/client/api/MarkOrderApi.java b/src/main/java/com/grabfood/client/api/MarkOrderApi.java index 97f38cb..1f6c408 100644 --- a/src/main/java/com/grabfood/client/api/MarkOrderApi.java +++ b/src/main/java/com/grabfood/client/api/MarkOrderApi.java @@ -30,7 +30,7 @@ import java.io.IOException; -import com.grabfood.client.model.MarkOrderFail; +import com.grabfood.client.model.Error; import com.grabfood.client.model.MarkOrderRequest; import java.lang.reflect.Type; diff --git a/src/main/java/com/grabfood/client/api/RedeemDineinVoucherApi.java b/src/main/java/com/grabfood/client/api/RedeemDineinVoucherApi.java index 5eee8b3..4a2c1f2 100644 --- a/src/main/java/com/grabfood/client/api/RedeemDineinVoucherApi.java +++ b/src/main/java/com/grabfood/client/api/RedeemDineinVoucherApi.java @@ -30,11 +30,9 @@ import java.io.IOException; -import com.grabfood.client.model.DineInVoucher400Fail; -import com.grabfood.client.model.DineInVoucher404Fail; +import com.grabfood.client.model.Error; import com.grabfood.client.model.RedeemDineInVoucherRequest; import com.grabfood.client.model.RedeemDineInVoucherResponse; -import com.grabfood.client.model.RedeemDineinVoucher500Response; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/src/main/java/com/grabfood/client/api/TraceMenuSyncApi.java b/src/main/java/com/grabfood/client/api/TraceMenuSyncApi.java index c75cde5..2d0253b 100644 --- a/src/main/java/com/grabfood/client/api/TraceMenuSyncApi.java +++ b/src/main/java/com/grabfood/client/api/TraceMenuSyncApi.java @@ -30,8 +30,8 @@ import java.io.IOException; -import com.grabfood.client.model.MenuSyncFail; -import com.grabfood.client.model.MenuSyncSuccess; +import com.grabfood.client.model.Error; +import com.grabfood.client.model.MenuSyncResponse; import java.lang.reflect.Type; import java.util.ArrayList; @@ -86,8 +86,8 @@ public void setCustomBaseUrl(String customBaseUrl) { * @http.response.details - - + +
Status Code Description Response Headers
200 Sync success -
4xx Sync fail -
200 Sync success or fail -
4xx Common error -
*/ public okhttp3.Call traceMenuSyncCall(String authorization, String merchantID, final ApiCallback _callback) throws ApiException { @@ -163,17 +163,17 @@ private okhttp3.Call traceMenuSyncValidateBeforeCall(String authorization, Strin * * @param authorization Specify the generated authorization token of the bearer type. (required) * @param merchantID The merchant's ID that is in GrabFood's database. (required) - * @return MenuSyncSuccess + * @return MenuSyncResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - - + +
Status Code Description Response Headers
200 Sync success -
4xx Sync fail -
200 Sync success or fail -
4xx Common error -
*/ - public MenuSyncSuccess traceMenuSync(String authorization, String merchantID) throws ApiException { - ApiResponse localVarResp = traceMenuSyncWithHttpInfo(authorization, merchantID); + public MenuSyncResponse traceMenuSync(String authorization, String merchantID) throws ApiException { + ApiResponse localVarResp = traceMenuSyncWithHttpInfo(authorization, merchantID); return localVarResp.getData(); } @@ -182,18 +182,18 @@ public MenuSyncSuccess traceMenuSync(String authorization, String merchantID) th * * @param authorization Specify the generated authorization token of the bearer type. (required) * @param merchantID The merchant's ID that is in GrabFood's database. (required) - * @return ApiResponse<MenuSyncSuccess> + * @return ApiResponse<MenuSyncResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - - + +
Status Code Description Response Headers
200 Sync success -
4xx Sync fail -
200 Sync success or fail -
4xx Common error -
*/ - public ApiResponse traceMenuSyncWithHttpInfo(String authorization, String merchantID) throws ApiException { + public ApiResponse traceMenuSyncWithHttpInfo(String authorization, String merchantID) throws ApiException { okhttp3.Call localVarCall = traceMenuSyncValidateBeforeCall(authorization, merchantID, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -208,14 +208,14 @@ public ApiResponse traceMenuSyncWithHttpInfo(String authorizati * @http.response.details - - + +
Status Code Description Response Headers
200 Sync success -
4xx Sync fail -
200 Sync success or fail -
4xx Common error -
*/ - public okhttp3.Call traceMenuSyncAsync(String authorization, String merchantID, final ApiCallback _callback) throws ApiException { + public okhttp3.Call traceMenuSyncAsync(String authorization, String merchantID, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = traceMenuSyncValidateBeforeCall(authorization, merchantID, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } diff --git a/src/main/java/com/grabfood/client/api/UpdateMenuNotiApi.java b/src/main/java/com/grabfood/client/api/UpdateMenuNotiApi.java index eb33e24..b38a10e 100644 --- a/src/main/java/com/grabfood/client/api/UpdateMenuNotiApi.java +++ b/src/main/java/com/grabfood/client/api/UpdateMenuNotiApi.java @@ -30,7 +30,7 @@ import java.io.IOException; -import com.grabfood.client.model.UpdateMenuNotiRequest; +import com.grabfood.client.model.UpdateMenuNotifRequest; import java.lang.reflect.Type; import java.util.ArrayList; @@ -79,7 +79,7 @@ public void setCustomBaseUrl(String customBaseUrl) { * Build call for updateMenuNotification * @param contentType The content type of the request body. You must use `application/json` for this header as GrabFood API currently does not support other formats. (required) * @param authorization Specify the generated authorization token of the bearer type. (required) - * @param updateMenuNotiRequest (required) + * @param updateMenuNotifRequest (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -89,7 +89,7 @@ public void setCustomBaseUrl(String customBaseUrl) { 204 Successful. No Content returned. * x-job-id - Uniquely identifies a menu sync job. Please mention this value while raising any issues on [Menu sync webhook](#tag/menu-sync-webhook).
*/ - public okhttp3.Call updateMenuNotificationCall(String contentType, String authorization, UpdateMenuNotiRequest updateMenuNotiRequest, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updateMenuNotificationCall(String contentType, String authorization, UpdateMenuNotifRequest updateMenuNotifRequest, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -103,7 +103,7 @@ public okhttp3.Call updateMenuNotificationCall(String contentType, String author basePath = null; } - Object localVarPostBody = updateMenuNotiRequest; + Object localVarPostBody = updateMenuNotifRequest; // create path and map variables String localVarPath = "/partner/v1/merchant/menu/notification"; @@ -142,7 +142,7 @@ public okhttp3.Call updateMenuNotificationCall(String contentType, String author } @SuppressWarnings("rawtypes") - private okhttp3.Call updateMenuNotificationValidateBeforeCall(String contentType, String authorization, UpdateMenuNotiRequest updateMenuNotiRequest, final ApiCallback _callback) throws ApiException { + private okhttp3.Call updateMenuNotificationValidateBeforeCall(String contentType, String authorization, UpdateMenuNotifRequest updateMenuNotifRequest, final ApiCallback _callback) throws ApiException { // verify the required parameter 'contentType' is set if (contentType == null) { throw new ApiException("Missing the required parameter 'contentType' when calling updateMenuNotification(Async)"); @@ -153,12 +153,12 @@ private okhttp3.Call updateMenuNotificationValidateBeforeCall(String contentType throw new ApiException("Missing the required parameter 'authorization' when calling updateMenuNotification(Async)"); } - // verify the required parameter 'updateMenuNotiRequest' is set - if (updateMenuNotiRequest == null) { - throw new ApiException("Missing the required parameter 'updateMenuNotiRequest' when calling updateMenuNotification(Async)"); + // verify the required parameter 'updateMenuNotifRequest' is set + if (updateMenuNotifRequest == null) { + throw new ApiException("Missing the required parameter 'updateMenuNotifRequest' when calling updateMenuNotification(Async)"); } - return updateMenuNotificationCall(contentType, authorization, updateMenuNotiRequest, _callback); + return updateMenuNotificationCall(contentType, authorization, updateMenuNotifRequest, _callback); } @@ -167,7 +167,7 @@ private okhttp3.Call updateMenuNotificationValidateBeforeCall(String contentType * * @param contentType The content type of the request body. You must use `application/json` for this header as GrabFood API currently does not support other formats. (required) * @param authorization Specify the generated authorization token of the bearer type. (required) - * @param updateMenuNotiRequest (required) + * @param updateMenuNotifRequest (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -175,8 +175,8 @@ private okhttp3.Call updateMenuNotificationValidateBeforeCall(String contentType
204 Successful. No Content returned. * x-job-id - Uniquely identifies a menu sync job. Please mention this value while raising any issues on [Menu sync webhook](#tag/menu-sync-webhook).
*/ - public void updateMenuNotification(String contentType, String authorization, UpdateMenuNotiRequest updateMenuNotiRequest) throws ApiException { - updateMenuNotificationWithHttpInfo(contentType, authorization, updateMenuNotiRequest); + public void updateMenuNotification(String contentType, String authorization, UpdateMenuNotifRequest updateMenuNotifRequest) throws ApiException { + updateMenuNotificationWithHttpInfo(contentType, authorization, updateMenuNotifRequest); } /** @@ -184,7 +184,7 @@ public void updateMenuNotification(String contentType, String authorization, Upd * * @param contentType The content type of the request body. You must use `application/json` for this header as GrabFood API currently does not support other formats. (required) * @param authorization Specify the generated authorization token of the bearer type. (required) - * @param updateMenuNotiRequest (required) + * @param updateMenuNotifRequest (required) * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -193,8 +193,8 @@ public void updateMenuNotification(String contentType, String authorization, Upd 204 Successful. No Content returned. * x-job-id - Uniquely identifies a menu sync job. Please mention this value while raising any issues on [Menu sync webhook](#tag/menu-sync-webhook).
*/ - public ApiResponse updateMenuNotificationWithHttpInfo(String contentType, String authorization, UpdateMenuNotiRequest updateMenuNotiRequest) throws ApiException { - okhttp3.Call localVarCall = updateMenuNotificationValidateBeforeCall(contentType, authorization, updateMenuNotiRequest, null); + public ApiResponse updateMenuNotificationWithHttpInfo(String contentType, String authorization, UpdateMenuNotifRequest updateMenuNotifRequest) throws ApiException { + okhttp3.Call localVarCall = updateMenuNotificationValidateBeforeCall(contentType, authorization, updateMenuNotifRequest, null); return localVarApiClient.execute(localVarCall); } @@ -203,7 +203,7 @@ public ApiResponse updateMenuNotificationWithHttpInfo(String contentType, * * @param contentType The content type of the request body. You must use `application/json` for this header as GrabFood API currently does not support other formats. (required) * @param authorization Specify the generated authorization token of the bearer type. (required) - * @param updateMenuNotiRequest (required) + * @param updateMenuNotifRequest (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -213,9 +213,9 @@ public ApiResponse updateMenuNotificationWithHttpInfo(String contentType, 204 Successful. No Content returned. * x-job-id - Uniquely identifies a menu sync job. Please mention this value while raising any issues on [Menu sync webhook](#tag/menu-sync-webhook).
*/ - public okhttp3.Call updateMenuNotificationAsync(String contentType, String authorization, UpdateMenuNotiRequest updateMenuNotiRequest, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updateMenuNotificationAsync(String contentType, String authorization, UpdateMenuNotifRequest updateMenuNotifRequest, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = updateMenuNotificationValidateBeforeCall(contentType, authorization, updateMenuNotiRequest, _callback); + okhttp3.Call localVarCall = updateMenuNotificationValidateBeforeCall(contentType, authorization, updateMenuNotifRequest, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } diff --git a/src/main/java/com/grabfood/client/api/UpdateMenuRecordApi.java b/src/main/java/com/grabfood/client/api/UpdateMenuRecordApi.java index 9285d20..d48ebe5 100644 --- a/src/main/java/com/grabfood/client/api/UpdateMenuRecordApi.java +++ b/src/main/java/com/grabfood/client/api/UpdateMenuRecordApi.java @@ -30,8 +30,8 @@ import java.io.IOException; -import com.grabfood.client.model.BatchUpdateMenuErrorMessage; import com.grabfood.client.model.BatchUpdateMenuItem; +import com.grabfood.client.model.BatchUpdateMenuResponse; import com.grabfood.client.model.UpdateMenuRequest; import java.lang.reflect.Type; @@ -174,7 +174,7 @@ private okhttp3.Call batchUpdateMenuRecordValidateBeforeCall(String contentType, * @param contentType The content type of the request body. You must use `application/json` for this header as GrabFood API currently does not support other formats. (required) * @param authorization Specify the generated authorization token of the bearer type. (required) * @param batchUpdateMenuItem (required) - * @return BatchUpdateMenuErrorMessage + * @return BatchUpdateMenuResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -185,8 +185,8 @@ private okhttp3.Call batchUpdateMenuRecordValidateBeforeCall(String contentType,
429 Too Many Requests -
*/ - public BatchUpdateMenuErrorMessage batchUpdateMenuRecord(String contentType, String authorization, BatchUpdateMenuItem batchUpdateMenuItem) throws ApiException { - ApiResponse localVarResp = batchUpdateMenuRecordWithHttpInfo(contentType, authorization, batchUpdateMenuItem); + public BatchUpdateMenuResponse batchUpdateMenuRecord(String contentType, String authorization, BatchUpdateMenuItem batchUpdateMenuItem) throws ApiException { + ApiResponse localVarResp = batchUpdateMenuRecordWithHttpInfo(contentType, authorization, batchUpdateMenuItem); return localVarResp.getData(); } @@ -196,7 +196,7 @@ public BatchUpdateMenuErrorMessage batchUpdateMenuRecord(String contentType, Str * @param contentType The content type of the request body. You must use `application/json` for this header as GrabFood API currently does not support other formats. (required) * @param authorization Specify the generated authorization token of the bearer type. (required) * @param batchUpdateMenuItem (required) - * @return ApiResponse<BatchUpdateMenuErrorMessage> + * @return ApiResponse<BatchUpdateMenuResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -207,9 +207,9 @@ public BatchUpdateMenuErrorMessage batchUpdateMenuRecord(String contentType, Str
429 Too Many Requests -
*/ - public ApiResponse batchUpdateMenuRecordWithHttpInfo(String contentType, String authorization, BatchUpdateMenuItem batchUpdateMenuItem) throws ApiException { + public ApiResponse batchUpdateMenuRecordWithHttpInfo(String contentType, String authorization, BatchUpdateMenuItem batchUpdateMenuItem) throws ApiException { okhttp3.Call localVarCall = batchUpdateMenuRecordValidateBeforeCall(contentType, authorization, batchUpdateMenuItem, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -231,10 +231,10 @@ public ApiResponse batchUpdateMenuRecordWithHttpInf 429 Too Many Requests - */ - public okhttp3.Call batchUpdateMenuRecordAsync(String contentType, String authorization, BatchUpdateMenuItem batchUpdateMenuItem, final ApiCallback _callback) throws ApiException { + public okhttp3.Call batchUpdateMenuRecordAsync(String contentType, String authorization, BatchUpdateMenuItem batchUpdateMenuItem, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = batchUpdateMenuRecordValidateBeforeCall(contentType, authorization, batchUpdateMenuItem, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } diff --git a/src/main/java/com/grabfood/client/api/UpdateOrderReadyTimeApi.java b/src/main/java/com/grabfood/client/api/UpdateOrderReadyTimeApi.java index 0ebc2e8..15d8232 100644 --- a/src/main/java/com/grabfood/client/api/UpdateOrderReadyTimeApi.java +++ b/src/main/java/com/grabfood/client/api/UpdateOrderReadyTimeApi.java @@ -30,8 +30,8 @@ import java.io.IOException; +import com.grabfood.client.model.Error; import com.grabfood.client.model.NewOrderTimeRequest; -import com.grabfood.client.model.NewReadyTimeFail; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/src/main/java/com/grabfood/client/auth/ApiKeyAuth.java b/src/main/java/com/grabfood/client/auth/ApiKeyAuth.java index 8aaac58..6e4775d 100644 --- a/src/main/java/com/grabfood/client/auth/ApiKeyAuth.java +++ b/src/main/java/com/grabfood/client/auth/ApiKeyAuth.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/src/main/java/com/grabfood/client/auth/HttpBasicAuth.java b/src/main/java/com/grabfood/client/auth/HttpBasicAuth.java index 56a1102..3f4a19d 100644 --- a/src/main/java/com/grabfood/client/auth/HttpBasicAuth.java +++ b/src/main/java/com/grabfood/client/auth/HttpBasicAuth.java @@ -25,8 +25,6 @@ import java.util.Map; import java.util.List; -import java.io.UnsupportedEncodingException; - public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/src/main/java/com/grabfood/client/auth/HttpBearerAuth.java b/src/main/java/com/grabfood/client/auth/HttpBearerAuth.java index 0fe7c65..0e1f820 100644 --- a/src/main/java/com/grabfood/client/auth/HttpBearerAuth.java +++ b/src/main/java/com/grabfood/client/auth/HttpBearerAuth.java @@ -25,7 +25,7 @@ import java.util.Optional; import java.util.function.Supplier; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class HttpBearerAuth implements Authentication { private final String scheme; private Supplier tokenSupplier; diff --git a/src/main/java/com/grabfood/client/model/AbstractOpenApiSchema.java b/src/main/java/com/grabfood/client/model/AbstractOpenApiSchema.java index fd45e36..31e9de3 100644 --- a/src/main/java/com/grabfood/client/model/AbstractOpenApiSchema.java +++ b/src/main/java/com/grabfood/client/model/AbstractOpenApiSchema.java @@ -24,7 +24,7 @@ /** * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public abstract class AbstractOpenApiSchema { // store the actual instance of the schema/object diff --git a/src/main/java/com/grabfood/client/model/AcceptOrderRequest.java b/src/main/java/com/grabfood/client/model/AcceptOrderRequest.java index 2af7019..dac27c3 100644 --- a/src/main/java/com/grabfood/client/model/AcceptOrderRequest.java +++ b/src/main/java/com/grabfood/client/model/AcceptOrderRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * The manual acceptance or rejection of an order on GrabFood. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class AcceptOrderRequest { public static final String SERIALIZED_NAME_ORDER_I_D = "orderID"; @SerializedName(SERIALIZED_NAME_ORDER_I_D) @@ -65,7 +64,9 @@ public class AcceptOrderRequest { public enum ToStateEnum { ACCEPTED("Accepted"), - REJECTED("Rejected"); + REJECTED("Rejected"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -88,7 +89,7 @@ public static ToStateEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -122,10 +123,10 @@ public AcceptOrderRequest orderID(String orderID) { return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -141,10 +142,10 @@ public AcceptOrderRequest toState(ToStateEnum toState) { return this; } - /** + /** * The order's updated state. * @return toState - **/ + */ @javax.annotation.Nonnull public ToStateEnum getToState() { return toState; @@ -154,6 +155,50 @@ public void setToState(ToStateEnum toState) { this.toState = toState; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AcceptOrderRequest instance itself + */ + public AcceptOrderRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -166,12 +211,13 @@ public boolean equals(Object o) { } AcceptOrderRequest acceptOrderRequest = (AcceptOrderRequest) o; return Objects.equals(this.orderID, acceptOrderRequest.orderID) && - Objects.equals(this.toState, acceptOrderRequest.toState); + Objects.equals(this.toState, acceptOrderRequest.toState)&& + Objects.equals(this.additionalProperties, acceptOrderRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(orderID, toState); + return Objects.hash(orderID, toState, additionalProperties); } @Override @@ -180,6 +226,7 @@ public String toString() { sb.append("class AcceptOrderRequest {\n"); sb.append(" orderID: ").append(toIndentedString(orderID)).append("\n"); sb.append(" toState: ").append(toIndentedString(toState)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -211,12 +258,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("toState"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to AcceptOrderRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to AcceptOrderRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AcceptOrderRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -224,14 +271,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AcceptOrderRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AcceptOrderRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AcceptOrderRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -264,6 +303,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AcceptOrderRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -271,29 +332,50 @@ public void write(JsonWriter out, AcceptOrderRequest value) throws IOException { public AcceptOrderRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AcceptOrderRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of AcceptOrderRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of AcceptOrderRequest - * @throws IOException if the JSON string is invalid with respect to AcceptOrderRequest - */ + /** + * Create an instance of AcceptOrderRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of AcceptOrderRequest + * @throws IOException if the JSON string is invalid with respect to AcceptOrderRequest + */ public static AcceptOrderRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, AcceptOrderRequest.class); } - /** - * Convert an instance of AcceptOrderRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of AcceptOrderRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Address.java b/src/main/java/com/grabfood/client/model/Address.java index 4466f49..846aa35 100644 --- a/src/main/java/com/grabfood/client/model/Address.java +++ b/src/main/java/com/grabfood/client/model/Address.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * A JSON object containing the receiver’s location information. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class Address { public static final String SERIALIZED_NAME_UNIT_NUMBER = "unitNumber"; @SerializedName(SERIALIZED_NAME_UNIT_NUMBER) @@ -70,7 +69,9 @@ public class Address { public enum PoiSourceEnum { GRAB("GRAB"), - GOOGLE("GOOGLE"); + GOOGLE("GOOGLE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -93,7 +94,7 @@ public static PoiSourceEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -143,10 +144,10 @@ public Address unitNumber(String unitNumber) { return this; } - /** + /** * The delivery address' unit number. * @return unitNumber - **/ + */ @javax.annotation.Nullable public String getUnitNumber() { return unitNumber; @@ -162,10 +163,10 @@ public Address deliveryInstruction(String deliveryInstruction) { return this; } - /** + /** * Instructions for the delivery. * @return deliveryInstruction - **/ + */ @javax.annotation.Nullable public String getDeliveryInstruction() { return deliveryInstruction; @@ -181,10 +182,10 @@ public Address poiSource(PoiSourceEnum poiSource) { return this; } - /** + /** * POI source * @return poiSource - **/ + */ @javax.annotation.Nullable public PoiSourceEnum getPoiSource() { return poiSource; @@ -200,10 +201,10 @@ public Address poiID(String poiID) { return this; } - /** + /** * POI ID, empty when poiSource is GRAB. * @return poiID - **/ + */ @javax.annotation.Nullable public String getPoiID() { return poiID; @@ -219,10 +220,10 @@ public Address address(String address) { return this; } - /** + /** * The delivery address containing street name, city, postal code, and country. Has value only when poiSource is `GRAB`. * @return address - **/ + */ @javax.annotation.Nullable public String getAddress() { return address; @@ -238,10 +239,10 @@ public Address postcode(String postcode) { return this; } - /** + /** * The postcode of the delivery address. Has value only when poiSource is `GRAB`. * @return postcode - **/ + */ @javax.annotation.Nullable public String getPostcode() { return postcode; @@ -257,10 +258,10 @@ public Address coordinates(Coordinates coordinates) { return this; } - /** + /** * Get coordinates * @return coordinates - **/ + */ @javax.annotation.Nullable public Coordinates getCoordinates() { return coordinates; @@ -270,6 +271,50 @@ public void setCoordinates(Coordinates coordinates) { this.coordinates = coordinates; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Address instance itself + */ + public Address putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -287,12 +332,13 @@ public boolean equals(Object o) { Objects.equals(this.poiID, address.poiID) && Objects.equals(this.address, address.address) && Objects.equals(this.postcode, address.postcode) && - Objects.equals(this.coordinates, address.coordinates); + Objects.equals(this.coordinates, address.coordinates)&& + Objects.equals(this.additionalProperties, address.additionalProperties); } @Override public int hashCode() { - return Objects.hash(unitNumber, deliveryInstruction, poiSource, poiID, address, postcode, coordinates); + return Objects.hash(unitNumber, deliveryInstruction, poiSource, poiID, address, postcode, coordinates, additionalProperties); } @Override @@ -306,6 +352,7 @@ public String toString() { sb.append(" address: ").append(toIndentedString(address)).append("\n"); sb.append(" postcode: ").append(toIndentedString(postcode)).append("\n"); sb.append(" coordinates: ").append(toIndentedString(coordinates)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -340,26 +387,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Address - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Address + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Address.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in Address is not found in the empty JSON string", Address.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Address.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Address` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("unitNumber") != null && !jsonObj.get("unitNumber").isJsonNull()) && !jsonObj.get("unitNumber").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `unitNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("unitNumber").toString())); @@ -404,6 +443,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Address value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -411,29 +472,50 @@ public void write(JsonWriter out, Address value) throws IOException { public Address read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Address instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Address given an JSON string - * - * @param jsonString JSON string - * @return An instance of Address - * @throws IOException if the JSON string is invalid with respect to Address - */ + /** + * Create an instance of Address given an JSON string + * + * @param jsonString JSON string + * @return An instance of Address + * @throws IOException if the JSON string is invalid with respect to Address + */ public static Address fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, Address.class); } - /** - * Convert an instance of Address to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of Address to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/AdvancedPricing.java b/src/main/java/com/grabfood/client/model/AdvancedPricing.java index 82f41e3..ee8c48d 100644 --- a/src/main/java/com/grabfood/client/model/AdvancedPricing.java +++ b/src/main/java/com/grabfood/client/model/AdvancedPricing.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. Refer [Service Based Menu](#section/Service-Based-Menu). */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class AdvancedPricing { public static final String SERIALIZED_NAME_DELIVERY_ON_DEMAND_GRAB_APP = "Delivery_OnDemand_GrabApp"; @SerializedName(SERIALIZED_NAME_DELIVERY_ON_DEMAND_GRAB_APP) @@ -90,10 +89,10 @@ public AdvancedPricing deliveryOnDemandGrabApp(Integer deliveryOnDemandGrabApp) return this; } - /** + /** * Service type: `Delivery`, Order type: `Instant`, Channel: `Grab App` * @return deliveryOnDemandGrabApp - **/ + */ @javax.annotation.Nullable public Integer getDeliveryOnDemandGrabApp() { return deliveryOnDemandGrabApp; @@ -109,10 +108,10 @@ public AdvancedPricing deliveryScheduledGrabApp(Integer deliveryScheduledGrabApp return this; } - /** + /** * Service type: `Delivery`, Order type: `Scheduled`, Channel: `Grab App` * @return deliveryScheduledGrabApp - **/ + */ @javax.annotation.Nullable public Integer getDeliveryScheduledGrabApp() { return deliveryScheduledGrabApp; @@ -128,10 +127,10 @@ public AdvancedPricing selfPickUpOnDemandGrabApp(Integer selfPickUpOnDemandGrabA return this; } - /** + /** * Service type: `Self Pick Up`, Order type: `Instant`, Channel: `Grab App` * @return selfPickUpOnDemandGrabApp - **/ + */ @javax.annotation.Nullable public Integer getSelfPickUpOnDemandGrabApp() { return selfPickUpOnDemandGrabApp; @@ -147,10 +146,10 @@ public AdvancedPricing dineInOnDemandGrabApp(Integer dineInOnDemandGrabApp) { return this; } - /** + /** * Service type: `Dine In`, Order type: `Instant`, Channel: `Grab App` * @return dineInOnDemandGrabApp - **/ + */ @javax.annotation.Nullable public Integer getDineInOnDemandGrabApp() { return dineInOnDemandGrabApp; @@ -166,10 +165,10 @@ public AdvancedPricing deliveryOnDemandStoreFront(Integer deliveryOnDemandStoreF return this; } - /** + /** * Service type: `Delivery`, Order type: `Instant`, Channel: `Store Front` * @return deliveryOnDemandStoreFront - **/ + */ @javax.annotation.Nullable public Integer getDeliveryOnDemandStoreFront() { return deliveryOnDemandStoreFront; @@ -185,10 +184,10 @@ public AdvancedPricing deliveryScheduledStoreFront(Integer deliveryScheduledStor return this; } - /** + /** * Service type: `Delivery`, Order type: `Scheduled`, Channel: `Store Front` * @return deliveryScheduledStoreFront - **/ + */ @javax.annotation.Nullable public Integer getDeliveryScheduledStoreFront() { return deliveryScheduledStoreFront; @@ -204,10 +203,10 @@ public AdvancedPricing selfPickUpOnDemandStoreFront(Integer selfPickUpOnDemandSt return this; } - /** + /** * Service type: `Self Pick Up`, Order type: `Instant`, Channel: `Store Front` * @return selfPickUpOnDemandStoreFront - **/ + */ @javax.annotation.Nullable public Integer getSelfPickUpOnDemandStoreFront() { return selfPickUpOnDemandStoreFront; @@ -217,6 +216,50 @@ public void setSelfPickUpOnDemandStoreFront(Integer selfPickUpOnDemandStoreFront this.selfPickUpOnDemandStoreFront = selfPickUpOnDemandStoreFront; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdvancedPricing instance itself + */ + public AdvancedPricing putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -234,12 +277,13 @@ public boolean equals(Object o) { Objects.equals(this.dineInOnDemandGrabApp, advancedPricing.dineInOnDemandGrabApp) && Objects.equals(this.deliveryOnDemandStoreFront, advancedPricing.deliveryOnDemandStoreFront) && Objects.equals(this.deliveryScheduledStoreFront, advancedPricing.deliveryScheduledStoreFront) && - Objects.equals(this.selfPickUpOnDemandStoreFront, advancedPricing.selfPickUpOnDemandStoreFront); + Objects.equals(this.selfPickUpOnDemandStoreFront, advancedPricing.selfPickUpOnDemandStoreFront)&& + Objects.equals(this.additionalProperties, advancedPricing.additionalProperties); } @Override public int hashCode() { - return Objects.hash(deliveryOnDemandGrabApp, deliveryScheduledGrabApp, selfPickUpOnDemandGrabApp, dineInOnDemandGrabApp, deliveryOnDemandStoreFront, deliveryScheduledStoreFront, selfPickUpOnDemandStoreFront); + return Objects.hash(deliveryOnDemandGrabApp, deliveryScheduledGrabApp, selfPickUpOnDemandGrabApp, dineInOnDemandGrabApp, deliveryOnDemandStoreFront, deliveryScheduledStoreFront, selfPickUpOnDemandStoreFront, additionalProperties); } @Override @@ -253,6 +297,7 @@ public String toString() { sb.append(" deliveryOnDemandStoreFront: ").append(toIndentedString(deliveryOnDemandStoreFront)).append("\n"); sb.append(" deliveryScheduledStoreFront: ").append(toIndentedString(deliveryScheduledStoreFront)).append("\n"); sb.append(" selfPickUpOnDemandStoreFront: ").append(toIndentedString(selfPickUpOnDemandStoreFront)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -287,26 +332,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to AdvancedPricing - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to AdvancedPricing + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!AdvancedPricing.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in AdvancedPricing is not found in the empty JSON string", AdvancedPricing.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AdvancedPricing.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdvancedPricing` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -325,6 +362,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AdvancedPricing value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -332,29 +391,50 @@ public void write(JsonWriter out, AdvancedPricing value) throws IOException { public AdvancedPricing read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdvancedPricing instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of AdvancedPricing given an JSON string - * - * @param jsonString JSON string - * @return An instance of AdvancedPricing - * @throws IOException if the JSON string is invalid with respect to AdvancedPricing - */ + /** + * Create an instance of AdvancedPricing given an JSON string + * + * @param jsonString JSON string + * @return An instance of AdvancedPricing + * @throws IOException if the JSON string is invalid with respect to AdvancedPricing + */ public static AdvancedPricing fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, AdvancedPricing.class); } - /** - * Convert an instance of AdvancedPricing to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of AdvancedPricing to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/BatchUpdateMenuErrorMessageErrorsInner.java b/src/main/java/com/grabfood/client/model/BatchUpdateMenuErrorMessageErrorsInner.java deleted file mode 100644 index c493026..0000000 --- a/src/main/java/com/grabfood/client/model/BatchUpdateMenuErrorMessageErrorsInner.java +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * BatchUpdateMenuErrorMessageErrorsInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class BatchUpdateMenuErrorMessageErrorsInner { - public static final String SERIALIZED_NAME_ENTITY_I_D = "entityID"; - @SerializedName(SERIALIZED_NAME_ENTITY_I_D) - private String entityID; - - public static final String SERIALIZED_NAME_ERR_MSG = "errMsg"; - @SerializedName(SERIALIZED_NAME_ERR_MSG) - private String errMsg; - - public BatchUpdateMenuErrorMessageErrorsInner() { - } - - public BatchUpdateMenuErrorMessageErrorsInner entityID(String entityID) { - this.entityID = entityID; - return this; - } - - /** - * The itemID. - * @return entityID - **/ - @javax.annotation.Nullable - public String getEntityID() { - return entityID; - } - - public void setEntityID(String entityID) { - this.entityID = entityID; - } - - - public BatchUpdateMenuErrorMessageErrorsInner errMsg(String errMsg) { - this.errMsg = errMsg; - return this; - } - - /** - * The error message. - * @return errMsg - **/ - @javax.annotation.Nullable - public String getErrMsg() { - return errMsg; - } - - public void setErrMsg(String errMsg) { - this.errMsg = errMsg; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BatchUpdateMenuErrorMessageErrorsInner batchUpdateMenuErrorMessageErrorsInner = (BatchUpdateMenuErrorMessageErrorsInner) o; - return Objects.equals(this.entityID, batchUpdateMenuErrorMessageErrorsInner.entityID) && - Objects.equals(this.errMsg, batchUpdateMenuErrorMessageErrorsInner.errMsg); - } - - @Override - public int hashCode() { - return Objects.hash(entityID, errMsg); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class BatchUpdateMenuErrorMessageErrorsInner {\n"); - sb.append(" entityID: ").append(toIndentedString(entityID)).append("\n"); - sb.append(" errMsg: ").append(toIndentedString(errMsg)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("entityID"); - openapiFields.add("errMsg"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to BatchUpdateMenuErrorMessageErrorsInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!BatchUpdateMenuErrorMessageErrorsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in BatchUpdateMenuErrorMessageErrorsInner is not found in the empty JSON string", BatchUpdateMenuErrorMessageErrorsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BatchUpdateMenuErrorMessageErrorsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BatchUpdateMenuErrorMessageErrorsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("entityID") != null && !jsonObj.get("entityID").isJsonNull()) && !jsonObj.get("entityID").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `entityID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("entityID").toString())); - } - if ((jsonObj.get("errMsg") != null && !jsonObj.get("errMsg").isJsonNull()) && !jsonObj.get("errMsg").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `errMsg` to be a primitive type in the JSON string but got `%s`", jsonObj.get("errMsg").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!BatchUpdateMenuErrorMessageErrorsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'BatchUpdateMenuErrorMessageErrorsInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(BatchUpdateMenuErrorMessageErrorsInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, BatchUpdateMenuErrorMessageErrorsInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public BatchUpdateMenuErrorMessageErrorsInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of BatchUpdateMenuErrorMessageErrorsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of BatchUpdateMenuErrorMessageErrorsInner - * @throws IOException if the JSON string is invalid with respect to BatchUpdateMenuErrorMessageErrorsInner - */ - public static BatchUpdateMenuErrorMessageErrorsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, BatchUpdateMenuErrorMessageErrorsInner.class); - } - - /** - * Convert an instance of BatchUpdateMenuErrorMessageErrorsInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/BatchUpdateMenuItem.java b/src/main/java/com/grabfood/client/model/BatchUpdateMenuItem.java index d424f0b..f79272e 100644 --- a/src/main/java/com/grabfood/client/model/BatchUpdateMenuItem.java +++ b/src/main/java/com/grabfood/client/model/BatchUpdateMenuItem.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.BatchUpdateMenuItemMenuEntitiesInner; +import com.grabfood.client.model.MenuEntity; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * Information about the GrabFood client updating their food menu. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class BatchUpdateMenuItem { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -66,7 +65,9 @@ public class BatchUpdateMenuItem { */ @JsonAdapter(FieldEnum.Adapter.class) public enum FieldEnum { - ITEM("ITEM"); + ITEM("ITEM"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -89,7 +90,7 @@ public static FieldEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -117,7 +118,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_MENU_ENTITIES = "menuEntities"; @SerializedName(SERIALIZED_NAME_MENU_ENTITIES) - private List menuEntities = new ArrayList<>(); + private List menuEntities = new ArrayList<>(); public BatchUpdateMenuItem() { } @@ -127,10 +128,10 @@ public BatchUpdateMenuItem merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -146,10 +147,10 @@ public BatchUpdateMenuItem field(FieldEnum field) { return this; } - /** + /** * The record type that you want to update. * @return field - **/ + */ @javax.annotation.Nonnull public FieldEnum getField() { return field; @@ -160,12 +161,12 @@ public void setField(FieldEnum field) { } - public BatchUpdateMenuItem menuEntities(List menuEntities) { + public BatchUpdateMenuItem menuEntities(List menuEntities) { this.menuEntities = menuEntities; return this; } - public BatchUpdateMenuItem addMenuEntitiesItem(BatchUpdateMenuItemMenuEntitiesInner menuEntitiesItem) { + public BatchUpdateMenuItem addMenuEntitiesItem(MenuEntity menuEntitiesItem) { if (this.menuEntities == null) { this.menuEntities = new ArrayList<>(); } @@ -173,19 +174,63 @@ public BatchUpdateMenuItem addMenuEntitiesItem(BatchUpdateMenuItemMenuEntitiesIn return this; } - /** + /** * The items in an array of JSON Object. * @return menuEntities - **/ + */ @javax.annotation.Nullable - public List getMenuEntities() { + public List getMenuEntities() { return menuEntities; } - public void setMenuEntities(List menuEntities) { + public void setMenuEntities(List menuEntities) { this.menuEntities = menuEntities; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BatchUpdateMenuItem instance itself + */ + public BatchUpdateMenuItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -199,12 +244,13 @@ public boolean equals(Object o) { BatchUpdateMenuItem batchUpdateMenuItem = (BatchUpdateMenuItem) o; return Objects.equals(this.merchantID, batchUpdateMenuItem.merchantID) && Objects.equals(this.field, batchUpdateMenuItem.field) && - Objects.equals(this.menuEntities, batchUpdateMenuItem.menuEntities); + Objects.equals(this.menuEntities, batchUpdateMenuItem.menuEntities)&& + Objects.equals(this.additionalProperties, batchUpdateMenuItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(merchantID, field, menuEntities); + return Objects.hash(merchantID, field, menuEntities, additionalProperties); } @Override @@ -214,6 +260,7 @@ public String toString() { sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); sb.append(" field: ").append(toIndentedString(field)).append("\n"); sb.append(" menuEntities: ").append(toIndentedString(menuEntities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -246,12 +293,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("field"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to BatchUpdateMenuItem - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to BatchUpdateMenuItem + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BatchUpdateMenuItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -259,14 +306,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BatchUpdateMenuItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BatchUpdateMenuItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BatchUpdateMenuItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -292,7 +331,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `menuEntities` (array) for (int i = 0; i < jsonArraymenuEntities.size(); i++) { - BatchUpdateMenuItemMenuEntitiesInner.validateJsonElement(jsonArraymenuEntities.get(i)); + MenuEntity.validateJsonElement(jsonArraymenuEntities.get(i)); }; } } @@ -313,6 +352,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BatchUpdateMenuItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -320,29 +381,50 @@ public void write(JsonWriter out, BatchUpdateMenuItem value) throws IOException public BatchUpdateMenuItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BatchUpdateMenuItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of BatchUpdateMenuItem given an JSON string - * - * @param jsonString JSON string - * @return An instance of BatchUpdateMenuItem - * @throws IOException if the JSON string is invalid with respect to BatchUpdateMenuItem - */ + /** + * Create an instance of BatchUpdateMenuItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of BatchUpdateMenuItem + * @throws IOException if the JSON string is invalid with respect to BatchUpdateMenuItem + */ public static BatchUpdateMenuItem fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, BatchUpdateMenuItem.class); } - /** - * Convert an instance of BatchUpdateMenuItem to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of BatchUpdateMenuItem to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/BatchUpdateMenuErrorMessage.java b/src/main/java/com/grabfood/client/model/BatchUpdateMenuResponse.java similarity index 54% rename from src/main/java/com/grabfood/client/model/BatchUpdateMenuErrorMessage.java rename to src/main/java/com/grabfood/client/model/BatchUpdateMenuResponse.java index 99ca6c8..2546581 100644 --- a/src/main/java/com/grabfood/client/model/BatchUpdateMenuErrorMessage.java +++ b/src/main/java/com/grabfood/client/model/BatchUpdateMenuResponse.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.BatchUpdateMenuErrorMessageErrorsInner; +import com.grabfood.client.model.MenuEntityError; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,10 +53,10 @@ import com.grabfood.client.JSON; /** - * BatchUpdateMenuErrorMessage + * BatchUpdateMenuResponse */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class BatchUpdateMenuErrorMessage { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class BatchUpdateMenuResponse { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) private String merchantID; @@ -71,7 +70,9 @@ public enum StatusEnum { PARTIAL_SUCCESS("partial success"), - FAIL("fail"); + FAIL("fail"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -94,7 +95,7 @@ public static StatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -122,20 +123,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_ERRORS = "errors"; @SerializedName(SERIALIZED_NAME_ERRORS) - private List errors; + private List errors; - public BatchUpdateMenuErrorMessage() { + public BatchUpdateMenuResponse() { } - public BatchUpdateMenuErrorMessage merchantID(String merchantID) { + public BatchUpdateMenuResponse merchantID(String merchantID) { this.merchantID = merchantID; return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -146,15 +147,15 @@ public void setMerchantID(String merchantID) { } - public BatchUpdateMenuErrorMessage status(StatusEnum status) { + public BatchUpdateMenuResponse status(StatusEnum status) { this.status = status; return this; } - /** + /** * The status of this request. * @return status - **/ + */ @javax.annotation.Nullable public StatusEnum getStatus() { return status; @@ -165,12 +166,12 @@ public void setStatus(StatusEnum status) { } - public BatchUpdateMenuErrorMessage errors(List errors) { + public BatchUpdateMenuResponse errors(List errors) { this.errors = errors; return this; } - public BatchUpdateMenuErrorMessage addErrorsItem(BatchUpdateMenuErrorMessageErrorsInner errorsItem) { + public BatchUpdateMenuResponse addErrorsItem(MenuEntityError errorsItem) { if (this.errors == null) { this.errors = new ArrayList<>(); } @@ -178,19 +179,63 @@ public BatchUpdateMenuErrorMessage addErrorsItem(BatchUpdateMenuErrorMessageErro return this; } - /** + /** * The error messages when batch update menu record was partial success/fail. `null` when the request was success. * @return errors - **/ + */ @javax.annotation.Nullable - public List getErrors() { + public List getErrors() { return errors; } - public void setErrors(List errors) { + public void setErrors(List errors) { this.errors = errors; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BatchUpdateMenuResponse instance itself + */ + public BatchUpdateMenuResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -201,10 +246,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - BatchUpdateMenuErrorMessage batchUpdateMenuErrorMessage = (BatchUpdateMenuErrorMessage) o; - return Objects.equals(this.merchantID, batchUpdateMenuErrorMessage.merchantID) && - Objects.equals(this.status, batchUpdateMenuErrorMessage.status) && - Objects.equals(this.errors, batchUpdateMenuErrorMessage.errors); + BatchUpdateMenuResponse batchUpdateMenuResponse = (BatchUpdateMenuResponse) o; + return Objects.equals(this.merchantID, batchUpdateMenuResponse.merchantID) && + Objects.equals(this.status, batchUpdateMenuResponse.status) && + Objects.equals(this.errors, batchUpdateMenuResponse.errors)&& + Objects.equals(this.additionalProperties, batchUpdateMenuResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -213,7 +259,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(merchantID, status, errors); + return Objects.hash(merchantID, status, errors, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -226,10 +272,11 @@ private static int hashCodeNullable(JsonNullable a) { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class BatchUpdateMenuErrorMessage {\n"); + sb.append("class BatchUpdateMenuResponse {\n"); sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -260,24 +307,16 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to BatchUpdateMenuErrorMessage - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to BatchUpdateMenuResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!BatchUpdateMenuErrorMessage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in BatchUpdateMenuErrorMessage is not found in the empty JSON string", BatchUpdateMenuErrorMessage.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BatchUpdateMenuErrorMessage.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BatchUpdateMenuErrorMessage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!BatchUpdateMenuResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in BatchUpdateMenuResponse is not found in the empty JSON string", BatchUpdateMenuResponse.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -301,7 +340,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `errors` (array) for (int i = 0; i < jsonArrayerrors.size(); i++) { - BatchUpdateMenuErrorMessageErrorsInner.validateJsonElement(jsonArrayerrors.get(i)); + MenuEntityError.validateJsonElement(jsonArrayerrors.get(i)); }; } } @@ -311,47 +350,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!BatchUpdateMenuErrorMessage.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'BatchUpdateMenuErrorMessage' and its subtypes + if (!BatchUpdateMenuResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'BatchUpdateMenuResponse' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(BatchUpdateMenuErrorMessage.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(BatchUpdateMenuResponse.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, BatchUpdateMenuErrorMessage value) throws IOException { + public void write(JsonWriter out, BatchUpdateMenuResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public BatchUpdateMenuErrorMessage read(JsonReader in) throws IOException { + public BatchUpdateMenuResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BatchUpdateMenuResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of BatchUpdateMenuErrorMessage given an JSON string - * - * @param jsonString JSON string - * @return An instance of BatchUpdateMenuErrorMessage - * @throws IOException if the JSON string is invalid with respect to BatchUpdateMenuErrorMessage - */ - public static BatchUpdateMenuErrorMessage fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, BatchUpdateMenuErrorMessage.class); + /** + * Create an instance of BatchUpdateMenuResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of BatchUpdateMenuResponse + * @throws IOException if the JSON string is invalid with respect to BatchUpdateMenuResponse + */ + public static BatchUpdateMenuResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, BatchUpdateMenuResponse.class); } - /** - * Convert an instance of BatchUpdateMenuErrorMessage to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of BatchUpdateMenuResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/BindMembershipNativeRequest.java b/src/main/java/com/grabfood/client/model/BindMembershipNativeRequest.java index ab210d5..3edc9f3 100644 --- a/src/main/java/com/grabfood/client/model/BindMembershipNativeRequest.java +++ b/src/main/java/com/grabfood/client/model/BindMembershipNativeRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request submits membership binding request to partner. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class BindMembershipNativeRequest { public static final String SERIALIZED_NAME_GRAB_I_D = "grabID"; @SerializedName(SERIALIZED_NAME_GRAB_I_D) @@ -70,10 +69,10 @@ public BindMembershipNativeRequest grabID(String grabID) { return this; } - /** + /** * The id used to identify an unique grab user. * @return grabID - **/ + */ @javax.annotation.Nonnull public String getGrabID() { return grabID; @@ -89,10 +88,10 @@ public BindMembershipNativeRequest phoneNumber(String phoneNumber) { return this; } - /** + /** * Grab user phone number used to login. * @return phoneNumber - **/ + */ @javax.annotation.Nullable public String getPhoneNumber() { return phoneNumber; @@ -102,6 +101,50 @@ public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BindMembershipNativeRequest instance itself + */ + public BindMembershipNativeRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +157,13 @@ public boolean equals(Object o) { } BindMembershipNativeRequest bindMembershipNativeRequest = (BindMembershipNativeRequest) o; return Objects.equals(this.grabID, bindMembershipNativeRequest.grabID) && - Objects.equals(this.phoneNumber, bindMembershipNativeRequest.phoneNumber); + Objects.equals(this.phoneNumber, bindMembershipNativeRequest.phoneNumber)&& + Objects.equals(this.additionalProperties, bindMembershipNativeRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(grabID, phoneNumber); + return Objects.hash(grabID, phoneNumber, additionalProperties); } @Override @@ -128,6 +172,7 @@ public String toString() { sb.append("class BindMembershipNativeRequest {\n"); sb.append(" grabID: ").append(toIndentedString(grabID)).append("\n"); sb.append(" phoneNumber: ").append(toIndentedString(phoneNumber)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -158,12 +203,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("grabID"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to BindMembershipNativeRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to BindMembershipNativeRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BindMembershipNativeRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -171,14 +216,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BindMembershipNativeRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BindMembershipNativeRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BindMembershipNativeRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -209,6 +246,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BindMembershipNativeRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -216,29 +275,50 @@ public void write(JsonWriter out, BindMembershipNativeRequest value) throws IOEx public BindMembershipNativeRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BindMembershipNativeRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of BindMembershipNativeRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of BindMembershipNativeRequest - * @throws IOException if the JSON string is invalid with respect to BindMembershipNativeRequest - */ + /** + * Create an instance of BindMembershipNativeRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of BindMembershipNativeRequest + * @throws IOException if the JSON string is invalid with respect to BindMembershipNativeRequest + */ public static BindMembershipNativeRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, BindMembershipNativeRequest.class); } - /** - * Convert an instance of BindMembershipNativeRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of BindMembershipNativeRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/BindMembershipNativeResponse.java b/src/main/java/com/grabfood/client/model/BindMembershipNativeResponse.java index a921468..ae1c133 100644 --- a/src/main/java/com/grabfood/client/model/BindMembershipNativeResponse.java +++ b/src/main/java/com/grabfood/client/model/BindMembershipNativeResponse.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This response returns membershipID after membership binding is successful. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class BindMembershipNativeResponse { public static final String SERIALIZED_NAME_MEMBER_I_D = "memberID"; @SerializedName(SERIALIZED_NAME_MEMBER_I_D) @@ -66,10 +65,10 @@ public BindMembershipNativeResponse memberID(String memberID) { return this; } - /** + /** * The unique member ID on the partner's database. * @return memberID - **/ + */ @javax.annotation.Nonnull public String getMemberID() { return memberID; @@ -79,6 +78,50 @@ public void setMemberID(String memberID) { this.memberID = memberID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BindMembershipNativeResponse instance itself + */ + public BindMembershipNativeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } BindMembershipNativeResponse bindMembershipNativeResponse = (BindMembershipNativeResponse) o; - return Objects.equals(this.memberID, bindMembershipNativeResponse.memberID); + return Objects.equals(this.memberID, bindMembershipNativeResponse.memberID)&& + Objects.equals(this.additionalProperties, bindMembershipNativeResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(memberID); + return Objects.hash(memberID, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BindMembershipNativeResponse {\n"); sb.append(" memberID: ").append(toIndentedString(memberID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -132,12 +177,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("memberID"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to BindMembershipNativeResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to BindMembershipNativeResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!BindMembershipNativeResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -145,14 +190,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BindMembershipNativeResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BindMembershipNativeResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BindMembershipNativeResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -180,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BindMembershipNativeResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -187,29 +246,50 @@ public void write(JsonWriter out, BindMembershipNativeResponse value) throws IOE public BindMembershipNativeResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BindMembershipNativeResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of BindMembershipNativeResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of BindMembershipNativeResponse - * @throws IOException if the JSON string is invalid with respect to BindMembershipNativeResponse - */ + /** + * Create an instance of BindMembershipNativeResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of BindMembershipNativeResponse + * @throws IOException if the JSON string is invalid with respect to BindMembershipNativeResponse + */ public static BindMembershipNativeResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, BindMembershipNativeResponse.class); } - /** - * Convert an instance of BindMembershipNativeResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of BindMembershipNativeResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Campaigns.java b/src/main/java/com/grabfood/client/model/Campaign.java similarity index 59% rename from src/main/java/com/grabfood/client/model/Campaigns.java rename to src/main/java/com/grabfood/client/model/Campaign.java index df7049c..8ef1661 100644 --- a/src/main/java/com/grabfood/client/model/Campaigns.java +++ b/src/main/java/com/grabfood/client/model/Campaign.java @@ -22,9 +22,9 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.Conditions; -import com.grabfood.client.model.Discount; -import com.grabfood.client.model.Quotas; +import com.grabfood.client.model.CampaignConditions; +import com.grabfood.client.model.CampaignDiscount; +import com.grabfood.client.model.CampaignQuotas; import java.io.IOException; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,8 +54,8 @@ /** * A JSON object containing the campaign details for a merchant. Only campaigns that are funded by merchants will be sent. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Campaigns { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class Campaign { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -70,7 +69,9 @@ public enum CreatedByEnum { MERCHANT("Merchant"), - PARTNER("Partner"); + PARTNER("Partner"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -93,7 +94,7 @@ public static CreatedByEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -129,32 +130,32 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_QUOTAS = "quotas"; @SerializedName(SERIALIZED_NAME_QUOTAS) - private Quotas quotas; + private CampaignQuotas quotas; public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; @SerializedName(SERIALIZED_NAME_CONDITIONS) - private Conditions conditions; + private CampaignConditions conditions; public static final String SERIALIZED_NAME_DISCOUNT = "discount"; @SerializedName(SERIALIZED_NAME_DISCOUNT) - private Discount discount; + private CampaignDiscount discount; public static final String SERIALIZED_NAME_CUSTOM_TAG = "customTag"; @SerializedName(SERIALIZED_NAME_CUSTOM_TAG) private String customTag; - public Campaigns() { + public Campaign() { } - public Campaigns id(String id) { + public Campaign id(String id) { this.id = id; return this; } - /** + /** * The campaign's ID. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -165,15 +166,15 @@ public void setId(String id) { } - public Campaigns createdBy(CreatedByEnum createdBy) { + public Campaign createdBy(CreatedByEnum createdBy) { this.createdBy = createdBy; return this; } - /** + /** * The party who created the campaign. Can be created by partners via API, merchants via the merchant app or Grab. * @return createdBy - **/ + */ @javax.annotation.Nonnull public CreatedByEnum getCreatedBy() { return createdBy; @@ -184,15 +185,15 @@ public void setCreatedBy(CreatedByEnum createdBy) { } - public Campaigns merchantID(String merchantID) { + public Campaign merchantID(String merchantID) { this.merchantID = merchantID; return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -203,15 +204,15 @@ public void setMerchantID(String merchantID) { } - public Campaigns name(String name) { + public Campaign name(String name) { this.name = name; return this; } - /** + /** * The campaign's name. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -222,72 +223,72 @@ public void setName(String name) { } - public Campaigns quotas(Quotas quotas) { + public Campaign quotas(CampaignQuotas quotas) { this.quotas = quotas; return this; } - /** + /** * Get quotas * @return quotas - **/ + */ @javax.annotation.Nullable - public Quotas getQuotas() { + public CampaignQuotas getQuotas() { return quotas; } - public void setQuotas(Quotas quotas) { + public void setQuotas(CampaignQuotas quotas) { this.quotas = quotas; } - public Campaigns conditions(Conditions conditions) { + public Campaign conditions(CampaignConditions conditions) { this.conditions = conditions; return this; } - /** + /** * Get conditions * @return conditions - **/ + */ @javax.annotation.Nullable - public Conditions getConditions() { + public CampaignConditions getConditions() { return conditions; } - public void setConditions(Conditions conditions) { + public void setConditions(CampaignConditions conditions) { this.conditions = conditions; } - public Campaigns discount(Discount discount) { + public Campaign discount(CampaignDiscount discount) { this.discount = discount; return this; } - /** + /** * Get discount * @return discount - **/ + */ @javax.annotation.Nullable - public Discount getDiscount() { + public CampaignDiscount getDiscount() { return discount; } - public void setDiscount(Discount discount) { + public void setDiscount(CampaignDiscount discount) { this.discount = discount; } - public Campaigns customTag(String customTag) { + public Campaign customTag(String customTag) { this.customTag = customTag; return this; } - /** + /** * Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. * @return customTag - **/ + */ @javax.annotation.Nullable public String getCustomTag() { return customTag; @@ -297,6 +298,50 @@ public void setCustomTag(String customTag) { this.customTag = customTag; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Campaign instance itself + */ + public Campaign putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -307,26 +352,27 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - Campaigns campaigns = (Campaigns) o; - return Objects.equals(this.id, campaigns.id) && - Objects.equals(this.createdBy, campaigns.createdBy) && - Objects.equals(this.merchantID, campaigns.merchantID) && - Objects.equals(this.name, campaigns.name) && - Objects.equals(this.quotas, campaigns.quotas) && - Objects.equals(this.conditions, campaigns.conditions) && - Objects.equals(this.discount, campaigns.discount) && - Objects.equals(this.customTag, campaigns.customTag); + Campaign campaign = (Campaign) o; + return Objects.equals(this.id, campaign.id) && + Objects.equals(this.createdBy, campaign.createdBy) && + Objects.equals(this.merchantID, campaign.merchantID) && + Objects.equals(this.name, campaign.name) && + Objects.equals(this.quotas, campaign.quotas) && + Objects.equals(this.conditions, campaign.conditions) && + Objects.equals(this.discount, campaign.discount) && + Objects.equals(this.customTag, campaign.customTag)&& + Objects.equals(this.additionalProperties, campaign.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, createdBy, merchantID, name, quotas, conditions, discount, customTag); + return Objects.hash(id, createdBy, merchantID, name, quotas, conditions, discount, customTag, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class Campaigns {\n"); + sb.append("class Campaign {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" createdBy: ").append(toIndentedString(createdBy)).append("\n"); sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); @@ -335,6 +381,7 @@ public String toString() { sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); sb.append(" discount: ").append(toIndentedString(discount)).append("\n"); sb.append(" customTag: ").append(toIndentedString(customTag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -374,29 +421,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("name"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Campaigns - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Campaign + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!Campaigns.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Campaigns is not found in the empty JSON string", Campaigns.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Campaigns.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Campaigns` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!Campaign.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Campaign is not found in the empty JSON string", Campaign.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Campaigns.openapiRequiredFields) { + for (String requiredField : Campaign.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -418,15 +457,15 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // validate the optional field `quotas` if (jsonObj.get("quotas") != null && !jsonObj.get("quotas").isJsonNull()) { - Quotas.validateJsonElement(jsonObj.get("quotas")); + CampaignQuotas.validateJsonElement(jsonObj.get("quotas")); } // validate the optional field `conditions` if (jsonObj.get("conditions") != null && !jsonObj.get("conditions").isJsonNull()) { - Conditions.validateJsonElement(jsonObj.get("conditions")); + CampaignConditions.validateJsonElement(jsonObj.get("conditions")); } // validate the optional field `discount` if (jsonObj.get("discount") != null && !jsonObj.get("discount").isJsonNull()) { - Discount.validateJsonElement(jsonObj.get("discount")); + CampaignDiscount.validateJsonElement(jsonObj.get("discount")); } if ((jsonObj.get("customTag") != null && !jsonObj.get("customTag").isJsonNull()) && !jsonObj.get("customTag").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `customTag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("customTag").toString())); @@ -437,47 +476,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!Campaigns.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Campaigns' and its subtypes + if (!Campaign.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Campaign' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Campaigns.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Campaign.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, Campaigns value) throws IOException { + public void write(JsonWriter out, Campaign value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public Campaigns read(JsonReader in) throws IOException { + public Campaign read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Campaign instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Campaigns given an JSON string - * - * @param jsonString JSON string - * @return An instance of Campaigns - * @throws IOException if the JSON string is invalid with respect to Campaigns - */ - public static Campaigns fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Campaigns.class); + /** + * Create an instance of Campaign given an JSON string + * + * @param jsonString JSON string + * @return An instance of Campaign + * @throws IOException if the JSON string is invalid with respect to Campaign + */ + public static Campaign fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Campaign.class); } - /** - * Convert an instance of Campaigns to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of Campaign to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Conditions.java b/src/main/java/com/grabfood/client/model/CampaignConditions.java similarity index 59% rename from src/main/java/com/grabfood/client/model/Conditions.java rename to src/main/java/com/grabfood/client/model/CampaignConditions.java index 1cf8c7b..9194779 100644 --- a/src/main/java/com/grabfood/client/model/Conditions.java +++ b/src/main/java/com/grabfood/client/model/CampaignConditions.java @@ -42,7 +42,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,8 +53,8 @@ /** * The conditions to apply to a campaign. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Conditions { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class CampaignConditions { public static final String SERIALIZED_NAME_START_TIME = "startTime"; @SerializedName(SERIALIZED_NAME_START_TIME) private OffsetDateTime startTime; @@ -71,7 +70,9 @@ public class Conditions { public enum EaterTypeEnum { ALL("all"), - NEW("new"); + NEW("new"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -94,7 +95,7 @@ public static EaterTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -132,18 +133,18 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_WORKING_HOUR) private WorkingHour workingHour; - public Conditions() { + public CampaignConditions() { } - public Conditions startTime(OffsetDateTime startTime) { + public CampaignConditions startTime(OffsetDateTime startTime) { this.startTime = startTime; return this; } - /** + /** * The campaign's start time in UTC format. For example, 2021-09-23T03:30:00Z means 2021-09-23 11:30:00 (UTC +08:00). * @return startTime - **/ + */ @javax.annotation.Nonnull public OffsetDateTime getStartTime() { return startTime; @@ -154,15 +155,15 @@ public void setStartTime(OffsetDateTime startTime) { } - public Conditions endTime(OffsetDateTime endTime) { + public CampaignConditions endTime(OffsetDateTime endTime) { this.endTime = endTime; return this; } - /** + /** * The campaign's end time in UTC format. * @return endTime - **/ + */ @javax.annotation.Nonnull public OffsetDateTime getEndTime() { return endTime; @@ -173,15 +174,15 @@ public void setEndTime(OffsetDateTime endTime) { } - public Conditions eaterType(EaterTypeEnum eaterType) { + public CampaignConditions eaterType(EaterTypeEnum eaterType) { this.eaterType = eaterType; return this; } - /** + /** * The type of eater eligible for the campaign. * `all` - campaign will be applied to everyone. No limitation on campaign type. * `new` - campaign will be applied to consumers who have not ordered from this store in the last three months. Only applicable to **order-level** campaign. * @return eaterType - **/ + */ @javax.annotation.Nonnull public EaterTypeEnum getEaterType() { return eaterType; @@ -192,15 +193,15 @@ public void setEaterType(EaterTypeEnum eaterType) { } - public Conditions minBasketAmount(Double minBasketAmount) { + public CampaignConditions minBasketAmount(Double minBasketAmount) { this.minBasketAmount = minBasketAmount; return this; } - /** + /** * The minimum basket amount to be eligible for the campaign. Only applicable for **order-level** campaign. For example, 10.5 means the basket amount has to be at least $10.50. * @return minBasketAmount - **/ + */ @javax.annotation.Nullable public Double getMinBasketAmount() { return minBasketAmount; @@ -211,15 +212,15 @@ public void setMinBasketAmount(Double minBasketAmount) { } - public Conditions bundleQuantity(Integer bundleQuantity) { + public CampaignConditions bundleQuantity(Integer bundleQuantity) { this.bundleQuantity = bundleQuantity; return this; } - /** + /** * Specify the bundle quantity for bundle offer campaign. * @return bundleQuantity - **/ + */ @javax.annotation.Nullable public Integer getBundleQuantity() { return bundleQuantity; @@ -230,15 +231,15 @@ public void setBundleQuantity(Integer bundleQuantity) { } - public Conditions workingHour(WorkingHour workingHour) { + public CampaignConditions workingHour(WorkingHour workingHour) { this.workingHour = workingHour; return this; } - /** + /** * Get workingHour * @return workingHour - **/ + */ @javax.annotation.Nullable public WorkingHour getWorkingHour() { return workingHour; @@ -248,6 +249,50 @@ public void setWorkingHour(WorkingHour workingHour) { this.workingHour = workingHour; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CampaignConditions instance itself + */ + public CampaignConditions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -258,30 +303,32 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - Conditions conditions = (Conditions) o; - return Objects.equals(this.startTime, conditions.startTime) && - Objects.equals(this.endTime, conditions.endTime) && - Objects.equals(this.eaterType, conditions.eaterType) && - Objects.equals(this.minBasketAmount, conditions.minBasketAmount) && - Objects.equals(this.bundleQuantity, conditions.bundleQuantity) && - Objects.equals(this.workingHour, conditions.workingHour); + CampaignConditions campaignConditions = (CampaignConditions) o; + return Objects.equals(this.startTime, campaignConditions.startTime) && + Objects.equals(this.endTime, campaignConditions.endTime) && + Objects.equals(this.eaterType, campaignConditions.eaterType) && + Objects.equals(this.minBasketAmount, campaignConditions.minBasketAmount) && + Objects.equals(this.bundleQuantity, campaignConditions.bundleQuantity) && + Objects.equals(this.workingHour, campaignConditions.workingHour)&& + Objects.equals(this.additionalProperties, campaignConditions.additionalProperties); } @Override public int hashCode() { - return Objects.hash(startTime, endTime, eaterType, minBasketAmount, bundleQuantity, workingHour); + return Objects.hash(startTime, endTime, eaterType, minBasketAmount, bundleQuantity, workingHour, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class Conditions {\n"); + sb.append("class CampaignConditions {\n"); sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n"); sb.append(" eaterType: ").append(toIndentedString(eaterType)).append("\n"); sb.append(" minBasketAmount: ").append(toIndentedString(minBasketAmount)).append("\n"); sb.append(" bundleQuantity: ").append(toIndentedString(bundleQuantity)).append("\n"); sb.append(" workingHour: ").append(toIndentedString(workingHour)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -318,29 +365,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("eaterType"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Conditions - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CampaignConditions + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!Conditions.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Conditions is not found in the empty JSON string", Conditions.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Conditions.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Conditions` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!CampaignConditions.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CampaignConditions is not found in the empty JSON string", CampaignConditions.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Conditions.openapiRequiredFields) { + for (String requiredField : CampaignConditions.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -361,47 +400,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!Conditions.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Conditions' and its subtypes + if (!CampaignConditions.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CampaignConditions' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Conditions.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CampaignConditions.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, Conditions value) throws IOException { + public void write(JsonWriter out, CampaignConditions value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public Conditions read(JsonReader in) throws IOException { + public CampaignConditions read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CampaignConditions instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Conditions given an JSON string - * - * @param jsonString JSON string - * @return An instance of Conditions - * @throws IOException if the JSON string is invalid with respect to Conditions - */ - public static Conditions fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Conditions.class); + /** + * Create an instance of CampaignConditions given an JSON string + * + * @param jsonString JSON string + * @return An instance of CampaignConditions + * @throws IOException if the JSON string is invalid with respect to CampaignConditions + */ + public static CampaignConditions fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CampaignConditions.class); } - /** - * Convert an instance of Conditions to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of CampaignConditions to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Discount.java b/src/main/java/com/grabfood/client/model/CampaignDiscount.java similarity index 53% rename from src/main/java/com/grabfood/client/model/Discount.java rename to src/main/java/com/grabfood/client/model/CampaignDiscount.java index 9413ff5..ed0c4d7 100644 --- a/src/main/java/com/grabfood/client/model/Discount.java +++ b/src/main/java/com/grabfood/client/model/CampaignDiscount.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.Scope; +import com.grabfood.client.model.CampaignScope; import java.io.IOException; import java.util.Arrays; @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,8 +52,8 @@ /** * The discount detail for a particular campaign when conditions are satisfied. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Discount { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class CampaignDiscount { /** * The type of discount */ @@ -66,19 +65,21 @@ public enum TypeEnum { DELIVERY("delivery"), - FREEITEM("freeItem"), + FREE_ITEM("freeItem"), - BUNDLESAMENET("bundleSameNet"), + BUNDLE_SAME_NET("bundleSameNet"), - BUNDLESAMEPERCENTAGE("bundleSamePercentage"), + BUNDLE_SAME_PERCENTAGE("bundleSamePercentage"), - BUNDLESAMEFIXPRICE("bundleSameFixPrice"), + BUNDLE_SAME_FIX_PRICE("bundleSameFixPrice"), - BUNDLEDIFFNET("bundleDiffNet"), + BUNDLE_DIFF_NET("bundleDiffNet"), - BUNDLEDIFFPERCENTAGE("bundleDiffPercentage"), + BUNDLE_DIFF_PERCENTAGE("bundleDiffPercentage"), - BUNDLEDIFFFIXPRICE("bundleDiffFixPrice"); + BUNDLE_DIFF_FIX_PRICE("bundleDiffFixPrice"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -101,7 +102,7 @@ public static TypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -137,20 +138,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_SCOPE = "scope"; @SerializedName(SERIALIZED_NAME_SCOPE) - private Scope scope; + private CampaignScope scope; - public Discount() { + public CampaignDiscount() { } - public Discount type(TypeEnum type) { + public CampaignDiscount type(TypeEnum type) { this.type = type; return this; } - /** + /** * The type of discount * @return type - **/ + */ @javax.annotation.Nonnull public TypeEnum getType() { return type; @@ -161,15 +162,15 @@ public void setType(TypeEnum type) { } - public Discount cap(Double cap) { + public CampaignDiscount cap(Double cap) { this.cap = cap; return this; } - /** + /** * The maximum discount dollar amount. It is **not required** and will be ignored when the `discount.type` is: - `net` - `delivery` - `freeItem` - `bundleSameNet` - `bundleSamePercentage` - `bundleSameFixPrice` - `bundleDiffNet` - `bundleDiffPercentage` - `bundleDiffFixPrice` * @return cap - **/ + */ @javax.annotation.Nullable public Double getCap() { return cap; @@ -180,15 +181,15 @@ public void setCap(Double cap) { } - public Discount value(Double value) { + public CampaignDiscount value(Double value) { this.value = value; return this; } - /** + /** * Specify the discount amount. Decimal number is not supported For VN, ID and TH. For example, `10.5` is not allowed and it should be `10.0`. * Dollar amount value when `discount.type` is `net`, `delivery`, `bundleSameNet`, `bundleSameFixPrice`, `bundleDiffNet`, `bundleDiffFixPrice`. * Percentage value (0-100) when `discount.type` is `percentage`, `bundleSamePercentage`, `bundleDiffPercentage`. * **Not required** when `discount.type` is `freeItem`. * @return value - **/ + */ @javax.annotation.Nullable public Double getValue() { return value; @@ -199,24 +200,68 @@ public void setValue(Double value) { } - public Discount scope(Scope scope) { + public CampaignDiscount scope(CampaignScope scope) { this.scope = scope; return this; } - /** + /** * Get scope * @return scope - **/ + */ @javax.annotation.Nonnull - public Scope getScope() { + public CampaignScope getScope() { return scope; } - public void setScope(Scope scope) { + public void setScope(CampaignScope scope) { this.scope = scope; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CampaignDiscount instance itself + */ + public CampaignDiscount putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -227,26 +272,28 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - Discount discount = (Discount) o; - return Objects.equals(this.type, discount.type) && - Objects.equals(this.cap, discount.cap) && - Objects.equals(this.value, discount.value) && - Objects.equals(this.scope, discount.scope); + CampaignDiscount campaignDiscount = (CampaignDiscount) o; + return Objects.equals(this.type, campaignDiscount.type) && + Objects.equals(this.cap, campaignDiscount.cap) && + Objects.equals(this.value, campaignDiscount.value) && + Objects.equals(this.scope, campaignDiscount.scope)&& + Objects.equals(this.additionalProperties, campaignDiscount.additionalProperties); } @Override public int hashCode() { - return Objects.hash(type, cap, value, scope); + return Objects.hash(type, cap, value, scope, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class Discount {\n"); + sb.append("class CampaignDiscount {\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" cap: ").append(toIndentedString(cap)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -280,29 +327,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("scope"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Discount - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CampaignDiscount + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!Discount.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Discount is not found in the empty JSON string", Discount.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Discount.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Discount` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!CampaignDiscount.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CampaignDiscount is not found in the empty JSON string", CampaignDiscount.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Discount.openapiRequiredFields) { + for (String requiredField : CampaignDiscount.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -314,54 +353,97 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the required field `type` TypeEnum.validateJsonElement(jsonObj.get("type")); // validate the required field `scope` - Scope.validateJsonElement(jsonObj.get("scope")); + CampaignScope.validateJsonElement(jsonObj.get("scope")); } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!Discount.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Discount' and its subtypes + if (!CampaignDiscount.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CampaignDiscount' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Discount.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CampaignDiscount.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, Discount value) throws IOException { + public void write(JsonWriter out, CampaignDiscount value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public Discount read(JsonReader in) throws IOException { + public CampaignDiscount read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CampaignDiscount instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Discount given an JSON string - * - * @param jsonString JSON string - * @return An instance of Discount - * @throws IOException if the JSON string is invalid with respect to Discount - */ - public static Discount fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Discount.class); + /** + * Create an instance of CampaignDiscount given an JSON string + * + * @param jsonString JSON string + * @return An instance of CampaignDiscount + * @throws IOException if the JSON string is invalid with respect to CampaignDiscount + */ + public static CampaignDiscount fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CampaignDiscount.class); } - /** - * Convert an instance of Discount to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of CampaignDiscount to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/CampaignQuotas.java b/src/main/java/com/grabfood/client/model/CampaignQuotas.java new file mode 100644 index 0000000..437808c --- /dev/null +++ b/src/main/java/com/grabfood/client/model/CampaignQuotas.java @@ -0,0 +1,312 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * The quotas/limits for a particular campaign. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class CampaignQuotas { + public static final String SERIALIZED_NAME_TOTAL_COUNT = "totalCount"; + @SerializedName(SERIALIZED_NAME_TOTAL_COUNT) + private Integer totalCount; + + public static final String SERIALIZED_NAME_TOTAL_COUNT_PER_USER = "totalCountPerUser"; + @SerializedName(SERIALIZED_NAME_TOTAL_COUNT_PER_USER) + private Integer totalCountPerUser; + + public CampaignQuotas() { + } + + public CampaignQuotas totalCount(Integer totalCount) { + this.totalCount = totalCount; + return this; + } + + /** + * The maximum number of redemptions. Default is unlimited if unspecified. + * @return totalCount + */ + @javax.annotation.Nullable + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + + public CampaignQuotas totalCountPerUser(Integer totalCountPerUser) { + this.totalCountPerUser = totalCountPerUser; + return this; + } + + /** + * The maximum number of redemptions per user. Default is unlimited if unspecified. + * @return totalCountPerUser + */ + @javax.annotation.Nullable + public Integer getTotalCountPerUser() { + return totalCountPerUser; + } + + public void setTotalCountPerUser(Integer totalCountPerUser) { + this.totalCountPerUser = totalCountPerUser; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CampaignQuotas instance itself + */ + public CampaignQuotas putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CampaignQuotas campaignQuotas = (CampaignQuotas) o; + return Objects.equals(this.totalCount, campaignQuotas.totalCount) && + Objects.equals(this.totalCountPerUser, campaignQuotas.totalCountPerUser)&& + Objects.equals(this.additionalProperties, campaignQuotas.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(totalCount, totalCountPerUser, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CampaignQuotas {\n"); + sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); + sb.append(" totalCountPerUser: ").append(toIndentedString(totalCountPerUser)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("totalCount"); + openapiFields.add("totalCountPerUser"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CampaignQuotas + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CampaignQuotas.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CampaignQuotas is not found in the empty JSON string", CampaignQuotas.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CampaignQuotas.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CampaignQuotas' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CampaignQuotas.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CampaignQuotas value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CampaignQuotas read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CampaignQuotas instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CampaignQuotas given an JSON string + * + * @param jsonString JSON string + * @return An instance of CampaignQuotas + * @throws IOException if the JSON string is invalid with respect to CampaignQuotas + */ + public static CampaignQuotas fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CampaignQuotas.class); + } + + /** + * Convert an instance of CampaignQuotas to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/Scope.java b/src/main/java/com/grabfood/client/model/CampaignScope.java similarity index 55% rename from src/main/java/com/grabfood/client/model/Scope.java rename to src/main/java/com/grabfood/client/model/CampaignScope.java index aa833e8..ccf737e 100644 --- a/src/main/java/com/grabfood/client/model/Scope.java +++ b/src/main/java/com/grabfood/client/model/CampaignScope.java @@ -42,7 +42,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,8 +53,8 @@ /** * The scope level for a particular campaign. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Scope { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class CampaignScope { /** * The scope type for this campaign. * `order` - order level campaign. * `items` - item level campaign or bundle offer. * `category` - category level campaign where all items within applies the same discount. */ @@ -65,7 +64,9 @@ public enum TypeEnum { ITEMS("items"), - CATEGORY("category"); + CATEGORY("category"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -88,7 +89,7 @@ public static TypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -118,18 +119,18 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_OBJECT_I_DS) private List objectIDs = new ArrayList<>(); - public Scope() { + public CampaignScope() { } - public Scope type(TypeEnum type) { + public CampaignScope type(TypeEnum type) { this.type = type; return this; } - /** + /** * The scope type for this campaign. * `order` - order level campaign. * `items` - item level campaign or bundle offer. * `category` - category level campaign where all items within applies the same discount. * @return type - **/ + */ @javax.annotation.Nonnull public TypeEnum getType() { return type; @@ -140,12 +141,12 @@ public void setType(TypeEnum type) { } - public Scope objectIDs(List objectIDs) { + public CampaignScope objectIDs(List objectIDs) { this.objectIDs = objectIDs; return this; } - public Scope addObjectIDsItem(String objectIDsItem) { + public CampaignScope addObjectIDsItem(String objectIDsItem) { if (this.objectIDs == null) { this.objectIDs = new ArrayList<>(); } @@ -153,10 +154,10 @@ public Scope addObjectIDsItem(String objectIDsItem) { return this; } - /** + /** * The list of item IDs in the partner's database applicable for discount when `discount.scope.type` is `items` (or category IDs for `category`). One and only 1 item supported when `discount.type` is: - `freeItem` - `bundleSameNet` - `bundleSamePercentage` - `bundleSameFixPrice` Minimum 2 - Maximum 20 items supported when `discount.type` is: - `bundleDiffNet` - `bundleDiffPercentage` - `bundleDiffFixPrice` * @return objectIDs - **/ + */ @javax.annotation.Nullable public List getObjectIDs() { return objectIDs; @@ -166,6 +167,50 @@ public void setObjectIDs(List objectIDs) { this.objectIDs = objectIDs; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CampaignScope instance itself + */ + public CampaignScope putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -176,22 +221,24 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - Scope scope = (Scope) o; - return Objects.equals(this.type, scope.type) && - Objects.equals(this.objectIDs, scope.objectIDs); + CampaignScope campaignScope = (CampaignScope) o; + return Objects.equals(this.type, campaignScope.type) && + Objects.equals(this.objectIDs, campaignScope.objectIDs)&& + Objects.equals(this.additionalProperties, campaignScope.additionalProperties); } @Override public int hashCode() { - return Objects.hash(type, objectIDs); + return Objects.hash(type, objectIDs, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class Scope {\n"); + sb.append("class CampaignScope {\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" objectIDs: ").append(toIndentedString(objectIDs)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -222,29 +269,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("type"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Scope - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CampaignScope + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!Scope.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Scope is not found in the empty JSON string", Scope.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Scope.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Scope` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!CampaignScope.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CampaignScope is not found in the empty JSON string", CampaignScope.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Scope.openapiRequiredFields) { + for (String requiredField : CampaignScope.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -265,47 +304,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!Scope.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Scope' and its subtypes + if (!CampaignScope.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CampaignScope' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Scope.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CampaignScope.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, Scope value) throws IOException { + public void write(JsonWriter out, CampaignScope value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public Scope read(JsonReader in) throws IOException { + public CampaignScope read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CampaignScope instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Scope given an JSON string - * - * @param jsonString JSON string - * @return An instance of Scope - * @throws IOException if the JSON string is invalid with respect to Scope - */ - public static Scope fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Scope.class); + /** + * Create an instance of CampaignScope given an JSON string + * + * @param jsonString JSON string + * @return An instance of CampaignScope + * @throws IOException if the JSON string is invalid with respect to CampaignScope + */ + public static CampaignScope fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CampaignScope.class); } - /** - * Convert an instance of Scope to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of CampaignScope to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/CancelCode.java b/src/main/java/com/grabfood/client/model/CancelCode.java index c5f664f..1b584ef 100644 --- a/src/main/java/com/grabfood/client/model/CancelCode.java +++ b/src/main/java/com/grabfood/client/model/CancelCode.java @@ -38,7 +38,9 @@ public enum CancelCode { NUMBER_1003(1003), - NUMBER_1004(1004); + NUMBER_1004(1004), + + NUMBER_unknown_default_open_api(11184809); private Integer value; @@ -61,7 +63,7 @@ public static CancelCode fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return NUMBER_unknown_default_open_api; } public static class Adapter extends TypeAdapter { diff --git a/src/main/java/com/grabfood/client/model/CancelOrderFail.java b/src/main/java/com/grabfood/client/model/CancelOrderFail.java deleted file mode 100644 index 0e96630..0000000 --- a/src/main/java/com/grabfood/client/model/CancelOrderFail.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class CancelOrderFail { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public CancelOrderFail() { - } - - public CancelOrderFail target(String target) { - this.target = target; - return this; - } - - /** - * Target of error - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public CancelOrderFail reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public CancelOrderFail message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CancelOrderFail cancelOrderFail = (CancelOrderFail) o; - return Objects.equals(this.target, cancelOrderFail.target) && - Objects.equals(this.reason, cancelOrderFail.reason) && - Objects.equals(this.message, cancelOrderFail.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CancelOrderFail {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CancelOrderFail - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!CancelOrderFail.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in CancelOrderFail is not found in the empty JSON string", CancelOrderFail.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CancelOrderFail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CancelOrderFail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CancelOrderFail.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CancelOrderFail' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CancelOrderFail.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CancelOrderFail value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CancelOrderFail read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CancelOrderFail given an JSON string - * - * @param jsonString JSON string - * @return An instance of CancelOrderFail - * @throws IOException if the JSON string is invalid with respect to CancelOrderFail - */ - public static CancelOrderFail fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CancelOrderFail.class); - } - - /** - * Convert an instance of CancelOrderFail to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/CancelOrderFail403.java b/src/main/java/com/grabfood/client/model/CancelOrderFail403.java deleted file mode 100644 index 6a169f3..0000000 --- a/src/main/java/com/grabfood/client/model/CancelOrderFail403.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class CancelOrderFail403 { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public CancelOrderFail403() { - } - - public CancelOrderFail403 target(String target) { - this.target = target; - return this; - } - - /** - * Target of error - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public CancelOrderFail403 reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public CancelOrderFail403 message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CancelOrderFail403 cancelOrderFail403 = (CancelOrderFail403) o; - return Objects.equals(this.target, cancelOrderFail403.target) && - Objects.equals(this.reason, cancelOrderFail403.reason) && - Objects.equals(this.message, cancelOrderFail403.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CancelOrderFail403 {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CancelOrderFail403 - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!CancelOrderFail403.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in CancelOrderFail403 is not found in the empty JSON string", CancelOrderFail403.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CancelOrderFail403.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CancelOrderFail403` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CancelOrderFail403.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CancelOrderFail403' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CancelOrderFail403.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CancelOrderFail403 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CancelOrderFail403 read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CancelOrderFail403 given an JSON string - * - * @param jsonString JSON string - * @return An instance of CancelOrderFail403 - * @throws IOException if the JSON string is invalid with respect to CancelOrderFail403 - */ - public static CancelOrderFail403 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CancelOrderFail403.class); - } - - /** - * Convert an instance of CancelOrderFail403 to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/LimitType.java b/src/main/java/com/grabfood/client/model/CancelOrderLimitType.java similarity index 70% rename from src/main/java/com/grabfood/client/model/LimitType.java rename to src/main/java/com/grabfood/client/model/CancelOrderLimitType.java index 39e0893..114baa2 100644 --- a/src/main/java/com/grabfood/client/model/LimitType.java +++ b/src/main/java/com/grabfood/client/model/CancelOrderLimitType.java @@ -29,8 +29,8 @@ /** * The type of the order cancellation limit. */ -@JsonAdapter(LimitType.Adapter.class) -public enum LimitType { +@JsonAdapter(CancelOrderLimitType.Adapter.class) +public enum CancelOrderLimitType { NOT_APPROACHING_LIMIT("not approaching limit"), @@ -40,11 +40,13 @@ public enum LimitType { APPROACHING_THE_MONTHLY_LIMIT("approaching the monthly limit"), - EMPTY(""); + EMPTY(""), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; - LimitType(String value) { + CancelOrderLimitType(String value) { this.value = value; } @@ -57,31 +59,31 @@ public String toString() { return String.valueOf(value); } - public static LimitType fromValue(String value) { - for (LimitType b : LimitType.values()) { + public static CancelOrderLimitType fromValue(String value) { + for (CancelOrderLimitType b : CancelOrderLimitType.values()) { if (b.value.equals(value)) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } - public static class Adapter extends TypeAdapter { + public static class Adapter extends TypeAdapter { @Override - public void write(final JsonWriter jsonWriter, final LimitType enumeration) throws IOException { + public void write(final JsonWriter jsonWriter, final CancelOrderLimitType enumeration) throws IOException { jsonWriter.value(enumeration.getValue()); } @Override - public LimitType read(final JsonReader jsonReader) throws IOException { + public CancelOrderLimitType read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); - return LimitType.fromValue(value); + return CancelOrderLimitType.fromValue(value); } } public static void validateJsonElement(JsonElement jsonElement) throws IOException { String value = jsonElement.getAsString(); - LimitType.fromValue(value); + CancelOrderLimitType.fromValue(value); } } diff --git a/src/main/java/com/grabfood/client/model/CancelOrderRequest.java b/src/main/java/com/grabfood/client/model/CancelOrderRequest.java index 5d7309f..21822e0 100644 --- a/src/main/java/com/grabfood/client/model/CancelOrderRequest.java +++ b/src/main/java/com/grabfood/client/model/CancelOrderRequest.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * This request cancels an order on GrabFood. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class CancelOrderRequest { public static final String SERIALIZED_NAME_ORDER_I_D = "orderID"; @SerializedName(SERIALIZED_NAME_ORDER_I_D) @@ -75,10 +74,10 @@ public CancelOrderRequest orderID(String orderID) { return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -94,10 +93,10 @@ public CancelOrderRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -113,10 +112,10 @@ public CancelOrderRequest cancelCode(CancelCode cancelCode) { return this; } - /** + /** * Get cancelCode * @return cancelCode - **/ + */ @javax.annotation.Nonnull public CancelCode getCancelCode() { return cancelCode; @@ -126,6 +125,50 @@ public void setCancelCode(CancelCode cancelCode) { this.cancelCode = cancelCode; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CancelOrderRequest instance itself + */ + public CancelOrderRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -139,12 +182,13 @@ public boolean equals(Object o) { CancelOrderRequest cancelOrderRequest = (CancelOrderRequest) o; return Objects.equals(this.orderID, cancelOrderRequest.orderID) && Objects.equals(this.merchantID, cancelOrderRequest.merchantID) && - Objects.equals(this.cancelCode, cancelOrderRequest.cancelCode); + Objects.equals(this.cancelCode, cancelOrderRequest.cancelCode)&& + Objects.equals(this.additionalProperties, cancelOrderRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(orderID, merchantID, cancelCode); + return Objects.hash(orderID, merchantID, cancelCode, additionalProperties); } @Override @@ -154,6 +198,7 @@ public String toString() { sb.append(" orderID: ").append(toIndentedString(orderID)).append("\n"); sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); sb.append(" cancelCode: ").append(toIndentedString(cancelCode)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -187,12 +232,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("cancelCode"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CancelOrderRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CancelOrderRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CancelOrderRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -200,14 +245,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CancelOrderRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CancelOrderRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CancelOrderRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -240,6 +277,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CancelOrderRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -247,29 +306,50 @@ public void write(JsonWriter out, CancelOrderRequest value) throws IOException { public CancelOrderRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CancelOrderRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of CancelOrderRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of CancelOrderRequest - * @throws IOException if the JSON string is invalid with respect to CancelOrderRequest - */ + /** + * Create an instance of CancelOrderRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CancelOrderRequest + * @throws IOException if the JSON string is invalid with respect to CancelOrderRequest + */ public static CancelOrderRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, CancelOrderRequest.class); } - /** - * Convert an instance of CancelOrderRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of CancelOrderRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/CancelOrderResponse.java b/src/main/java/com/grabfood/client/model/CancelOrderResponse.java index efdbb24..15bc266 100644 --- a/src/main/java/com/grabfood/client/model/CancelOrderResponse.java +++ b/src/main/java/com/grabfood/client/model/CancelOrderResponse.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.LimitType; +import com.grabfood.client.model.CancelOrderLimitType; import java.io.IOException; import java.util.Arrays; @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,11 +52,11 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class CancelOrderResponse { public static final String SERIALIZED_NAME_LIMIT_TYPE = "limitType"; @SerializedName(SERIALIZED_NAME_LIMIT_TYPE) - private LimitType limitType; + private CancelOrderLimitType limitType; public static final String SERIALIZED_NAME_LIMIT_TIMES = "limitTimes"; @SerializedName(SERIALIZED_NAME_LIMIT_TIMES) @@ -66,21 +65,21 @@ public class CancelOrderResponse { public CancelOrderResponse() { } - public CancelOrderResponse limitType(LimitType limitType) { + public CancelOrderResponse limitType(CancelOrderLimitType limitType) { this.limitType = limitType; return this; } - /** + /** * Get limitType * @return limitType - **/ + */ @javax.annotation.Nullable - public LimitType getLimitType() { + public CancelOrderLimitType getLimitType() { return limitType; } - public void setLimitType(LimitType limitType) { + public void setLimitType(CancelOrderLimitType limitType) { this.limitType = limitType; } @@ -90,10 +89,10 @@ public CancelOrderResponse limitTimes(Integer limitTimes) { return this; } - /** + /** * The remaining cancellation quota for the merchant. A value is only returned when the nearest remaining cancellation limit is approaching, else it returns 0. * @return limitTimes - **/ + */ @javax.annotation.Nullable public Integer getLimitTimes() { return limitTimes; @@ -103,6 +102,50 @@ public void setLimitTimes(Integer limitTimes) { this.limitTimes = limitTimes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CancelOrderResponse instance itself + */ + public CancelOrderResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -115,12 +158,13 @@ public boolean equals(Object o) { } CancelOrderResponse cancelOrderResponse = (CancelOrderResponse) o; return Objects.equals(this.limitType, cancelOrderResponse.limitType) && - Objects.equals(this.limitTimes, cancelOrderResponse.limitTimes); + Objects.equals(this.limitTimes, cancelOrderResponse.limitTimes)&& + Objects.equals(this.additionalProperties, cancelOrderResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(limitType, limitTimes); + return Objects.hash(limitType, limitTimes, additionalProperties); } @Override @@ -129,6 +173,7 @@ public String toString() { sb.append("class CancelOrderResponse {\n"); sb.append(" limitType: ").append(toIndentedString(limitType)).append("\n"); sb.append(" limitTimes: ").append(toIndentedString(limitTimes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -158,30 +203,22 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CancelOrderResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CancelOrderResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CancelOrderResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in CancelOrderResponse is not found in the empty JSON string", CancelOrderResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CancelOrderResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CancelOrderResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `limitType` if (jsonObj.get("limitType") != null && !jsonObj.get("limitType").isJsonNull()) { - LimitType.validateJsonElement(jsonObj.get("limitType")); + CancelOrderLimitType.validateJsonElement(jsonObj.get("limitType")); } } @@ -200,6 +237,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CancelOrderResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -207,29 +266,50 @@ public void write(JsonWriter out, CancelOrderResponse value) throws IOException public CancelOrderResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CancelOrderResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of CancelOrderResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of CancelOrderResponse - * @throws IOException if the JSON string is invalid with respect to CancelOrderResponse - */ + /** + * Create an instance of CancelOrderResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CancelOrderResponse + * @throws IOException if the JSON string is invalid with respect to CancelOrderResponse + */ public static CancelOrderResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, CancelOrderResponse.class); } - /** - * Convert an instance of CancelOrderResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of CancelOrderResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/CancelReason.java b/src/main/java/com/grabfood/client/model/CancelReason.java new file mode 100644 index 0000000..c0a4886 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/CancelReason.java @@ -0,0 +1,320 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.grabfood.client.model.CancelCode; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * CancelReason + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class CancelReason { + public static final String SERIALIZED_NAME_CODE = "code"; + @SerializedName(SERIALIZED_NAME_CODE) + private CancelCode code; + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + + public CancelReason() { + } + + public CancelReason code(CancelCode code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @javax.annotation.Nullable + public CancelCode getCode() { + return code; + } + + public void setCode(CancelCode code) { + this.code = code; + } + + + public CancelReason reason(String reason) { + this.reason = reason; + return this; + } + + /** + * The detailed cancel reason for the specific cancel code. - Items are unavailable <code 1001> - I have too many orders now <code 1002> - My shop is closed <code 1003> - My shop is closing soon <code 1004> + * @return reason + */ + @javax.annotation.Nullable + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CancelReason instance itself + */ + public CancelReason putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CancelReason cancelReason = (CancelReason) o; + return Objects.equals(this.code, cancelReason.code) && + Objects.equals(this.reason, cancelReason.reason)&& + Objects.equals(this.additionalProperties, cancelReason.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, reason, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CancelReason {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("code"); + openapiFields.add("reason"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CancelReason + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CancelReason.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CancelReason is not found in the empty JSON string", CancelReason.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `code` + if (jsonObj.get("code") != null && !jsonObj.get("code").isJsonNull()) { + CancelCode.validateJsonElement(jsonObj.get("code")); + } + if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CancelReason.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CancelReason' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CancelReason.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CancelReason value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CancelReason read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CancelReason instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CancelReason given an JSON string + * + * @param jsonString JSON string + * @return An instance of CancelReason + * @throws IOException if the JSON string is invalid with respect to CancelReason + */ + public static CancelReason fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CancelReason.class); + } + + /** + * Convert an instance of CancelReason to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/CancelReasonsInner.java b/src/main/java/com/grabfood/client/model/CancelReasonsInner.java deleted file mode 100644 index 84345ce..0000000 --- a/src/main/java/com/grabfood/client/model/CancelReasonsInner.java +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.CancelCode; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * CancelReasonsInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class CancelReasonsInner { - public static final String SERIALIZED_NAME_CODE = "code"; - @SerializedName(SERIALIZED_NAME_CODE) - private CancelCode code; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public CancelReasonsInner() { - } - - public CancelReasonsInner code(CancelCode code) { - this.code = code; - return this; - } - - /** - * Get code - * @return code - **/ - @javax.annotation.Nullable - public CancelCode getCode() { - return code; - } - - public void setCode(CancelCode code) { - this.code = code; - } - - - public CancelReasonsInner reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The detailed cancel reason for the specific cancel code. - Items are unavailable <code 1001> - I have too many orders now <code 1002> - My shop is closed <code 1003> - My shop is closing soon <code 1004> - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CancelReasonsInner cancelReasonsInner = (CancelReasonsInner) o; - return Objects.equals(this.code, cancelReasonsInner.code) && - Objects.equals(this.reason, cancelReasonsInner.reason); - } - - @Override - public int hashCode() { - return Objects.hash(code, reason); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CancelReasonsInner {\n"); - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("code"); - openapiFields.add("reason"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CancelReasonsInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!CancelReasonsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in CancelReasonsInner is not found in the empty JSON string", CancelReasonsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CancelReasonsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CancelReasonsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // validate the optional field `code` - if (jsonObj.get("code") != null && !jsonObj.get("code").isJsonNull()) { - CancelCode.validateJsonElement(jsonObj.get("code")); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CancelReasonsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CancelReasonsInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CancelReasonsInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CancelReasonsInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CancelReasonsInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CancelReasonsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of CancelReasonsInner - * @throws IOException if the JSON string is invalid with respect to CancelReasonsInner - */ - public static CancelReasonsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CancelReasonsInner.class); - } - - /** - * Convert an instance of CancelReasonsInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/CategoriesInnerNameTranslation.java b/src/main/java/com/grabfood/client/model/CategoriesInnerNameTranslation.java deleted file mode 100644 index 2893dea..0000000 --- a/src/main/java/com/grabfood/client/model/CategoriesInnerNameTranslation.java +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Translation of the category name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class CategoriesInnerNameTranslation { - public static final String SERIALIZED_NAME_EN = "en"; - @SerializedName(SERIALIZED_NAME_EN) - private String en; - - public CategoriesInnerNameTranslation() { - } - - public CategoriesInnerNameTranslation en(String en) { - this.en = en; - return this; - } - - /** - * The English translation of the name. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - * @return en - **/ - @javax.annotation.Nullable - public String getEn() { - return en; - } - - public void setEn(String en) { - this.en = en; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CategoriesInnerNameTranslation categoriesInnerNameTranslation = (CategoriesInnerNameTranslation) o; - return Objects.equals(this.en, categoriesInnerNameTranslation.en); - } - - @Override - public int hashCode() { - return Objects.hash(en); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CategoriesInnerNameTranslation {\n"); - sb.append(" en: ").append(toIndentedString(en)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("en"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CategoriesInnerNameTranslation - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!CategoriesInnerNameTranslation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in CategoriesInnerNameTranslation is not found in the empty JSON string", CategoriesInnerNameTranslation.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CategoriesInnerNameTranslation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CategoriesInnerNameTranslation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("en") != null && !jsonObj.get("en").isJsonNull()) && !jsonObj.get("en").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `en` to be a primitive type in the JSON string but got `%s`", jsonObj.get("en").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CategoriesInnerNameTranslation.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CategoriesInnerNameTranslation' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CategoriesInnerNameTranslation.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CategoriesInnerNameTranslation value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CategoriesInnerNameTranslation read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CategoriesInnerNameTranslation given an JSON string - * - * @param jsonString JSON string - * @return An instance of CategoriesInnerNameTranslation - * @throws IOException if the JSON string is invalid with respect to CategoriesInnerNameTranslation - */ - public static CategoriesInnerNameTranslation fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CategoriesInnerNameTranslation.class); - } - - /** - * Convert an instance of CategoriesInnerNameTranslation to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/CheckOrderCancelableResponse.java b/src/main/java/com/grabfood/client/model/CheckOrderCancelableResponse.java index d665c3c..4d2f499 100644 --- a/src/main/java/com/grabfood/client/model/CheckOrderCancelableResponse.java +++ b/src/main/java/com/grabfood/client/model/CheckOrderCancelableResponse.java @@ -22,8 +22,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.CancelReasonsInner; -import com.grabfood.client.model.LimitType; +import com.grabfood.client.model.CancelOrderLimitType; +import com.grabfood.client.model.CancelReason; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -56,7 +55,7 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class CheckOrderCancelableResponse { public static final String SERIALIZED_NAME_CANCEL_ABLE = "cancelAble"; @SerializedName(SERIALIZED_NAME_CANCEL_ABLE) @@ -89,7 +88,9 @@ public enum NonCancellationReasonEnum { DEFAULT_ERROR("Default Error"), - EMPTY(""); + EMPTY(""), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -112,7 +113,7 @@ public static NonCancellationReasonEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -140,7 +141,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_LIMIT_TYPE = "limitType"; @SerializedName(SERIALIZED_NAME_LIMIT_TYPE) - private LimitType limitType; + private CancelOrderLimitType limitType; public static final String SERIALIZED_NAME_LIMIT_TIMES = "limitTimes"; @SerializedName(SERIALIZED_NAME_LIMIT_TIMES) @@ -148,7 +149,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_CANCEL_REASONS = "cancelReasons"; @SerializedName(SERIALIZED_NAME_CANCEL_REASONS) - private List cancelReasons = new ArrayList<>(); + private List cancelReasons = new ArrayList<>(); public CheckOrderCancelableResponse() { } @@ -158,10 +159,10 @@ public CheckOrderCancelableResponse cancelAble(Boolean cancelAble) { return this; } - /** + /** * The boolean value to indicate whether an order can be cancelled. * @return cancelAble - **/ + */ @javax.annotation.Nullable public Boolean getCancelAble() { return cancelAble; @@ -177,10 +178,10 @@ public CheckOrderCancelableResponse nonCancellationReason(NonCancellationReasonE return this; } - /** + /** * The reason for the order to be non-cancelable. * @return nonCancellationReason - **/ + */ @javax.annotation.Nullable public NonCancellationReasonEnum getNonCancellationReason() { return nonCancellationReason; @@ -191,21 +192,21 @@ public void setNonCancellationReason(NonCancellationReasonEnum nonCancellationRe } - public CheckOrderCancelableResponse limitType(LimitType limitType) { + public CheckOrderCancelableResponse limitType(CancelOrderLimitType limitType) { this.limitType = limitType; return this; } - /** + /** * Get limitType * @return limitType - **/ + */ @javax.annotation.Nullable - public LimitType getLimitType() { + public CancelOrderLimitType getLimitType() { return limitType; } - public void setLimitType(LimitType limitType) { + public void setLimitType(CancelOrderLimitType limitType) { this.limitType = limitType; } @@ -215,10 +216,10 @@ public CheckOrderCancelableResponse limitTimes(Integer limitTimes) { return this; } - /** + /** * The remaining cancellation quota for the merchant. A value is only returned when the nearest remaining cancellation limit is approaching, else it returns 0. * @return limitTimes - **/ + */ @javax.annotation.Nullable public Integer getLimitTimes() { return limitTimes; @@ -229,12 +230,12 @@ public void setLimitTimes(Integer limitTimes) { } - public CheckOrderCancelableResponse cancelReasons(List cancelReasons) { + public CheckOrderCancelableResponse cancelReasons(List cancelReasons) { this.cancelReasons = cancelReasons; return this; } - public CheckOrderCancelableResponse addCancelReasonsItem(CancelReasonsInner cancelReasonsItem) { + public CheckOrderCancelableResponse addCancelReasonsItem(CancelReason cancelReasonsItem) { if (this.cancelReasons == null) { this.cancelReasons = new ArrayList<>(); } @@ -242,19 +243,63 @@ public CheckOrderCancelableResponse addCancelReasonsItem(CancelReasonsInner canc return this; } - /** + /** * An array of cancel order reasons JSON objects. * @return cancelReasons - **/ + */ @javax.annotation.Nullable - public List getCancelReasons() { + public List getCancelReasons() { return cancelReasons; } - public void setCancelReasons(List cancelReasons) { + public void setCancelReasons(List cancelReasons) { this.cancelReasons = cancelReasons; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CheckOrderCancelableResponse instance itself + */ + public CheckOrderCancelableResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -270,12 +315,13 @@ public boolean equals(Object o) { Objects.equals(this.nonCancellationReason, checkOrderCancelableResponse.nonCancellationReason) && Objects.equals(this.limitType, checkOrderCancelableResponse.limitType) && Objects.equals(this.limitTimes, checkOrderCancelableResponse.limitTimes) && - Objects.equals(this.cancelReasons, checkOrderCancelableResponse.cancelReasons); + Objects.equals(this.cancelReasons, checkOrderCancelableResponse.cancelReasons)&& + Objects.equals(this.additionalProperties, checkOrderCancelableResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(cancelAble, nonCancellationReason, limitType, limitTimes, cancelReasons); + return Objects.hash(cancelAble, nonCancellationReason, limitType, limitTimes, cancelReasons, additionalProperties); } @Override @@ -287,6 +333,7 @@ public String toString() { sb.append(" limitType: ").append(toIndentedString(limitType)).append("\n"); sb.append(" limitTimes: ").append(toIndentedString(limitTimes)).append("\n"); sb.append(" cancelReasons: ").append(toIndentedString(cancelReasons)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -319,26 +366,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CheckOrderCancelableResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CheckOrderCancelableResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CheckOrderCancelableResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in CheckOrderCancelableResponse is not found in the empty JSON string", CheckOrderCancelableResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CheckOrderCancelableResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CheckOrderCancelableResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("nonCancellationReason") != null && !jsonObj.get("nonCancellationReason").isJsonNull()) && !jsonObj.get("nonCancellationReason").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `nonCancellationReason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("nonCancellationReason").toString())); @@ -349,7 +388,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // validate the optional field `limitType` if (jsonObj.get("limitType") != null && !jsonObj.get("limitType").isJsonNull()) { - LimitType.validateJsonElement(jsonObj.get("limitType")); + CancelOrderLimitType.validateJsonElement(jsonObj.get("limitType")); } if (jsonObj.get("cancelReasons") != null && !jsonObj.get("cancelReasons").isJsonNull()) { JsonArray jsonArraycancelReasons = jsonObj.getAsJsonArray("cancelReasons"); @@ -361,7 +400,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `cancelReasons` (array) for (int i = 0; i < jsonArraycancelReasons.size(); i++) { - CancelReasonsInner.validateJsonElement(jsonArraycancelReasons.get(i)); + CancelReason.validateJsonElement(jsonArraycancelReasons.get(i)); }; } } @@ -382,6 +421,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CheckOrderCancelableResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -389,29 +450,50 @@ public void write(JsonWriter out, CheckOrderCancelableResponse value) throws IOE public CheckOrderCancelableResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CheckOrderCancelableResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of CheckOrderCancelableResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of CheckOrderCancelableResponse - * @throws IOException if the JSON string is invalid with respect to CheckOrderCancelableResponse - */ + /** + * Create an instance of CheckOrderCancelableResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CheckOrderCancelableResponse + * @throws IOException if the JSON string is invalid with respect to CheckOrderCancelableResponse + */ public static CheckOrderCancelableResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, CheckOrderCancelableResponse.class); } - /** - * Convert an instance of CheckOrderCancelableResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of CheckOrderCancelableResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Coordinates.java b/src/main/java/com/grabfood/client/model/Coordinates.java index 1f88c3e..53f7292 100644 --- a/src/main/java/com/grabfood/client/model/Coordinates.java +++ b/src/main/java/com/grabfood/client/model/Coordinates.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * A JSON object containing the coordinates of the delivery address. Only has value when poiSource is `GRAB`. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class Coordinates { public static final String SERIALIZED_NAME_LATITUDE = "latitude"; @SerializedName(SERIALIZED_NAME_LATITUDE) @@ -70,10 +69,10 @@ public Coordinates latitude(Double latitude) { return this; } - /** + /** * The latitude coordinates of the delivery address. * @return latitude - **/ + */ @javax.annotation.Nullable public Double getLatitude() { return latitude; @@ -89,10 +88,10 @@ public Coordinates longitude(Double longitude) { return this; } - /** + /** * The longitude coordinates of the delivery address. * @return longitude - **/ + */ @javax.annotation.Nullable public Double getLongitude() { return longitude; @@ -102,6 +101,50 @@ public void setLongitude(Double longitude) { this.longitude = longitude; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Coordinates instance itself + */ + public Coordinates putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +157,13 @@ public boolean equals(Object o) { } Coordinates coordinates = (Coordinates) o; return Objects.equals(this.latitude, coordinates.latitude) && - Objects.equals(this.longitude, coordinates.longitude); + Objects.equals(this.longitude, coordinates.longitude)&& + Objects.equals(this.additionalProperties, coordinates.additionalProperties); } @Override public int hashCode() { - return Objects.hash(latitude, longitude); + return Objects.hash(latitude, longitude, additionalProperties); } @Override @@ -128,6 +172,7 @@ public String toString() { sb.append("class Coordinates {\n"); sb.append(" latitude: ").append(toIndentedString(latitude)).append("\n"); sb.append(" longitude: ").append(toIndentedString(longitude)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -157,26 +202,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Coordinates - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Coordinates + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Coordinates.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in Coordinates is not found in the empty JSON string", Coordinates.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Coordinates.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Coordinates` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -195,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Coordinates value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -202,29 +261,50 @@ public void write(JsonWriter out, Coordinates value) throws IOException { public Coordinates read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Coordinates instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Coordinates given an JSON string - * - * @param jsonString JSON string - * @return An instance of Coordinates - * @throws IOException if the JSON string is invalid with respect to Coordinates - */ + /** + * Create an instance of Coordinates given an JSON string + * + * @param jsonString JSON string + * @return An instance of Coordinates + * @throws IOException if the JSON string is invalid with respect to Coordinates + */ public static Coordinates fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, Coordinates.class); } - /** - * Convert an instance of Coordinates to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of Coordinates to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/CreateCampaignFail.java b/src/main/java/com/grabfood/client/model/CreateCampaignFail.java deleted file mode 100644 index c1f9329..0000000 --- a/src/main/java/com/grabfood/client/model/CreateCampaignFail.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class CreateCampaignFail { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public CreateCampaignFail() { - } - - public CreateCampaignFail target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public CreateCampaignFail reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public CreateCampaignFail message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CreateCampaignFail createCampaignFail = (CreateCampaignFail) o; - return Objects.equals(this.target, createCampaignFail.target) && - Objects.equals(this.reason, createCampaignFail.reason) && - Objects.equals(this.message, createCampaignFail.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CreateCampaignFail {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CreateCampaignFail - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!CreateCampaignFail.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in CreateCampaignFail is not found in the empty JSON string", CreateCampaignFail.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateCampaignFail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateCampaignFail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!CreateCampaignFail.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CreateCampaignFail' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CreateCampaignFail.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, CreateCampaignFail value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public CreateCampaignFail read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of CreateCampaignFail given an JSON string - * - * @param jsonString JSON string - * @return An instance of CreateCampaignFail - * @throws IOException if the JSON string is invalid with respect to CreateCampaignFail - */ - public static CreateCampaignFail fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CreateCampaignFail.class); - } - - /** - * Convert an instance of CreateCampaignFail to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/CreateCampaignRequest.java b/src/main/java/com/grabfood/client/model/CreateCampaignRequest.java index cc449b1..f21558d 100644 --- a/src/main/java/com/grabfood/client/model/CreateCampaignRequest.java +++ b/src/main/java/com/grabfood/client/model/CreateCampaignRequest.java @@ -22,9 +22,9 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.Conditions; -import com.grabfood.client.model.Discount; -import com.grabfood.client.model.Quotas; +import com.grabfood.client.model.CampaignConditions; +import com.grabfood.client.model.CampaignDiscount; +import com.grabfood.client.model.CampaignQuotas; import java.io.IOException; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * This request creates a campaign for your GrabFood store. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class CreateCampaignRequest { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -67,15 +66,15 @@ public class CreateCampaignRequest { public static final String SERIALIZED_NAME_QUOTAS = "quotas"; @SerializedName(SERIALIZED_NAME_QUOTAS) - private Quotas quotas; + private CampaignQuotas quotas; public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; @SerializedName(SERIALIZED_NAME_CONDITIONS) - private Conditions conditions; + private CampaignConditions conditions; public static final String SERIALIZED_NAME_DISCOUNT = "discount"; @SerializedName(SERIALIZED_NAME_DISCOUNT) - private Discount discount; + private CampaignDiscount discount; public static final String SERIALIZED_NAME_CUSTOM_TAG = "customTag"; @SerializedName(SERIALIZED_NAME_CUSTOM_TAG) @@ -89,10 +88,10 @@ public CreateCampaignRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -108,10 +107,10 @@ public CreateCampaignRequest name(String name) { return this; } - /** + /** * The campaign's name. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -122,59 +121,59 @@ public void setName(String name) { } - public CreateCampaignRequest quotas(Quotas quotas) { + public CreateCampaignRequest quotas(CampaignQuotas quotas) { this.quotas = quotas; return this; } - /** + /** * Get quotas * @return quotas - **/ + */ @javax.annotation.Nullable - public Quotas getQuotas() { + public CampaignQuotas getQuotas() { return quotas; } - public void setQuotas(Quotas quotas) { + public void setQuotas(CampaignQuotas quotas) { this.quotas = quotas; } - public CreateCampaignRequest conditions(Conditions conditions) { + public CreateCampaignRequest conditions(CampaignConditions conditions) { this.conditions = conditions; return this; } - /** + /** * Get conditions * @return conditions - **/ + */ @javax.annotation.Nonnull - public Conditions getConditions() { + public CampaignConditions getConditions() { return conditions; } - public void setConditions(Conditions conditions) { + public void setConditions(CampaignConditions conditions) { this.conditions = conditions; } - public CreateCampaignRequest discount(Discount discount) { + public CreateCampaignRequest discount(CampaignDiscount discount) { this.discount = discount; return this; } - /** + /** * Get discount * @return discount - **/ + */ @javax.annotation.Nonnull - public Discount getDiscount() { + public CampaignDiscount getDiscount() { return discount; } - public void setDiscount(Discount discount) { + public void setDiscount(CampaignDiscount discount) { this.discount = discount; } @@ -184,10 +183,10 @@ public CreateCampaignRequest customTag(String customTag) { return this; } - /** + /** * Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. * @return customTag - **/ + */ @javax.annotation.Nullable public String getCustomTag() { return customTag; @@ -197,6 +196,50 @@ public void setCustomTag(String customTag) { this.customTag = customTag; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateCampaignRequest instance itself + */ + public CreateCampaignRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -213,12 +256,13 @@ public boolean equals(Object o) { Objects.equals(this.quotas, createCampaignRequest.quotas) && Objects.equals(this.conditions, createCampaignRequest.conditions) && Objects.equals(this.discount, createCampaignRequest.discount) && - Objects.equals(this.customTag, createCampaignRequest.customTag); + Objects.equals(this.customTag, createCampaignRequest.customTag)&& + Objects.equals(this.additionalProperties, createCampaignRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(merchantID, name, quotas, conditions, discount, customTag); + return Objects.hash(merchantID, name, quotas, conditions, discount, customTag, additionalProperties); } @Override @@ -231,6 +275,7 @@ public String toString() { sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); sb.append(" discount: ").append(toIndentedString(discount)).append("\n"); sb.append(" customTag: ").append(toIndentedString(customTag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -268,12 +313,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("discount"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CreateCampaignRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateCampaignRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CreateCampaignRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -281,14 +326,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateCampaignRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateCampaignRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateCampaignRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -304,12 +341,12 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // validate the optional field `quotas` if (jsonObj.get("quotas") != null && !jsonObj.get("quotas").isJsonNull()) { - Quotas.validateJsonElement(jsonObj.get("quotas")); + CampaignQuotas.validateJsonElement(jsonObj.get("quotas")); } // validate the required field `conditions` - Conditions.validateJsonElement(jsonObj.get("conditions")); + CampaignConditions.validateJsonElement(jsonObj.get("conditions")); // validate the required field `discount` - Discount.validateJsonElement(jsonObj.get("discount")); + CampaignDiscount.validateJsonElement(jsonObj.get("discount")); if ((jsonObj.get("customTag") != null && !jsonObj.get("customTag").isJsonNull()) && !jsonObj.get("customTag").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `customTag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("customTag").toString())); } @@ -330,6 +367,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateCampaignRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -337,29 +396,50 @@ public void write(JsonWriter out, CreateCampaignRequest value) throws IOExceptio public CreateCampaignRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateCampaignRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of CreateCampaignRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of CreateCampaignRequest - * @throws IOException if the JSON string is invalid with respect to CreateCampaignRequest - */ + /** + * Create an instance of CreateCampaignRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateCampaignRequest + * @throws IOException if the JSON string is invalid with respect to CreateCampaignRequest + */ public static CreateCampaignRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, CreateCampaignRequest.class); } - /** - * Convert an instance of CreateCampaignRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of CreateCampaignRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/CreateCampaignResponse.java b/src/main/java/com/grabfood/client/model/CreateCampaignResponse.java index 35ddfd6..aa6807f 100644 --- a/src/main/java/com/grabfood/client/model/CreateCampaignResponse.java +++ b/src/main/java/com/grabfood/client/model/CreateCampaignResponse.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class CreateCampaignResponse { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -66,10 +65,10 @@ public CreateCampaignResponse id(String id) { return this; } - /** + /** * The campaign's ID. * @return id - **/ + */ @javax.annotation.Nullable public String getId() { return id; @@ -79,6 +78,50 @@ public void setId(String id) { this.id = id; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateCampaignResponse instance itself + */ + public CreateCampaignResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } CreateCampaignResponse createCampaignResponse = (CreateCampaignResponse) o; - return Objects.equals(this.id, createCampaignResponse.id); + return Objects.equals(this.id, createCampaignResponse.id)&& + Objects.equals(this.additionalProperties, createCampaignResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(id, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CreateCampaignResponse {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -131,26 +176,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CreateCampaignResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateCampaignResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!CreateCampaignResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in CreateCampaignResponse is not found in the empty JSON string", CreateCampaignResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateCampaignResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateCampaignResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); @@ -172,6 +209,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateCampaignResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -179,29 +238,50 @@ public void write(JsonWriter out, CreateCampaignResponse value) throws IOExcepti public CreateCampaignResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateCampaignResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of CreateCampaignResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of CreateCampaignResponse - * @throws IOException if the JSON string is invalid with respect to CreateCampaignResponse - */ + /** + * Create an instance of CreateCampaignResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateCampaignResponse + * @throws IOException if the JSON string is invalid with respect to CreateCampaignResponse + */ public static CreateCampaignResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, CreateCampaignResponse.class); } - /** - * Convert an instance of CreateCampaignResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of CreateCampaignResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Currency.java b/src/main/java/com/grabfood/client/model/Currency.java index b1bf2ac..f080f24 100644 --- a/src/main/java/com/grabfood/client/model/Currency.java +++ b/src/main/java/com/grabfood/client/model/Currency.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * A JSON object containing code, symbol, and exponent for a given currency. Refer to [Country and Currency](#section/Getting-started/Country-and-currency). */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class Currency { /** * The three-letter ISO currency code. This is the currency that is associated with the payment amount. @@ -69,7 +68,9 @@ public enum CodeEnum { THB("THB"), - VND("VND"); + VND("VND"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -92,7 +93,7 @@ public static CodeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -133,7 +134,9 @@ public enum SymbolEnum { u2("฿"), - u3("₫"); + u3("₫"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -156,7 +159,7 @@ public static SymbolEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -194,10 +197,10 @@ public Currency code(CodeEnum code) { return this; } - /** + /** * The three-letter ISO currency code. This is the currency that is associated with the payment amount. * @return code - **/ + */ @javax.annotation.Nonnull public CodeEnum getCode() { return code; @@ -213,10 +216,10 @@ public Currency symbol(SymbolEnum symbol) { return this; } - /** + /** * The currency symbol. * @return symbol - **/ + */ @javax.annotation.Nonnull public SymbolEnum getSymbol() { return symbol; @@ -232,10 +235,10 @@ public Currency exponent(Integer exponent) { return this; } - /** + /** * The log base 10 of the number of times we have to multiply the major unit to get the minor unit. Should be 0 for VN and 2 for other countries (SG/MY/ID/TH/PH/KH). * @return exponent - **/ + */ @javax.annotation.Nonnull public Integer getExponent() { return exponent; @@ -245,6 +248,50 @@ public void setExponent(Integer exponent) { this.exponent = exponent; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Currency instance itself + */ + public Currency putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -258,12 +305,13 @@ public boolean equals(Object o) { Currency currency = (Currency) o; return Objects.equals(this.code, currency.code) && Objects.equals(this.symbol, currency.symbol) && - Objects.equals(this.exponent, currency.exponent); + Objects.equals(this.exponent, currency.exponent)&& + Objects.equals(this.additionalProperties, currency.additionalProperties); } @Override public int hashCode() { - return Objects.hash(code, symbol, exponent); + return Objects.hash(code, symbol, exponent, additionalProperties); } @Override @@ -273,6 +321,7 @@ public String toString() { sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" symbol: ").append(toIndentedString(symbol)).append("\n"); sb.append(" exponent: ").append(toIndentedString(exponent)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -306,12 +355,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("exponent"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Currency - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Currency + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Currency.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -319,14 +368,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Currency.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Currency` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Currency.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -361,6 +402,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Currency value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -368,29 +431,50 @@ public void write(JsonWriter out, Currency value) throws IOException { public Currency read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Currency instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Currency given an JSON string - * - * @param jsonString JSON string - * @return An instance of Currency - * @throws IOException if the JSON string is invalid with respect to Currency - */ + /** + * Create an instance of Currency given an JSON string + * + * @param jsonString JSON string + * @return An instance of Currency + * @throws IOException if the JSON string is invalid with respect to Currency + */ public static Currency fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, Currency.class); } - /** - * Convert an instance of Currency to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of Currency to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/DineIn.java b/src/main/java/com/grabfood/client/model/DineIn.java index b6d9a90..ba71340 100644 --- a/src/main/java/com/grabfood/client/model/DineIn.java +++ b/src/main/java/com/grabfood/client/model/DineIn.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * A JSON object containing order at table information. Present only for dineIn order. **Not available** in [ListOrder](#tag/list-order/operation/list-orders) response. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class DineIn { public static final String SERIALIZED_NAME_TABLE_I_D = "tableID"; @SerializedName(SERIALIZED_NAME_TABLE_I_D) @@ -70,10 +69,10 @@ public DineIn tableID(String tableID) { return this; } - /** + /** * Table number. * @return tableID - **/ + */ @javax.annotation.Nullable public String getTableID() { return tableID; @@ -89,10 +88,10 @@ public DineIn eaterCount(Integer eaterCount) { return this; } - /** + /** * The number of eaters. * @return eaterCount - **/ + */ @javax.annotation.Nullable public Integer getEaterCount() { return eaterCount; @@ -102,6 +101,50 @@ public void setEaterCount(Integer eaterCount) { this.eaterCount = eaterCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DineIn instance itself + */ + public DineIn putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +157,13 @@ public boolean equals(Object o) { } DineIn dineIn = (DineIn) o; return Objects.equals(this.tableID, dineIn.tableID) && - Objects.equals(this.eaterCount, dineIn.eaterCount); + Objects.equals(this.eaterCount, dineIn.eaterCount)&& + Objects.equals(this.additionalProperties, dineIn.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tableID, eaterCount); + return Objects.hash(tableID, eaterCount, additionalProperties); } @Override @@ -128,6 +172,7 @@ public String toString() { sb.append("class DineIn {\n"); sb.append(" tableID: ").append(toIndentedString(tableID)).append("\n"); sb.append(" eaterCount: ").append(toIndentedString(eaterCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -157,26 +202,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to DineIn - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to DineIn + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!DineIn.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in DineIn is not found in the empty JSON string", DineIn.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DineIn.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DineIn` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("tableID") != null && !jsonObj.get("tableID").isJsonNull()) && !jsonObj.get("tableID").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `tableID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tableID").toString())); @@ -198,6 +235,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DineIn value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,29 +264,50 @@ public void write(JsonWriter out, DineIn value) throws IOException { public DineIn read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DineIn instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of DineIn given an JSON string - * - * @param jsonString JSON string - * @return An instance of DineIn - * @throws IOException if the JSON string is invalid with respect to DineIn - */ + /** + * Create an instance of DineIn given an JSON string + * + * @param jsonString JSON string + * @return An instance of DineIn + * @throws IOException if the JSON string is invalid with respect to DineIn + */ public static DineIn fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, DineIn.class); } - /** - * Convert an instance of DineIn to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of DineIn to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/DineInVoucher400Fail.java b/src/main/java/com/grabfood/client/model/DineInVoucher400Fail.java deleted file mode 100644 index b83f7cb..0000000 --- a/src/main/java/com/grabfood/client/model/DineInVoucher400Fail.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * The failed example with code and reason. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class DineInVoucher400Fail { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public DineInVoucher400Fail() { - } - - public DineInVoucher400Fail target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public DineInVoucher400Fail reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public DineInVoucher400Fail message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DineInVoucher400Fail dineInVoucher400Fail = (DineInVoucher400Fail) o; - return Objects.equals(this.target, dineInVoucher400Fail.target) && - Objects.equals(this.reason, dineInVoucher400Fail.reason) && - Objects.equals(this.message, dineInVoucher400Fail.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DineInVoucher400Fail {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to DineInVoucher400Fail - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!DineInVoucher400Fail.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in DineInVoucher400Fail is not found in the empty JSON string", DineInVoucher400Fail.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DineInVoucher400Fail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DineInVoucher400Fail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!DineInVoucher400Fail.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'DineInVoucher400Fail' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(DineInVoucher400Fail.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, DineInVoucher400Fail value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public DineInVoucher400Fail read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of DineInVoucher400Fail given an JSON string - * - * @param jsonString JSON string - * @return An instance of DineInVoucher400Fail - * @throws IOException if the JSON string is invalid with respect to DineInVoucher400Fail - */ - public static DineInVoucher400Fail fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, DineInVoucher400Fail.class); - } - - /** - * Convert an instance of DineInVoucher400Fail to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/DineInVoucher404Fail.java b/src/main/java/com/grabfood/client/model/DineInVoucher404Fail.java deleted file mode 100644 index 782d34e..0000000 --- a/src/main/java/com/grabfood/client/model/DineInVoucher404Fail.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * The specified resource does not exist. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class DineInVoucher404Fail { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public DineInVoucher404Fail() { - } - - public DineInVoucher404Fail target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public DineInVoucher404Fail reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public DineInVoucher404Fail message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DineInVoucher404Fail dineInVoucher404Fail = (DineInVoucher404Fail) o; - return Objects.equals(this.target, dineInVoucher404Fail.target) && - Objects.equals(this.reason, dineInVoucher404Fail.reason) && - Objects.equals(this.message, dineInVoucher404Fail.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DineInVoucher404Fail {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to DineInVoucher404Fail - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!DineInVoucher404Fail.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in DineInVoucher404Fail is not found in the empty JSON string", DineInVoucher404Fail.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DineInVoucher404Fail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DineInVoucher404Fail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!DineInVoucher404Fail.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'DineInVoucher404Fail' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(DineInVoucher404Fail.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, DineInVoucher404Fail value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public DineInVoucher404Fail read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of DineInVoucher404Fail given an JSON string - * - * @param jsonString JSON string - * @return An instance of DineInVoucher404Fail - * @throws IOException if the JSON string is invalid with respect to DineInVoucher404Fail - */ - public static DineInVoucher404Fail fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, DineInVoucher404Fail.class); - } - - /** - * Convert an instance of DineInVoucher404Fail to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/EditOrderRequestItemsInner.java b/src/main/java/com/grabfood/client/model/EditOrderItem.java similarity index 57% rename from src/main/java/com/grabfood/client/model/EditOrderRequestItemsInner.java rename to src/main/java/com/grabfood/client/model/EditOrderItem.java index da43e2a..d1265e7 100644 --- a/src/main/java/com/grabfood/client/model/EditOrderRequestItemsInner.java +++ b/src/main/java/com/grabfood/client/model/EditOrderItem.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -50,10 +49,10 @@ import com.grabfood.client.JSON; /** - * EditOrderRequestItemsInner + * EditOrderItem */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class EditOrderRequestItemsInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class EditOrderItem { public static final String SERIALIZED_NAME_ITEM_I_D = "itemID"; @SerializedName(SERIALIZED_NAME_ITEM_I_D) private String itemID; @@ -69,7 +68,9 @@ public enum StatusEnum { ADDED("ADDED"), - EMPTY(""); + EMPTY(""), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -92,7 +93,7 @@ public static StatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -126,18 +127,18 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_IS_EXTERNAL_ITEM_I_D) private Boolean isExternalItemID; - public EditOrderRequestItemsInner() { + public EditOrderItem() { } - public EditOrderRequestItemsInner itemID(String itemID) { + public EditOrderItem itemID(String itemID) { this.itemID = itemID; return this; } - /** + /** * The item's ID in Grab system that can be obtained from the [Submit Order Webhook](#tag/submit-order-webhook/operation/submit-order-webhook) request payload parameters under `items[].grabItemID`, or `items[].outOfStockInstruction.replacementGrabItemID` for item replacement. External item ID from Partner system is only supported when `ADDED` status and `isExternalItemID: true`. * @return itemID - **/ + */ @javax.annotation.Nonnull public String getItemID() { return itemID; @@ -148,15 +149,15 @@ public void setItemID(String itemID) { } - public EditOrderRequestItemsInner status(StatusEnum status) { + public EditOrderItem status(StatusEnum status) { this.status = status; return this; } - /** + /** * The item's edited status. Leave empty string if there is no change to the item. * @return status - **/ + */ @javax.annotation.Nonnull public StatusEnum getStatus() { return status; @@ -167,15 +168,15 @@ public void setStatus(StatusEnum status) { } - public EditOrderRequestItemsInner quantity(Integer quantity) { + public EditOrderItem quantity(Integer quantity) { this.quantity = quantity; return this; } - /** + /** * The item's quantity. If the item is not being updated or deleted, use the original quantity. * @return quantity - **/ + */ @javax.annotation.Nullable public Integer getQuantity() { return quantity; @@ -186,15 +187,15 @@ public void setQuantity(Integer quantity) { } - public EditOrderRequestItemsInner isExternalItemID(Boolean isExternalItemID) { + public EditOrderItem isExternalItemID(Boolean isExternalItemID) { this.isExternalItemID = isExternalItemID; return this; } - /** + /** * Only applicable for `ADDED`status. Indicate if the `itemID` is an external item ID. Grab checks for the items that are mapped to the provided item ID, considering their availability. If multiple Grab items are found to be mapped to the provided external item ID, the last updated item will be chosen. If no suitable record is found, an 400 error will be returned to the partner, indicating that the submitted external item ID cannot be edited. * @return isExternalItemID - **/ + */ @javax.annotation.Nullable public Boolean getIsExternalItemID() { return isExternalItemID; @@ -204,6 +205,50 @@ public void setIsExternalItemID(Boolean isExternalItemID) { this.isExternalItemID = isExternalItemID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EditOrderItem instance itself + */ + public EditOrderItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -214,26 +259,28 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - EditOrderRequestItemsInner editOrderRequestItemsInner = (EditOrderRequestItemsInner) o; - return Objects.equals(this.itemID, editOrderRequestItemsInner.itemID) && - Objects.equals(this.status, editOrderRequestItemsInner.status) && - Objects.equals(this.quantity, editOrderRequestItemsInner.quantity) && - Objects.equals(this.isExternalItemID, editOrderRequestItemsInner.isExternalItemID); + EditOrderItem editOrderItem = (EditOrderItem) o; + return Objects.equals(this.itemID, editOrderItem.itemID) && + Objects.equals(this.status, editOrderItem.status) && + Objects.equals(this.quantity, editOrderItem.quantity) && + Objects.equals(this.isExternalItemID, editOrderItem.isExternalItemID)&& + Objects.equals(this.additionalProperties, editOrderItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(itemID, status, quantity, isExternalItemID); + return Objects.hash(itemID, status, quantity, isExternalItemID, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class EditOrderRequestItemsInner {\n"); + sb.append("class EditOrderItem {\n"); sb.append(" itemID: ").append(toIndentedString(itemID)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); sb.append(" isExternalItemID: ").append(toIndentedString(isExternalItemID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -267,29 +314,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("status"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to EditOrderRequestItemsInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EditOrderItem + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!EditOrderRequestItemsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in EditOrderRequestItemsInner is not found in the empty JSON string", EditOrderRequestItemsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EditOrderRequestItemsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EditOrderRequestItemsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!EditOrderItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in EditOrderItem is not found in the empty JSON string", EditOrderItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : EditOrderRequestItemsInner.openapiRequiredFields) { + for (String requiredField : EditOrderItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -309,47 +348,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!EditOrderRequestItemsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'EditOrderRequestItemsInner' and its subtypes + if (!EditOrderItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EditOrderItem' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(EditOrderRequestItemsInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EditOrderItem.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, EditOrderRequestItemsInner value) throws IOException { + public void write(JsonWriter out, EditOrderItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public EditOrderRequestItemsInner read(JsonReader in) throws IOException { + public EditOrderItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EditOrderItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of EditOrderRequestItemsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of EditOrderRequestItemsInner - * @throws IOException if the JSON string is invalid with respect to EditOrderRequestItemsInner - */ - public static EditOrderRequestItemsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, EditOrderRequestItemsInner.class); + /** + * Create an instance of EditOrderItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of EditOrderItem + * @throws IOException if the JSON string is invalid with respect to EditOrderItem + */ + public static EditOrderItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EditOrderItem.class); } - /** - * Convert an instance of EditOrderRequestItemsInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of EditOrderItem to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/EditOrderRequest.java b/src/main/java/com/grabfood/client/model/EditOrderRequest.java index 2c65775..136a456 100644 --- a/src/main/java/com/grabfood/client/model/EditOrderRequest.java +++ b/src/main/java/com/grabfood/client/model/EditOrderRequest.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.EditOrderRequestItemsInner; +import com.grabfood.client.model.EditOrderItem; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * Information about editing an existing order on GrabFood. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class EditOrderRequest { public static final String SERIALIZED_NAME_ORDER_I_D = "orderID"; @SerializedName(SERIALIZED_NAME_ORDER_I_D) @@ -63,7 +62,7 @@ public class EditOrderRequest { public static final String SERIALIZED_NAME_ITEMS = "items"; @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); + private List items = new ArrayList<>(); public static final String SERIALIZED_NAME_ONLY_RECALCULATE = "onlyRecalculate"; @SerializedName(SERIALIZED_NAME_ONLY_RECALCULATE) @@ -77,10 +76,10 @@ public EditOrderRequest orderID(String orderID) { return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -91,12 +90,12 @@ public void setOrderID(String orderID) { } - public EditOrderRequest items(List items) { + public EditOrderRequest items(List items) { this.items = items; return this; } - public EditOrderRequest addItemsItem(EditOrderRequestItemsInner itemsItem) { + public EditOrderRequest addItemsItem(EditOrderItem itemsItem) { if (this.items == null) { this.items = new ArrayList<>(); } @@ -104,16 +103,16 @@ public EditOrderRequest addItemsItem(EditOrderRequestItemsInner itemsItem) { return this; } - /** + /** * Specify the array of all items in the order, including deleted, added, updated and unchanged items. * @return items - **/ + */ @javax.annotation.Nonnull - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } @@ -123,10 +122,10 @@ public EditOrderRequest onlyRecalculate(Boolean onlyRecalculate) { return this; } - /** + /** * This parameter specifies whether to recalculate the edited order without submitting it. It is intended for testing purposes only. This parameter is set to false by default, which means the edited order will be recalculated and re-submitted to partners. * @return onlyRecalculate - **/ + */ @javax.annotation.Nullable public Boolean getOnlyRecalculate() { return onlyRecalculate; @@ -136,6 +135,50 @@ public void setOnlyRecalculate(Boolean onlyRecalculate) { this.onlyRecalculate = onlyRecalculate; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EditOrderRequest instance itself + */ + public EditOrderRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -149,12 +192,13 @@ public boolean equals(Object o) { EditOrderRequest editOrderRequest = (EditOrderRequest) o; return Objects.equals(this.orderID, editOrderRequest.orderID) && Objects.equals(this.items, editOrderRequest.items) && - Objects.equals(this.onlyRecalculate, editOrderRequest.onlyRecalculate); + Objects.equals(this.onlyRecalculate, editOrderRequest.onlyRecalculate)&& + Objects.equals(this.additionalProperties, editOrderRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(orderID, items, onlyRecalculate); + return Objects.hash(orderID, items, onlyRecalculate, additionalProperties); } @Override @@ -164,6 +208,7 @@ public String toString() { sb.append(" orderID: ").append(toIndentedString(orderID)).append("\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); sb.append(" onlyRecalculate: ").append(toIndentedString(onlyRecalculate)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -196,12 +241,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("items"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to EditOrderRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EditOrderRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!EditOrderRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -209,14 +254,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EditOrderRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EditOrderRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EditOrderRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -235,7 +272,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); // validate the required field `items` (array) for (int i = 0; i < jsonArrayitems.size(); i++) { - EditOrderRequestItemsInner.validateJsonElement(jsonArrayitems.get(i)); + EditOrderItem.validateJsonElement(jsonArrayitems.get(i)); }; } @@ -254,6 +291,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, EditOrderRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -261,29 +320,50 @@ public void write(JsonWriter out, EditOrderRequest value) throws IOException { public EditOrderRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EditOrderRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of EditOrderRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of EditOrderRequest - * @throws IOException if the JSON string is invalid with respect to EditOrderRequest - */ + /** + * Create an instance of EditOrderRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of EditOrderRequest + * @throws IOException if the JSON string is invalid with respect to EditOrderRequest + */ public static EditOrderRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, EditOrderRequest.class); } - /** - * Convert an instance of EditOrderRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of EditOrderRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Error.java b/src/main/java/com/grabfood/client/model/Error.java new file mode 100644 index 0000000..bdcd1bd --- /dev/null +++ b/src/main/java/com/grabfood/client/model/Error.java @@ -0,0 +1,347 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * Error + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class Error { + public static final String SERIALIZED_NAME_TARGET = "target"; + @SerializedName(SERIALIZED_NAME_TARGET) + private String target; + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public Error() { + } + + public Error target(String target) { + this.target = target; + return this; + } + + /** + * Target of error + * @return target + */ + @javax.annotation.Nullable + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + + public Error reason(String reason) { + this.reason = reason; + return this; + } + + /** + * The type of error. + * @return reason + */ + @javax.annotation.Nullable + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + + public Error message(String message) { + this.message = message; + return this; + } + + /** + * The details of the error. + * @return message + */ + @javax.annotation.Nullable + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Error instance itself + */ + public Error putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.target, error.target) && + Objects.equals(this.reason, error.reason) && + Objects.equals(this.message, error.message)&& + Objects.equals(this.additionalProperties, error.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(target, reason, message, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + sb.append(" target: ").append(toIndentedString(target)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("target"); + openapiFields.add("reason"); + openapiFields.add("message"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Error + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Error.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Error is not found in the empty JSON string", Error.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); + } + if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Error.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Error' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Error.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Error value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Error read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Error instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Error given an JSON string + * + * @param jsonString JSON string + * @return An instance of Error + * @throws IOException if the JSON string is invalid with respect to Error + */ + public static Error fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Error.class); + } + + /** + * Convert an instance of Error to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/Error404.java b/src/main/java/com/grabfood/client/model/Error404.java deleted file mode 100644 index 67a468f..0000000 --- a/src/main/java/com/grabfood/client/model/Error404.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * The specified resource does not exist. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Error404 { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public Error404() { - } - - public Error404 target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public Error404 reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public Error404 message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Error404 error404 = (Error404) o; - return Objects.equals(this.target, error404.target) && - Objects.equals(this.reason, error404.reason) && - Objects.equals(this.message, error404.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Error404 {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Error404 - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!Error404.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Error404 is not found in the empty JSON string", Error404.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Error404.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Error404` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Error404.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Error404' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Error404.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Error404 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Error404 read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Error404 given an JSON string - * - * @param jsonString JSON string - * @return An instance of Error404 - * @throws IOException if the JSON string is invalid with respect to Error404 - */ - public static Error404 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Error404.class); - } - - /** - * Convert an instance of Error404 to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/Error409.java b/src/main/java/com/grabfood/client/model/Error409.java deleted file mode 100644 index b0b4a1d..0000000 --- a/src/main/java/com/grabfood/client/model/Error409.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Common error, probably due to a process failure. The reason for the failure is usually indicated in the response. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Error409 { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public Error409() { - } - - public Error409 target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public Error409 reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public Error409 message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Error409 error409 = (Error409) o; - return Objects.equals(this.target, error409.target) && - Objects.equals(this.reason, error409.reason) && - Objects.equals(this.message, error409.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Error409 {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Error409 - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!Error409.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Error409 is not found in the empty JSON string", Error409.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Error409.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Error409` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Error409.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Error409' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Error409.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Error409 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Error409 read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Error409 given an JSON string - * - * @param jsonString JSON string - * @return An instance of Error409 - * @throws IOException if the JSON string is invalid with respect to Error409 - */ - public static Error409 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Error409.class); - } - - /** - * Convert an instance of Error409 to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/Error500.java b/src/main/java/com/grabfood/client/model/Error500.java deleted file mode 100644 index ca73699..0000000 --- a/src/main/java/com/grabfood/client/model/Error500.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * A system or application error occurred. Although the client appears to provide a correct request, there may be something unexpected on the server. You may retry the request in this case. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Error500 { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public Error500() { - } - - public Error500 target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public Error500 reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public Error500 message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Error500 error500 = (Error500) o; - return Objects.equals(this.target, error500.target) && - Objects.equals(this.reason, error500.reason) && - Objects.equals(this.message, error500.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Error500 {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Error500 - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!Error500.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Error500 is not found in the empty JSON string", Error500.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Error500.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Error500` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Error500.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Error500' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Error500.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Error500 value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Error500 read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Error500 given an JSON string - * - * @param jsonString JSON string - * @return An instance of Error500 - * @throws IOException if the JSON string is invalid with respect to Error500 - */ - public static Error500 fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Error500.class); - } - - /** - * Convert an instance of Error500 to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/FreeItem.java b/src/main/java/com/grabfood/client/model/FreeItem.java deleted file mode 100644 index dc186cb..0000000 --- a/src/main/java/com/grabfood/client/model/FreeItem.java +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Free item information for `freeItem` campaign. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class FreeItem { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private String id; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_QUANTITY = "quantity"; - @SerializedName(SERIALIZED_NAME_QUANTITY) - private Integer quantity; - - public static final String SERIALIZED_NAME_PRICE = "price"; - @SerializedName(SERIALIZED_NAME_PRICE) - private Integer price; - - public FreeItem() { - } - - public FreeItem id(String id) { - this.id = id; - return this; - } - - /** - * The item's ID - * @return id - **/ - @javax.annotation.Nullable - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - - public FreeItem name(String name) { - this.name = name; - return this; - } - - /** - * The name of the item. - * @return name - **/ - @javax.annotation.Nullable - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - - public FreeItem quantity(Integer quantity) { - this.quantity = quantity; - return this; - } - - /** - * The item's quantity. Maximum is **1**. - * @return quantity - **/ - @javax.annotation.Nullable - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - - public FreeItem price(Integer price) { - this.price = price; - return this; - } - - /** - * The item's price in minor unit format. - * @return price - **/ - @javax.annotation.Nullable - public Integer getPrice() { - return price; - } - - public void setPrice(Integer price) { - this.price = price; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FreeItem freeItem = (FreeItem) o; - return Objects.equals(this.id, freeItem.id) && - Objects.equals(this.name, freeItem.name) && - Objects.equals(this.quantity, freeItem.quantity) && - Objects.equals(this.price, freeItem.price); - } - - @Override - public int hashCode() { - return Objects.hash(id, name, quantity, price); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class FreeItem {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); - sb.append(" price: ").append(toIndentedString(price)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("id"); - openapiFields.add("name"); - openapiFields.add("quantity"); - openapiFields.add("price"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to FreeItem - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!FreeItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in FreeItem is not found in the empty JSON string", FreeItem.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FreeItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FreeItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!FreeItem.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'FreeItem' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(FreeItem.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, FreeItem value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public FreeItem read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of FreeItem given an JSON string - * - * @param jsonString JSON string - * @return An instance of FreeItem - * @throws IOException if the JSON string is invalid with respect to FreeItem - */ - public static FreeItem fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, FreeItem.class); - } - - /** - * Convert an instance of FreeItem to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/GetDineInVoucherResponse.java b/src/main/java/com/grabfood/client/model/GetDineInVoucherResponse.java index 6510750..a3eba8d 100644 --- a/src/main/java/com/grabfood/client/model/GetDineInVoucherResponse.java +++ b/src/main/java/com/grabfood/client/model/GetDineInVoucherResponse.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetDineInVoucherResponse { public static final String SERIALIZED_NAME_CERTIFICATE_I_D = "certificateID"; @SerializedName(SERIALIZED_NAME_CERTIFICATE_I_D) @@ -78,7 +77,9 @@ public enum VoucherStatusEnum { EXPIRED("EXPIRED"), - REFUNDED("REFUNDED"); + REFUNDED("REFUNDED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -101,7 +102,7 @@ public static VoucherStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -143,10 +144,10 @@ public GetDineInVoucherResponse certificateID(String certificateID) { return this; } - /** + /** * This certificateID is decoded from scanning the QR code, and 1:1 mapping with `voucherCode`. * @return certificateID - **/ + */ @javax.annotation.Nullable public String getCertificateID() { return certificateID; @@ -162,10 +163,10 @@ public GetDineInVoucherResponse voucherCode(String voucherCode) { return this; } - /** + /** * A short code for the dine-in voucher purchased by the user. * @return voucherCode - **/ + */ @javax.annotation.Nullable public String getVoucherCode() { return voucherCode; @@ -181,10 +182,10 @@ public GetDineInVoucherResponse voucher(Voucher voucher) { return this; } - /** + /** * Get voucher * @return voucher - **/ + */ @javax.annotation.Nullable public Voucher getVoucher() { return voucher; @@ -200,10 +201,10 @@ public GetDineInVoucherResponse voucherStatus(VoucherStatusEnum voucherStatus) { return this; } - /** + /** * The status of the dine-in voucher purchased. Only active voucher is eligible for redemption. * @return voucherStatus - **/ + */ @javax.annotation.Nullable public VoucherStatusEnum getVoucherStatus() { return voucherStatus; @@ -219,10 +220,10 @@ public GetDineInVoucherResponse merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -238,10 +239,10 @@ public GetDineInVoucherResponse campaignID(String campaignID) { return this; } - /** + /** * The dine-in voucher campaign's ID in GrabFood's database. * @return campaignID - **/ + */ @javax.annotation.Nullable public String getCampaignID() { return campaignID; @@ -251,6 +252,50 @@ public void setCampaignID(String campaignID) { this.campaignID = campaignID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetDineInVoucherResponse instance itself + */ + public GetDineInVoucherResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -267,12 +312,13 @@ public boolean equals(Object o) { Objects.equals(this.voucher, getDineInVoucherResponse.voucher) && Objects.equals(this.voucherStatus, getDineInVoucherResponse.voucherStatus) && Objects.equals(this.merchantID, getDineInVoucherResponse.merchantID) && - Objects.equals(this.campaignID, getDineInVoucherResponse.campaignID); + Objects.equals(this.campaignID, getDineInVoucherResponse.campaignID)&& + Objects.equals(this.additionalProperties, getDineInVoucherResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(certificateID, voucherCode, voucher, voucherStatus, merchantID, campaignID); + return Objects.hash(certificateID, voucherCode, voucher, voucherStatus, merchantID, campaignID, additionalProperties); } @Override @@ -285,6 +331,7 @@ public String toString() { sb.append(" voucherStatus: ").append(toIndentedString(voucherStatus)).append("\n"); sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); sb.append(" campaignID: ").append(toIndentedString(campaignID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -318,26 +365,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetDineInVoucherResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetDineInVoucherResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetDineInVoucherResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in GetDineInVoucherResponse is not found in the empty JSON string", GetDineInVoucherResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetDineInVoucherResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetDineInVoucherResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("certificateID") != null && !jsonObj.get("certificateID").isJsonNull()) && !jsonObj.get("certificateID").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `certificateID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("certificateID").toString())); @@ -379,6 +418,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetDineInVoucherResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -386,29 +447,50 @@ public void write(JsonWriter out, GetDineInVoucherResponse value) throws IOExcep public GetDineInVoucherResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetDineInVoucherResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetDineInVoucherResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetDineInVoucherResponse - * @throws IOException if the JSON string is invalid with respect to GetDineInVoucherResponse - */ + /** + * Create an instance of GetDineInVoucherResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetDineInVoucherResponse + * @throws IOException if the JSON string is invalid with respect to GetDineInVoucherResponse + */ public static GetDineInVoucherResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetDineInVoucherResponse.class); } - /** - * Convert an instance of GetDineInVoucherResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetDineInVoucherResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GetMembershipNativeResponse.java b/src/main/java/com/grabfood/client/model/GetMembershipNativeResponse.java index 2fbf9f5..f3988e6 100644 --- a/src/main/java/com/grabfood/client/model/GetMembershipNativeResponse.java +++ b/src/main/java/com/grabfood/client/model/GetMembershipNativeResponse.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * This response returns membership detail. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetMembershipNativeResponse { /** * Status of the memberID. @@ -62,7 +61,9 @@ public class GetMembershipNativeResponse { public enum MembershipStatusEnum { VALID("VALID"), - INVALID("INVALID"); + INVALID("INVALID"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -85,7 +86,7 @@ public static MembershipStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -127,10 +128,10 @@ public GetMembershipNativeResponse membershipStatus(MembershipStatusEnum members return this; } - /** + /** * Status of the memberID. * @return membershipStatus - **/ + */ @javax.annotation.Nullable public MembershipStatusEnum getMembershipStatus() { return membershipStatus; @@ -146,10 +147,10 @@ public GetMembershipNativeResponse pointInfo(GetMembershipNativeResponsePointInf return this; } - /** + /** * Get pointInfo * @return pointInfo - **/ + */ @javax.annotation.Nullable public GetMembershipNativeResponsePointInfo getPointInfo() { return pointInfo; @@ -165,10 +166,10 @@ public GetMembershipNativeResponse pointsExpireDate(String pointsExpireDate) { return this; } - /** + /** * Earliest points expiry date. In `yyyy-mm-dd` format * @return pointsExpireDate - **/ + */ @javax.annotation.Nullable public String getPointsExpireDate() { return pointsExpireDate; @@ -178,6 +179,50 @@ public void setPointsExpireDate(String pointsExpireDate) { this.pointsExpireDate = pointsExpireDate; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMembershipNativeResponse instance itself + */ + public GetMembershipNativeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -191,12 +236,13 @@ public boolean equals(Object o) { GetMembershipNativeResponse getMembershipNativeResponse = (GetMembershipNativeResponse) o; return Objects.equals(this.membershipStatus, getMembershipNativeResponse.membershipStatus) && Objects.equals(this.pointInfo, getMembershipNativeResponse.pointInfo) && - Objects.equals(this.pointsExpireDate, getMembershipNativeResponse.pointsExpireDate); + Objects.equals(this.pointsExpireDate, getMembershipNativeResponse.pointsExpireDate)&& + Objects.equals(this.additionalProperties, getMembershipNativeResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(membershipStatus, pointInfo, pointsExpireDate); + return Objects.hash(membershipStatus, pointInfo, pointsExpireDate, additionalProperties); } @Override @@ -206,6 +252,7 @@ public String toString() { sb.append(" membershipStatus: ").append(toIndentedString(membershipStatus)).append("\n"); sb.append(" pointInfo: ").append(toIndentedString(pointInfo)).append("\n"); sb.append(" pointsExpireDate: ").append(toIndentedString(pointsExpireDate)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -236,26 +283,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetMembershipNativeResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetMembershipNativeResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetMembershipNativeResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in GetMembershipNativeResponse is not found in the empty JSON string", GetMembershipNativeResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMembershipNativeResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetMembershipNativeResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("membershipStatus") != null && !jsonObj.get("membershipStatus").isJsonNull()) && !jsonObj.get("membershipStatus").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `membershipStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("membershipStatus").toString())); @@ -288,6 +327,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMembershipNativeResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -295,29 +356,50 @@ public void write(JsonWriter out, GetMembershipNativeResponse value) throws IOEx public GetMembershipNativeResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMembershipNativeResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetMembershipNativeResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetMembershipNativeResponse - * @throws IOException if the JSON string is invalid with respect to GetMembershipNativeResponse - */ + /** + * Create an instance of GetMembershipNativeResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetMembershipNativeResponse + * @throws IOException if the JSON string is invalid with respect to GetMembershipNativeResponse + */ public static GetMembershipNativeResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetMembershipNativeResponse.class); } - /** - * Convert an instance of GetMembershipNativeResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetMembershipNativeResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GetMembershipNativeResponsePointInfo.java b/src/main/java/com/grabfood/client/model/GetMembershipNativeResponsePointInfo.java index 3980a97..5ee22b9 100644 --- a/src/main/java/com/grabfood/client/model/GetMembershipNativeResponsePointInfo.java +++ b/src/main/java/com/grabfood/client/model/GetMembershipNativeResponsePointInfo.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * Obtain contains user's point details. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetMembershipNativeResponsePointInfo { public static final String SERIALIZED_NAME_CURRENT_POINTS = "currentPoints"; @SerializedName(SERIALIZED_NAME_CURRENT_POINTS) @@ -74,10 +73,10 @@ public GetMembershipNativeResponsePointInfo currentPoints(Integer currentPoints) return this; } - /** + /** * Point that user currently obtained. * @return currentPoints - **/ + */ @javax.annotation.Nullable public Integer getCurrentPoints() { return currentPoints; @@ -93,10 +92,10 @@ public GetMembershipNativeResponsePointInfo maxPoints(Integer maxPoints) { return this; } - /** + /** * Maximum point that user can obtain. * @return maxPoints - **/ + */ @javax.annotation.Nullable public Integer getMaxPoints() { return maxPoints; @@ -112,10 +111,10 @@ public GetMembershipNativeResponsePointInfo expirePoints(Integer expirePoints) { return this; } - /** + /** * Points that would get expired in future. * @return expirePoints - **/ + */ @javax.annotation.Nullable public Integer getExpirePoints() { return expirePoints; @@ -125,6 +124,50 @@ public void setExpirePoints(Integer expirePoints) { this.expirePoints = expirePoints; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMembershipNativeResponsePointInfo instance itself + */ + public GetMembershipNativeResponsePointInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -138,12 +181,13 @@ public boolean equals(Object o) { GetMembershipNativeResponsePointInfo getMembershipNativeResponsePointInfo = (GetMembershipNativeResponsePointInfo) o; return Objects.equals(this.currentPoints, getMembershipNativeResponsePointInfo.currentPoints) && Objects.equals(this.maxPoints, getMembershipNativeResponsePointInfo.maxPoints) && - Objects.equals(this.expirePoints, getMembershipNativeResponsePointInfo.expirePoints); + Objects.equals(this.expirePoints, getMembershipNativeResponsePointInfo.expirePoints)&& + Objects.equals(this.additionalProperties, getMembershipNativeResponsePointInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(currentPoints, maxPoints, expirePoints); + return Objects.hash(currentPoints, maxPoints, expirePoints, additionalProperties); } @Override @@ -153,6 +197,7 @@ public String toString() { sb.append(" currentPoints: ").append(toIndentedString(currentPoints)).append("\n"); sb.append(" maxPoints: ").append(toIndentedString(maxPoints)).append("\n"); sb.append(" expirePoints: ").append(toIndentedString(expirePoints)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -183,26 +228,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetMembershipNativeResponsePointInfo - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetMembershipNativeResponsePointInfo + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetMembershipNativeResponsePointInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in GetMembershipNativeResponsePointInfo is not found in the empty JSON string", GetMembershipNativeResponsePointInfo.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMembershipNativeResponsePointInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetMembershipNativeResponsePointInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -221,6 +258,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMembershipNativeResponsePointInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -228,29 +287,50 @@ public void write(JsonWriter out, GetMembershipNativeResponsePointInfo value) th public GetMembershipNativeResponsePointInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMembershipNativeResponsePointInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetMembershipNativeResponsePointInfo given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetMembershipNativeResponsePointInfo - * @throws IOException if the JSON string is invalid with respect to GetMembershipNativeResponsePointInfo - */ + /** + * Create an instance of GetMembershipNativeResponsePointInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetMembershipNativeResponsePointInfo + * @throws IOException if the JSON string is invalid with respect to GetMembershipNativeResponsePointInfo + */ public static GetMembershipNativeResponsePointInfo fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetMembershipNativeResponsePointInfo.class); } - /** - * Convert an instance of GetMembershipNativeResponsePointInfo to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetMembershipNativeResponsePointInfo to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GetMembershipRequest.java b/src/main/java/com/grabfood/client/model/GetMembershipRequest.java index f2cbb9e..445780c 100644 --- a/src/main/java/com/grabfood/client/model/GetMembershipRequest.java +++ b/src/main/java/com/grabfood/client/model/GetMembershipRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request submits membership unbind request to partner. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetMembershipRequest { public static final String SERIALIZED_NAME_MEMBER_I_D = "memberID"; @SerializedName(SERIALIZED_NAME_MEMBER_I_D) @@ -66,10 +65,10 @@ public GetMembershipRequest memberID(String memberID) { return this; } - /** + /** * The unique member ID on the partner's database. * @return memberID - **/ + */ @javax.annotation.Nonnull public String getMemberID() { return memberID; @@ -79,6 +78,50 @@ public void setMemberID(String memberID) { this.memberID = memberID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMembershipRequest instance itself + */ + public GetMembershipRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } GetMembershipRequest getMembershipRequest = (GetMembershipRequest) o; - return Objects.equals(this.memberID, getMembershipRequest.memberID); + return Objects.equals(this.memberID, getMembershipRequest.memberID)&& + Objects.equals(this.additionalProperties, getMembershipRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(memberID); + return Objects.hash(memberID, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetMembershipRequest {\n"); sb.append(" memberID: ").append(toIndentedString(memberID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -132,12 +177,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("memberID"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetMembershipRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetMembershipRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetMembershipRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -145,14 +190,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMembershipRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetMembershipRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetMembershipRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -180,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMembershipRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -187,29 +246,50 @@ public void write(JsonWriter out, GetMembershipRequest value) throws IOException public GetMembershipRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMembershipRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetMembershipRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetMembershipRequest - * @throws IOException if the JSON string is invalid with respect to GetMembershipRequest - */ + /** + * Create an instance of GetMembershipRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetMembershipRequest + * @throws IOException if the JSON string is invalid with respect to GetMembershipRequest + */ public static GetMembershipRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetMembershipRequest.class); } - /** - * Convert an instance of GetMembershipRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetMembershipRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GetMembershipWebviewResponse.java b/src/main/java/com/grabfood/client/model/GetMembershipWebviewResponse.java index e8427f9..bd85260 100644 --- a/src/main/java/com/grabfood/client/model/GetMembershipWebviewResponse.java +++ b/src/main/java/com/grabfood/client/model/GetMembershipWebviewResponse.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This response returns membership detail. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetMembershipWebviewResponse { /** * Status of the memberID. @@ -61,7 +60,9 @@ public class GetMembershipWebviewResponse { public enum MembershipStatusEnum { VALID("VALID"), - INVALID("INVALID"); + INVALID("INVALID"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -84,7 +85,7 @@ public static MembershipStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -118,10 +119,10 @@ public GetMembershipWebviewResponse membershipStatus(MembershipStatusEnum member return this; } - /** + /** * Status of the memberID. * @return membershipStatus - **/ + */ @javax.annotation.Nullable public MembershipStatusEnum getMembershipStatus() { return membershipStatus; @@ -131,6 +132,50 @@ public void setMembershipStatus(MembershipStatusEnum membershipStatus) { this.membershipStatus = membershipStatus; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMembershipWebviewResponse instance itself + */ + public GetMembershipWebviewResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -142,12 +187,13 @@ public boolean equals(Object o) { return false; } GetMembershipWebviewResponse getMembershipWebviewResponse = (GetMembershipWebviewResponse) o; - return Objects.equals(this.membershipStatus, getMembershipWebviewResponse.membershipStatus); + return Objects.equals(this.membershipStatus, getMembershipWebviewResponse.membershipStatus)&& + Objects.equals(this.additionalProperties, getMembershipWebviewResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(membershipStatus); + return Objects.hash(membershipStatus, additionalProperties); } @Override @@ -155,6 +201,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetMembershipWebviewResponse {\n"); sb.append(" membershipStatus: ").append(toIndentedString(membershipStatus)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -183,26 +230,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetMembershipWebviewResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetMembershipWebviewResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetMembershipWebviewResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in GetMembershipWebviewResponse is not found in the empty JSON string", GetMembershipWebviewResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMembershipWebviewResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetMembershipWebviewResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("membershipStatus") != null && !jsonObj.get("membershipStatus").isJsonNull()) && !jsonObj.get("membershipStatus").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `membershipStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("membershipStatus").toString())); @@ -228,6 +267,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMembershipWebviewResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -235,29 +296,50 @@ public void write(JsonWriter out, GetMembershipWebviewResponse value) throws IOE public GetMembershipWebviewResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMembershipWebviewResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetMembershipWebviewResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetMembershipWebviewResponse - * @throws IOException if the JSON string is invalid with respect to GetMembershipWebviewResponse - */ + /** + * Create an instance of GetMembershipWebviewResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetMembershipWebviewResponse + * @throws IOException if the JSON string is invalid with respect to GetMembershipWebviewResponse + */ public static GetMembershipWebviewResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetMembershipWebviewResponse.class); } - /** - * Convert an instance of GetMembershipWebviewResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetMembershipWebviewResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GetMenuNewResponse.java b/src/main/java/com/grabfood/client/model/GetMenuNewResponse.java index 57cb800..6eb8043 100644 --- a/src/main/java/com/grabfood/client/model/GetMenuNewResponse.java +++ b/src/main/java/com/grabfood/client/model/GetMenuNewResponse.java @@ -22,9 +22,9 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.CategoriesInner; import com.grabfood.client.model.Currency; -import com.grabfood.client.model.SellingTimesInner; +import com.grabfood.client.model.MenuCategory; +import com.grabfood.client.model.SellingTime; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -45,7 +45,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -57,7 +56,7 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetMenuNewResponse { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -73,11 +72,11 @@ public class GetMenuNewResponse { public static final String SERIALIZED_NAME_SELLING_TIMES = "sellingTimes"; @SerializedName(SERIALIZED_NAME_SELLING_TIMES) - private List sellingTimes = new ArrayList<>(); + private List sellingTimes = new ArrayList<>(); public static final String SERIALIZED_NAME_CATEGORIES = "categories"; @SerializedName(SERIALIZED_NAME_CATEGORIES) - private List categories = new ArrayList<>(); + private List categories = new ArrayList<>(); public GetMenuNewResponse() { } @@ -87,10 +86,10 @@ public GetMenuNewResponse merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -106,10 +105,10 @@ public GetMenuNewResponse partnerMerchantID(String partnerMerchantID) { return this; } - /** + /** * The merchant's ID that is on the partner's database. * @return partnerMerchantID - **/ + */ @javax.annotation.Nullable public String getPartnerMerchantID() { return partnerMerchantID; @@ -125,10 +124,10 @@ public GetMenuNewResponse currency(Currency currency) { return this; } - /** + /** * Get currency * @return currency - **/ + */ @javax.annotation.Nonnull public Currency getCurrency() { return currency; @@ -139,12 +138,12 @@ public void setCurrency(Currency currency) { } - public GetMenuNewResponse sellingTimes(List sellingTimes) { + public GetMenuNewResponse sellingTimes(List sellingTimes) { this.sellingTimes = sellingTimes; return this; } - public GetMenuNewResponse addSellingTimesItem(SellingTimesInner sellingTimesItem) { + public GetMenuNewResponse addSellingTimesItem(SellingTime sellingTimesItem) { if (this.sellingTimes == null) { this.sellingTimes = new ArrayList<>(); } @@ -152,26 +151,26 @@ public GetMenuNewResponse addSellingTimesItem(SellingTimesInner sellingTimesItem return this; } - /** + /** * An array of sellingTimes JSON objects. Max 20 allowed. Refer to [Selling Times](#selling-times) for more information. * @return sellingTimes - **/ + */ @javax.annotation.Nonnull - public List getSellingTimes() { + public List getSellingTimes() { return sellingTimes; } - public void setSellingTimes(List sellingTimes) { + public void setSellingTimes(List sellingTimes) { this.sellingTimes = sellingTimes; } - public GetMenuNewResponse categories(List categories) { + public GetMenuNewResponse categories(List categories) { this.categories = categories; return this; } - public GetMenuNewResponse addCategoriesItem(CategoriesInner categoriesItem) { + public GetMenuNewResponse addCategoriesItem(MenuCategory categoriesItem) { if (this.categories == null) { this.categories = new ArrayList<>(); } @@ -179,19 +178,63 @@ public GetMenuNewResponse addCategoriesItem(CategoriesInner categoriesItem) { return this; } - /** + /** * An array of category JSON objects. Max 100 allowed per section. Refer to [Categories](#categories) for more information. * @return categories - **/ + */ @javax.annotation.Nonnull - public List getCategories() { + public List getCategories() { return categories; } - public void setCategories(List categories) { + public void setCategories(List categories) { this.categories = categories; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMenuNewResponse instance itself + */ + public GetMenuNewResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -207,12 +250,13 @@ public boolean equals(Object o) { Objects.equals(this.partnerMerchantID, getMenuNewResponse.partnerMerchantID) && Objects.equals(this.currency, getMenuNewResponse.currency) && Objects.equals(this.sellingTimes, getMenuNewResponse.sellingTimes) && - Objects.equals(this.categories, getMenuNewResponse.categories); + Objects.equals(this.categories, getMenuNewResponse.categories)&& + Objects.equals(this.additionalProperties, getMenuNewResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(merchantID, partnerMerchantID, currency, sellingTimes, categories); + return Objects.hash(merchantID, partnerMerchantID, currency, sellingTimes, categories, additionalProperties); } @Override @@ -224,6 +268,7 @@ public String toString() { sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); sb.append(" sellingTimes: ").append(toIndentedString(sellingTimes)).append("\n"); sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -259,12 +304,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("categories"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetMenuNewResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetMenuNewResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetMenuNewResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -272,14 +317,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMenuNewResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetMenuNewResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetMenuNewResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -303,7 +340,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArraysellingTimes = jsonObj.getAsJsonArray("sellingTimes"); // validate the required field `sellingTimes` (array) for (int i = 0; i < jsonArraysellingTimes.size(); i++) { - SellingTimesInner.validateJsonElement(jsonArraysellingTimes.get(i)); + SellingTime.validateJsonElement(jsonArraysellingTimes.get(i)); }; // ensure the json data is an array if (!jsonObj.get("categories").isJsonArray()) { @@ -313,7 +350,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArraycategories = jsonObj.getAsJsonArray("categories"); // validate the required field `categories` (array) for (int i = 0; i < jsonArraycategories.size(); i++) { - CategoriesInner.validateJsonElement(jsonArraycategories.get(i)); + MenuCategory.validateJsonElement(jsonArraycategories.get(i)); }; } @@ -332,6 +369,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMenuNewResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -339,29 +398,50 @@ public void write(JsonWriter out, GetMenuNewResponse value) throws IOException { public GetMenuNewResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMenuNewResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetMenuNewResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetMenuNewResponse - * @throws IOException if the JSON string is invalid with respect to GetMenuNewResponse - */ + /** + * Create an instance of GetMenuNewResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetMenuNewResponse + * @throws IOException if the JSON string is invalid with respect to GetMenuNewResponse + */ public static GetMenuNewResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetMenuNewResponse.class); } - /** - * Convert an instance of GetMenuNewResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetMenuNewResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GetMenuOldResponse.java b/src/main/java/com/grabfood/client/model/GetMenuOldResponse.java index d8a7b31..0bd5d56 100644 --- a/src/main/java/com/grabfood/client/model/GetMenuOldResponse.java +++ b/src/main/java/com/grabfood/client/model/GetMenuOldResponse.java @@ -23,7 +23,7 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.grabfood.client.model.Currency; -import com.grabfood.client.model.SectionsInner; +import com.grabfood.client.model.MenuSection; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -56,7 +55,7 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetMenuOldResponse { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -72,7 +71,7 @@ public class GetMenuOldResponse { public static final String SERIALIZED_NAME_SECTIONS = "sections"; @SerializedName(SERIALIZED_NAME_SECTIONS) - private List sections = new ArrayList<>(); + private List sections = new ArrayList<>(); public GetMenuOldResponse() { } @@ -82,10 +81,10 @@ public GetMenuOldResponse merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -101,10 +100,10 @@ public GetMenuOldResponse partnerMerchantID(String partnerMerchantID) { return this; } - /** + /** * The merchant's ID that is on the partner's database. * @return partnerMerchantID - **/ + */ @javax.annotation.Nullable public String getPartnerMerchantID() { return partnerMerchantID; @@ -120,10 +119,10 @@ public GetMenuOldResponse currency(Currency currency) { return this; } - /** + /** * Get currency * @return currency - **/ + */ @javax.annotation.Nonnull public Currency getCurrency() { return currency; @@ -134,12 +133,12 @@ public void setCurrency(Currency currency) { } - public GetMenuOldResponse sections(List sections) { + public GetMenuOldResponse sections(List sections) { this.sections = sections; return this; } - public GetMenuOldResponse addSectionsItem(SectionsInner sectionsItem) { + public GetMenuOldResponse addSectionsItem(MenuSection sectionsItem) { if (this.sections == null) { this.sections = new ArrayList<>(); } @@ -147,19 +146,63 @@ public GetMenuOldResponse addSectionsItem(SectionsInner sectionsItem) { return this; } - /** + /** * An array of section JSON objects. Max 7 allowed. Refer to [Sections](#sections) for more information. * @return sections - **/ + */ @javax.annotation.Nonnull - public List getSections() { + public List getSections() { return sections; } - public void setSections(List sections) { + public void setSections(List sections) { this.sections = sections; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMenuOldResponse instance itself + */ + public GetMenuOldResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -174,12 +217,13 @@ public boolean equals(Object o) { return Objects.equals(this.merchantID, getMenuOldResponse.merchantID) && Objects.equals(this.partnerMerchantID, getMenuOldResponse.partnerMerchantID) && Objects.equals(this.currency, getMenuOldResponse.currency) && - Objects.equals(this.sections, getMenuOldResponse.sections); + Objects.equals(this.sections, getMenuOldResponse.sections)&& + Objects.equals(this.additionalProperties, getMenuOldResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(merchantID, partnerMerchantID, currency, sections); + return Objects.hash(merchantID, partnerMerchantID, currency, sections, additionalProperties); } @Override @@ -190,6 +234,7 @@ public String toString() { sb.append(" partnerMerchantID: ").append(toIndentedString(partnerMerchantID)).append("\n"); sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); sb.append(" sections: ").append(toIndentedString(sections)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -223,12 +268,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("sections"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetMenuOldResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetMenuOldResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetMenuOldResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -236,14 +281,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMenuOldResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetMenuOldResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetMenuOldResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -267,7 +304,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArraysections = jsonObj.getAsJsonArray("sections"); // validate the required field `sections` (array) for (int i = 0; i < jsonArraysections.size(); i++) { - SectionsInner.validateJsonElement(jsonArraysections.get(i)); + MenuSection.validateJsonElement(jsonArraysections.get(i)); }; } @@ -286,6 +323,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMenuOldResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -293,29 +352,50 @@ public void write(JsonWriter out, GetMenuOldResponse value) throws IOException { public GetMenuOldResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMenuOldResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetMenuOldResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetMenuOldResponse - * @throws IOException if the JSON string is invalid with respect to GetMenuOldResponse - */ + /** + * Create an instance of GetMenuOldResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetMenuOldResponse + * @throws IOException if the JSON string is invalid with respect to GetMenuOldResponse + */ public static GetMenuOldResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetMenuOldResponse.class); } - /** - * Convert an instance of GetMenuOldResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetMenuOldResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GetRewardNativeRequest.java b/src/main/java/com/grabfood/client/model/GetRewardNativeRequest.java index 24562c6..a9bbb13 100644 --- a/src/main/java/com/grabfood/client/model/GetRewardNativeRequest.java +++ b/src/main/java/com/grabfood/client/model/GetRewardNativeRequest.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.GetRewardNativeRequestItemsInner; +import com.grabfood.client.model.RewardItem; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * This request submits membership detail and order value to get reward calculation. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetRewardNativeRequest { public static final String SERIALIZED_NAME_MEMBER_I_D = "memberID"; @SerializedName(SERIALIZED_NAME_MEMBER_I_D) @@ -67,7 +66,7 @@ public class GetRewardNativeRequest { public static final String SERIALIZED_NAME_ITEMS = "items"; @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); + private List items = new ArrayList<>(); public static final String SERIALIZED_NAME_ORDER_VALUE = "orderValue"; @SerializedName(SERIALIZED_NAME_ORDER_VALUE) @@ -81,10 +80,10 @@ public GetRewardNativeRequest memberID(String memberID) { return this; } - /** + /** * The unique member ID on the partner's database. * @return memberID - **/ + */ @javax.annotation.Nullable public String getMemberID() { return memberID; @@ -100,10 +99,10 @@ public GetRewardNativeRequest merchantID(String merchantID) { return this; } - /** + /** * Grab merchant's ID. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -114,12 +113,12 @@ public void setMerchantID(String merchantID) { } - public GetRewardNativeRequest items(List items) { + public GetRewardNativeRequest items(List items) { this.items = items; return this; } - public GetRewardNativeRequest addItemsItem(GetRewardNativeRequestItemsInner itemsItem) { + public GetRewardNativeRequest addItemsItem(RewardItem itemsItem) { if (this.items == null) { this.items = new ArrayList<>(); } @@ -127,16 +126,16 @@ public GetRewardNativeRequest addItemsItem(GetRewardNativeRequestItemsInner item return this; } - /** + /** * Get items * @return items - **/ + */ @javax.annotation.Nullable - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } @@ -146,10 +145,10 @@ public GetRewardNativeRequest orderValue(Integer orderValue) { return this; } - /** + /** * The post-discount order value. * @return orderValue - **/ + */ @javax.annotation.Nullable public Integer getOrderValue() { return orderValue; @@ -159,6 +158,50 @@ public void setOrderValue(Integer orderValue) { this.orderValue = orderValue; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetRewardNativeRequest instance itself + */ + public GetRewardNativeRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -173,12 +216,13 @@ public boolean equals(Object o) { return Objects.equals(this.memberID, getRewardNativeRequest.memberID) && Objects.equals(this.merchantID, getRewardNativeRequest.merchantID) && Objects.equals(this.items, getRewardNativeRequest.items) && - Objects.equals(this.orderValue, getRewardNativeRequest.orderValue); + Objects.equals(this.orderValue, getRewardNativeRequest.orderValue)&& + Objects.equals(this.additionalProperties, getRewardNativeRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(memberID, merchantID, items, orderValue); + return Objects.hash(memberID, merchantID, items, orderValue, additionalProperties); } @Override @@ -189,6 +233,7 @@ public String toString() { sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); sb.append(" orderValue: ").append(toIndentedString(orderValue)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -220,26 +265,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetRewardNativeRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetRewardNativeRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetRewardNativeRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in GetRewardNativeRequest is not found in the empty JSON string", GetRewardNativeRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetRewardNativeRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetRewardNativeRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("memberID") != null && !jsonObj.get("memberID").isJsonNull()) && !jsonObj.get("memberID").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `memberID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("memberID").toString())); @@ -257,7 +294,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `items` (array) for (int i = 0; i < jsonArrayitems.size(); i++) { - GetRewardNativeRequestItemsInner.validateJsonElement(jsonArrayitems.get(i)); + RewardItem.validateJsonElement(jsonArrayitems.get(i)); }; } } @@ -278,6 +315,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetRewardNativeRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -285,29 +344,50 @@ public void write(JsonWriter out, GetRewardNativeRequest value) throws IOExcepti public GetRewardNativeRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetRewardNativeRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetRewardNativeRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetRewardNativeRequest - * @throws IOException if the JSON string is invalid with respect to GetRewardNativeRequest - */ + /** + * Create an instance of GetRewardNativeRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetRewardNativeRequest + * @throws IOException if the JSON string is invalid with respect to GetRewardNativeRequest + */ public static GetRewardNativeRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetRewardNativeRequest.class); } - /** - * Convert an instance of GetRewardNativeRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetRewardNativeRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GetRewardNativeRequestItemsInner.java b/src/main/java/com/grabfood/client/model/GetRewardNativeRequestItemsInner.java deleted file mode 100644 index 53c2a64..0000000 --- a/src/main/java/com/grabfood/client/model/GetRewardNativeRequestItemsInner.java +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * GetRewardNativeRequestItemsInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class GetRewardNativeRequestItemsInner { - public static final String SERIALIZED_NAME_ITEM_I_D = "itemID"; - @SerializedName(SERIALIZED_NAME_ITEM_I_D) - private String itemID; - - public static final String SERIALIZED_NAME_QUANTITY = "quantity"; - @SerializedName(SERIALIZED_NAME_QUANTITY) - private Integer quantity; - - public GetRewardNativeRequestItemsInner() { - } - - public GetRewardNativeRequestItemsInner itemID(String itemID) { - this.itemID = itemID; - return this; - } - - /** - * The item's ID in partner system. - * @return itemID - **/ - @javax.annotation.Nullable - public String getItemID() { - return itemID; - } - - public void setItemID(String itemID) { - this.itemID = itemID; - } - - - public GetRewardNativeRequestItemsInner quantity(Integer quantity) { - this.quantity = quantity; - return this; - } - - /** - * The item's quantity. - * @return quantity - **/ - @javax.annotation.Nullable - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - GetRewardNativeRequestItemsInner getRewardNativeRequestItemsInner = (GetRewardNativeRequestItemsInner) o; - return Objects.equals(this.itemID, getRewardNativeRequestItemsInner.itemID) && - Objects.equals(this.quantity, getRewardNativeRequestItemsInner.quantity); - } - - @Override - public int hashCode() { - return Objects.hash(itemID, quantity); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class GetRewardNativeRequestItemsInner {\n"); - sb.append(" itemID: ").append(toIndentedString(itemID)).append("\n"); - sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("itemID"); - openapiFields.add("quantity"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetRewardNativeRequestItemsInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!GetRewardNativeRequestItemsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in GetRewardNativeRequestItemsInner is not found in the empty JSON string", GetRewardNativeRequestItemsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetRewardNativeRequestItemsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetRewardNativeRequestItemsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("itemID") != null && !jsonObj.get("itemID").isJsonNull()) && !jsonObj.get("itemID").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `itemID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("itemID").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!GetRewardNativeRequestItemsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'GetRewardNativeRequestItemsInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(GetRewardNativeRequestItemsInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, GetRewardNativeRequestItemsInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public GetRewardNativeRequestItemsInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of GetRewardNativeRequestItemsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetRewardNativeRequestItemsInner - * @throws IOException if the JSON string is invalid with respect to GetRewardNativeRequestItemsInner - */ - public static GetRewardNativeRequestItemsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, GetRewardNativeRequestItemsInner.class); - } - - /** - * Convert an instance of GetRewardNativeRequestItemsInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/GetRewardNativeResponse.java b/src/main/java/com/grabfood/client/model/GetRewardNativeResponse.java index 3cd7e72..47d5abd 100644 --- a/src/main/java/com/grabfood/client/model/GetRewardNativeResponse.java +++ b/src/main/java/com/grabfood/client/model/GetRewardNativeResponse.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This response returns reward points earn for this order. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GetRewardNativeResponse { public static final String SERIALIZED_NAME_POINTS = "points"; @SerializedName(SERIALIZED_NAME_POINTS) @@ -66,10 +65,10 @@ public GetRewardNativeResponse points(Integer points) { return this; } - /** + /** * The reward points earned in this purchase. * @return points - **/ + */ @javax.annotation.Nonnull public Integer getPoints() { return points; @@ -79,6 +78,50 @@ public void setPoints(Integer points) { this.points = points; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetRewardNativeResponse instance itself + */ + public GetRewardNativeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } GetRewardNativeResponse getRewardNativeResponse = (GetRewardNativeResponse) o; - return Objects.equals(this.points, getRewardNativeResponse.points); + return Objects.equals(this.points, getRewardNativeResponse.points)&& + Objects.equals(this.additionalProperties, getRewardNativeResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(points); + return Objects.hash(points, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetRewardNativeResponse {\n"); sb.append(" points: ").append(toIndentedString(points)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -132,12 +177,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("points"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GetRewardNativeResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetRewardNativeResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GetRewardNativeResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -145,14 +190,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetRewardNativeResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetRewardNativeResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetRewardNativeResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -177,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetRewardNativeResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -184,29 +243,50 @@ public void write(JsonWriter out, GetRewardNativeResponse value) throws IOExcept public GetRewardNativeResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetRewardNativeResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GetRewardNativeResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of GetRewardNativeResponse - * @throws IOException if the JSON string is invalid with respect to GetRewardNativeResponse - */ + /** + * Create an instance of GetRewardNativeResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetRewardNativeResponse + * @throws IOException if the JSON string is invalid with respect to GetRewardNativeResponse + */ public static GetRewardNativeResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GetRewardNativeResponse.class); } - /** - * Convert an instance of GetRewardNativeResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GetRewardNativeResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GrabOauthRequest.java b/src/main/java/com/grabfood/client/model/GrabOauthRequest.java index 4616f2d..8dd5449 100644 --- a/src/main/java/com/grabfood/client/model/GrabOauthRequest.java +++ b/src/main/java/com/grabfood/client/model/GrabOauthRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * Information about the GrabFood client getting an OAuth 2.0 access token from partners. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GrabOauthRequest { public static final String SERIALIZED_NAME_CLIENT_ID = "client_id"; @SerializedName(SERIALIZED_NAME_CLIENT_ID) @@ -78,10 +77,10 @@ public GrabOauthRequest clientId(String clientId) { return this; } - /** + /** * The client identifier issued to the client to obtain the OAuth 2.0 access_token. * @return clientId - **/ + */ @javax.annotation.Nonnull public String getClientId() { return clientId; @@ -97,10 +96,10 @@ public GrabOauthRequest clientSecret(String clientSecret) { return this; } - /** + /** * The client secret issued to the client to obtain the OAuth 2.0 access_token. * @return clientSecret - **/ + */ @javax.annotation.Nonnull public String getClientSecret() { return clientSecret; @@ -116,10 +115,10 @@ public GrabOauthRequest grantType(String grantType) { return this; } - /** + /** * The grant type for the client to obtain the OAuth 2.0 access_token. * @return grantType - **/ + */ @javax.annotation.Nonnull public String getGrantType() { return grantType; @@ -135,10 +134,10 @@ public GrabOauthRequest scope(String scope) { return this; } - /** + /** * The scope for the client to obtain the OAuth 2.0 access_token. * @return scope - **/ + */ @javax.annotation.Nonnull public String getScope() { return scope; @@ -148,6 +147,50 @@ public void setScope(String scope) { this.scope = scope; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GrabOauthRequest instance itself + */ + public GrabOauthRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.clientId, grabOauthRequest.clientId) && Objects.equals(this.clientSecret, grabOauthRequest.clientSecret) && Objects.equals(this.grantType, grabOauthRequest.grantType) && - Objects.equals(this.scope, grabOauthRequest.scope); + Objects.equals(this.scope, grabOauthRequest.scope)&& + Objects.equals(this.additionalProperties, grabOauthRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(clientId, clientSecret, grantType, scope); + return Objects.hash(clientId, clientSecret, grantType, scope, additionalProperties); } @Override @@ -178,6 +222,7 @@ public String toString() { sb.append(" clientSecret: ").append(toIndentedString(clientSecret)).append("\n"); sb.append(" grantType: ").append(toIndentedString(grantType)).append("\n"); sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -213,12 +258,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("scope"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GrabOauthRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GrabOauthRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GrabOauthRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -226,14 +271,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GrabOauthRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GrabOauthRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GrabOauthRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -270,6 +307,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GrabOauthRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -277,29 +336,50 @@ public void write(JsonWriter out, GrabOauthRequest value) throws IOException { public GrabOauthRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GrabOauthRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GrabOauthRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of GrabOauthRequest - * @throws IOException if the JSON string is invalid with respect to GrabOauthRequest - */ + /** + * Create an instance of GrabOauthRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of GrabOauthRequest + * @throws IOException if the JSON string is invalid with respect to GrabOauthRequest + */ public static GrabOauthRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GrabOauthRequest.class); } - /** - * Convert an instance of GrabOauthRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GrabOauthRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/GrabOauthResponse.java b/src/main/java/com/grabfood/client/model/GrabOauthResponse.java index 930423d..379e821 100644 --- a/src/main/java/com/grabfood/client/model/GrabOauthResponse.java +++ b/src/main/java/com/grabfood/client/model/GrabOauthResponse.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * GrabOauthResponse */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class GrabOauthResponse { public static final String SERIALIZED_NAME_ACCESS_TOKEN = "access_token"; @SerializedName(SERIALIZED_NAME_ACCESS_TOKEN) @@ -74,10 +73,10 @@ public GrabOauthResponse accessToken(String accessToken) { return this; } - /** + /** * The OAuth 2.0 access token issued by the partner. * @return accessToken - **/ + */ @javax.annotation.Nullable public String getAccessToken() { return accessToken; @@ -93,10 +92,10 @@ public GrabOauthResponse tokenType(String tokenType) { return this; } - /** + /** * The type of token issued which is case insensitive. * @return tokenType - **/ + */ @javax.annotation.Nullable public String getTokenType() { return tokenType; @@ -112,10 +111,10 @@ public GrabOauthResponse expiresIn(Integer expiresIn) { return this; } - /** + /** * The access token lifespan in seconds. The token is reused till it expires - default is 604799 (7 days). * @return expiresIn - **/ + */ @javax.annotation.Nullable public Integer getExpiresIn() { return expiresIn; @@ -125,6 +124,50 @@ public void setExpiresIn(Integer expiresIn) { this.expiresIn = expiresIn; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GrabOauthResponse instance itself + */ + public GrabOauthResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -138,12 +181,13 @@ public boolean equals(Object o) { GrabOauthResponse grabOauthResponse = (GrabOauthResponse) o; return Objects.equals(this.accessToken, grabOauthResponse.accessToken) && Objects.equals(this.tokenType, grabOauthResponse.tokenType) && - Objects.equals(this.expiresIn, grabOauthResponse.expiresIn); + Objects.equals(this.expiresIn, grabOauthResponse.expiresIn)&& + Objects.equals(this.additionalProperties, grabOauthResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(accessToken, tokenType, expiresIn); + return Objects.hash(accessToken, tokenType, expiresIn, additionalProperties); } @Override @@ -153,6 +197,7 @@ public String toString() { sb.append(" accessToken: ").append(toIndentedString(accessToken)).append("\n"); sb.append(" tokenType: ").append(toIndentedString(tokenType)).append("\n"); sb.append(" expiresIn: ").append(toIndentedString(expiresIn)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -183,26 +228,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to GrabOauthResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GrabOauthResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GrabOauthResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in GrabOauthResponse is not found in the empty JSON string", GrabOauthResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GrabOauthResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GrabOauthResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("access_token") != null && !jsonObj.get("access_token").isJsonNull()) && !jsonObj.get("access_token").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `access_token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("access_token").toString())); @@ -227,6 +264,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GrabOauthResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -234,29 +293,50 @@ public void write(JsonWriter out, GrabOauthResponse value) throws IOException { public GrabOauthResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GrabOauthResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of GrabOauthResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of GrabOauthResponse - * @throws IOException if the JSON string is invalid with respect to GrabOauthResponse - */ + /** + * Create an instance of GrabOauthResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GrabOauthResponse + * @throws IOException if the JSON string is invalid with respect to GrabOauthResponse + */ public static GrabOauthResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GrabOauthResponse.class); } - /** - * Convert an instance of GrabOauthResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of GrabOauthResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/ListCampaignResponse.java b/src/main/java/com/grabfood/client/model/ListCampaignResponse.java index 85baf6b..90adb4a 100644 --- a/src/main/java/com/grabfood/client/model/ListCampaignResponse.java +++ b/src/main/java/com/grabfood/client/model/ListCampaignResponse.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.Campaigns; +import com.grabfood.client.model.Campaign; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,25 +54,25 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class ListCampaignResponse { public static final String SERIALIZED_NAME_ONGOING = "ongoing"; @SerializedName(SERIALIZED_NAME_ONGOING) - private List ongoing = new ArrayList<>(); + private List ongoing = new ArrayList<>(); public static final String SERIALIZED_NAME_UPCOMING = "upcoming"; @SerializedName(SERIALIZED_NAME_UPCOMING) - private List upcoming = new ArrayList<>(); + private List upcoming = new ArrayList<>(); public ListCampaignResponse() { } - public ListCampaignResponse ongoing(List ongoing) { + public ListCampaignResponse ongoing(List ongoing) { this.ongoing = ongoing; return this; } - public ListCampaignResponse addOngoingItem(Campaigns ongoingItem) { + public ListCampaignResponse addOngoingItem(Campaign ongoingItem) { if (this.ongoing == null) { this.ongoing = new ArrayList<>(); } @@ -81,26 +80,26 @@ public ListCampaignResponse addOngoingItem(Campaigns ongoingItem) { return this; } - /** + /** * Get ongoing * @return ongoing - **/ + */ @javax.annotation.Nullable - public List getOngoing() { + public List getOngoing() { return ongoing; } - public void setOngoing(List ongoing) { + public void setOngoing(List ongoing) { this.ongoing = ongoing; } - public ListCampaignResponse upcoming(List upcoming) { + public ListCampaignResponse upcoming(List upcoming) { this.upcoming = upcoming; return this; } - public ListCampaignResponse addUpcomingItem(Campaigns upcomingItem) { + public ListCampaignResponse addUpcomingItem(Campaign upcomingItem) { if (this.upcoming == null) { this.upcoming = new ArrayList<>(); } @@ -108,19 +107,63 @@ public ListCampaignResponse addUpcomingItem(Campaigns upcomingItem) { return this; } - /** + /** * Get upcoming * @return upcoming - **/ + */ @javax.annotation.Nullable - public List getUpcoming() { + public List getUpcoming() { return upcoming; } - public void setUpcoming(List upcoming) { + public void setUpcoming(List upcoming) { this.upcoming = upcoming; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListCampaignResponse instance itself + */ + public ListCampaignResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -133,12 +176,13 @@ public boolean equals(Object o) { } ListCampaignResponse listCampaignResponse = (ListCampaignResponse) o; return Objects.equals(this.ongoing, listCampaignResponse.ongoing) && - Objects.equals(this.upcoming, listCampaignResponse.upcoming); + Objects.equals(this.upcoming, listCampaignResponse.upcoming)&& + Objects.equals(this.additionalProperties, listCampaignResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(ongoing, upcoming); + return Objects.hash(ongoing, upcoming, additionalProperties); } @Override @@ -147,6 +191,7 @@ public String toString() { sb.append("class ListCampaignResponse {\n"); sb.append(" ongoing: ").append(toIndentedString(ongoing)).append("\n"); sb.append(" upcoming: ").append(toIndentedString(upcoming)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -176,26 +221,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ListCampaignResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ListCampaignResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ListCampaignResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in ListCampaignResponse is not found in the empty JSON string", ListCampaignResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListCampaignResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ListCampaignResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("ongoing") != null && !jsonObj.get("ongoing").isJsonNull()) { JsonArray jsonArrayongoing = jsonObj.getAsJsonArray("ongoing"); @@ -207,7 +244,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `ongoing` (array) for (int i = 0; i < jsonArrayongoing.size(); i++) { - Campaigns.validateJsonElement(jsonArrayongoing.get(i)); + Campaign.validateJsonElement(jsonArrayongoing.get(i)); }; } } @@ -221,7 +258,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `upcoming` (array) for (int i = 0; i < jsonArrayupcoming.size(); i++) { - Campaigns.validateJsonElement(jsonArrayupcoming.get(i)); + Campaign.validateJsonElement(jsonArrayupcoming.get(i)); }; } } @@ -242,6 +279,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListCampaignResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -249,29 +308,50 @@ public void write(JsonWriter out, ListCampaignResponse value) throws IOException public ListCampaignResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListCampaignResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of ListCampaignResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of ListCampaignResponse - * @throws IOException if the JSON string is invalid with respect to ListCampaignResponse - */ + /** + * Create an instance of ListCampaignResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListCampaignResponse + * @throws IOException if the JSON string is invalid with respect to ListCampaignResponse + */ public static ListCampaignResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, ListCampaignResponse.class); } - /** - * Convert an instance of ListCampaignResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of ListCampaignResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/ListOrdersResponse.java b/src/main/java/com/grabfood/client/model/ListOrdersResponse.java index 8fcdbac..18a5e9e 100644 --- a/src/main/java/com/grabfood/client/model/ListOrdersResponse.java +++ b/src/main/java/com/grabfood/client/model/ListOrdersResponse.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.Orders; +import com.grabfood.client.model.Order; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class ListOrdersResponse { public static final String SERIALIZED_NAME_MORE = "more"; @SerializedName(SERIALIZED_NAME_MORE) @@ -63,7 +62,7 @@ public class ListOrdersResponse { public static final String SERIALIZED_NAME_ORDERS = "orders"; @SerializedName(SERIALIZED_NAME_ORDERS) - private List orders = new ArrayList<>(); + private List orders = new ArrayList<>(); public ListOrdersResponse() { } @@ -73,10 +72,10 @@ public ListOrdersResponse more(Boolean more) { return this; } - /** + /** * The boolean value to indicate if there is more order data. If `true`, you can continue requesting with page+1. * @return more - **/ + */ @javax.annotation.Nullable public Boolean getMore() { return more; @@ -87,12 +86,12 @@ public void setMore(Boolean more) { } - public ListOrdersResponse orders(List orders) { + public ListOrdersResponse orders(List orders) { this.orders = orders; return this; } - public ListOrdersResponse addOrdersItem(Orders ordersItem) { + public ListOrdersResponse addOrdersItem(Order ordersItem) { if (this.orders == null) { this.orders = new ArrayList<>(); } @@ -100,19 +99,63 @@ public ListOrdersResponse addOrdersItem(Orders ordersItem) { return this; } - /** + /** * Get orders * @return orders - **/ + */ @javax.annotation.Nullable - public List getOrders() { + public List getOrders() { return orders; } - public void setOrders(List orders) { + public void setOrders(List orders) { this.orders = orders; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListOrdersResponse instance itself + */ + public ListOrdersResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -125,12 +168,13 @@ public boolean equals(Object o) { } ListOrdersResponse listOrdersResponse = (ListOrdersResponse) o; return Objects.equals(this.more, listOrdersResponse.more) && - Objects.equals(this.orders, listOrdersResponse.orders); + Objects.equals(this.orders, listOrdersResponse.orders)&& + Objects.equals(this.additionalProperties, listOrdersResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(more, orders); + return Objects.hash(more, orders, additionalProperties); } @Override @@ -139,6 +183,7 @@ public String toString() { sb.append("class ListOrdersResponse {\n"); sb.append(" more: ").append(toIndentedString(more)).append("\n"); sb.append(" orders: ").append(toIndentedString(orders)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,26 +213,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ListOrdersResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ListOrdersResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ListOrdersResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in ListOrdersResponse is not found in the empty JSON string", ListOrdersResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListOrdersResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ListOrdersResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("orders") != null && !jsonObj.get("orders").isJsonNull()) { JsonArray jsonArrayorders = jsonObj.getAsJsonArray("orders"); @@ -199,7 +236,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `orders` (array) for (int i = 0; i < jsonArrayorders.size(); i++) { - Orders.validateJsonElement(jsonArrayorders.get(i)); + Order.validateJsonElement(jsonArrayorders.get(i)); }; } } @@ -220,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListOrdersResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -227,29 +286,50 @@ public void write(JsonWriter out, ListOrdersResponse value) throws IOException { public ListOrdersResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListOrdersResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of ListOrdersResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of ListOrdersResponse - * @throws IOException if the JSON string is invalid with respect to ListOrdersResponse - */ + /** + * Create an instance of ListOrdersResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListOrdersResponse + * @throws IOException if the JSON string is invalid with respect to ListOrdersResponse + */ public static ListOrdersResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, ListOrdersResponse.class); } - /** - * Convert an instance of ListOrdersResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of ListOrdersResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/MarkOrderFail.java b/src/main/java/com/grabfood/client/model/MarkOrderFail.java deleted file mode 100644 index 6ef9c5c..0000000 --- a/src/main/java/com/grabfood/client/model/MarkOrderFail.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class MarkOrderFail { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public MarkOrderFail() { - } - - public MarkOrderFail target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public MarkOrderFail reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public MarkOrderFail message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MarkOrderFail markOrderFail = (MarkOrderFail) o; - return Objects.equals(this.target, markOrderFail.target) && - Objects.equals(this.reason, markOrderFail.reason) && - Objects.equals(this.message, markOrderFail.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MarkOrderFail {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MarkOrderFail - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!MarkOrderFail.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in MarkOrderFail is not found in the empty JSON string", MarkOrderFail.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MarkOrderFail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MarkOrderFail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!MarkOrderFail.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'MarkOrderFail' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MarkOrderFail.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, MarkOrderFail value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public MarkOrderFail read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of MarkOrderFail given an JSON string - * - * @param jsonString JSON string - * @return An instance of MarkOrderFail - * @throws IOException if the JSON string is invalid with respect to MarkOrderFail - */ - public static MarkOrderFail fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MarkOrderFail.class); - } - - /** - * Convert an instance of MarkOrderFail to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/MarkOrderRequest.java b/src/main/java/com/grabfood/client/model/MarkOrderRequest.java index 3b6d90d..8412d1b 100644 --- a/src/main/java/com/grabfood/client/model/MarkOrderRequest.java +++ b/src/main/java/com/grabfood/client/model/MarkOrderRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request marks an order as ready for delivery or completed on GrabFood. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class MarkOrderRequest { public static final String SERIALIZED_NAME_ORDER_I_D = "orderID"; @SerializedName(SERIALIZED_NAME_ORDER_I_D) @@ -65,7 +64,9 @@ public class MarkOrderRequest { public enum MarkStatusEnum { NUMBER_1(1), - NUMBER_2(2); + NUMBER_2(2), + + NUMBER_unknown_default_open_api(11184809); private Integer value; @@ -88,7 +89,7 @@ public static MarkStatusEnum fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return NUMBER_unknown_default_open_api; } public static class Adapter extends TypeAdapter { @@ -122,10 +123,10 @@ public MarkOrderRequest orderID(String orderID) { return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -141,10 +142,10 @@ public MarkOrderRequest markStatus(MarkStatusEnum markStatus) { return this; } - /** + /** * The status to be marked accordingly. * `1` - mark order as ready * `2` - mark order as completed and only applicable to **dine-in** orders * @return markStatus - **/ + */ @javax.annotation.Nonnull public MarkStatusEnum getMarkStatus() { return markStatus; @@ -154,6 +155,50 @@ public void setMarkStatus(MarkStatusEnum markStatus) { this.markStatus = markStatus; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MarkOrderRequest instance itself + */ + public MarkOrderRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -166,12 +211,13 @@ public boolean equals(Object o) { } MarkOrderRequest markOrderRequest = (MarkOrderRequest) o; return Objects.equals(this.orderID, markOrderRequest.orderID) && - Objects.equals(this.markStatus, markOrderRequest.markStatus); + Objects.equals(this.markStatus, markOrderRequest.markStatus)&& + Objects.equals(this.additionalProperties, markOrderRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(orderID, markStatus); + return Objects.hash(orderID, markStatus, additionalProperties); } @Override @@ -180,6 +226,7 @@ public String toString() { sb.append("class MarkOrderRequest {\n"); sb.append(" orderID: ").append(toIndentedString(orderID)).append("\n"); sb.append(" markStatus: ").append(toIndentedString(markStatus)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -211,12 +258,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("markStatus"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MarkOrderRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MarkOrderRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MarkOrderRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -224,14 +271,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MarkOrderRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MarkOrderRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MarkOrderRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -261,6 +300,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MarkOrderRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -268,29 +329,50 @@ public void write(JsonWriter out, MarkOrderRequest value) throws IOException { public MarkOrderRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MarkOrderRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of MarkOrderRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of MarkOrderRequest - * @throws IOException if the JSON string is invalid with respect to MarkOrderRequest - */ + /** + * Create an instance of MarkOrderRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of MarkOrderRequest + * @throws IOException if the JSON string is invalid with respect to MarkOrderRequest + */ public static MarkOrderRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, MarkOrderRequest.class); } - /** - * Convert an instance of MarkOrderRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MarkOrderRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/CategoriesInner.java b/src/main/java/com/grabfood/client/model/MenuCategory.java similarity index 57% rename from src/main/java/com/grabfood/client/model/CategoriesInner.java rename to src/main/java/com/grabfood/client/model/MenuCategory.java index 777d98e..fea12e0 100644 --- a/src/main/java/com/grabfood/client/model/CategoriesInner.java +++ b/src/main/java/com/grabfood/client/model/MenuCategory.java @@ -22,12 +22,13 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.CategoriesInnerNameTranslation; -import com.grabfood.client.model.MenuItemsInner; +import com.grabfood.client.model.MenuItem; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -44,7 +45,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,10 +54,10 @@ import com.grabfood.client.JSON; /** - * CategoriesInner + * MenuCategory */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class CategoriesInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuCategory { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -68,7 +68,7 @@ public class CategoriesInner { public static final String SERIALIZED_NAME_NAME_TRANSLATION = "nameTranslation"; @SerializedName(SERIALIZED_NAME_NAME_TRANSLATION) - private CategoriesInnerNameTranslation nameTranslation; + private Map nameTranslation = new HashMap<>(); /** * The status for the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). @@ -79,7 +79,9 @@ public enum AvailableStatusEnum { UNAVAILABLE("UNAVAILABLE"), - HIDE("HIDE"); + HIDE("HIDE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -102,7 +104,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -134,20 +136,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_ITEMS = "items"; @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); + private List items = new ArrayList<>(); - public CategoriesInner() { + public MenuCategory() { } - public CategoriesInner id(String id) { + public MenuCategory id(String id) { this.id = id; return this; } - /** + /** * The category's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -158,15 +160,15 @@ public void setId(String id) { } - public CategoriesInner name(String name) { + public MenuCategory name(String name) { this.name = name; return this; } - /** + /** * The name of the category. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -177,34 +179,42 @@ public void setName(String name) { } - public CategoriesInner nameTranslation(CategoriesInnerNameTranslation nameTranslation) { + public MenuCategory nameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; return this; } - /** - * Get nameTranslation + public MenuCategory putNameTranslationItem(String key, String nameTranslationItem) { + if (this.nameTranslation == null) { + this.nameTranslation = new HashMap<>(); + } + this.nameTranslation.put(key, nameTranslationItem); + return this; + } + + /** + * Translation of the category name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). * @return nameTranslation - **/ + */ @javax.annotation.Nullable - public CategoriesInnerNameTranslation getNameTranslation() { + public Map getNameTranslation() { return nameTranslation; } - public void setNameTranslation(CategoriesInnerNameTranslation nameTranslation) { + public void setNameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; } - public CategoriesInner availableStatus(AvailableStatusEnum availableStatus) { + public MenuCategory availableStatus(AvailableStatusEnum availableStatus) { this.availableStatus = availableStatus; return this; } - /** + /** * The status for the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). * @return availableStatus - **/ + */ @javax.annotation.Nonnull public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -215,15 +225,15 @@ public void setAvailableStatus(AvailableStatusEnum availableStatus) { } - public CategoriesInner sellingTimeID(String sellingTimeID) { + public MenuCategory sellingTimeID(String sellingTimeID) { this.sellingTimeID = sellingTimeID; return this; } - /** + /** * The selling time's ID for the category. All items within the category will apply the same selling time unless there is another selling time specified for the item. * @return sellingTimeID - **/ + */ @javax.annotation.Nonnull public String getSellingTimeID() { return sellingTimeID; @@ -234,12 +244,12 @@ public void setSellingTimeID(String sellingTimeID) { } - public CategoriesInner items(List items) { + public MenuCategory items(List items) { this.items = items; return this; } - public CategoriesInner addItemsItem(MenuItemsInner itemsItem) { + public MenuCategory addItemsItem(MenuItem itemsItem) { if (this.items == null) { this.items = new ArrayList<>(); } @@ -247,19 +257,63 @@ public CategoriesInner addItemsItem(MenuItemsInner itemsItem) { return this; } - /** + /** * An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. * @return items - **/ + */ @javax.annotation.Nonnull - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuCategory instance itself + */ + public MenuCategory putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -270,30 +324,32 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - CategoriesInner categoriesInner = (CategoriesInner) o; - return Objects.equals(this.id, categoriesInner.id) && - Objects.equals(this.name, categoriesInner.name) && - Objects.equals(this.nameTranslation, categoriesInner.nameTranslation) && - Objects.equals(this.availableStatus, categoriesInner.availableStatus) && - Objects.equals(this.sellingTimeID, categoriesInner.sellingTimeID) && - Objects.equals(this.items, categoriesInner.items); + MenuCategory menuCategory = (MenuCategory) o; + return Objects.equals(this.id, menuCategory.id) && + Objects.equals(this.name, menuCategory.name) && + Objects.equals(this.nameTranslation, menuCategory.nameTranslation) && + Objects.equals(this.availableStatus, menuCategory.availableStatus) && + Objects.equals(this.sellingTimeID, menuCategory.sellingTimeID) && + Objects.equals(this.items, menuCategory.items)&& + Objects.equals(this.additionalProperties, menuCategory.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, nameTranslation, availableStatus, sellingTimeID, items); + return Objects.hash(id, name, nameTranslation, availableStatus, sellingTimeID, items, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class CategoriesInner {\n"); + sb.append("class MenuCategory {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" nameTranslation: ").append(toIndentedString(nameTranslation)).append("\n"); sb.append(" availableStatus: ").append(toIndentedString(availableStatus)).append("\n"); sb.append(" sellingTimeID: ").append(toIndentedString(sellingTimeID)).append("\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -332,29 +388,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("items"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to CategoriesInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuCategory + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!CategoriesInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in CategoriesInner is not found in the empty JSON string", CategoriesInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CategoriesInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CategoriesInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!MenuCategory.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuCategory is not found in the empty JSON string", MenuCategory.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : CategoriesInner.openapiRequiredFields) { + for (String requiredField : MenuCategory.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -366,10 +414,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // validate the optional field `nameTranslation` - if (jsonObj.get("nameTranslation") != null && !jsonObj.get("nameTranslation").isJsonNull()) { - CategoriesInnerNameTranslation.validateJsonElement(jsonObj.get("nameTranslation")); - } if (!jsonObj.get("availableStatus").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `availableStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("availableStatus").toString())); } @@ -386,7 +430,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); // validate the required field `items` (array) for (int i = 0; i < jsonArrayitems.size(); i++) { - MenuItemsInner.validateJsonElement(jsonArrayitems.get(i)); + MenuItem.validateJsonElement(jsonArrayitems.get(i)); }; } @@ -394,47 +438,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!CategoriesInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'CategoriesInner' and its subtypes + if (!MenuCategory.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuCategory' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(CategoriesInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuCategory.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, CategoriesInner value) throws IOException { + public void write(JsonWriter out, MenuCategory value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public CategoriesInner read(JsonReader in) throws IOException { + public MenuCategory read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuCategory instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of CategoriesInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of CategoriesInner - * @throws IOException if the JSON string is invalid with respect to CategoriesInner - */ - public static CategoriesInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, CategoriesInner.class); + /** + * Create an instance of MenuCategory given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuCategory + * @throws IOException if the JSON string is invalid with respect to MenuCategory + */ + public static MenuCategory fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuCategory.class); } - /** - * Convert an instance of CategoriesInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuCategory to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/BatchUpdateMenuItemMenuEntitiesInner.java b/src/main/java/com/grabfood/client/model/MenuEntity.java similarity index 60% rename from src/main/java/com/grabfood/client/model/BatchUpdateMenuItemMenuEntitiesInner.java rename to src/main/java/com/grabfood/client/model/MenuEntity.java index dd77be6..5838fd6 100644 --- a/src/main/java/com/grabfood/client/model/BatchUpdateMenuItemMenuEntitiesInner.java +++ b/src/main/java/com/grabfood/client/model/MenuEntity.java @@ -22,8 +22,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.UpdateMenuItemAdvancedPricingsInner; -import com.grabfood.client.model.UpdateMenuItemPurchasabilitiesInner; +import com.grabfood.client.model.UpdateAdvancedPricing; +import com.grabfood.client.model.UpdatePurchasability; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,10 +53,10 @@ import com.grabfood.client.JSON; /** - * BatchUpdateMenuItemMenuEntitiesInner + * MenuEntity */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class BatchUpdateMenuItemMenuEntitiesInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuEntity { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -75,7 +74,9 @@ public enum AvailableStatusEnum { UNAVAILABLE("UNAVAILABLE"), - UNAVAILABLETODAY("UNAVAILABLETODAY"); + UNAVAILABLETODAY("UNAVAILABLETODAY"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -98,7 +99,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -130,24 +131,24 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_ADVANCED_PRICINGS = "advancedPricings"; @SerializedName(SERIALIZED_NAME_ADVANCED_PRICINGS) - private List advancedPricings = new ArrayList<>(); + private List advancedPricings = new ArrayList<>(); public static final String SERIALIZED_NAME_PURCHASABILITIES = "purchasabilities"; @SerializedName(SERIALIZED_NAME_PURCHASABILITIES) - private List purchasabilities = new ArrayList<>(); + private List purchasabilities = new ArrayList<>(); - public BatchUpdateMenuItemMenuEntitiesInner() { + public MenuEntity() { } - public BatchUpdateMenuItemMenuEntitiesInner id(String id) { + public MenuEntity id(String id) { this.id = id; return this; } - /** + /** * The record's ID on the partner system. For example, the item id in case type is ITEM, modifier id is MODIFIER. * @return id - **/ + */ @javax.annotation.Nullable public String getId() { return id; @@ -158,15 +159,15 @@ public void setId(String id) { } - public BatchUpdateMenuItemMenuEntitiesInner price(Integer price) { + public MenuEntity price(Integer price) { this.price = price; return this; } - /** + /** * The record's price in minor unit format. * @return price - **/ + */ @javax.annotation.Nullable public Integer getPrice() { return price; @@ -177,15 +178,15 @@ public void setPrice(Integer price) { } - public BatchUpdateMenuItemMenuEntitiesInner availableStatus(AvailableStatusEnum availableStatus) { + public MenuEntity availableStatus(AvailableStatusEnum availableStatus) { this.availableStatus = availableStatus; return this; } - /** + /** * The record's availableStatus. Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. * @return availableStatus - **/ + */ @javax.annotation.Nullable public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -196,15 +197,15 @@ public void setAvailableStatus(AvailableStatusEnum availableStatus) { } - public BatchUpdateMenuItemMenuEntitiesInner maxStock(Integer maxStock) { + public MenuEntity maxStock(Integer maxStock) { this.maxStock = maxStock; return this; } - /** + /** * Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. * @return maxStock - **/ + */ @javax.annotation.Nullable public Integer getMaxStock() { return maxStock; @@ -215,12 +216,12 @@ public void setMaxStock(Integer maxStock) { } - public BatchUpdateMenuItemMenuEntitiesInner advancedPricings(List advancedPricings) { + public MenuEntity advancedPricings(List advancedPricings) { this.advancedPricings = advancedPricings; return this; } - public BatchUpdateMenuItemMenuEntitiesInner addAdvancedPricingsItem(UpdateMenuItemAdvancedPricingsInner advancedPricingsItem) { + public MenuEntity addAdvancedPricingsItem(UpdateAdvancedPricing advancedPricingsItem) { if (this.advancedPricings == null) { this.advancedPricings = new ArrayList<>(); } @@ -228,26 +229,26 @@ public BatchUpdateMenuItemMenuEntitiesInner addAdvancedPricingsItem(UpdateMenuIt return this; } - /** + /** * Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. * @return advancedPricings - **/ + */ @javax.annotation.Nullable - public List getAdvancedPricings() { + public List getAdvancedPricings() { return advancedPricings; } - public void setAdvancedPricings(List advancedPricings) { + public void setAdvancedPricings(List advancedPricings) { this.advancedPricings = advancedPricings; } - public BatchUpdateMenuItemMenuEntitiesInner purchasabilities(List purchasabilities) { + public MenuEntity purchasabilities(List purchasabilities) { this.purchasabilities = purchasabilities; return this; } - public BatchUpdateMenuItemMenuEntitiesInner addPurchasabilitiesItem(UpdateMenuItemPurchasabilitiesInner purchasabilitiesItem) { + public MenuEntity addPurchasabilitiesItem(UpdatePurchasability purchasabilitiesItem) { if (this.purchasabilities == null) { this.purchasabilities = new ArrayList<>(); } @@ -255,19 +256,63 @@ public BatchUpdateMenuItemMenuEntitiesInner addPurchasabilitiesItem(UpdateMenuIt return this; } - /** + /** * Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. * @return purchasabilities - **/ + */ @javax.annotation.Nullable - public List getPurchasabilities() { + public List getPurchasabilities() { return purchasabilities; } - public void setPurchasabilities(List purchasabilities) { + public void setPurchasabilities(List purchasabilities) { this.purchasabilities = purchasabilities; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuEntity instance itself + */ + public MenuEntity putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -278,30 +323,32 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - BatchUpdateMenuItemMenuEntitiesInner batchUpdateMenuItemMenuEntitiesInner = (BatchUpdateMenuItemMenuEntitiesInner) o; - return Objects.equals(this.id, batchUpdateMenuItemMenuEntitiesInner.id) && - Objects.equals(this.price, batchUpdateMenuItemMenuEntitiesInner.price) && - Objects.equals(this.availableStatus, batchUpdateMenuItemMenuEntitiesInner.availableStatus) && - Objects.equals(this.maxStock, batchUpdateMenuItemMenuEntitiesInner.maxStock) && - Objects.equals(this.advancedPricings, batchUpdateMenuItemMenuEntitiesInner.advancedPricings) && - Objects.equals(this.purchasabilities, batchUpdateMenuItemMenuEntitiesInner.purchasabilities); + MenuEntity menuEntity = (MenuEntity) o; + return Objects.equals(this.id, menuEntity.id) && + Objects.equals(this.price, menuEntity.price) && + Objects.equals(this.availableStatus, menuEntity.availableStatus) && + Objects.equals(this.maxStock, menuEntity.maxStock) && + Objects.equals(this.advancedPricings, menuEntity.advancedPricings) && + Objects.equals(this.purchasabilities, menuEntity.purchasabilities)&& + Objects.equals(this.additionalProperties, menuEntity.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, price, availableStatus, maxStock, advancedPricings, purchasabilities); + return Objects.hash(id, price, availableStatus, maxStock, advancedPricings, purchasabilities, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class BatchUpdateMenuItemMenuEntitiesInner {\n"); + sb.append("class MenuEntity {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" price: ").append(toIndentedString(price)).append("\n"); sb.append(" availableStatus: ").append(toIndentedString(availableStatus)).append("\n"); sb.append(" maxStock: ").append(toIndentedString(maxStock)).append("\n"); sb.append(" advancedPricings: ").append(toIndentedString(advancedPricings)).append("\n"); sb.append(" purchasabilities: ").append(toIndentedString(purchasabilities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -335,24 +382,16 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to BatchUpdateMenuItemMenuEntitiesInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuEntity + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!BatchUpdateMenuItemMenuEntitiesInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in BatchUpdateMenuItemMenuEntitiesInner is not found in the empty JSON string", BatchUpdateMenuItemMenuEntitiesInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BatchUpdateMenuItemMenuEntitiesInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BatchUpdateMenuItemMenuEntitiesInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!MenuEntity.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuEntity is not found in the empty JSON string", MenuEntity.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -376,7 +415,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `advancedPricings` (array) for (int i = 0; i < jsonArrayadvancedPricings.size(); i++) { - UpdateMenuItemAdvancedPricingsInner.validateJsonElement(jsonArrayadvancedPricings.get(i)); + UpdateAdvancedPricing.validateJsonElement(jsonArrayadvancedPricings.get(i)); }; } } @@ -390,7 +429,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `purchasabilities` (array) for (int i = 0; i < jsonArraypurchasabilities.size(); i++) { - UpdateMenuItemPurchasabilitiesInner.validateJsonElement(jsonArraypurchasabilities.get(i)); + UpdatePurchasability.validateJsonElement(jsonArraypurchasabilities.get(i)); }; } } @@ -400,47 +439,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!BatchUpdateMenuItemMenuEntitiesInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'BatchUpdateMenuItemMenuEntitiesInner' and its subtypes + if (!MenuEntity.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuEntity' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(BatchUpdateMenuItemMenuEntitiesInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuEntity.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, BatchUpdateMenuItemMenuEntitiesInner value) throws IOException { + public void write(JsonWriter out, MenuEntity value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public BatchUpdateMenuItemMenuEntitiesInner read(JsonReader in) throws IOException { + public MenuEntity read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuEntity instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of BatchUpdateMenuItemMenuEntitiesInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of BatchUpdateMenuItemMenuEntitiesInner - * @throws IOException if the JSON string is invalid with respect to BatchUpdateMenuItemMenuEntitiesInner - */ - public static BatchUpdateMenuItemMenuEntitiesInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, BatchUpdateMenuItemMenuEntitiesInner.class); + /** + * Create an instance of MenuEntity given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuEntity + * @throws IOException if the JSON string is invalid with respect to MenuEntity + */ + public static MenuEntity fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuEntity.class); } - /** - * Convert an instance of BatchUpdateMenuItemMenuEntitiesInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuEntity to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/MenuEntityError.java b/src/main/java/com/grabfood/client/model/MenuEntityError.java new file mode 100644 index 0000000..00099c7 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/MenuEntityError.java @@ -0,0 +1,318 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * MenuEntityError + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuEntityError { + public static final String SERIALIZED_NAME_ENTITY_I_D = "entityID"; + @SerializedName(SERIALIZED_NAME_ENTITY_I_D) + private String entityID; + + public static final String SERIALIZED_NAME_ERR_MSG = "errMsg"; + @SerializedName(SERIALIZED_NAME_ERR_MSG) + private String errMsg; + + public MenuEntityError() { + } + + public MenuEntityError entityID(String entityID) { + this.entityID = entityID; + return this; + } + + /** + * The itemID. + * @return entityID + */ + @javax.annotation.Nullable + public String getEntityID() { + return entityID; + } + + public void setEntityID(String entityID) { + this.entityID = entityID; + } + + + public MenuEntityError errMsg(String errMsg) { + this.errMsg = errMsg; + return this; + } + + /** + * The error message. + * @return errMsg + */ + @javax.annotation.Nullable + public String getErrMsg() { + return errMsg; + } + + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuEntityError instance itself + */ + public MenuEntityError putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MenuEntityError menuEntityError = (MenuEntityError) o; + return Objects.equals(this.entityID, menuEntityError.entityID) && + Objects.equals(this.errMsg, menuEntityError.errMsg)&& + Objects.equals(this.additionalProperties, menuEntityError.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(entityID, errMsg, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MenuEntityError {\n"); + sb.append(" entityID: ").append(toIndentedString(entityID)).append("\n"); + sb.append(" errMsg: ").append(toIndentedString(errMsg)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entityID"); + openapiFields.add("errMsg"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuEntityError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MenuEntityError.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuEntityError is not found in the empty JSON string", MenuEntityError.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("entityID") != null && !jsonObj.get("entityID").isJsonNull()) && !jsonObj.get("entityID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `entityID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("entityID").toString())); + } + if ((jsonObj.get("errMsg") != null && !jsonObj.get("errMsg").isJsonNull()) && !jsonObj.get("errMsg").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `errMsg` to be a primitive type in the JSON string but got `%s`", jsonObj.get("errMsg").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MenuEntityError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuEntityError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuEntityError.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MenuEntityError value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MenuEntityError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuEntityError instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MenuEntityError given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuEntityError + * @throws IOException if the JSON string is invalid with respect to MenuEntityError + */ + public static MenuEntityError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuEntityError.class); + } + + /** + * Convert an instance of MenuEntityError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/MenuItemsInner.java b/src/main/java/com/grabfood/client/model/MenuItem.java similarity index 68% rename from src/main/java/com/grabfood/client/model/MenuItemsInner.java rename to src/main/java/com/grabfood/client/model/MenuItem.java index b780091..2e3160c 100644 --- a/src/main/java/com/grabfood/client/model/MenuItemsInner.java +++ b/src/main/java/com/grabfood/client/model/MenuItem.java @@ -23,14 +23,14 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.grabfood.client.model.AdvancedPricing; -import com.grabfood.client.model.MenuItemsInnerDescriptionTranslation; -import com.grabfood.client.model.ModifierGroupsInner; -import com.grabfood.client.model.OldMenuSectionCategoryItemsInnerNameTranslation; +import com.grabfood.client.model.ModifierGroup; import com.grabfood.client.model.Purchasability; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -47,7 +47,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -57,10 +56,10 @@ import com.grabfood.client.JSON; /** - * MenuItemsInner + * MenuItem */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class MenuItemsInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuItem { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -71,7 +70,7 @@ public class MenuItemsInner { public static final String SERIALIZED_NAME_NAME_TRANSLATION = "nameTranslation"; @SerializedName(SERIALIZED_NAME_NAME_TRANSLATION) - private OldMenuSectionCategoryItemsInnerNameTranslation nameTranslation; + private Map nameTranslation = new HashMap<>(); /** * The status for the item that is in the category. Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. @@ -84,7 +83,9 @@ public enum AvailableStatusEnum { HIDE("HIDE"), - UNAVAILABLETODAY("UNAVAILABLETODAY"); + UNAVAILABLETODAY("UNAVAILABLETODAY"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -107,7 +108,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -139,7 +140,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_DESCRIPTION_TRANSLATION = "descriptionTranslation"; @SerializedName(SERIALIZED_NAME_DESCRIPTION_TRANSLATION) - private MenuItemsInnerDescriptionTranslation descriptionTranslation; + private Map descriptionTranslation = new HashMap<>(); public static final String SERIALIZED_NAME_PRICE = "price"; @SerializedName(SERIALIZED_NAME_PRICE) @@ -156,7 +157,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public enum SpecialTypeEnum { ALCOHOL("alcohol"), - EMPTY(""); + EMPTY(""), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -179,7 +182,7 @@ public static SpecialTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -231,20 +234,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_MODIFIER_GROUPS = "modifierGroups"; @SerializedName(SERIALIZED_NAME_MODIFIER_GROUPS) - private List modifierGroups = new ArrayList<>(); + private List modifierGroups = new ArrayList<>(); - public MenuItemsInner() { + public MenuItem() { } - public MenuItemsInner id(String id) { + public MenuItem id(String id) { this.id = id; return this; } - /** + /** * The item's ID in the partner system. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -255,15 +258,15 @@ public void setId(String id) { } - public MenuItemsInner name(String name) { + public MenuItem name(String name) { this.name = name; return this; } - /** + /** * The name of the item. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -274,34 +277,42 @@ public void setName(String name) { } - public MenuItemsInner nameTranslation(OldMenuSectionCategoryItemsInnerNameTranslation nameTranslation) { + public MenuItem nameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; return this; } - /** - * Get nameTranslation + public MenuItem putNameTranslationItem(String key, String nameTranslationItem) { + if (this.nameTranslation == null) { + this.nameTranslation = new HashMap<>(); + } + this.nameTranslation.put(key, nameTranslationItem); + return this; + } + + /** + * Translation of the item name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). * @return nameTranslation - **/ + */ @javax.annotation.Nullable - public OldMenuSectionCategoryItemsInnerNameTranslation getNameTranslation() { + public Map getNameTranslation() { return nameTranslation; } - public void setNameTranslation(OldMenuSectionCategoryItemsInnerNameTranslation nameTranslation) { + public void setNameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; } - public MenuItemsInner availableStatus(AvailableStatusEnum availableStatus) { + public MenuItem availableStatus(AvailableStatusEnum availableStatus) { this.availableStatus = availableStatus; return this; } - /** + /** * The status for the item that is in the category. Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. * @return availableStatus - **/ + */ @javax.annotation.Nonnull public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -312,15 +323,15 @@ public void setAvailableStatus(AvailableStatusEnum availableStatus) { } - public MenuItemsInner description(String description) { + public MenuItem description(String description) { this.description = description; return this; } - /** + /** * The description of the item. There is a custom length limit of 2000 for `VN`. * @return description - **/ + */ @javax.annotation.Nullable public String getDescription() { return description; @@ -331,34 +342,42 @@ public void setDescription(String description) { } - public MenuItemsInner descriptionTranslation(MenuItemsInnerDescriptionTranslation descriptionTranslation) { + public MenuItem descriptionTranslation(Map descriptionTranslation) { this.descriptionTranslation = descriptionTranslation; return this; } - /** - * Get descriptionTranslation + public MenuItem putDescriptionTranslationItem(String key, String descriptionTranslationItem) { + if (this.descriptionTranslation == null) { + this.descriptionTranslation = new HashMap<>(); + } + this.descriptionTranslation.put(key, descriptionTranslationItem); + return this; + } + + /** + * Translation of the item description. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). * @return descriptionTranslation - **/ + */ @javax.annotation.Nullable - public MenuItemsInnerDescriptionTranslation getDescriptionTranslation() { + public Map getDescriptionTranslation() { return descriptionTranslation; } - public void setDescriptionTranslation(MenuItemsInnerDescriptionTranslation descriptionTranslation) { + public void setDescriptionTranslation(Map descriptionTranslation) { this.descriptionTranslation = descriptionTranslation; } - public MenuItemsInner price(Integer price) { + public MenuItem price(Integer price) { this.price = price; return this; } - /** + /** * The item's price (excluding tax) in minor format. For example: 1900 means $19 with `currency.exponent` as 2. Refer to [FAQ](#section/Menu/Is-the-item-price-with-or-without-tax) for more details. * @return price - **/ + */ @javax.annotation.Nonnull public Integer getPrice() { return price; @@ -369,12 +388,12 @@ public void setPrice(Integer price) { } - public MenuItemsInner photos(List photos) { + public MenuItem photos(List photos) { this.photos = photos; return this; } - public MenuItemsInner addPhotosItem(String photosItem) { + public MenuItem addPhotosItem(String photosItem) { if (this.photos == null) { this.photos = new ArrayList<>(); } @@ -382,10 +401,10 @@ public MenuItemsInner addPhotosItem(String photosItem) { return this; } - /** + /** * An array string for the item’s image URL links. Refer to FAQs for more details about [images](#section/Menu/What-are-the-recommended-formats-for-an-item-image). * @return photos - **/ + */ @javax.annotation.Nullable public List getPhotos() { return photos; @@ -396,15 +415,15 @@ public void setPhotos(List photos) { } - public MenuItemsInner specialType(SpecialTypeEnum specialType) { + public MenuItem specialType(SpecialTypeEnum specialType) { this.specialType = specialType; return this; } - /** + /** * The item's special Tag. Refer to FAQs for more details about [specialType](#section/Menu/What's-specialType). * @return specialType - **/ + */ @javax.annotation.Nullable public SpecialTypeEnum getSpecialType() { return specialType; @@ -415,15 +434,15 @@ public void setSpecialType(SpecialTypeEnum specialType) { } - public MenuItemsInner taxable(Boolean taxable) { + public MenuItem taxable(Boolean taxable) { this.taxable = taxable; return this; } - /** + /** * **For Indonesia only.** This field allows the configuration for an item to be marked as tax applicable, and marked item would then be included in a commercial invoice to consumers as per the government's regulations. * @return taxable - **/ + */ @javax.annotation.Nullable public Boolean getTaxable() { return taxable; @@ -434,15 +453,15 @@ public void setTaxable(Boolean taxable) { } - public MenuItemsInner barcode(String barcode) { + public MenuItem barcode(String barcode) { this.barcode = barcode; return this; } - /** + /** * The barcode Number (GTIN). Max 64 allowed. GTIN must be 8, 12, 13, 14 numeric digits. * @return barcode - **/ + */ @javax.annotation.Nullable public String getBarcode() { return barcode; @@ -453,15 +472,15 @@ public void setBarcode(String barcode) { } - public MenuItemsInner sellingTimeID(String sellingTimeID) { + public MenuItem sellingTimeID(String sellingTimeID) { this.sellingTimeID = sellingTimeID; return this; } - /** + /** * The selling time's ID for the item. This value overwrites the category's selling time if it is different. Empty value implies the category's selling time will be applied. * @return sellingTimeID - **/ + */ @javax.annotation.Nullable public String getSellingTimeID() { return sellingTimeID; @@ -472,15 +491,15 @@ public void setSellingTimeID(String sellingTimeID) { } - public MenuItemsInner maxStock(Integer maxStock) { + public MenuItem maxStock(Integer maxStock) { this.maxStock = maxStock; return this; } - /** + /** * Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Empty value implies no limit. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. * @return maxStock - **/ + */ @javax.annotation.Nullable public Integer getMaxStock() { return maxStock; @@ -491,15 +510,15 @@ public void setMaxStock(Integer maxStock) { } - public MenuItemsInner advancedPricing(AdvancedPricing advancedPricing) { + public MenuItem advancedPricing(AdvancedPricing advancedPricing) { this.advancedPricing = advancedPricing; return this; } - /** + /** * Get advancedPricing * @return advancedPricing - **/ + */ @javax.annotation.Nullable public AdvancedPricing getAdvancedPricing() { return advancedPricing; @@ -510,15 +529,15 @@ public void setAdvancedPricing(AdvancedPricing advancedPricing) { } - public MenuItemsInner purchasability(Purchasability purchasability) { + public MenuItem purchasability(Purchasability purchasability) { this.purchasability = purchasability; return this; } - /** + /** * Get purchasability * @return purchasability - **/ + */ @javax.annotation.Nullable public Purchasability getPurchasability() { return purchasability; @@ -529,12 +548,12 @@ public void setPurchasability(Purchasability purchasability) { } - public MenuItemsInner modifierGroups(List modifierGroups) { + public MenuItem modifierGroups(List modifierGroups) { this.modifierGroups = modifierGroups; return this; } - public MenuItemsInner addModifierGroupsItem(ModifierGroupsInner modifierGroupsItem) { + public MenuItem addModifierGroupsItem(ModifierGroup modifierGroupsItem) { if (this.modifierGroups == null) { this.modifierGroups = new ArrayList<>(); } @@ -542,19 +561,63 @@ public MenuItemsInner addModifierGroupsItem(ModifierGroupsInner modifierGroupsIt return this; } - /** + /** * An array of the modifierGroup JSON objects. Max 30 allowed per item. Refer to [Modifier groups](#modifier-groups) for more information. * @return modifierGroups - **/ + */ @javax.annotation.Nullable - public List getModifierGroups() { + public List getModifierGroups() { return modifierGroups; } - public void setModifierGroups(List modifierGroups) { + public void setModifierGroups(List modifierGroups) { this.modifierGroups = modifierGroups; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuItem instance itself + */ + public MenuItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -565,34 +628,35 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - MenuItemsInner menuItemsInner = (MenuItemsInner) o; - return Objects.equals(this.id, menuItemsInner.id) && - Objects.equals(this.name, menuItemsInner.name) && - Objects.equals(this.nameTranslation, menuItemsInner.nameTranslation) && - Objects.equals(this.availableStatus, menuItemsInner.availableStatus) && - Objects.equals(this.description, menuItemsInner.description) && - Objects.equals(this.descriptionTranslation, menuItemsInner.descriptionTranslation) && - Objects.equals(this.price, menuItemsInner.price) && - Objects.equals(this.photos, menuItemsInner.photos) && - Objects.equals(this.specialType, menuItemsInner.specialType) && - Objects.equals(this.taxable, menuItemsInner.taxable) && - Objects.equals(this.barcode, menuItemsInner.barcode) && - Objects.equals(this.sellingTimeID, menuItemsInner.sellingTimeID) && - Objects.equals(this.maxStock, menuItemsInner.maxStock) && - Objects.equals(this.advancedPricing, menuItemsInner.advancedPricing) && - Objects.equals(this.purchasability, menuItemsInner.purchasability) && - Objects.equals(this.modifierGroups, menuItemsInner.modifierGroups); + MenuItem menuItem = (MenuItem) o; + return Objects.equals(this.id, menuItem.id) && + Objects.equals(this.name, menuItem.name) && + Objects.equals(this.nameTranslation, menuItem.nameTranslation) && + Objects.equals(this.availableStatus, menuItem.availableStatus) && + Objects.equals(this.description, menuItem.description) && + Objects.equals(this.descriptionTranslation, menuItem.descriptionTranslation) && + Objects.equals(this.price, menuItem.price) && + Objects.equals(this.photos, menuItem.photos) && + Objects.equals(this.specialType, menuItem.specialType) && + Objects.equals(this.taxable, menuItem.taxable) && + Objects.equals(this.barcode, menuItem.barcode) && + Objects.equals(this.sellingTimeID, menuItem.sellingTimeID) && + Objects.equals(this.maxStock, menuItem.maxStock) && + Objects.equals(this.advancedPricing, menuItem.advancedPricing) && + Objects.equals(this.purchasability, menuItem.purchasability) && + Objects.equals(this.modifierGroups, menuItem.modifierGroups)&& + Objects.equals(this.additionalProperties, menuItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, nameTranslation, availableStatus, description, descriptionTranslation, price, photos, specialType, taxable, barcode, sellingTimeID, maxStock, advancedPricing, purchasability, modifierGroups); + return Objects.hash(id, name, nameTranslation, availableStatus, description, descriptionTranslation, price, photos, specialType, taxable, barcode, sellingTimeID, maxStock, advancedPricing, purchasability, modifierGroups, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class MenuItemsInner {\n"); + sb.append("class MenuItem {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" nameTranslation: ").append(toIndentedString(nameTranslation)).append("\n"); @@ -609,6 +673,7 @@ public String toString() { sb.append(" advancedPricing: ").append(toIndentedString(advancedPricing)).append("\n"); sb.append(" purchasability: ").append(toIndentedString(purchasability)).append("\n"); sb.append(" modifierGroups: ").append(toIndentedString(modifierGroups)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -656,29 +721,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("price"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MenuItemsInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuItem + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!MenuItemsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in MenuItemsInner is not found in the empty JSON string", MenuItemsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MenuItemsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MenuItemsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!MenuItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuItem is not found in the empty JSON string", MenuItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : MenuItemsInner.openapiRequiredFields) { + for (String requiredField : MenuItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -690,10 +747,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // validate the optional field `nameTranslation` - if (jsonObj.get("nameTranslation") != null && !jsonObj.get("nameTranslation").isJsonNull()) { - OldMenuSectionCategoryItemsInnerNameTranslation.validateJsonElement(jsonObj.get("nameTranslation")); - } if (!jsonObj.get("availableStatus").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `availableStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("availableStatus").toString())); } @@ -702,10 +755,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } - // validate the optional field `descriptionTranslation` - if (jsonObj.get("descriptionTranslation") != null && !jsonObj.get("descriptionTranslation").isJsonNull()) { - MenuItemsInnerDescriptionTranslation.validateJsonElement(jsonObj.get("descriptionTranslation")); - } // ensure the optional json data is an array if present if (jsonObj.get("photos") != null && !jsonObj.get("photos").isJsonNull() && !jsonObj.get("photos").isJsonArray()) { throw new IllegalArgumentException(String.format("Expected the field `photos` to be an array in the JSON string but got `%s`", jsonObj.get("photos").toString())); @@ -741,7 +790,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `modifierGroups` (array) for (int i = 0; i < jsonArraymodifierGroups.size(); i++) { - ModifierGroupsInner.validateJsonElement(jsonArraymodifierGroups.get(i)); + ModifierGroup.validateJsonElement(jsonArraymodifierGroups.get(i)); }; } } @@ -751,47 +800,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!MenuItemsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'MenuItemsInner' and its subtypes + if (!MenuItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuItem' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MenuItemsInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuItem.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, MenuItemsInner value) throws IOException { + public void write(JsonWriter out, MenuItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public MenuItemsInner read(JsonReader in) throws IOException { + public MenuItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of MenuItemsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of MenuItemsInner - * @throws IOException if the JSON string is invalid with respect to MenuItemsInner - */ - public static MenuItemsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MenuItemsInner.class); + /** + * Create an instance of MenuItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuItem + * @throws IOException if the JSON string is invalid with respect to MenuItem + */ + public static MenuItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuItem.class); } - /** - * Convert an instance of MenuItemsInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuItem to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/MenuItemsInnerDescriptionTranslation.java b/src/main/java/com/grabfood/client/model/MenuItemsInnerDescriptionTranslation.java deleted file mode 100644 index ad4f23f..0000000 --- a/src/main/java/com/grabfood/client/model/MenuItemsInnerDescriptionTranslation.java +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Translation of the item description. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class MenuItemsInnerDescriptionTranslation { - public static final String SERIALIZED_NAME_EN = "en"; - @SerializedName(SERIALIZED_NAME_EN) - private String en; - - public MenuItemsInnerDescriptionTranslation() { - } - - public MenuItemsInnerDescriptionTranslation en(String en) { - this.en = en; - return this; - } - - /** - * The English translation of the description. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - * @return en - **/ - @javax.annotation.Nullable - public String getEn() { - return en; - } - - public void setEn(String en) { - this.en = en; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MenuItemsInnerDescriptionTranslation menuItemsInnerDescriptionTranslation = (MenuItemsInnerDescriptionTranslation) o; - return Objects.equals(this.en, menuItemsInnerDescriptionTranslation.en); - } - - @Override - public int hashCode() { - return Objects.hash(en); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MenuItemsInnerDescriptionTranslation {\n"); - sb.append(" en: ").append(toIndentedString(en)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("en"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MenuItemsInnerDescriptionTranslation - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!MenuItemsInnerDescriptionTranslation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in MenuItemsInnerDescriptionTranslation is not found in the empty JSON string", MenuItemsInnerDescriptionTranslation.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MenuItemsInnerDescriptionTranslation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MenuItemsInnerDescriptionTranslation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("en") != null && !jsonObj.get("en").isJsonNull()) && !jsonObj.get("en").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `en` to be a primitive type in the JSON string but got `%s`", jsonObj.get("en").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!MenuItemsInnerDescriptionTranslation.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'MenuItemsInnerDescriptionTranslation' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MenuItemsInnerDescriptionTranslation.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, MenuItemsInnerDescriptionTranslation value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public MenuItemsInnerDescriptionTranslation read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of MenuItemsInnerDescriptionTranslation given an JSON string - * - * @param jsonString JSON string - * @return An instance of MenuItemsInnerDescriptionTranslation - * @throws IOException if the JSON string is invalid with respect to MenuItemsInnerDescriptionTranslation - */ - public static MenuItemsInnerDescriptionTranslation fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MenuItemsInnerDescriptionTranslation.class); - } - - /** - * Convert an instance of MenuItemsInnerDescriptionTranslation to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/MenuModifiersInner.java b/src/main/java/com/grabfood/client/model/MenuModifier.java similarity index 59% rename from src/main/java/com/grabfood/client/model/MenuModifiersInner.java rename to src/main/java/com/grabfood/client/model/MenuModifier.java index 781ad3f..d21ef8c 100644 --- a/src/main/java/com/grabfood/client/model/MenuModifiersInner.java +++ b/src/main/java/com/grabfood/client/model/MenuModifier.java @@ -23,9 +23,10 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.grabfood.client.model.AdvancedPricing; -import com.grabfood.client.model.MenuModifiersInnerNameTranslation; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -42,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,10 +52,10 @@ import com.grabfood.client.JSON; /** - * MenuModifiersInner + * MenuModifier */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class MenuModifiersInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuModifier { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -66,7 +66,7 @@ public class MenuModifiersInner { public static final String SERIALIZED_NAME_NAME_TRANSLATION = "nameTranslation"; @SerializedName(SERIALIZED_NAME_NAME_TRANSLATION) - private MenuModifiersInnerNameTranslation nameTranslation; + private Map nameTranslation = new HashMap<>(); /** * The status for the modifier that is in the ModifierGroup. @@ -79,7 +79,9 @@ public enum AvailableStatusEnum { UNAVAILABLETODAY("UNAVAILABLETODAY"), - HIDE("HIDE"); + HIDE("HIDE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -102,7 +104,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -140,18 +142,18 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_ADVANCED_PRICING) private AdvancedPricing advancedPricing; - public MenuModifiersInner() { + public MenuModifier() { } - public MenuModifiersInner id(String id) { + public MenuModifier id(String id) { this.id = id; return this; } - /** + /** * The modifier's ID that is on the partner's system. This ID should be unique with a min length of 1 and max of 64. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -162,15 +164,15 @@ public void setId(String id) { } - public MenuModifiersInner name(String name) { + public MenuModifier name(String name) { this.name = name; return this; } - /** + /** * The name of the modifier. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -181,34 +183,42 @@ public void setName(String name) { } - public MenuModifiersInner nameTranslation(MenuModifiersInnerNameTranslation nameTranslation) { + public MenuModifier nameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; return this; } - /** - * Get nameTranslation + public MenuModifier putNameTranslationItem(String key, String nameTranslationItem) { + if (this.nameTranslation == null) { + this.nameTranslation = new HashMap<>(); + } + this.nameTranslation.put(key, nameTranslationItem); + return this; + } + + /** + * Translation of the modifier name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). * @return nameTranslation - **/ + */ @javax.annotation.Nullable - public MenuModifiersInnerNameTranslation getNameTranslation() { + public Map getNameTranslation() { return nameTranslation; } - public void setNameTranslation(MenuModifiersInnerNameTranslation nameTranslation) { + public void setNameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; } - public MenuModifiersInner availableStatus(AvailableStatusEnum availableStatus) { + public MenuModifier availableStatus(AvailableStatusEnum availableStatus) { this.availableStatus = availableStatus; return this; } - /** + /** * The status for the modifier that is in the ModifierGroup. * @return availableStatus - **/ + */ @javax.annotation.Nonnull public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -219,15 +229,15 @@ public void setAvailableStatus(AvailableStatusEnum availableStatus) { } - public MenuModifiersInner price(Integer price) { + public MenuModifier price(Integer price) { this.price = price; return this; } - /** + /** * The modifier's price (excluding tax) in minor format. Refer to FAQs for more details about [tax](#section/Order/How-is-tax-calculated). * @return price - **/ + */ @javax.annotation.Nullable public Integer getPrice() { return price; @@ -238,15 +248,15 @@ public void setPrice(Integer price) { } - public MenuModifiersInner barcode(String barcode) { + public MenuModifier barcode(String barcode) { this.barcode = barcode; return this; } - /** + /** * The barcode Number (GTIN). GTIN must be 8, 12, 13, 14 numeric digits. * @return barcode - **/ + */ @javax.annotation.Nullable public String getBarcode() { return barcode; @@ -257,15 +267,15 @@ public void setBarcode(String barcode) { } - public MenuModifiersInner advancedPricing(AdvancedPricing advancedPricing) { + public MenuModifier advancedPricing(AdvancedPricing advancedPricing) { this.advancedPricing = advancedPricing; return this; } - /** + /** * Get advancedPricing * @return advancedPricing - **/ + */ @javax.annotation.Nullable public AdvancedPricing getAdvancedPricing() { return advancedPricing; @@ -275,6 +285,50 @@ public void setAdvancedPricing(AdvancedPricing advancedPricing) { this.advancedPricing = advancedPricing; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuModifier instance itself + */ + public MenuModifier putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -285,25 +339,26 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - MenuModifiersInner menuModifiersInner = (MenuModifiersInner) o; - return Objects.equals(this.id, menuModifiersInner.id) && - Objects.equals(this.name, menuModifiersInner.name) && - Objects.equals(this.nameTranslation, menuModifiersInner.nameTranslation) && - Objects.equals(this.availableStatus, menuModifiersInner.availableStatus) && - Objects.equals(this.price, menuModifiersInner.price) && - Objects.equals(this.barcode, menuModifiersInner.barcode) && - Objects.equals(this.advancedPricing, menuModifiersInner.advancedPricing); + MenuModifier menuModifier = (MenuModifier) o; + return Objects.equals(this.id, menuModifier.id) && + Objects.equals(this.name, menuModifier.name) && + Objects.equals(this.nameTranslation, menuModifier.nameTranslation) && + Objects.equals(this.availableStatus, menuModifier.availableStatus) && + Objects.equals(this.price, menuModifier.price) && + Objects.equals(this.barcode, menuModifier.barcode) && + Objects.equals(this.advancedPricing, menuModifier.advancedPricing)&& + Objects.equals(this.additionalProperties, menuModifier.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, nameTranslation, availableStatus, price, barcode, advancedPricing); + return Objects.hash(id, name, nameTranslation, availableStatus, price, barcode, advancedPricing, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class MenuModifiersInner {\n"); + sb.append("class MenuModifier {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" nameTranslation: ").append(toIndentedString(nameTranslation)).append("\n"); @@ -311,6 +366,7 @@ public String toString() { sb.append(" price: ").append(toIndentedString(price)).append("\n"); sb.append(" barcode: ").append(toIndentedString(barcode)).append("\n"); sb.append(" advancedPricing: ").append(toIndentedString(advancedPricing)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -348,29 +404,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("availableStatus"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MenuModifiersInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuModifier + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!MenuModifiersInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in MenuModifiersInner is not found in the empty JSON string", MenuModifiersInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MenuModifiersInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MenuModifiersInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!MenuModifier.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuModifier is not found in the empty JSON string", MenuModifier.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : MenuModifiersInner.openapiRequiredFields) { + for (String requiredField : MenuModifier.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -382,10 +430,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // validate the optional field `nameTranslation` - if (jsonObj.get("nameTranslation") != null && !jsonObj.get("nameTranslation").isJsonNull()) { - MenuModifiersInnerNameTranslation.validateJsonElement(jsonObj.get("nameTranslation")); - } if (!jsonObj.get("availableStatus").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `availableStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("availableStatus").toString())); } @@ -404,47 +448,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!MenuModifiersInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'MenuModifiersInner' and its subtypes + if (!MenuModifier.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuModifier' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MenuModifiersInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuModifier.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, MenuModifiersInner value) throws IOException { + public void write(JsonWriter out, MenuModifier value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public MenuModifiersInner read(JsonReader in) throws IOException { + public MenuModifier read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuModifier instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of MenuModifiersInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of MenuModifiersInner - * @throws IOException if the JSON string is invalid with respect to MenuModifiersInner - */ - public static MenuModifiersInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MenuModifiersInner.class); + /** + * Create an instance of MenuModifier given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuModifier + * @throws IOException if the JSON string is invalid with respect to MenuModifier + */ + public static MenuModifier fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuModifier.class); } - /** - * Convert an instance of MenuModifiersInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuModifier to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/MenuModifiersInnerNameTranslation.java b/src/main/java/com/grabfood/client/model/MenuModifiersInnerNameTranslation.java deleted file mode 100644 index ef295b3..0000000 --- a/src/main/java/com/grabfood/client/model/MenuModifiersInnerNameTranslation.java +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Translation of the modifier name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class MenuModifiersInnerNameTranslation { - public static final String SERIALIZED_NAME_EN = "en"; - @SerializedName(SERIALIZED_NAME_EN) - private String en; - - public MenuModifiersInnerNameTranslation() { - } - - public MenuModifiersInnerNameTranslation en(String en) { - this.en = en; - return this; - } - - /** - * The English translation of the name. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - * @return en - **/ - @javax.annotation.Nullable - public String getEn() { - return en; - } - - public void setEn(String en) { - this.en = en; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MenuModifiersInnerNameTranslation menuModifiersInnerNameTranslation = (MenuModifiersInnerNameTranslation) o; - return Objects.equals(this.en, menuModifiersInnerNameTranslation.en); - } - - @Override - public int hashCode() { - return Objects.hash(en); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MenuModifiersInnerNameTranslation {\n"); - sb.append(" en: ").append(toIndentedString(en)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("en"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MenuModifiersInnerNameTranslation - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!MenuModifiersInnerNameTranslation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in MenuModifiersInnerNameTranslation is not found in the empty JSON string", MenuModifiersInnerNameTranslation.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MenuModifiersInnerNameTranslation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MenuModifiersInnerNameTranslation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("en") != null && !jsonObj.get("en").isJsonNull()) && !jsonObj.get("en").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `en` to be a primitive type in the JSON string but got `%s`", jsonObj.get("en").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!MenuModifiersInnerNameTranslation.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'MenuModifiersInnerNameTranslation' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MenuModifiersInnerNameTranslation.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, MenuModifiersInnerNameTranslation value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public MenuModifiersInnerNameTranslation read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of MenuModifiersInnerNameTranslation given an JSON string - * - * @param jsonString JSON string - * @return An instance of MenuModifiersInnerNameTranslation - * @throws IOException if the JSON string is invalid with respect to MenuModifiersInnerNameTranslation - */ - public static MenuModifiersInnerNameTranslation fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MenuModifiersInnerNameTranslation.class); - } - - /** - * Convert an instance of MenuModifiersInnerNameTranslation to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/SectionsInner.java b/src/main/java/com/grabfood/client/model/MenuSection.java similarity index 51% rename from src/main/java/com/grabfood/client/model/SectionsInner.java rename to src/main/java/com/grabfood/client/model/MenuSection.java index 0a2a1fe..f1c140d 100644 --- a/src/main/java/com/grabfood/client/model/SectionsInner.java +++ b/src/main/java/com/grabfood/client/model/MenuSection.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.SectionsInnerCategoriesInner; +import com.grabfood.client.model.MenuSectionCategory; import com.grabfood.client.model.ServiceHours; import java.io.IOException; import java.util.ArrayList; @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,10 +53,10 @@ import com.grabfood.client.JSON; /** - * SectionsInner + * MenuSection */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SectionsInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSection { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -72,20 +71,20 @@ public class SectionsInner { public static final String SERIALIZED_NAME_CATEGORIES = "categories"; @SerializedName(SERIALIZED_NAME_CATEGORIES) - private List categories = new ArrayList<>(); + private List categories = new ArrayList<>(); - public SectionsInner() { + public MenuSection() { } - public SectionsInner id(String id) { + public MenuSection id(String id) { this.id = id; return this; } - /** + /** * The section's ID in the partner system. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -96,15 +95,15 @@ public void setId(String id) { } - public SectionsInner name(String name) { + public MenuSection name(String name) { this.name = name; return this; } - /** + /** * The name of the section. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -115,15 +114,15 @@ public void setName(String name) { } - public SectionsInner serviceHours(ServiceHours serviceHours) { + public MenuSection serviceHours(ServiceHours serviceHours) { this.serviceHours = serviceHours; return this; } - /** + /** * Get serviceHours * @return serviceHours - **/ + */ @javax.annotation.Nonnull public ServiceHours getServiceHours() { return serviceHours; @@ -134,12 +133,12 @@ public void setServiceHours(ServiceHours serviceHours) { } - public SectionsInner categories(List categories) { + public MenuSection categories(List categories) { this.categories = categories; return this; } - public SectionsInner addCategoriesItem(SectionsInnerCategoriesInner categoriesItem) { + public MenuSection addCategoriesItem(MenuSectionCategory categoriesItem) { if (this.categories == null) { this.categories = new ArrayList<>(); } @@ -147,19 +146,63 @@ public SectionsInner addCategoriesItem(SectionsInnerCategoriesInner categoriesIt return this; } - /** + /** * An array of category JSON objects. Max 100 allowed per section. Refer to [Categories](#categories) for more information. * @return categories - **/ + */ @javax.annotation.Nonnull - public List getCategories() { + public List getCategories() { return categories; } - public void setCategories(List categories) { + public void setCategories(List categories) { this.categories = categories; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSection instance itself + */ + public MenuSection putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -170,26 +213,28 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - SectionsInner sectionsInner = (SectionsInner) o; - return Objects.equals(this.id, sectionsInner.id) && - Objects.equals(this.name, sectionsInner.name) && - Objects.equals(this.serviceHours, sectionsInner.serviceHours) && - Objects.equals(this.categories, sectionsInner.categories); + MenuSection menuSection = (MenuSection) o; + return Objects.equals(this.id, menuSection.id) && + Objects.equals(this.name, menuSection.name) && + Objects.equals(this.serviceHours, menuSection.serviceHours) && + Objects.equals(this.categories, menuSection.categories)&& + Objects.equals(this.additionalProperties, menuSection.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, serviceHours, categories); + return Objects.hash(id, name, serviceHours, categories, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class SectionsInner {\n"); + sb.append("class MenuSection {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" serviceHours: ").append(toIndentedString(serviceHours)).append("\n"); sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -225,29 +270,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("categories"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SectionsInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSection + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!SectionsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SectionsInner is not found in the empty JSON string", SectionsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SectionsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SectionsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!MenuSection.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSection is not found in the empty JSON string", MenuSection.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : SectionsInner.openapiRequiredFields) { + for (String requiredField : MenuSection.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -269,7 +306,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArraycategories = jsonObj.getAsJsonArray("categories"); // validate the required field `categories` (array) for (int i = 0; i < jsonArraycategories.size(); i++) { - SectionsInnerCategoriesInner.validateJsonElement(jsonArraycategories.get(i)); + MenuSectionCategory.validateJsonElement(jsonArraycategories.get(i)); }; } @@ -277,47 +314,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!SectionsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SectionsInner' and its subtypes + if (!MenuSection.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSection' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SectionsInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSection.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, SectionsInner value) throws IOException { + public void write(JsonWriter out, MenuSection value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public SectionsInner read(JsonReader in) throws IOException { + public MenuSection read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSection instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of SectionsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of SectionsInner - * @throws IOException if the JSON string is invalid with respect to SectionsInner - */ - public static SectionsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SectionsInner.class); + /** + * Create an instance of MenuSection given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSection + * @throws IOException if the JSON string is invalid with respect to MenuSection + */ + public static MenuSection fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSection.class); } - /** - * Convert an instance of SectionsInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuSection to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/SectionsInnerCategoriesInner.java b/src/main/java/com/grabfood/client/model/MenuSectionCategory.java similarity index 54% rename from src/main/java/com/grabfood/client/model/SectionsInnerCategoriesInner.java rename to src/main/java/com/grabfood/client/model/MenuSectionCategory.java index 282f41b..ef94163 100644 --- a/src/main/java/com/grabfood/client/model/SectionsInnerCategoriesInner.java +++ b/src/main/java/com/grabfood/client/model/MenuSectionCategory.java @@ -22,12 +22,13 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.CategoriesInnerNameTranslation; -import com.grabfood.client.model.OldMenuSectionCategoryItemsInner; +import com.grabfood.client.model.MenuSectionCategoryItem; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -44,7 +45,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,10 +54,10 @@ import com.grabfood.client.JSON; /** - * SectionsInnerCategoriesInner + * MenuSectionCategory */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SectionsInnerCategoriesInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSectionCategory { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -68,7 +68,7 @@ public class SectionsInnerCategoriesInner { public static final String SERIALIZED_NAME_NAME_TRANSLATION = "nameTranslation"; @SerializedName(SERIALIZED_NAME_NAME_TRANSLATION) - private CategoriesInnerNameTranslation nameTranslation; + private Map nameTranslation = new HashMap<>(); /** * The status for the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). @@ -79,7 +79,9 @@ public enum AvailableStatusEnum { UNAVAILABLE("UNAVAILABLE"), - HIDE("HIDE"); + HIDE("HIDE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -102,7 +104,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -130,20 +132,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_ITEMS = "items"; @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); + private List items = new ArrayList<>(); - public SectionsInnerCategoriesInner() { + public MenuSectionCategory() { } - public SectionsInnerCategoriesInner id(String id) { + public MenuSectionCategory id(String id) { this.id = id; return this; } - /** + /** * The category's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -154,15 +156,15 @@ public void setId(String id) { } - public SectionsInnerCategoriesInner name(String name) { + public MenuSectionCategory name(String name) { this.name = name; return this; } - /** + /** * The name of the category. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -173,34 +175,42 @@ public void setName(String name) { } - public SectionsInnerCategoriesInner nameTranslation(CategoriesInnerNameTranslation nameTranslation) { + public MenuSectionCategory nameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; return this; } - /** - * Get nameTranslation + public MenuSectionCategory putNameTranslationItem(String key, String nameTranslationItem) { + if (this.nameTranslation == null) { + this.nameTranslation = new HashMap<>(); + } + this.nameTranslation.put(key, nameTranslationItem); + return this; + } + + /** + * Translation of the category name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). * @return nameTranslation - **/ + */ @javax.annotation.Nullable - public CategoriesInnerNameTranslation getNameTranslation() { + public Map getNameTranslation() { return nameTranslation; } - public void setNameTranslation(CategoriesInnerNameTranslation nameTranslation) { + public void setNameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; } - public SectionsInnerCategoriesInner availableStatus(AvailableStatusEnum availableStatus) { + public MenuSectionCategory availableStatus(AvailableStatusEnum availableStatus) { this.availableStatus = availableStatus; return this; } - /** + /** * The status for the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). * @return availableStatus - **/ + */ @javax.annotation.Nonnull public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -211,12 +221,12 @@ public void setAvailableStatus(AvailableStatusEnum availableStatus) { } - public SectionsInnerCategoriesInner items(List items) { + public MenuSectionCategory items(List items) { this.items = items; return this; } - public SectionsInnerCategoriesInner addItemsItem(OldMenuSectionCategoryItemsInner itemsItem) { + public MenuSectionCategory addItemsItem(MenuSectionCategoryItem itemsItem) { if (this.items == null) { this.items = new ArrayList<>(); } @@ -224,19 +234,63 @@ public SectionsInnerCategoriesInner addItemsItem(OldMenuSectionCategoryItemsInne return this; } - /** + /** * An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. * @return items - **/ + */ @javax.annotation.Nonnull - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSectionCategory instance itself + */ + public MenuSectionCategory putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -247,28 +301,30 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - SectionsInnerCategoriesInner sectionsInnerCategoriesInner = (SectionsInnerCategoriesInner) o; - return Objects.equals(this.id, sectionsInnerCategoriesInner.id) && - Objects.equals(this.name, sectionsInnerCategoriesInner.name) && - Objects.equals(this.nameTranslation, sectionsInnerCategoriesInner.nameTranslation) && - Objects.equals(this.availableStatus, sectionsInnerCategoriesInner.availableStatus) && - Objects.equals(this.items, sectionsInnerCategoriesInner.items); + MenuSectionCategory menuSectionCategory = (MenuSectionCategory) o; + return Objects.equals(this.id, menuSectionCategory.id) && + Objects.equals(this.name, menuSectionCategory.name) && + Objects.equals(this.nameTranslation, menuSectionCategory.nameTranslation) && + Objects.equals(this.availableStatus, menuSectionCategory.availableStatus) && + Objects.equals(this.items, menuSectionCategory.items)&& + Objects.equals(this.additionalProperties, menuSectionCategory.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, nameTranslation, availableStatus, items); + return Objects.hash(id, name, nameTranslation, availableStatus, items, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class SectionsInnerCategoriesInner {\n"); + sb.append("class MenuSectionCategory {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" nameTranslation: ").append(toIndentedString(nameTranslation)).append("\n"); sb.append(" availableStatus: ").append(toIndentedString(availableStatus)).append("\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -305,29 +361,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("items"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SectionsInnerCategoriesInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSectionCategory + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!SectionsInnerCategoriesInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SectionsInnerCategoriesInner is not found in the empty JSON string", SectionsInnerCategoriesInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SectionsInnerCategoriesInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SectionsInnerCategoriesInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!MenuSectionCategory.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSectionCategory is not found in the empty JSON string", MenuSectionCategory.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : SectionsInnerCategoriesInner.openapiRequiredFields) { + for (String requiredField : MenuSectionCategory.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -339,10 +387,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // validate the optional field `nameTranslation` - if (jsonObj.get("nameTranslation") != null && !jsonObj.get("nameTranslation").isJsonNull()) { - CategoriesInnerNameTranslation.validateJsonElement(jsonObj.get("nameTranslation")); - } if (!jsonObj.get("availableStatus").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `availableStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("availableStatus").toString())); } @@ -356,7 +400,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); // validate the required field `items` (array) for (int i = 0; i < jsonArrayitems.size(); i++) { - OldMenuSectionCategoryItemsInner.validateJsonElement(jsonArrayitems.get(i)); + MenuSectionCategoryItem.validateJsonElement(jsonArrayitems.get(i)); }; } @@ -364,47 +408,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!SectionsInnerCategoriesInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SectionsInnerCategoriesInner' and its subtypes + if (!MenuSectionCategory.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSectionCategory' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SectionsInnerCategoriesInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSectionCategory.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, SectionsInnerCategoriesInner value) throws IOException { + public void write(JsonWriter out, MenuSectionCategory value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public SectionsInnerCategoriesInner read(JsonReader in) throws IOException { + public MenuSectionCategory read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSectionCategory instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of SectionsInnerCategoriesInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of SectionsInnerCategoriesInner - * @throws IOException if the JSON string is invalid with respect to SectionsInnerCategoriesInner - */ - public static SectionsInnerCategoriesInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SectionsInnerCategoriesInner.class); + /** + * Create an instance of MenuSectionCategory given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSectionCategory + * @throws IOException if the JSON string is invalid with respect to MenuSectionCategory + */ + public static MenuSectionCategory fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSectionCategory.class); } - /** - * Convert an instance of SectionsInnerCategoriesInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuSectionCategory to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInner.java b/src/main/java/com/grabfood/client/model/MenuSectionCategoryItem.java similarity index 66% rename from src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInner.java rename to src/main/java/com/grabfood/client/model/MenuSectionCategoryItem.java index 2421ac3..64060f1 100644 --- a/src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInner.java +++ b/src/main/java/com/grabfood/client/model/MenuSectionCategoryItem.java @@ -23,14 +23,14 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.grabfood.client.model.AdvancedPricing; -import com.grabfood.client.model.ModifierGroupsInner; -import com.grabfood.client.model.OldMenuSectionCategoryItemsInnerDescriptionTranslation; -import com.grabfood.client.model.OldMenuSectionCategoryItemsInnerNameTranslation; +import com.grabfood.client.model.ModifierGroup; import com.grabfood.client.model.Purchasability; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -47,7 +47,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -57,10 +56,10 @@ import com.grabfood.client.JSON; /** - * OldMenuSectionCategoryItemsInner + * MenuSectionCategoryItem */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class OldMenuSectionCategoryItemsInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSectionCategoryItem { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -71,7 +70,7 @@ public class OldMenuSectionCategoryItemsInner { public static final String SERIALIZED_NAME_NAME_TRANSLATION = "nameTranslation"; @SerializedName(SERIALIZED_NAME_NAME_TRANSLATION) - private OldMenuSectionCategoryItemsInnerNameTranslation nameTranslation; + private Map nameTranslation = new HashMap<>(); /** * The status for the item that is in the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. @@ -84,7 +83,9 @@ public enum AvailableStatusEnum { HIDE("HIDE"), - UNAVAILABLETODAY("UNAVAILABLETODAY"); + UNAVAILABLETODAY("UNAVAILABLETODAY"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -107,7 +108,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -139,7 +140,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_DESCRIPTION_TRANSLATION = "descriptionTranslation"; @SerializedName(SERIALIZED_NAME_DESCRIPTION_TRANSLATION) - private OldMenuSectionCategoryItemsInnerDescriptionTranslation descriptionTranslation; + private Map descriptionTranslation = new HashMap<>(); public static final String SERIALIZED_NAME_PRICE = "price"; @SerializedName(SERIALIZED_NAME_PRICE) @@ -156,7 +157,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public enum SpecialTypeEnum { ALCOHOL("alcohol"), - EMPTY(""); + EMPTY(""), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -179,7 +182,7 @@ public static SpecialTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -227,20 +230,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_MODIFIER_GROUPS = "modifierGroups"; @SerializedName(SERIALIZED_NAME_MODIFIER_GROUPS) - private List modifierGroups = new ArrayList<>(); + private List modifierGroups = new ArrayList<>(); - public OldMenuSectionCategoryItemsInner() { + public MenuSectionCategoryItem() { } - public OldMenuSectionCategoryItemsInner id(String id) { + public MenuSectionCategoryItem id(String id) { this.id = id; return this; } - /** + /** * The item's ID in the partner system. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -251,15 +254,15 @@ public void setId(String id) { } - public OldMenuSectionCategoryItemsInner name(String name) { + public MenuSectionCategoryItem name(String name) { this.name = name; return this; } - /** + /** * The name of the item. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -270,34 +273,42 @@ public void setName(String name) { } - public OldMenuSectionCategoryItemsInner nameTranslation(OldMenuSectionCategoryItemsInnerNameTranslation nameTranslation) { + public MenuSectionCategoryItem nameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; return this; } - /** - * Get nameTranslation + public MenuSectionCategoryItem putNameTranslationItem(String key, String nameTranslationItem) { + if (this.nameTranslation == null) { + this.nameTranslation = new HashMap<>(); + } + this.nameTranslation.put(key, nameTranslationItem); + return this; + } + + /** + * Translation of the item name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). * @return nameTranslation - **/ + */ @javax.annotation.Nullable - public OldMenuSectionCategoryItemsInnerNameTranslation getNameTranslation() { + public Map getNameTranslation() { return nameTranslation; } - public void setNameTranslation(OldMenuSectionCategoryItemsInnerNameTranslation nameTranslation) { + public void setNameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; } - public OldMenuSectionCategoryItemsInner availableStatus(AvailableStatusEnum availableStatus) { + public MenuSectionCategoryItem availableStatus(AvailableStatusEnum availableStatus) { this.availableStatus = availableStatus; return this; } - /** + /** * The status for the item that is in the category. Refer to FAQs for more details about [availableStatus](#section/Menu/What-is-availableStatus). Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. * @return availableStatus - **/ + */ @javax.annotation.Nonnull public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -308,15 +319,15 @@ public void setAvailableStatus(AvailableStatusEnum availableStatus) { } - public OldMenuSectionCategoryItemsInner description(String description) { + public MenuSectionCategoryItem description(String description) { this.description = description; return this; } - /** + /** * The description of the item. There is a custom length limit of 2000 for `VN`. * @return description - **/ + */ @javax.annotation.Nullable public String getDescription() { return description; @@ -327,34 +338,42 @@ public void setDescription(String description) { } - public OldMenuSectionCategoryItemsInner descriptionTranslation(OldMenuSectionCategoryItemsInnerDescriptionTranslation descriptionTranslation) { + public MenuSectionCategoryItem descriptionTranslation(Map descriptionTranslation) { this.descriptionTranslation = descriptionTranslation; return this; } - /** - * Get descriptionTranslation + public MenuSectionCategoryItem putDescriptionTranslationItem(String key, String descriptionTranslationItem) { + if (this.descriptionTranslation == null) { + this.descriptionTranslation = new HashMap<>(); + } + this.descriptionTranslation.put(key, descriptionTranslationItem); + return this; + } + + /** + * Translation of the item description. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). * @return descriptionTranslation - **/ + */ @javax.annotation.Nullable - public OldMenuSectionCategoryItemsInnerDescriptionTranslation getDescriptionTranslation() { + public Map getDescriptionTranslation() { return descriptionTranslation; } - public void setDescriptionTranslation(OldMenuSectionCategoryItemsInnerDescriptionTranslation descriptionTranslation) { + public void setDescriptionTranslation(Map descriptionTranslation) { this.descriptionTranslation = descriptionTranslation; } - public OldMenuSectionCategoryItemsInner price(Integer price) { + public MenuSectionCategoryItem price(Integer price) { this.price = price; return this; } - /** + /** * The item's price (excluding tax) in minor format. For example: 1900 means $19 with `currency.exponent` as 2. Refer to [FAQ](#section/Menu/Is-the-item-price-with-or-without-tax) for more details. * @return price - **/ + */ @javax.annotation.Nonnull public Integer getPrice() { return price; @@ -365,12 +384,12 @@ public void setPrice(Integer price) { } - public OldMenuSectionCategoryItemsInner photos(List photos) { + public MenuSectionCategoryItem photos(List photos) { this.photos = photos; return this; } - public OldMenuSectionCategoryItemsInner addPhotosItem(String photosItem) { + public MenuSectionCategoryItem addPhotosItem(String photosItem) { if (this.photos == null) { this.photos = new ArrayList<>(); } @@ -378,10 +397,10 @@ public OldMenuSectionCategoryItemsInner addPhotosItem(String photosItem) { return this; } - /** + /** * An array string for the item’s image URL links. Refer to FAQs for more details about [images](#section/Menu/What-are-the-recommended-formats-for-an-item-image). * @return photos - **/ + */ @javax.annotation.Nullable public List getPhotos() { return photos; @@ -392,15 +411,15 @@ public void setPhotos(List photos) { } - public OldMenuSectionCategoryItemsInner specialType(SpecialTypeEnum specialType) { + public MenuSectionCategoryItem specialType(SpecialTypeEnum specialType) { this.specialType = specialType; return this; } - /** + /** * The item's special Tag. Refer to FAQs for more details about [specialType](#section/Menu/What's-specialType). * @return specialType - **/ + */ @javax.annotation.Nullable public SpecialTypeEnum getSpecialType() { return specialType; @@ -411,15 +430,15 @@ public void setSpecialType(SpecialTypeEnum specialType) { } - public OldMenuSectionCategoryItemsInner taxable(Boolean taxable) { + public MenuSectionCategoryItem taxable(Boolean taxable) { this.taxable = taxable; return this; } - /** + /** * **For Indonesia only.** This field allows the configuration for an item to be marked as tax applicable, and marked item would then be included in a commercial invoice to consumers as per the government's regulations. * @return taxable - **/ + */ @javax.annotation.Nullable public Boolean getTaxable() { return taxable; @@ -430,15 +449,15 @@ public void setTaxable(Boolean taxable) { } - public OldMenuSectionCategoryItemsInner barcode(String barcode) { + public MenuSectionCategoryItem barcode(String barcode) { this.barcode = barcode; return this; } - /** + /** * The barcode Number (GTIN). Max 64 allowed. GTIN must be 8, 12, 13, 14 numeric digits. * @return barcode - **/ + */ @javax.annotation.Nullable public String getBarcode() { return barcode; @@ -449,15 +468,15 @@ public void setBarcode(String barcode) { } - public OldMenuSectionCategoryItemsInner maxStock(Integer maxStock) { + public MenuSectionCategoryItem maxStock(Integer maxStock) { this.maxStock = maxStock; return this; } - /** + /** * Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Empty value implies no limit. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. * @return maxStock - **/ + */ @javax.annotation.Nullable public Integer getMaxStock() { return maxStock; @@ -468,15 +487,15 @@ public void setMaxStock(Integer maxStock) { } - public OldMenuSectionCategoryItemsInner advancedPricing(AdvancedPricing advancedPricing) { + public MenuSectionCategoryItem advancedPricing(AdvancedPricing advancedPricing) { this.advancedPricing = advancedPricing; return this; } - /** + /** * Get advancedPricing * @return advancedPricing - **/ + */ @javax.annotation.Nullable public AdvancedPricing getAdvancedPricing() { return advancedPricing; @@ -487,15 +506,15 @@ public void setAdvancedPricing(AdvancedPricing advancedPricing) { } - public OldMenuSectionCategoryItemsInner purchasability(Purchasability purchasability) { + public MenuSectionCategoryItem purchasability(Purchasability purchasability) { this.purchasability = purchasability; return this; } - /** + /** * Get purchasability * @return purchasability - **/ + */ @javax.annotation.Nullable public Purchasability getPurchasability() { return purchasability; @@ -506,12 +525,12 @@ public void setPurchasability(Purchasability purchasability) { } - public OldMenuSectionCategoryItemsInner modifierGroups(List modifierGroups) { + public MenuSectionCategoryItem modifierGroups(List modifierGroups) { this.modifierGroups = modifierGroups; return this; } - public OldMenuSectionCategoryItemsInner addModifierGroupsItem(ModifierGroupsInner modifierGroupsItem) { + public MenuSectionCategoryItem addModifierGroupsItem(ModifierGroup modifierGroupsItem) { if (this.modifierGroups == null) { this.modifierGroups = new ArrayList<>(); } @@ -519,19 +538,63 @@ public OldMenuSectionCategoryItemsInner addModifierGroupsItem(ModifierGroupsInne return this; } - /** + /** * An array of the modifierGroup JSON objects. Max 30 allowed per item. Refer to [Modifier groups](#modifier-groups) for more information. * @return modifierGroups - **/ + */ @javax.annotation.Nullable - public List getModifierGroups() { + public List getModifierGroups() { return modifierGroups; } - public void setModifierGroups(List modifierGroups) { + public void setModifierGroups(List modifierGroups) { this.modifierGroups = modifierGroups; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSectionCategoryItem instance itself + */ + public MenuSectionCategoryItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -542,33 +605,34 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - OldMenuSectionCategoryItemsInner oldMenuSectionCategoryItemsInner = (OldMenuSectionCategoryItemsInner) o; - return Objects.equals(this.id, oldMenuSectionCategoryItemsInner.id) && - Objects.equals(this.name, oldMenuSectionCategoryItemsInner.name) && - Objects.equals(this.nameTranslation, oldMenuSectionCategoryItemsInner.nameTranslation) && - Objects.equals(this.availableStatus, oldMenuSectionCategoryItemsInner.availableStatus) && - Objects.equals(this.description, oldMenuSectionCategoryItemsInner.description) && - Objects.equals(this.descriptionTranslation, oldMenuSectionCategoryItemsInner.descriptionTranslation) && - Objects.equals(this.price, oldMenuSectionCategoryItemsInner.price) && - Objects.equals(this.photos, oldMenuSectionCategoryItemsInner.photos) && - Objects.equals(this.specialType, oldMenuSectionCategoryItemsInner.specialType) && - Objects.equals(this.taxable, oldMenuSectionCategoryItemsInner.taxable) && - Objects.equals(this.barcode, oldMenuSectionCategoryItemsInner.barcode) && - Objects.equals(this.maxStock, oldMenuSectionCategoryItemsInner.maxStock) && - Objects.equals(this.advancedPricing, oldMenuSectionCategoryItemsInner.advancedPricing) && - Objects.equals(this.purchasability, oldMenuSectionCategoryItemsInner.purchasability) && - Objects.equals(this.modifierGroups, oldMenuSectionCategoryItemsInner.modifierGroups); + MenuSectionCategoryItem menuSectionCategoryItem = (MenuSectionCategoryItem) o; + return Objects.equals(this.id, menuSectionCategoryItem.id) && + Objects.equals(this.name, menuSectionCategoryItem.name) && + Objects.equals(this.nameTranslation, menuSectionCategoryItem.nameTranslation) && + Objects.equals(this.availableStatus, menuSectionCategoryItem.availableStatus) && + Objects.equals(this.description, menuSectionCategoryItem.description) && + Objects.equals(this.descriptionTranslation, menuSectionCategoryItem.descriptionTranslation) && + Objects.equals(this.price, menuSectionCategoryItem.price) && + Objects.equals(this.photos, menuSectionCategoryItem.photos) && + Objects.equals(this.specialType, menuSectionCategoryItem.specialType) && + Objects.equals(this.taxable, menuSectionCategoryItem.taxable) && + Objects.equals(this.barcode, menuSectionCategoryItem.barcode) && + Objects.equals(this.maxStock, menuSectionCategoryItem.maxStock) && + Objects.equals(this.advancedPricing, menuSectionCategoryItem.advancedPricing) && + Objects.equals(this.purchasability, menuSectionCategoryItem.purchasability) && + Objects.equals(this.modifierGroups, menuSectionCategoryItem.modifierGroups)&& + Objects.equals(this.additionalProperties, menuSectionCategoryItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, nameTranslation, availableStatus, description, descriptionTranslation, price, photos, specialType, taxable, barcode, maxStock, advancedPricing, purchasability, modifierGroups); + return Objects.hash(id, name, nameTranslation, availableStatus, description, descriptionTranslation, price, photos, specialType, taxable, barcode, maxStock, advancedPricing, purchasability, modifierGroups, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class OldMenuSectionCategoryItemsInner {\n"); + sb.append("class MenuSectionCategoryItem {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" nameTranslation: ").append(toIndentedString(nameTranslation)).append("\n"); @@ -584,6 +648,7 @@ public String toString() { sb.append(" advancedPricing: ").append(toIndentedString(advancedPricing)).append("\n"); sb.append(" purchasability: ").append(toIndentedString(purchasability)).append("\n"); sb.append(" modifierGroups: ").append(toIndentedString(modifierGroups)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -630,29 +695,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("price"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OldMenuSectionCategoryItemsInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSectionCategoryItem + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!OldMenuSectionCategoryItemsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in OldMenuSectionCategoryItemsInner is not found in the empty JSON string", OldMenuSectionCategoryItemsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OldMenuSectionCategoryItemsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OldMenuSectionCategoryItemsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!MenuSectionCategoryItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSectionCategoryItem is not found in the empty JSON string", MenuSectionCategoryItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : OldMenuSectionCategoryItemsInner.openapiRequiredFields) { + for (String requiredField : MenuSectionCategoryItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -664,10 +721,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // validate the optional field `nameTranslation` - if (jsonObj.get("nameTranslation") != null && !jsonObj.get("nameTranslation").isJsonNull()) { - OldMenuSectionCategoryItemsInnerNameTranslation.validateJsonElement(jsonObj.get("nameTranslation")); - } if (!jsonObj.get("availableStatus").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `availableStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("availableStatus").toString())); } @@ -676,10 +729,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); } - // validate the optional field `descriptionTranslation` - if (jsonObj.get("descriptionTranslation") != null && !jsonObj.get("descriptionTranslation").isJsonNull()) { - OldMenuSectionCategoryItemsInnerDescriptionTranslation.validateJsonElement(jsonObj.get("descriptionTranslation")); - } // ensure the optional json data is an array if present if (jsonObj.get("photos") != null && !jsonObj.get("photos").isJsonNull() && !jsonObj.get("photos").isJsonArray()) { throw new IllegalArgumentException(String.format("Expected the field `photos` to be an array in the JSON string but got `%s`", jsonObj.get("photos").toString())); @@ -712,7 +761,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `modifierGroups` (array) for (int i = 0; i < jsonArraymodifierGroups.size(); i++) { - ModifierGroupsInner.validateJsonElement(jsonArraymodifierGroups.get(i)); + ModifierGroup.validateJsonElement(jsonArraymodifierGroups.get(i)); }; } } @@ -722,47 +771,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!OldMenuSectionCategoryItemsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'OldMenuSectionCategoryItemsInner' and its subtypes + if (!MenuSectionCategoryItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSectionCategoryItem' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(OldMenuSectionCategoryItemsInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSectionCategoryItem.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, OldMenuSectionCategoryItemsInner value) throws IOException { + public void write(JsonWriter out, MenuSectionCategoryItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public OldMenuSectionCategoryItemsInner read(JsonReader in) throws IOException { + public MenuSectionCategoryItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSectionCategoryItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OldMenuSectionCategoryItemsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of OldMenuSectionCategoryItemsInner - * @throws IOException if the JSON string is invalid with respect to OldMenuSectionCategoryItemsInner - */ - public static OldMenuSectionCategoryItemsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, OldMenuSectionCategoryItemsInner.class); + /** + * Create an instance of MenuSectionCategoryItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSectionCategoryItem + * @throws IOException if the JSON string is invalid with respect to MenuSectionCategoryItem + */ + public static MenuSectionCategoryItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSectionCategoryItem.class); } - /** - * Convert an instance of OldMenuSectionCategoryItemsInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuSectionCategoryItem to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/MenuSyncFail.java b/src/main/java/com/grabfood/client/model/MenuSyncFail.java index b76893a..b29dc35 100644 --- a/src/main/java/com/grabfood/client/model/MenuSyncFail.java +++ b/src/main/java/com/grabfood/client/model/MenuSyncFail.java @@ -22,9 +22,9 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.SyncFail; +import com.grabfood.client.model.MenuSyncFailCategory; +import com.grabfood.client.model.MenuSyncFailServiceHours; import java.io.IOException; -import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,195 +53,166 @@ import com.grabfood.client.JSON; /** - * + * MenuSyncFail */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class MenuSyncFail { - public static final String SERIALIZED_NAME_CREATED_TIME = "createdTime"; - @SerializedName(SERIALIZED_NAME_CREATED_TIME) - private OffsetDateTime createdTime; - - public static final String SERIALIZED_NAME_UPDATED_TIME = "updatedTime"; - @SerializedName(SERIALIZED_NAME_UPDATED_TIME) - private OffsetDateTime updatedTime; - - /** - * The status code for this request. See [Menu sync response statuses](#section/Menu-sync-response-statuses) for more information. - */ - @JsonAdapter(CodeEnum.Adapter.class) - public enum CodeEnum { - FAILED("Failed"); - - private String value; - - CodeEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static CodeEnum fromValue(String value) { - for (CodeEnum b : CodeEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final CodeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public CodeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return CodeEnum.fromValue(value); - } - } - - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - String value = jsonElement.getAsString(); - CodeEnum.fromValue(value); - } - } - - public static final String SERIALIZED_NAME_CODE = "code"; - @SerializedName(SERIALIZED_NAME_CODE) - private CodeEnum code; + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; public static final String SERIALIZED_NAME_ERRORS = "errors"; @SerializedName(SERIALIZED_NAME_ERRORS) private List errors = new ArrayList<>(); - public static final String SERIALIZED_NAME_SECTIONS = "sections"; - @SerializedName(SERIALIZED_NAME_SECTIONS) - private List sections = new ArrayList<>(); + public static final String SERIALIZED_NAME_SERVICE_HOURS = "serviceHours"; + @SerializedName(SERIALIZED_NAME_SERVICE_HOURS) + private MenuSyncFailServiceHours serviceHours; + + public static final String SERIALIZED_NAME_CATEGORIES = "categories"; + @SerializedName(SERIALIZED_NAME_CATEGORIES) + private List categories = new ArrayList<>(); public MenuSyncFail() { } - public MenuSyncFail createdTime(OffsetDateTime createdTime) { - this.createdTime = createdTime; + public MenuSyncFail id(String id) { + this.id = id; return this; } - /** - * The Unix time the specified menu was created in GrabFood's database. - * @return createdTime - **/ + /** + * Get id + * @return id + */ @javax.annotation.Nullable - public OffsetDateTime getCreatedTime() { - return createdTime; + public String getId() { + return id; } - public void setCreatedTime(OffsetDateTime createdTime) { - this.createdTime = createdTime; + public void setId(String id) { + this.id = id; } - public MenuSyncFail updatedTime(OffsetDateTime updatedTime) { - this.updatedTime = updatedTime; + public MenuSyncFail errors(List errors) { + this.errors = errors; + return this; + } + + public MenuSyncFail addErrorsItem(String errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); return this; } - /** - * The Unix time the specified menu was created in GrabFood's database. - * @return updatedTime - **/ + /** + * An array of strings of error message. + * @return errors + */ @javax.annotation.Nullable - public OffsetDateTime getUpdatedTime() { - return updatedTime; + public List getErrors() { + return errors; } - public void setUpdatedTime(OffsetDateTime updatedTime) { - this.updatedTime = updatedTime; + public void setErrors(List errors) { + this.errors = errors; } - public MenuSyncFail code(CodeEnum code) { - this.code = code; + public MenuSyncFail serviceHours(MenuSyncFailServiceHours serviceHours) { + this.serviceHours = serviceHours; return this; } - /** - * The status code for this request. See [Menu sync response statuses](#section/Menu-sync-response-statuses) for more information. - * @return code - **/ + /** + * Get serviceHours + * @return serviceHours + */ @javax.annotation.Nullable - public CodeEnum getCode() { - return code; + public MenuSyncFailServiceHours getServiceHours() { + return serviceHours; } - public void setCode(CodeEnum code) { - this.code = code; + public void setServiceHours(MenuSyncFailServiceHours serviceHours) { + this.serviceHours = serviceHours; } - public MenuSyncFail errors(List errors) { - this.errors = errors; + public MenuSyncFail categories(List categories) { + this.categories = categories; return this; } - public MenuSyncFail addErrorsItem(String errorsItem) { - if (this.errors == null) { - this.errors = new ArrayList<>(); + public MenuSyncFail addCategoriesItem(MenuSyncFailCategory categoriesItem) { + if (this.categories == null) { + this.categories = new ArrayList<>(); } - this.errors.add(errorsItem); + this.categories.add(categoriesItem); return this; } - /** - * An array of strings of error message. - * @return errors - **/ + /** + * Get categories + * @return categories + */ @javax.annotation.Nullable - public List getErrors() { - return errors; + public List getCategories() { + return categories; } - public void setErrors(List errors) { - this.errors = errors; + public void setCategories(List categories) { + this.categories = categories; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; - public MenuSyncFail sections(List sections) { - this.sections = sections; - return this; - } - - public MenuSyncFail addSectionsItem(SyncFail sectionsItem) { - if (this.sections == null) { - this.sections = new ArrayList<>(); + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSyncFail instance itself + */ + public MenuSyncFail putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); } - this.sections.add(sectionsItem); + this.additionalProperties.put(key, value); return this; } - /** - * Get sections - * @return sections - **/ - @javax.annotation.Nullable - public List getSections() { - return sections; + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; } - public void setSections(List sections) { - this.sections = sections; + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); } - @Override public boolean equals(Object o) { if (this == o) { @@ -252,27 +222,27 @@ public boolean equals(Object o) { return false; } MenuSyncFail menuSyncFail = (MenuSyncFail) o; - return Objects.equals(this.createdTime, menuSyncFail.createdTime) && - Objects.equals(this.updatedTime, menuSyncFail.updatedTime) && - Objects.equals(this.code, menuSyncFail.code) && + return Objects.equals(this.id, menuSyncFail.id) && Objects.equals(this.errors, menuSyncFail.errors) && - Objects.equals(this.sections, menuSyncFail.sections); + Objects.equals(this.serviceHours, menuSyncFail.serviceHours) && + Objects.equals(this.categories, menuSyncFail.categories)&& + Objects.equals(this.additionalProperties, menuSyncFail.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdTime, updatedTime, code, errors, sections); + return Objects.hash(id, errors, serviceHours, categories, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class MenuSyncFail {\n"); - sb.append(" createdTime: ").append(toIndentedString(createdTime)).append("\n"); - sb.append(" updatedTime: ").append(toIndentedString(updatedTime)).append("\n"); - sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); - sb.append(" sections: ").append(toIndentedString(sections)).append("\n"); + sb.append(" serviceHours: ").append(toIndentedString(serviceHours)).append("\n"); + sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -295,59 +265,50 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); - openapiFields.add("createdTime"); - openapiFields.add("updatedTime"); - openapiFields.add("code"); + openapiFields.add("id"); openapiFields.add("errors"); - openapiFields.add("sections"); + openapiFields.add("serviceHours"); + openapiFields.add("categories"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MenuSyncFail - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSyncFail + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MenuSyncFail.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncFail is not found in the empty JSON string", MenuSyncFail.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MenuSyncFail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MenuSyncFail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("code") != null && !jsonObj.get("code").isJsonNull()) && !jsonObj.get("code").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); - } - // validate the optional field `code` - if (jsonObj.get("code") != null && !jsonObj.get("code").isJsonNull()) { - CodeEnum.validateJsonElement(jsonObj.get("code")); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); } // ensure the optional json data is an array if present if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); } - if (jsonObj.get("sections") != null && !jsonObj.get("sections").isJsonNull()) { - JsonArray jsonArraysections = jsonObj.getAsJsonArray("sections"); - if (jsonArraysections != null) { + // validate the optional field `serviceHours` + if (jsonObj.get("serviceHours") != null && !jsonObj.get("serviceHours").isJsonNull()) { + MenuSyncFailServiceHours.validateJsonElement(jsonObj.get("serviceHours")); + } + if (jsonObj.get("categories") != null && !jsonObj.get("categories").isJsonNull()) { + JsonArray jsonArraycategories = jsonObj.getAsJsonArray("categories"); + if (jsonArraycategories != null) { // ensure the json data is an array - if (!jsonObj.get("sections").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `sections` to be an array in the JSON string but got `%s`", jsonObj.get("sections").toString())); + if (!jsonObj.get("categories").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); } - // validate the optional field `sections` (array) - for (int i = 0; i < jsonArraysections.size(); i++) { - SyncFail.validateJsonElement(jsonArraysections.get(i)); + // validate the optional field `categories` (array) + for (int i = 0; i < jsonArraycategories.size(); i++) { + MenuSyncFailCategory.validateJsonElement(jsonArraycategories.get(i)); }; } } @@ -368,6 +329,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MenuSyncFail value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -375,29 +358,50 @@ public void write(JsonWriter out, MenuSyncFail value) throws IOException { public MenuSyncFail read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSyncFail instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of MenuSyncFail given an JSON string - * - * @param jsonString JSON string - * @return An instance of MenuSyncFail - * @throws IOException if the JSON string is invalid with respect to MenuSyncFail - */ + /** + * Create an instance of MenuSyncFail given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSyncFail + * @throws IOException if the JSON string is invalid with respect to MenuSyncFail + */ public static MenuSyncFail fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, MenuSyncFail.class); } - /** - * Convert an instance of MenuSyncFail to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuSyncFail to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/MenuSyncFailCategory.java b/src/main/java/com/grabfood/client/model/MenuSyncFailCategory.java new file mode 100644 index 0000000..d9ad493 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/MenuSyncFailCategory.java @@ -0,0 +1,378 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.grabfood.client.model.MenuSyncFailItem; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * MenuSyncFailCategory + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSyncFailCategory { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private List errors = new ArrayList<>(); + + public static final String SERIALIZED_NAME_ITEMS = "items"; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + + public MenuSyncFailCategory() { + } + + public MenuSyncFailCategory id(String id) { + this.id = id; + return this; + } + + /** + * The category's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. + * @return id + */ + @javax.annotation.Nullable + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public MenuSyncFailCategory errors(List errors) { + this.errors = errors; + return this; + } + + public MenuSyncFailCategory addErrorsItem(String errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * An array of strings of error message. + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } + + + public MenuSyncFailCategory items(List items) { + this.items = items; + return this; + } + + public MenuSyncFailCategory addItemsItem(MenuSyncFailItem itemsItem) { + if (this.items == null) { + this.items = new ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. + * @return items + */ + @javax.annotation.Nullable + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSyncFailCategory instance itself + */ + public MenuSyncFailCategory putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MenuSyncFailCategory menuSyncFailCategory = (MenuSyncFailCategory) o; + return Objects.equals(this.id, menuSyncFailCategory.id) && + Objects.equals(this.errors, menuSyncFailCategory.errors) && + Objects.equals(this.items, menuSyncFailCategory.items)&& + Objects.equals(this.additionalProperties, menuSyncFailCategory.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, errors, items, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MenuSyncFailCategory {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("errors"); + openapiFields.add("items"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSyncFailCategory + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MenuSyncFailCategory.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncFailCategory is not found in the empty JSON string", MenuSyncFailCategory.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + if (jsonObj.get("items") != null && !jsonObj.get("items").isJsonNull()) { + JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); + if (jsonArrayitems != null) { + // ensure the json data is an array + if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); + } + + // validate the optional field `items` (array) + for (int i = 0; i < jsonArrayitems.size(); i++) { + MenuSyncFailItem.validateJsonElement(jsonArrayitems.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MenuSyncFailCategory.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSyncFailCategory' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSyncFailCategory.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MenuSyncFailCategory value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MenuSyncFailCategory read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSyncFailCategory instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MenuSyncFailCategory given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSyncFailCategory + * @throws IOException if the JSON string is invalid with respect to MenuSyncFailCategory + */ + public static MenuSyncFailCategory fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSyncFailCategory.class); + } + + /** + * Convert an instance of MenuSyncFailCategory to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/MenuSyncFailItem.java b/src/main/java/com/grabfood/client/model/MenuSyncFailItem.java new file mode 100644 index 0000000..6dda43d --- /dev/null +++ b/src/main/java/com/grabfood/client/model/MenuSyncFailItem.java @@ -0,0 +1,378 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.grabfood.client.model.MenuSyncFailModifierGroup; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * MenuSyncFailItem + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSyncFailItem { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private List errors = new ArrayList<>(); + + public static final String SERIALIZED_NAME_MODIFIER_GROUPS = "modifierGroups"; + @SerializedName(SERIALIZED_NAME_MODIFIER_GROUPS) + private List modifierGroups = new ArrayList<>(); + + public MenuSyncFailItem() { + } + + public MenuSyncFailItem id(String id) { + this.id = id; + return this; + } + + /** + * The item's ID in the partner system. + * @return id + */ + @javax.annotation.Nullable + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public MenuSyncFailItem errors(List errors) { + this.errors = errors; + return this; + } + + public MenuSyncFailItem addErrorsItem(String errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * An array of strings of error message. + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } + + + public MenuSyncFailItem modifierGroups(List modifierGroups) { + this.modifierGroups = modifierGroups; + return this; + } + + public MenuSyncFailItem addModifierGroupsItem(MenuSyncFailModifierGroup modifierGroupsItem) { + if (this.modifierGroups == null) { + this.modifierGroups = new ArrayList<>(); + } + this.modifierGroups.add(modifierGroupsItem); + return this; + } + + /** + * Get modifierGroups + * @return modifierGroups + */ + @javax.annotation.Nullable + public List getModifierGroups() { + return modifierGroups; + } + + public void setModifierGroups(List modifierGroups) { + this.modifierGroups = modifierGroups; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSyncFailItem instance itself + */ + public MenuSyncFailItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MenuSyncFailItem menuSyncFailItem = (MenuSyncFailItem) o; + return Objects.equals(this.id, menuSyncFailItem.id) && + Objects.equals(this.errors, menuSyncFailItem.errors) && + Objects.equals(this.modifierGroups, menuSyncFailItem.modifierGroups)&& + Objects.equals(this.additionalProperties, menuSyncFailItem.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, errors, modifierGroups, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MenuSyncFailItem {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" modifierGroups: ").append(toIndentedString(modifierGroups)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("errors"); + openapiFields.add("modifierGroups"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSyncFailItem + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MenuSyncFailItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncFailItem is not found in the empty JSON string", MenuSyncFailItem.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + if (jsonObj.get("modifierGroups") != null && !jsonObj.get("modifierGroups").isJsonNull()) { + JsonArray jsonArraymodifierGroups = jsonObj.getAsJsonArray("modifierGroups"); + if (jsonArraymodifierGroups != null) { + // ensure the json data is an array + if (!jsonObj.get("modifierGroups").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `modifierGroups` to be an array in the JSON string but got `%s`", jsonObj.get("modifierGroups").toString())); + } + + // validate the optional field `modifierGroups` (array) + for (int i = 0; i < jsonArraymodifierGroups.size(); i++) { + MenuSyncFailModifierGroup.validateJsonElement(jsonArraymodifierGroups.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MenuSyncFailItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSyncFailItem' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSyncFailItem.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MenuSyncFailItem value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MenuSyncFailItem read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSyncFailItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MenuSyncFailItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSyncFailItem + * @throws IOException if the JSON string is invalid with respect to MenuSyncFailItem + */ + public static MenuSyncFailItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSyncFailItem.class); + } + + /** + * Convert an instance of MenuSyncFailItem to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/MenuSyncFailModifier.java b/src/main/java/com/grabfood/client/model/MenuSyncFailModifier.java new file mode 100644 index 0000000..5134a00 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/MenuSyncFailModifier.java @@ -0,0 +1,329 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * MenuSyncFailModifier + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSyncFailModifier { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private List errors = new ArrayList<>(); + + public MenuSyncFailModifier() { + } + + public MenuSyncFailModifier id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public MenuSyncFailModifier errors(List errors) { + this.errors = errors; + return this; + } + + public MenuSyncFailModifier addErrorsItem(String errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * An array of strings of error message. + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSyncFailModifier instance itself + */ + public MenuSyncFailModifier putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MenuSyncFailModifier menuSyncFailModifier = (MenuSyncFailModifier) o; + return Objects.equals(this.id, menuSyncFailModifier.id) && + Objects.equals(this.errors, menuSyncFailModifier.errors)&& + Objects.equals(this.additionalProperties, menuSyncFailModifier.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, errors, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MenuSyncFailModifier {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("errors"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSyncFailModifier + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MenuSyncFailModifier.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncFailModifier is not found in the empty JSON string", MenuSyncFailModifier.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MenuSyncFailModifier.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSyncFailModifier' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSyncFailModifier.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MenuSyncFailModifier value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MenuSyncFailModifier read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSyncFailModifier instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MenuSyncFailModifier given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSyncFailModifier + * @throws IOException if the JSON string is invalid with respect to MenuSyncFailModifier + */ + public static MenuSyncFailModifier fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSyncFailModifier.class); + } + + /** + * Convert an instance of MenuSyncFailModifier to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/MenuSyncFailModifierGroup.java b/src/main/java/com/grabfood/client/model/MenuSyncFailModifierGroup.java new file mode 100644 index 0000000..ea24556 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/MenuSyncFailModifierGroup.java @@ -0,0 +1,378 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.grabfood.client.model.MenuSyncFailModifier; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * MenuSyncFailModifierGroup + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSyncFailModifierGroup { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private List errors = new ArrayList<>(); + + public static final String SERIALIZED_NAME_MODIFIERS = "modifiers"; + @SerializedName(SERIALIZED_NAME_MODIFIERS) + private List modifiers = new ArrayList<>(); + + public MenuSyncFailModifierGroup() { + } + + public MenuSyncFailModifierGroup id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + */ + @javax.annotation.Nullable + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public MenuSyncFailModifierGroup errors(List errors) { + this.errors = errors; + return this; + } + + public MenuSyncFailModifierGroup addErrorsItem(String errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * An array of strings of error message. + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } + + + public MenuSyncFailModifierGroup modifiers(List modifiers) { + this.modifiers = modifiers; + return this; + } + + public MenuSyncFailModifierGroup addModifiersItem(MenuSyncFailModifier modifiersItem) { + if (this.modifiers == null) { + this.modifiers = new ArrayList<>(); + } + this.modifiers.add(modifiersItem); + return this; + } + + /** + * Get modifiers + * @return modifiers + */ + @javax.annotation.Nullable + public List getModifiers() { + return modifiers; + } + + public void setModifiers(List modifiers) { + this.modifiers = modifiers; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSyncFailModifierGroup instance itself + */ + public MenuSyncFailModifierGroup putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MenuSyncFailModifierGroup menuSyncFailModifierGroup = (MenuSyncFailModifierGroup) o; + return Objects.equals(this.id, menuSyncFailModifierGroup.id) && + Objects.equals(this.errors, menuSyncFailModifierGroup.errors) && + Objects.equals(this.modifiers, menuSyncFailModifierGroup.modifiers)&& + Objects.equals(this.additionalProperties, menuSyncFailModifierGroup.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, errors, modifiers, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MenuSyncFailModifierGroup {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" modifiers: ").append(toIndentedString(modifiers)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("errors"); + openapiFields.add("modifiers"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSyncFailModifierGroup + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MenuSyncFailModifierGroup.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncFailModifierGroup is not found in the empty JSON string", MenuSyncFailModifierGroup.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + if (jsonObj.get("modifiers") != null && !jsonObj.get("modifiers").isJsonNull()) { + JsonArray jsonArraymodifiers = jsonObj.getAsJsonArray("modifiers"); + if (jsonArraymodifiers != null) { + // ensure the json data is an array + if (!jsonObj.get("modifiers").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `modifiers` to be an array in the JSON string but got `%s`", jsonObj.get("modifiers").toString())); + } + + // validate the optional field `modifiers` (array) + for (int i = 0; i < jsonArraymodifiers.size(); i++) { + MenuSyncFailModifier.validateJsonElement(jsonArraymodifiers.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MenuSyncFailModifierGroup.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSyncFailModifierGroup' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSyncFailModifierGroup.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MenuSyncFailModifierGroup value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MenuSyncFailModifierGroup read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSyncFailModifierGroup instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MenuSyncFailModifierGroup given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSyncFailModifierGroup + * @throws IOException if the JSON string is invalid with respect to MenuSyncFailModifierGroup + */ + public static MenuSyncFailModifierGroup fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSyncFailModifierGroup.class); + } + + /** + * Convert an instance of MenuSyncFailModifierGroup to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/MenuSyncFailServiceHours.java b/src/main/java/com/grabfood/client/model/MenuSyncFailServiceHours.java new file mode 100644 index 0000000..b5ccb70 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/MenuSyncFailServiceHours.java @@ -0,0 +1,300 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * MenuSyncFailServiceHours + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSyncFailServiceHours { + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + private List errors = new ArrayList<>(); + + public MenuSyncFailServiceHours() { + } + + public MenuSyncFailServiceHours errors(List errors) { + this.errors = errors; + return this; + } + + public MenuSyncFailServiceHours addErrorsItem(String errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * An array of strings of error message. + * @return errors + */ + @javax.annotation.Nullable + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSyncFailServiceHours instance itself + */ + public MenuSyncFailServiceHours putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MenuSyncFailServiceHours menuSyncFailServiceHours = (MenuSyncFailServiceHours) o; + return Objects.equals(this.errors, menuSyncFailServiceHours.errors)&& + Objects.equals(this.additionalProperties, menuSyncFailServiceHours.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(errors, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MenuSyncFailServiceHours {\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("errors"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSyncFailServiceHours + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!MenuSyncFailServiceHours.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncFailServiceHours is not found in the empty JSON string", MenuSyncFailServiceHours.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!MenuSyncFailServiceHours.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSyncFailServiceHours' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSyncFailServiceHours.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, MenuSyncFailServiceHours value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public MenuSyncFailServiceHours read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSyncFailServiceHours instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of MenuSyncFailServiceHours given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSyncFailServiceHours + * @throws IOException if the JSON string is invalid with respect to MenuSyncFailServiceHours + */ + public static MenuSyncFailServiceHours fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSyncFailServiceHours.class); + } + + /** + * Convert an instance of MenuSyncFailServiceHours to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/MenuSyncSuccess.java b/src/main/java/com/grabfood/client/model/MenuSyncResponse.java similarity index 58% rename from src/main/java/com/grabfood/client/model/MenuSyncSuccess.java rename to src/main/java/com/grabfood/client/model/MenuSyncResponse.java index f5b8374..6f1c57c 100644 --- a/src/main/java/com/grabfood/client/model/MenuSyncSuccess.java +++ b/src/main/java/com/grabfood/client/model/MenuSyncResponse.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.SyncFail; +import com.grabfood.client.model.MenuSyncFail; import java.io.IOException; import java.time.OffsetDateTime; import java.util.ArrayList; @@ -45,7 +45,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -57,8 +56,8 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class MenuSyncSuccess { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class MenuSyncResponse { public static final String SERIALIZED_NAME_CREATED_TIME = "createdTime"; @SerializedName(SERIALIZED_NAME_CREATED_TIME) private OffsetDateTime createdTime; @@ -74,9 +73,11 @@ public class MenuSyncSuccess { public enum CodeEnum { SUCCESS("Success"), - PARTIALSUCCESS("PartialSuccess"), + PARTIAL_SUCCESS("PartialSuccess"), - INQUEUING("InQueuing"); + IN_QUEUING("InQueuing"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -99,7 +100,7 @@ public static CodeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -131,20 +132,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_SECTIONS = "sections"; @SerializedName(SERIALIZED_NAME_SECTIONS) - private List sections; + private List sections; - public MenuSyncSuccess() { + public MenuSyncResponse() { } - public MenuSyncSuccess createdTime(OffsetDateTime createdTime) { + public MenuSyncResponse createdTime(OffsetDateTime createdTime) { this.createdTime = createdTime; return this; } - /** + /** * The Unix time the specified menu was created in GrabFood's database. * @return createdTime - **/ + */ @javax.annotation.Nonnull public OffsetDateTime getCreatedTime() { return createdTime; @@ -155,15 +156,15 @@ public void setCreatedTime(OffsetDateTime createdTime) { } - public MenuSyncSuccess updatedTime(OffsetDateTime updatedTime) { + public MenuSyncResponse updatedTime(OffsetDateTime updatedTime) { this.updatedTime = updatedTime; return this; } - /** + /** * The Unix time the specified menu was created in GrabFood's database. * @return updatedTime - **/ + */ @javax.annotation.Nonnull public OffsetDateTime getUpdatedTime() { return updatedTime; @@ -174,15 +175,15 @@ public void setUpdatedTime(OffsetDateTime updatedTime) { } - public MenuSyncSuccess code(CodeEnum code) { + public MenuSyncResponse code(CodeEnum code) { this.code = code; return this; } - /** + /** * The status code for this request. See [Menu sync response statuses](#section/Menu-sync-response-statuses) for more information. * @return code - **/ + */ @javax.annotation.Nonnull public CodeEnum getCode() { return code; @@ -193,12 +194,12 @@ public void setCode(CodeEnum code) { } - public MenuSyncSuccess errors(List errors) { + public MenuSyncResponse errors(List errors) { this.errors = errors; return this; } - public MenuSyncSuccess addErrorsItem(String errorsItem) { + public MenuSyncResponse addErrorsItem(String errorsItem) { if (this.errors == null) { this.errors = new ArrayList<>(); } @@ -206,10 +207,10 @@ public MenuSyncSuccess addErrorsItem(String errorsItem) { return this; } - /** + /** * An array of strings of error message. * @return errors - **/ + */ @javax.annotation.Nullable public List getErrors() { return errors; @@ -220,12 +221,12 @@ public void setErrors(List errors) { } - public MenuSyncSuccess sections(List sections) { + public MenuSyncResponse sections(List sections) { this.sections = sections; return this; } - public MenuSyncSuccess addSectionsItem(SyncFail sectionsItem) { + public MenuSyncResponse addSectionsItem(MenuSyncFail sectionsItem) { if (this.sections == null) { this.sections = new ArrayList<>(); } @@ -233,19 +234,63 @@ public MenuSyncSuccess addSectionsItem(SyncFail sectionsItem) { return this; } - /** + /** * Get sections * @return sections - **/ + */ @javax.annotation.Nullable - public List getSections() { + public List getSections() { return sections; } - public void setSections(List sections) { + public void setSections(List sections) { this.sections = sections; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSyncResponse instance itself + */ + public MenuSyncResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -256,12 +301,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - MenuSyncSuccess menuSyncSuccess = (MenuSyncSuccess) o; - return Objects.equals(this.createdTime, menuSyncSuccess.createdTime) && - Objects.equals(this.updatedTime, menuSyncSuccess.updatedTime) && - Objects.equals(this.code, menuSyncSuccess.code) && - Objects.equals(this.errors, menuSyncSuccess.errors) && - Objects.equals(this.sections, menuSyncSuccess.sections); + MenuSyncResponse menuSyncResponse = (MenuSyncResponse) o; + return Objects.equals(this.createdTime, menuSyncResponse.createdTime) && + Objects.equals(this.updatedTime, menuSyncResponse.updatedTime) && + Objects.equals(this.code, menuSyncResponse.code) && + Objects.equals(this.errors, menuSyncResponse.errors) && + Objects.equals(this.sections, menuSyncResponse.sections)&& + Objects.equals(this.additionalProperties, menuSyncResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -270,7 +316,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(createdTime, updatedTime, code, errors, sections); + return Objects.hash(createdTime, updatedTime, code, errors, sections, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -283,12 +329,13 @@ private static int hashCodeNullable(JsonNullable a) { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class MenuSyncSuccess {\n"); + sb.append("class MenuSyncResponse {\n"); sb.append(" createdTime: ").append(toIndentedString(createdTime)).append("\n"); sb.append(" updatedTime: ").append(toIndentedString(updatedTime)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" sections: ").append(toIndentedString(sections)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -324,29 +371,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("code"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MenuSyncSuccess - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSyncResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!MenuSyncSuccess.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncSuccess is not found in the empty JSON string", MenuSyncSuccess.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MenuSyncSuccess.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MenuSyncSuccess` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!MenuSyncResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncResponse is not found in the empty JSON string", MenuSyncResponse.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : MenuSyncSuccess.openapiRequiredFields) { + for (String requiredField : MenuSyncResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -371,7 +410,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `sections` (array) for (int i = 0; i < jsonArraysections.size(); i++) { - SyncFail.validateJsonElement(jsonArraysections.get(i)); + MenuSyncFail.validateJsonElement(jsonArraysections.get(i)); }; } } @@ -381,47 +420,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!MenuSyncSuccess.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'MenuSyncSuccess' and its subtypes + if (!MenuSyncResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'MenuSyncResponse' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(MenuSyncSuccess.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(MenuSyncResponse.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, MenuSyncSuccess value) throws IOException { + public void write(JsonWriter out, MenuSyncResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public MenuSyncSuccess read(JsonReader in) throws IOException { + public MenuSyncResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSyncResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of MenuSyncSuccess given an JSON string - * - * @param jsonString JSON string - * @return An instance of MenuSyncSuccess - * @throws IOException if the JSON string is invalid with respect to MenuSyncSuccess - */ - public static MenuSyncSuccess fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, MenuSyncSuccess.class); + /** + * Create an instance of MenuSyncResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSyncResponse + * @throws IOException if the JSON string is invalid with respect to MenuSyncResponse + */ + public static MenuSyncResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, MenuSyncResponse.class); } - /** - * Convert an instance of MenuSyncSuccess to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuSyncResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/MenuSyncWebhookRequest.java b/src/main/java/com/grabfood/client/model/MenuSyncWebhookRequest.java index 298a8b7..4badb88 100644 --- a/src/main/java/com/grabfood/client/model/MenuSyncWebhookRequest.java +++ b/src/main/java/com/grabfood/client/model/MenuSyncWebhookRequest.java @@ -42,7 +42,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,7 +53,7 @@ /** * This request pushes the state of a menu sync operation. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class MenuSyncWebhookRequest { public static final String SERIALIZED_NAME_REQUEST_I_D = "requestID"; @SerializedName(SERIALIZED_NAME_REQUEST_I_D) @@ -87,7 +86,9 @@ public enum StatusEnum { SUCCESS("SUCCESS"), - FAILED("FAILED"); + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -110,7 +111,7 @@ public static StatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -148,10 +149,10 @@ public MenuSyncWebhookRequest requestID(String requestID) { return this; } - /** + /** * An universally unique identifier (UUID) string. Used to uniquely identify a webhook request. Partners should use this value to distinguish between different webhook requests. If two requests contain the same requestID, only the first request should be considered and later requests **must** be ignored or discarded. * @return requestID - **/ + */ @javax.annotation.Nullable public String getRequestID() { return requestID; @@ -167,10 +168,10 @@ public MenuSyncWebhookRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -186,10 +187,10 @@ public MenuSyncWebhookRequest partnerMerchantID(String partnerMerchantID) { return this; } - /** + /** * The merchant's ID that is on the partner's database. * @return partnerMerchantID - **/ + */ @javax.annotation.Nullable public String getPartnerMerchantID() { return partnerMerchantID; @@ -205,10 +206,10 @@ public MenuSyncWebhookRequest jobID(String jobID) { return this; } - /** + /** * An UUID string. Uniquely identifies a menu sync job. This can be found from the [Menu Update Notification](#tag/update-menu-noti) API response header. * @return jobID - **/ + */ @javax.annotation.Nullable public String getJobID() { return jobID; @@ -224,10 +225,10 @@ public MenuSyncWebhookRequest updatedAt(String updatedAt) { return this; } - /** + /** * Indicates the time of menu sync status change. This is based on ISO_8601/RFC3339. For example: `2022-07-29T15:55:59Z`. * @return updatedAt - **/ + */ @javax.annotation.Nullable public String getUpdatedAt() { return updatedAt; @@ -243,10 +244,10 @@ public MenuSyncWebhookRequest status(StatusEnum status) { return this; } - /** + /** * Indicates the state of the menu sync job. * @return status - **/ + */ @javax.annotation.Nullable public StatusEnum getStatus() { return status; @@ -270,10 +271,10 @@ public MenuSyncWebhookRequest addErrorsItem(String errorsItem) { return this; } - /** + /** * A string array of errors that occurred during processing. This array is empty if the status is not `FAILED`. * @return errors - **/ + */ @javax.annotation.Nullable public List getErrors() { return errors; @@ -283,6 +284,50 @@ public void setErrors(List errors) { this.errors = errors; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MenuSyncWebhookRequest instance itself + */ + public MenuSyncWebhookRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -300,12 +345,13 @@ public boolean equals(Object o) { Objects.equals(this.jobID, menuSyncWebhookRequest.jobID) && Objects.equals(this.updatedAt, menuSyncWebhookRequest.updatedAt) && Objects.equals(this.status, menuSyncWebhookRequest.status) && - Objects.equals(this.errors, menuSyncWebhookRequest.errors); + Objects.equals(this.errors, menuSyncWebhookRequest.errors)&& + Objects.equals(this.additionalProperties, menuSyncWebhookRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(requestID, merchantID, partnerMerchantID, jobID, updatedAt, status, errors); + return Objects.hash(requestID, merchantID, partnerMerchantID, jobID, updatedAt, status, errors, additionalProperties); } @Override @@ -319,6 +365,7 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -353,26 +400,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to MenuSyncWebhookRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to MenuSyncWebhookRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!MenuSyncWebhookRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in MenuSyncWebhookRequest is not found in the empty JSON string", MenuSyncWebhookRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MenuSyncWebhookRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MenuSyncWebhookRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("requestID") != null && !jsonObj.get("requestID").isJsonNull()) && !jsonObj.get("requestID").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `requestID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("requestID").toString())); @@ -417,6 +456,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MenuSyncWebhookRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -424,29 +485,50 @@ public void write(JsonWriter out, MenuSyncWebhookRequest value) throws IOExcepti public MenuSyncWebhookRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MenuSyncWebhookRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of MenuSyncWebhookRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of MenuSyncWebhookRequest - * @throws IOException if the JSON string is invalid with respect to MenuSyncWebhookRequest - */ + /** + * Create an instance of MenuSyncWebhookRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of MenuSyncWebhookRequest + * @throws IOException if the JSON string is invalid with respect to MenuSyncWebhookRequest + */ public static MenuSyncWebhookRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, MenuSyncWebhookRequest.class); } - /** - * Convert an instance of MenuSyncWebhookRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of MenuSyncWebhookRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/ModifierGroupsInner.java b/src/main/java/com/grabfood/client/model/ModifierGroup.java similarity index 59% rename from src/main/java/com/grabfood/client/model/ModifierGroupsInner.java rename to src/main/java/com/grabfood/client/model/ModifierGroup.java index 10b1279..8339de3 100644 --- a/src/main/java/com/grabfood/client/model/ModifierGroupsInner.java +++ b/src/main/java/com/grabfood/client/model/ModifierGroup.java @@ -22,12 +22,13 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.MenuModifiersInner; -import com.grabfood.client.model.ModifierGroupsInnerNameTranslation; +import com.grabfood.client.model.MenuModifier; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -44,7 +45,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,10 +54,10 @@ import com.grabfood.client.JSON; /** - * ModifierGroupsInner + * ModifierGroup */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class ModifierGroupsInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class ModifierGroup { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -68,7 +68,7 @@ public class ModifierGroupsInner { public static final String SERIALIZED_NAME_NAME_TRANSLATION = "nameTranslation"; @SerializedName(SERIALIZED_NAME_NAME_TRANSLATION) - private ModifierGroupsInnerNameTranslation nameTranslation; + private Map nameTranslation = new HashMap<>(); /** * The status for the ModifierGroup that is in the item. @@ -81,7 +81,9 @@ public enum AvailableStatusEnum { UNAVAILABLETODAY("UNAVAILABLETODAY"), - HIDE("HIDE"); + HIDE("HIDE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -104,7 +106,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -140,20 +142,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_MODIFIERS = "modifiers"; @SerializedName(SERIALIZED_NAME_MODIFIERS) - private List modifiers = new ArrayList<>(); + private List modifiers = new ArrayList<>(); - public ModifierGroupsInner() { + public ModifierGroup() { } - public ModifierGroupsInner id(String id) { + public ModifierGroup id(String id) { this.id = id; return this; } - /** + /** * The ModifierGroup's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -164,15 +166,15 @@ public void setId(String id) { } - public ModifierGroupsInner name(String name) { + public ModifierGroup name(String name) { this.name = name; return this; } - /** + /** * The name of the ModifierGroup for the item that is in the parent category and section. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -183,34 +185,42 @@ public void setName(String name) { } - public ModifierGroupsInner nameTranslation(ModifierGroupsInnerNameTranslation nameTranslation) { + public ModifierGroup nameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; return this; } - /** - * Get nameTranslation + public ModifierGroup putNameTranslationItem(String key, String nameTranslationItem) { + if (this.nameTranslation == null) { + this.nameTranslation = new HashMap<>(); + } + this.nameTranslation.put(key, nameTranslationItem); + return this; + } + + /** + * Translation of the modifier group name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). * @return nameTranslation - **/ + */ @javax.annotation.Nullable - public ModifierGroupsInnerNameTranslation getNameTranslation() { + public Map getNameTranslation() { return nameTranslation; } - public void setNameTranslation(ModifierGroupsInnerNameTranslation nameTranslation) { + public void setNameTranslation(Map nameTranslation) { this.nameTranslation = nameTranslation; } - public ModifierGroupsInner availableStatus(AvailableStatusEnum availableStatus) { + public ModifierGroup availableStatus(AvailableStatusEnum availableStatus) { this.availableStatus = availableStatus; return this; } - /** + /** * The status for the ModifierGroup that is in the item. * @return availableStatus - **/ + */ @javax.annotation.Nonnull public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -221,15 +231,15 @@ public void setAvailableStatus(AvailableStatusEnum availableStatus) { } - public ModifierGroupsInner selectionRangeMin(Integer selectionRangeMin) { + public ModifierGroup selectionRangeMin(Integer selectionRangeMin) { this.selectionRangeMin = selectionRangeMin; return this; } - /** + /** * The minimum quantity of the attribute. Refer to FAQs for more details about [selection range](#section/Menu/What-does-the-selection-range-do). * @return selectionRangeMin - **/ + */ @javax.annotation.Nullable public Integer getSelectionRangeMin() { return selectionRangeMin; @@ -240,15 +250,15 @@ public void setSelectionRangeMin(Integer selectionRangeMin) { } - public ModifierGroupsInner selectionRangeMax(Integer selectionRangeMax) { + public ModifierGroup selectionRangeMax(Integer selectionRangeMax) { this.selectionRangeMax = selectionRangeMax; return this; } - /** + /** * The maximum quantity of the attribute. Refer to FAQs for more details about [selection range](#section/Menu/What-does-the-selection-range-do). * @return selectionRangeMax - **/ + */ @javax.annotation.Nonnull public Integer getSelectionRangeMax() { return selectionRangeMax; @@ -259,12 +269,12 @@ public void setSelectionRangeMax(Integer selectionRangeMax) { } - public ModifierGroupsInner modifiers(List modifiers) { + public ModifierGroup modifiers(List modifiers) { this.modifiers = modifiers; return this; } - public ModifierGroupsInner addModifiersItem(MenuModifiersInner modifiersItem) { + public ModifierGroup addModifiersItem(MenuModifier modifiersItem) { if (this.modifiers == null) { this.modifiers = new ArrayList<>(); } @@ -272,19 +282,63 @@ public ModifierGroupsInner addModifiersItem(MenuModifiersInner modifiersItem) { return this; } - /** + /** * An array of modifier JSON objects. Max 100 per modifierGroup. Refer to [Modifiers](#modifiers) for more information. * @return modifiers - **/ + */ @javax.annotation.Nullable - public List getModifiers() { + public List getModifiers() { return modifiers; } - public void setModifiers(List modifiers) { + public void setModifiers(List modifiers) { this.modifiers = modifiers; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModifierGroup instance itself + */ + public ModifierGroup putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -295,25 +349,26 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - ModifierGroupsInner modifierGroupsInner = (ModifierGroupsInner) o; - return Objects.equals(this.id, modifierGroupsInner.id) && - Objects.equals(this.name, modifierGroupsInner.name) && - Objects.equals(this.nameTranslation, modifierGroupsInner.nameTranslation) && - Objects.equals(this.availableStatus, modifierGroupsInner.availableStatus) && - Objects.equals(this.selectionRangeMin, modifierGroupsInner.selectionRangeMin) && - Objects.equals(this.selectionRangeMax, modifierGroupsInner.selectionRangeMax) && - Objects.equals(this.modifiers, modifierGroupsInner.modifiers); + ModifierGroup modifierGroup = (ModifierGroup) o; + return Objects.equals(this.id, modifierGroup.id) && + Objects.equals(this.name, modifierGroup.name) && + Objects.equals(this.nameTranslation, modifierGroup.nameTranslation) && + Objects.equals(this.availableStatus, modifierGroup.availableStatus) && + Objects.equals(this.selectionRangeMin, modifierGroup.selectionRangeMin) && + Objects.equals(this.selectionRangeMax, modifierGroup.selectionRangeMax) && + Objects.equals(this.modifiers, modifierGroup.modifiers)&& + Objects.equals(this.additionalProperties, modifierGroup.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, nameTranslation, availableStatus, selectionRangeMin, selectionRangeMax, modifiers); + return Objects.hash(id, name, nameTranslation, availableStatus, selectionRangeMin, selectionRangeMax, modifiers, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ModifierGroupsInner {\n"); + sb.append("class ModifierGroup {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" nameTranslation: ").append(toIndentedString(nameTranslation)).append("\n"); @@ -321,6 +376,7 @@ public String toString() { sb.append(" selectionRangeMin: ").append(toIndentedString(selectionRangeMin)).append("\n"); sb.append(" selectionRangeMax: ").append(toIndentedString(selectionRangeMax)).append("\n"); sb.append(" modifiers: ").append(toIndentedString(modifiers)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -359,29 +415,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("selectionRangeMax"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ModifierGroupsInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ModifierGroup + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!ModifierGroupsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in ModifierGroupsInner is not found in the empty JSON string", ModifierGroupsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModifierGroupsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModifierGroupsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!ModifierGroup.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ModifierGroup is not found in the empty JSON string", ModifierGroup.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ModifierGroupsInner.openapiRequiredFields) { + for (String requiredField : ModifierGroup.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -393,10 +441,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (!jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); } - // validate the optional field `nameTranslation` - if (jsonObj.get("nameTranslation") != null && !jsonObj.get("nameTranslation").isJsonNull()) { - ModifierGroupsInnerNameTranslation.validateJsonElement(jsonObj.get("nameTranslation")); - } if (!jsonObj.get("availableStatus").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `availableStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("availableStatus").toString())); } @@ -412,7 +456,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `modifiers` (array) for (int i = 0; i < jsonArraymodifiers.size(); i++) { - MenuModifiersInner.validateJsonElement(jsonArraymodifiers.get(i)); + MenuModifier.validateJsonElement(jsonArraymodifiers.get(i)); }; } } @@ -422,47 +466,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!ModifierGroupsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ModifierGroupsInner' and its subtypes + if (!ModifierGroup.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ModifierGroup' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ModifierGroupsInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ModifierGroup.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, ModifierGroupsInner value) throws IOException { + public void write(JsonWriter out, ModifierGroup value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public ModifierGroupsInner read(JsonReader in) throws IOException { + public ModifierGroup read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModifierGroup instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of ModifierGroupsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of ModifierGroupsInner - * @throws IOException if the JSON string is invalid with respect to ModifierGroupsInner - */ - public static ModifierGroupsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ModifierGroupsInner.class); + /** + * Create an instance of ModifierGroup given an JSON string + * + * @param jsonString JSON string + * @return An instance of ModifierGroup + * @throws IOException if the JSON string is invalid with respect to ModifierGroup + */ + public static ModifierGroup fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ModifierGroup.class); } - /** - * Convert an instance of ModifierGroupsInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of ModifierGroup to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/ModifierGroupsInnerNameTranslation.java b/src/main/java/com/grabfood/client/model/ModifierGroupsInnerNameTranslation.java deleted file mode 100644 index 4365917..0000000 --- a/src/main/java/com/grabfood/client/model/ModifierGroupsInnerNameTranslation.java +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Translation of the modifier group name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class ModifierGroupsInnerNameTranslation { - public static final String SERIALIZED_NAME_EN = "en"; - @SerializedName(SERIALIZED_NAME_EN) - private String en; - - public ModifierGroupsInnerNameTranslation() { - } - - public ModifierGroupsInnerNameTranslation en(String en) { - this.en = en; - return this; - } - - /** - * The English translation of the name. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - * @return en - **/ - @javax.annotation.Nullable - public String getEn() { - return en; - } - - public void setEn(String en) { - this.en = en; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModifierGroupsInnerNameTranslation modifierGroupsInnerNameTranslation = (ModifierGroupsInnerNameTranslation) o; - return Objects.equals(this.en, modifierGroupsInnerNameTranslation.en); - } - - @Override - public int hashCode() { - return Objects.hash(en); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModifierGroupsInnerNameTranslation {\n"); - sb.append(" en: ").append(toIndentedString(en)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("en"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ModifierGroupsInnerNameTranslation - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!ModifierGroupsInnerNameTranslation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in ModifierGroupsInnerNameTranslation is not found in the empty JSON string", ModifierGroupsInnerNameTranslation.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModifierGroupsInnerNameTranslation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModifierGroupsInnerNameTranslation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("en") != null && !jsonObj.get("en").isJsonNull()) && !jsonObj.get("en").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `en` to be a primitive type in the JSON string but got `%s`", jsonObj.get("en").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!ModifierGroupsInnerNameTranslation.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ModifierGroupsInnerNameTranslation' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(ModifierGroupsInnerNameTranslation.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, ModifierGroupsInnerNameTranslation value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public ModifierGroupsInnerNameTranslation read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of ModifierGroupsInnerNameTranslation given an JSON string - * - * @param jsonString JSON string - * @return An instance of ModifierGroupsInnerNameTranslation - * @throws IOException if the JSON string is invalid with respect to ModifierGroupsInnerNameTranslation - */ - public static ModifierGroupsInnerNameTranslation fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ModifierGroupsInnerNameTranslation.class); - } - - /** - * Convert an instance of ModifierGroupsInnerNameTranslation to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/NewOrderTimeRequest.java b/src/main/java/com/grabfood/client/model/NewOrderTimeRequest.java index 535fe32..95d0b3e 100644 --- a/src/main/java/com/grabfood/client/model/NewOrderTimeRequest.java +++ b/src/main/java/com/grabfood/client/model/NewOrderTimeRequest.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * This request updates an order with a new ready time on GrabFood. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class NewOrderTimeRequest { public static final String SERIALIZED_NAME_ORDER_I_D = "orderID"; @SerializedName(SERIALIZED_NAME_ORDER_I_D) @@ -71,10 +70,10 @@ public NewOrderTimeRequest orderID(String orderID) { return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -90,10 +89,10 @@ public NewOrderTimeRequest newOrderReadyTime(OffsetDateTime newOrderReadyTime) { return this; } - /** + /** * The new order ready time for this order, based on ISO_8601/RFC3339. * @return newOrderReadyTime - **/ + */ @javax.annotation.Nonnull public OffsetDateTime getNewOrderReadyTime() { return newOrderReadyTime; @@ -103,6 +102,50 @@ public void setNewOrderReadyTime(OffsetDateTime newOrderReadyTime) { this.newOrderReadyTime = newOrderReadyTime; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NewOrderTimeRequest instance itself + */ + public NewOrderTimeRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -115,12 +158,13 @@ public boolean equals(Object o) { } NewOrderTimeRequest newOrderTimeRequest = (NewOrderTimeRequest) o; return Objects.equals(this.orderID, newOrderTimeRequest.orderID) && - Objects.equals(this.newOrderReadyTime, newOrderTimeRequest.newOrderReadyTime); + Objects.equals(this.newOrderReadyTime, newOrderTimeRequest.newOrderReadyTime)&& + Objects.equals(this.additionalProperties, newOrderTimeRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(orderID, newOrderReadyTime); + return Objects.hash(orderID, newOrderReadyTime, additionalProperties); } @Override @@ -129,6 +173,7 @@ public String toString() { sb.append("class NewOrderTimeRequest {\n"); sb.append(" orderID: ").append(toIndentedString(orderID)).append("\n"); sb.append(" newOrderReadyTime: ").append(toIndentedString(newOrderReadyTime)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -160,12 +205,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("newOrderReadyTime"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to NewOrderTimeRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NewOrderTimeRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!NewOrderTimeRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -173,14 +218,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NewOrderTimeRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NewOrderTimeRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NewOrderTimeRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -208,6 +245,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NewOrderTimeRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -215,29 +274,50 @@ public void write(JsonWriter out, NewOrderTimeRequest value) throws IOException public NewOrderTimeRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NewOrderTimeRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of NewOrderTimeRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of NewOrderTimeRequest - * @throws IOException if the JSON string is invalid with respect to NewOrderTimeRequest - */ + /** + * Create an instance of NewOrderTimeRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of NewOrderTimeRequest + * @throws IOException if the JSON string is invalid with respect to NewOrderTimeRequest + */ public static NewOrderTimeRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, NewOrderTimeRequest.class); } - /** - * Convert an instance of NewOrderTimeRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of NewOrderTimeRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/NewReadyTimeFail.java b/src/main/java/com/grabfood/client/model/NewReadyTimeFail.java deleted file mode 100644 index 4e58a60..0000000 --- a/src/main/java/com/grabfood/client/model/NewReadyTimeFail.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class NewReadyTimeFail { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public NewReadyTimeFail() { - } - - public NewReadyTimeFail target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public NewReadyTimeFail reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public NewReadyTimeFail message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NewReadyTimeFail newReadyTimeFail = (NewReadyTimeFail) o; - return Objects.equals(this.target, newReadyTimeFail.target) && - Objects.equals(this.reason, newReadyTimeFail.reason) && - Objects.equals(this.message, newReadyTimeFail.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class NewReadyTimeFail {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to NewReadyTimeFail - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!NewReadyTimeFail.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in NewReadyTimeFail is not found in the empty JSON string", NewReadyTimeFail.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NewReadyTimeFail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NewReadyTimeFail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!NewReadyTimeFail.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'NewReadyTimeFail' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(NewReadyTimeFail.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, NewReadyTimeFail value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public NewReadyTimeFail read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of NewReadyTimeFail given an JSON string - * - * @param jsonString JSON string - * @return An instance of NewReadyTimeFail - * @throws IOException if the JSON string is invalid with respect to NewReadyTimeFail - */ - public static NewReadyTimeFail fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, NewReadyTimeFail.class); - } - - /** - * Convert an instance of NewReadyTimeFail to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/NotifyMembershipWebviewRequest.java b/src/main/java/com/grabfood/client/model/NotifyMembershipWebviewRequest.java index 1aea71a..60c5d9b 100644 --- a/src/main/java/com/grabfood/client/model/NotifyMembershipWebviewRequest.java +++ b/src/main/java/com/grabfood/client/model/NotifyMembershipWebviewRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request submits membership registration request to partner. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class NotifyMembershipWebviewRequest { public static final String SERIALIZED_NAME_MEMBER_I_D = "memberID"; @SerializedName(SERIALIZED_NAME_MEMBER_I_D) @@ -75,7 +74,9 @@ public enum ActionEnum { REGISTER("REGISTER"), - UNLINK("UNLINK"); + UNLINK("UNLINK"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -98,7 +99,7 @@ public static ActionEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -132,10 +133,10 @@ public NotifyMembershipWebviewRequest memberID(String memberID) { return this; } - /** + /** * The unique member ID on the partner's database. * @return memberID - **/ + */ @javax.annotation.Nullable public String getMemberID() { return memberID; @@ -151,10 +152,10 @@ public NotifyMembershipWebviewRequest grabID(String grabID) { return this; } - /** + /** * The id used to identify an unique grab user. * @return grabID - **/ + */ @javax.annotation.Nullable public String getGrabID() { return grabID; @@ -170,10 +171,10 @@ public NotifyMembershipWebviewRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -189,10 +190,10 @@ public NotifyMembershipWebviewRequest action(ActionEnum action) { return this; } - /** + /** * Action completed in partner's webview. * @return action - **/ + */ @javax.annotation.Nullable public ActionEnum getAction() { return action; @@ -202,6 +203,50 @@ public void setAction(ActionEnum action) { this.action = action; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NotifyMembershipWebviewRequest instance itself + */ + public NotifyMembershipWebviewRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -216,12 +261,13 @@ public boolean equals(Object o) { return Objects.equals(this.memberID, notifyMembershipWebviewRequest.memberID) && Objects.equals(this.grabID, notifyMembershipWebviewRequest.grabID) && Objects.equals(this.merchantID, notifyMembershipWebviewRequest.merchantID) && - Objects.equals(this.action, notifyMembershipWebviewRequest.action); + Objects.equals(this.action, notifyMembershipWebviewRequest.action)&& + Objects.equals(this.additionalProperties, notifyMembershipWebviewRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(memberID, grabID, merchantID, action); + return Objects.hash(memberID, grabID, merchantID, action, additionalProperties); } @Override @@ -232,6 +278,7 @@ public String toString() { sb.append(" grabID: ").append(toIndentedString(grabID)).append("\n"); sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); sb.append(" action: ").append(toIndentedString(action)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -263,26 +310,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to NotifyMembershipWebviewRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to NotifyMembershipWebviewRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!NotifyMembershipWebviewRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in NotifyMembershipWebviewRequest is not found in the empty JSON string", NotifyMembershipWebviewRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NotifyMembershipWebviewRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NotifyMembershipWebviewRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("memberID") != null && !jsonObj.get("memberID").isJsonNull()) && !jsonObj.get("memberID").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `memberID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("memberID").toString())); @@ -317,6 +356,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NotifyMembershipWebviewRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -324,29 +385,50 @@ public void write(JsonWriter out, NotifyMembershipWebviewRequest value) throws I public NotifyMembershipWebviewRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NotifyMembershipWebviewRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of NotifyMembershipWebviewRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of NotifyMembershipWebviewRequest - * @throws IOException if the JSON string is invalid with respect to NotifyMembershipWebviewRequest - */ + /** + * Create an instance of NotifyMembershipWebviewRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of NotifyMembershipWebviewRequest + * @throws IOException if the JSON string is invalid with respect to NotifyMembershipWebviewRequest + */ public static NotifyMembershipWebviewRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, NotifyMembershipWebviewRequest.class); } - /** - * Convert an instance of NotifyMembershipWebviewRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of NotifyMembershipWebviewRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInnerDescriptionTranslation.java b/src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInnerDescriptionTranslation.java deleted file mode 100644 index ede0a8d..0000000 --- a/src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInnerDescriptionTranslation.java +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Translation of the item description. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class OldMenuSectionCategoryItemsInnerDescriptionTranslation { - public static final String SERIALIZED_NAME_EN = "en"; - @SerializedName(SERIALIZED_NAME_EN) - private String en; - - public OldMenuSectionCategoryItemsInnerDescriptionTranslation() { - } - - public OldMenuSectionCategoryItemsInnerDescriptionTranslation en(String en) { - this.en = en; - return this; - } - - /** - * The English translation of the description. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my`. - * @return en - **/ - @javax.annotation.Nullable - public String getEn() { - return en; - } - - public void setEn(String en) { - this.en = en; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - OldMenuSectionCategoryItemsInnerDescriptionTranslation oldMenuSectionCategoryItemsInnerDescriptionTranslation = (OldMenuSectionCategoryItemsInnerDescriptionTranslation) o; - return Objects.equals(this.en, oldMenuSectionCategoryItemsInnerDescriptionTranslation.en); - } - - @Override - public int hashCode() { - return Objects.hash(en); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class OldMenuSectionCategoryItemsInnerDescriptionTranslation {\n"); - sb.append(" en: ").append(toIndentedString(en)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("en"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OldMenuSectionCategoryItemsInnerDescriptionTranslation - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!OldMenuSectionCategoryItemsInnerDescriptionTranslation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in OldMenuSectionCategoryItemsInnerDescriptionTranslation is not found in the empty JSON string", OldMenuSectionCategoryItemsInnerDescriptionTranslation.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OldMenuSectionCategoryItemsInnerDescriptionTranslation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OldMenuSectionCategoryItemsInnerDescriptionTranslation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("en") != null && !jsonObj.get("en").isJsonNull()) && !jsonObj.get("en").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `en` to be a primitive type in the JSON string but got `%s`", jsonObj.get("en").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!OldMenuSectionCategoryItemsInnerDescriptionTranslation.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'OldMenuSectionCategoryItemsInnerDescriptionTranslation' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(OldMenuSectionCategoryItemsInnerDescriptionTranslation.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, OldMenuSectionCategoryItemsInnerDescriptionTranslation value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public OldMenuSectionCategoryItemsInnerDescriptionTranslation read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of OldMenuSectionCategoryItemsInnerDescriptionTranslation given an JSON string - * - * @param jsonString JSON string - * @return An instance of OldMenuSectionCategoryItemsInnerDescriptionTranslation - * @throws IOException if the JSON string is invalid with respect to OldMenuSectionCategoryItemsInnerDescriptionTranslation - */ - public static OldMenuSectionCategoryItemsInnerDescriptionTranslation fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, OldMenuSectionCategoryItemsInnerDescriptionTranslation.class); - } - - /** - * Convert an instance of OldMenuSectionCategoryItemsInnerDescriptionTranslation to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInnerNameTranslation.java b/src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInnerNameTranslation.java deleted file mode 100644 index 7f9bec2..0000000 --- a/src/main/java/com/grabfood/client/model/OldMenuSectionCategoryItemsInnerNameTranslation.java +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Translation of the item name. Only support up to 1 translated language. Refer [Menu Translation](#section/Menu-Translation). - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class OldMenuSectionCategoryItemsInnerNameTranslation { - public static final String SERIALIZED_NAME_EN = "en"; - @SerializedName(SERIALIZED_NAME_EN) - private String en; - - public OldMenuSectionCategoryItemsInnerNameTranslation() { - } - - public OldMenuSectionCategoryItemsInnerNameTranslation en(String en) { - this.en = en; - return this; - } - - /** - * The English translation of the name. Other supported languages are: `th`,`ms`,`zh`,`vi`,`id`,`km` and `my` - * @return en - **/ - @javax.annotation.Nullable - public String getEn() { - return en; - } - - public void setEn(String en) { - this.en = en; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - OldMenuSectionCategoryItemsInnerNameTranslation oldMenuSectionCategoryItemsInnerNameTranslation = (OldMenuSectionCategoryItemsInnerNameTranslation) o; - return Objects.equals(this.en, oldMenuSectionCategoryItemsInnerNameTranslation.en); - } - - @Override - public int hashCode() { - return Objects.hash(en); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class OldMenuSectionCategoryItemsInnerNameTranslation {\n"); - sb.append(" en: ").append(toIndentedString(en)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("en"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OldMenuSectionCategoryItemsInnerNameTranslation - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!OldMenuSectionCategoryItemsInnerNameTranslation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in OldMenuSectionCategoryItemsInnerNameTranslation is not found in the empty JSON string", OldMenuSectionCategoryItemsInnerNameTranslation.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OldMenuSectionCategoryItemsInnerNameTranslation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OldMenuSectionCategoryItemsInnerNameTranslation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("en") != null && !jsonObj.get("en").isJsonNull()) && !jsonObj.get("en").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `en` to be a primitive type in the JSON string but got `%s`", jsonObj.get("en").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!OldMenuSectionCategoryItemsInnerNameTranslation.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'OldMenuSectionCategoryItemsInnerNameTranslation' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(OldMenuSectionCategoryItemsInnerNameTranslation.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, OldMenuSectionCategoryItemsInnerNameTranslation value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public OldMenuSectionCategoryItemsInnerNameTranslation read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of OldMenuSectionCategoryItemsInnerNameTranslation given an JSON string - * - * @param jsonString JSON string - * @return An instance of OldMenuSectionCategoryItemsInnerNameTranslation - * @throws IOException if the JSON string is invalid with respect to OldMenuSectionCategoryItemsInnerNameTranslation - */ - public static OldMenuSectionCategoryItemsInnerNameTranslation fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, OldMenuSectionCategoryItemsInnerNameTranslation.class); - } - - /** - * Convert an instance of OldMenuSectionCategoryItemsInnerNameTranslation to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/OpenPeriod.java b/src/main/java/com/grabfood/client/model/OpenPeriod.java index 1e00825..f40fd1c 100644 --- a/src/main/java/com/grabfood/client/model/OpenPeriod.java +++ b/src/main/java/com/grabfood/client/model/OpenPeriod.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * OpenPeriod */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class OpenPeriod { public static final String SERIALIZED_NAME_START_TIME = "startTime"; @SerializedName(SERIALIZED_NAME_START_TIME) @@ -70,10 +69,10 @@ public OpenPeriod startTime(String startTime) { return this; } - /** + /** * The open start time in 24h format. * @return startTime - **/ + */ @javax.annotation.Nonnull public String getStartTime() { return startTime; @@ -89,10 +88,10 @@ public OpenPeriod endTime(String endTime) { return this; } - /** + /** * The open start time in 24h format. * @return endTime - **/ + */ @javax.annotation.Nonnull public String getEndTime() { return endTime; @@ -102,6 +101,50 @@ public void setEndTime(String endTime) { this.endTime = endTime; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OpenPeriod instance itself + */ + public OpenPeriod putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +157,13 @@ public boolean equals(Object o) { } OpenPeriod openPeriod = (OpenPeriod) o; return Objects.equals(this.startTime, openPeriod.startTime) && - Objects.equals(this.endTime, openPeriod.endTime); + Objects.equals(this.endTime, openPeriod.endTime)&& + Objects.equals(this.additionalProperties, openPeriod.additionalProperties); } @Override public int hashCode() { - return Objects.hash(startTime, endTime); + return Objects.hash(startTime, endTime, additionalProperties); } @Override @@ -128,6 +172,7 @@ public String toString() { sb.append("class OpenPeriod {\n"); sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -159,12 +204,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("endTime"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OpenPeriod - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OpenPeriod + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!OpenPeriod.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -172,14 +217,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OpenPeriod.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OpenPeriod` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : OpenPeriod.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -210,6 +247,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, OpenPeriod value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -217,29 +276,50 @@ public void write(JsonWriter out, OpenPeriod value) throws IOException { public OpenPeriod read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OpenPeriod instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OpenPeriod given an JSON string - * - * @param jsonString JSON string - * @return An instance of OpenPeriod - * @throws IOException if the JSON string is invalid with respect to OpenPeriod - */ + /** + * Create an instance of OpenPeriod given an JSON string + * + * @param jsonString JSON string + * @return An instance of OpenPeriod + * @throws IOException if the JSON string is invalid with respect to OpenPeriod + */ public static OpenPeriod fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, OpenPeriod.class); } - /** - * Convert an instance of OpenPeriod to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OpenPeriod to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Orders.java b/src/main/java/com/grabfood/client/model/Order.java similarity index 69% rename from src/main/java/com/grabfood/client/model/Orders.java rename to src/main/java/com/grabfood/client/model/Order.java index 1be4140..117b413 100644 --- a/src/main/java/com/grabfood/client/model/Orders.java +++ b/src/main/java/com/grabfood/client/model/Order.java @@ -24,12 +24,12 @@ import com.google.gson.stream.JsonWriter; import com.grabfood.client.model.Currency; import com.grabfood.client.model.DineIn; -import com.grabfood.client.model.FeatureFlags; -import com.grabfood.client.model.OrderCampaignsInner; -import com.grabfood.client.model.OrderItemsInner; +import com.grabfood.client.model.OrderCampaign; +import com.grabfood.client.model.OrderFeatureFlags; +import com.grabfood.client.model.OrderItem; import com.grabfood.client.model.OrderPrice; +import com.grabfood.client.model.OrderPromo; import com.grabfood.client.model.OrderReadyEstimation; -import com.grabfood.client.model.PromosInner; import com.grabfood.client.model.Receiver; import java.io.IOException; import java.time.OffsetDateTime; @@ -53,7 +53,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -65,8 +64,8 @@ /** * A JSON object containing the order information. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Orders { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class Order { public static final String SERIALIZED_NAME_ORDER_I_D = "orderID"; @SerializedName(SERIALIZED_NAME_ORDER_I_D) private String orderID; @@ -90,7 +89,9 @@ public class Orders { public enum PaymentTypeEnum { CASH("CASH"), - CASHLESS("CASHLESS"); + CASHLESS("CASHLESS"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -113,7 +114,7 @@ public static PaymentTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -145,7 +146,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_ORDER_TIME = "orderTime"; @SerializedName(SERIALIZED_NAME_ORDER_TIME) - private OffsetDateTime orderTime; + private String orderTime; public static final String SERIALIZED_NAME_SUBMIT_TIME = "submitTime"; @SerializedName(SERIALIZED_NAME_SUBMIT_TIME) @@ -157,7 +158,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_SCHEDULED_TIME = "scheduledTime"; @SerializedName(SERIALIZED_NAME_SCHEDULED_TIME) - private OffsetDateTime scheduledTime; + private String scheduledTime; public static final String SERIALIZED_NAME_ORDER_STATE = "orderState"; @SerializedName(SERIALIZED_NAME_ORDER_STATE) @@ -169,19 +170,19 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_FEATURE_FLAGS = "featureFlags"; @SerializedName(SERIALIZED_NAME_FEATURE_FLAGS) - private FeatureFlags featureFlags; + private OrderFeatureFlags featureFlags; public static final String SERIALIZED_NAME_ITEMS = "items"; @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); + private List items = new ArrayList<>(); public static final String SERIALIZED_NAME_CAMPAIGNS = "campaigns"; @SerializedName(SERIALIZED_NAME_CAMPAIGNS) - private List campaigns; + private List campaigns; public static final String SERIALIZED_NAME_PROMOS = "promos"; @SerializedName(SERIALIZED_NAME_PROMOS) - private List promos = new ArrayList<>(); + private List promos = new ArrayList<>(); public static final String SERIALIZED_NAME_PRICE = "price"; @SerializedName(SERIALIZED_NAME_PRICE) @@ -203,18 +204,18 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_MEMBERSHIP_I_D) private String membershipID; - public Orders() { + public Order() { } - public Orders orderID(String orderID) { + public Order orderID(String orderID) { this.orderID = orderID; return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -225,15 +226,15 @@ public void setOrderID(String orderID) { } - public Orders shortOrderNumber(String shortOrderNumber) { + public Order shortOrderNumber(String shortOrderNumber) { this.shortOrderNumber = shortOrderNumber; return this; } - /** + /** * The GrabFood short order number. This is unique for each merchant per day. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return shortOrderNumber - **/ + */ @javax.annotation.Nonnull public String getShortOrderNumber() { return shortOrderNumber; @@ -244,15 +245,15 @@ public void setShortOrderNumber(String shortOrderNumber) { } - public Orders merchantID(String merchantID) { + public Order merchantID(String merchantID) { this.merchantID = merchantID; return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -263,15 +264,15 @@ public void setMerchantID(String merchantID) { } - public Orders partnerMerchantID(String partnerMerchantID) { + public Order partnerMerchantID(String partnerMerchantID) { this.partnerMerchantID = partnerMerchantID; return this; } - /** + /** * The merchant's ID that is on the partner's database. * @return partnerMerchantID - **/ + */ @javax.annotation.Nullable public String getPartnerMerchantID() { return partnerMerchantID; @@ -282,15 +283,15 @@ public void setPartnerMerchantID(String partnerMerchantID) { } - public Orders paymentType(PaymentTypeEnum paymentType) { + public Order paymentType(PaymentTypeEnum paymentType) { this.paymentType = paymentType; return this; } - /** + /** * The payment method used. Refer to FAQs for more details about [paymentType](#section/Order/Does-the-paymentType-affect-partners). * @return paymentType - **/ + */ @javax.annotation.Nonnull public PaymentTypeEnum getPaymentType() { return paymentType; @@ -301,15 +302,15 @@ public void setPaymentType(PaymentTypeEnum paymentType) { } - public Orders cutlery(Boolean cutlery) { + public Order cutlery(Boolean cutlery) { this.cutlery = cutlery; return this; } - /** + /** * The boolean value to indicate whether cutlery are needed or not. Refer to FAQs for more details about [cutlery](#section/Order/What-do-the-true-or-false-values-mean-for-cutlery). * @return cutlery - **/ + */ @javax.annotation.Nonnull public Boolean getCutlery() { return cutlery; @@ -320,34 +321,34 @@ public void setCutlery(Boolean cutlery) { } - public Orders orderTime(OffsetDateTime orderTime) { + public Order orderTime(String orderTime) { this.orderTime = orderTime; return this; } - /** + /** * The UTC time that a consumer places the order, based on ISO_8601/RFC3339. * @return orderTime - **/ + */ @javax.annotation.Nonnull - public OffsetDateTime getOrderTime() { + public String getOrderTime() { return orderTime; } - public void setOrderTime(OffsetDateTime orderTime) { + public void setOrderTime(String orderTime) { this.orderTime = orderTime; } - public Orders submitTime(OffsetDateTime submitTime) { + public Order submitTime(OffsetDateTime submitTime) { this.submitTime = submitTime; return this; } - /** + /** * The order submit time, based on ISO_8601/RFC3339. Only present in the [List Orders](#tag/list-order) response. * @return submitTime - **/ + */ @javax.annotation.Nullable public OffsetDateTime getSubmitTime() { return submitTime; @@ -358,15 +359,15 @@ public void setSubmitTime(OffsetDateTime submitTime) { } - public Orders completeTime(OffsetDateTime completeTime) { + public Order completeTime(OffsetDateTime completeTime) { this.completeTime = completeTime; return this; } - /** + /** * The order complete time, based on ISO_8601/RFC3339. Only present in the [List Orders](#tag/list-order) response. * @return completeTime - **/ + */ @javax.annotation.Nullable public OffsetDateTime getCompleteTime() { return completeTime; @@ -377,34 +378,34 @@ public void setCompleteTime(OffsetDateTime completeTime) { } - public Orders scheduledTime(OffsetDateTime scheduledTime) { + public Order scheduledTime(String scheduledTime) { this.scheduledTime = scheduledTime; return this; } - /** + /** * The order scheduled time, based on ISO_8601/RFC3339. Empty for non-scheduled orders. * @return scheduledTime - **/ + */ @javax.annotation.Nullable - public OffsetDateTime getScheduledTime() { + public String getScheduledTime() { return scheduledTime; } - public void setScheduledTime(OffsetDateTime scheduledTime) { + public void setScheduledTime(String scheduledTime) { this.scheduledTime = scheduledTime; } - public Orders orderState(String orderState) { + public Order orderState(String orderState) { this.orderState = orderState; return this; } - /** + /** * The state of the order. Only present in the [List Orders](#tag/list-order) response. Refer to [Order States](#section/Order-states). * @return orderState - **/ + */ @javax.annotation.Nullable public String getOrderState() { return orderState; @@ -415,15 +416,15 @@ public void setOrderState(String orderState) { } - public Orders currency(Currency currency) { + public Order currency(Currency currency) { this.currency = currency; return this; } - /** + /** * Get currency * @return currency - **/ + */ @javax.annotation.Nonnull public Currency getCurrency() { return currency; @@ -434,31 +435,31 @@ public void setCurrency(Currency currency) { } - public Orders featureFlags(FeatureFlags featureFlags) { + public Order featureFlags(OrderFeatureFlags featureFlags) { this.featureFlags = featureFlags; return this; } - /** + /** * Get featureFlags * @return featureFlags - **/ + */ @javax.annotation.Nonnull - public FeatureFlags getFeatureFlags() { + public OrderFeatureFlags getFeatureFlags() { return featureFlags; } - public void setFeatureFlags(FeatureFlags featureFlags) { + public void setFeatureFlags(OrderFeatureFlags featureFlags) { this.featureFlags = featureFlags; } - public Orders items(List items) { + public Order items(List items) { this.items = items; return this; } - public Orders addItemsItem(OrderItemsInner itemsItem) { + public Order addItemsItem(OrderItem itemsItem) { if (this.items == null) { this.items = new ArrayList<>(); } @@ -466,26 +467,26 @@ public Orders addItemsItem(OrderItemsInner itemsItem) { return this; } - /** + /** * The items in an array of JSON Object. Refer to [Items](#items) for more information. * @return items - **/ + */ @javax.annotation.Nonnull - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } - public Orders campaigns(List campaigns) { + public Order campaigns(List campaigns) { this.campaigns = campaigns; return this; } - public Orders addCampaignsItem(OrderCampaignsInner campaignsItem) { + public Order addCampaignsItem(OrderCampaign campaignsItem) { if (this.campaigns == null) { this.campaigns = new ArrayList<>(); } @@ -493,26 +494,26 @@ public Orders addCampaignsItem(OrderCampaignsInner campaignsItem) { return this; } - /** + /** * The campaigns that are applicable for the order.`null` when there is no campaign applied. * @return campaigns - **/ + */ @javax.annotation.Nullable - public List getCampaigns() { + public List getCampaigns() { return campaigns; } - public void setCampaigns(List campaigns) { + public void setCampaigns(List campaigns) { this.campaigns = campaigns; } - public Orders promos(List promos) { + public Order promos(List promos) { this.promos = promos; return this; } - public Orders addPromosItem(PromosInner promosItem) { + public Order addPromosItem(OrderPromo promosItem) { if (this.promos == null) { this.promos = new ArrayList<>(); } @@ -520,29 +521,29 @@ public Orders addPromosItem(PromosInner promosItem) { return this; } - /** + /** * An array of promotion objects. Only promotions that are funded by merchants will be sent. * @return promos - **/ + */ @javax.annotation.Nullable - public List getPromos() { + public List getPromos() { return promos; } - public void setPromos(List promos) { + public void setPromos(List promos) { this.promos = promos; } - public Orders price(OrderPrice price) { + public Order price(OrderPrice price) { this.price = price; return this; } - /** + /** * Get price * @return price - **/ + */ @javax.annotation.Nonnull public OrderPrice getPrice() { return price; @@ -553,15 +554,15 @@ public void setPrice(OrderPrice price) { } - public Orders dineIn(DineIn dineIn) { + public Order dineIn(DineIn dineIn) { this.dineIn = dineIn; return this; } - /** + /** * Get dineIn * @return dineIn - **/ + */ @javax.annotation.Nullable public DineIn getDineIn() { return dineIn; @@ -572,15 +573,15 @@ public void setDineIn(DineIn dineIn) { } - public Orders receiver(Receiver receiver) { + public Order receiver(Receiver receiver) { this.receiver = receiver; return this; } - /** + /** * Get receiver * @return receiver - **/ + */ @javax.annotation.Nullable public Receiver getReceiver() { return receiver; @@ -591,15 +592,15 @@ public void setReceiver(Receiver receiver) { } - public Orders orderReadyEstimation(OrderReadyEstimation orderReadyEstimation) { + public Order orderReadyEstimation(OrderReadyEstimation orderReadyEstimation) { this.orderReadyEstimation = orderReadyEstimation; return this; } - /** + /** * Get orderReadyEstimation * @return orderReadyEstimation - **/ + */ @javax.annotation.Nullable public OrderReadyEstimation getOrderReadyEstimation() { return orderReadyEstimation; @@ -610,15 +611,15 @@ public void setOrderReadyEstimation(OrderReadyEstimation orderReadyEstimation) { } - public Orders membershipID(String membershipID) { + public Order membershipID(String membershipID) { this.membershipID = membershipID; return this; } - /** + /** * Membership ID for loyalty project. Only present for loyalty program partners. * @return membershipID - **/ + */ @javax.annotation.Nullable public String getMembershipID() { return membershipID; @@ -628,6 +629,50 @@ public void setMembershipID(String membershipID) { this.membershipID = membershipID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Order instance itself + */ + public Order putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -638,28 +683,29 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - Orders orders = (Orders) o; - return Objects.equals(this.orderID, orders.orderID) && - Objects.equals(this.shortOrderNumber, orders.shortOrderNumber) && - Objects.equals(this.merchantID, orders.merchantID) && - Objects.equals(this.partnerMerchantID, orders.partnerMerchantID) && - Objects.equals(this.paymentType, orders.paymentType) && - Objects.equals(this.cutlery, orders.cutlery) && - Objects.equals(this.orderTime, orders.orderTime) && - Objects.equals(this.submitTime, orders.submitTime) && - Objects.equals(this.completeTime, orders.completeTime) && - Objects.equals(this.scheduledTime, orders.scheduledTime) && - Objects.equals(this.orderState, orders.orderState) && - Objects.equals(this.currency, orders.currency) && - Objects.equals(this.featureFlags, orders.featureFlags) && - Objects.equals(this.items, orders.items) && - Objects.equals(this.campaigns, orders.campaigns) && - Objects.equals(this.promos, orders.promos) && - Objects.equals(this.price, orders.price) && - Objects.equals(this.dineIn, orders.dineIn) && - Objects.equals(this.receiver, orders.receiver) && - Objects.equals(this.orderReadyEstimation, orders.orderReadyEstimation) && - Objects.equals(this.membershipID, orders.membershipID); + Order order = (Order) o; + return Objects.equals(this.orderID, order.orderID) && + Objects.equals(this.shortOrderNumber, order.shortOrderNumber) && + Objects.equals(this.merchantID, order.merchantID) && + Objects.equals(this.partnerMerchantID, order.partnerMerchantID) && + Objects.equals(this.paymentType, order.paymentType) && + Objects.equals(this.cutlery, order.cutlery) && + Objects.equals(this.orderTime, order.orderTime) && + Objects.equals(this.submitTime, order.submitTime) && + Objects.equals(this.completeTime, order.completeTime) && + Objects.equals(this.scheduledTime, order.scheduledTime) && + Objects.equals(this.orderState, order.orderState) && + Objects.equals(this.currency, order.currency) && + Objects.equals(this.featureFlags, order.featureFlags) && + Objects.equals(this.items, order.items) && + Objects.equals(this.campaigns, order.campaigns) && + Objects.equals(this.promos, order.promos) && + Objects.equals(this.price, order.price) && + Objects.equals(this.dineIn, order.dineIn) && + Objects.equals(this.receiver, order.receiver) && + Objects.equals(this.orderReadyEstimation, order.orderReadyEstimation) && + Objects.equals(this.membershipID, order.membershipID)&& + Objects.equals(this.additionalProperties, order.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -668,7 +714,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(orderID, shortOrderNumber, merchantID, partnerMerchantID, paymentType, cutlery, orderTime, submitTime, completeTime, scheduledTime, orderState, currency, featureFlags, items, campaigns, promos, price, dineIn, receiver, orderReadyEstimation, membershipID); + return Objects.hash(orderID, shortOrderNumber, merchantID, partnerMerchantID, paymentType, cutlery, orderTime, submitTime, completeTime, scheduledTime, orderState, currency, featureFlags, items, campaigns, promos, price, dineIn, receiver, orderReadyEstimation, membershipID, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -681,7 +727,7 @@ private static int hashCodeNullable(JsonNullable a) { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class Orders {\n"); + sb.append("class Order {\n"); sb.append(" orderID: ").append(toIndentedString(orderID)).append("\n"); sb.append(" shortOrderNumber: ").append(toIndentedString(shortOrderNumber)).append("\n"); sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); @@ -703,6 +749,7 @@ public String toString() { sb.append(" receiver: ").append(toIndentedString(receiver)).append("\n"); sb.append(" orderReadyEstimation: ").append(toIndentedString(orderReadyEstimation)).append("\n"); sb.append(" membershipID: ").append(toIndentedString(membershipID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -761,29 +808,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("price"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Orders - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Order + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!Orders.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Orders is not found in the empty JSON string", Orders.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Orders.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Orders` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!Order.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Order is not found in the empty JSON string", Order.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Orders.openapiRequiredFields) { + for (String requiredField : Order.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -806,13 +845,19 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // validate the required field `paymentType` PaymentTypeEnum.validateJsonElement(jsonObj.get("paymentType")); + if (!jsonObj.get("orderTime").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `orderTime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orderTime").toString())); + } + if ((jsonObj.get("scheduledTime") != null && !jsonObj.get("scheduledTime").isJsonNull()) && !jsonObj.get("scheduledTime").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `scheduledTime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("scheduledTime").toString())); + } if ((jsonObj.get("orderState") != null && !jsonObj.get("orderState").isJsonNull()) && !jsonObj.get("orderState").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `orderState` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orderState").toString())); } // validate the required field `currency` Currency.validateJsonElement(jsonObj.get("currency")); // validate the required field `featureFlags` - FeatureFlags.validateJsonElement(jsonObj.get("featureFlags")); + OrderFeatureFlags.validateJsonElement(jsonObj.get("featureFlags")); // ensure the json data is an array if (!jsonObj.get("items").isJsonArray()) { throw new IllegalArgumentException(String.format("Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); @@ -821,7 +866,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); // validate the required field `items` (array) for (int i = 0; i < jsonArrayitems.size(); i++) { - OrderItemsInner.validateJsonElement(jsonArrayitems.get(i)); + OrderItem.validateJsonElement(jsonArrayitems.get(i)); }; if (jsonObj.get("campaigns") != null && !jsonObj.get("campaigns").isJsonNull()) { JsonArray jsonArraycampaigns = jsonObj.getAsJsonArray("campaigns"); @@ -833,7 +878,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `campaigns` (array) for (int i = 0; i < jsonArraycampaigns.size(); i++) { - OrderCampaignsInner.validateJsonElement(jsonArraycampaigns.get(i)); + OrderCampaign.validateJsonElement(jsonArraycampaigns.get(i)); }; } } @@ -847,7 +892,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `promos` (array) for (int i = 0; i < jsonArraypromos.size(); i++) { - PromosInner.validateJsonElement(jsonArraypromos.get(i)); + OrderPromo.validateJsonElement(jsonArraypromos.get(i)); }; } } @@ -874,47 +919,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!Orders.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Orders' and its subtypes + if (!Order.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Order' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Orders.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Order.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, Orders value) throws IOException { + public void write(JsonWriter out, Order value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public Orders read(JsonReader in) throws IOException { + public Order read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Order instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Orders given an JSON string - * - * @param jsonString JSON string - * @return An instance of Orders - * @throws IOException if the JSON string is invalid with respect to Orders - */ - public static Orders fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Orders.class); + /** + * Create an instance of Order given an JSON string + * + * @param jsonString JSON string + * @return An instance of Order + * @throws IOException if the JSON string is invalid with respect to Order + */ + public static Order fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Order.class); } - /** - * Convert an instance of Orders to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of Order to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OrderCampaignsInner.java b/src/main/java/com/grabfood/client/model/OrderCampaign.java similarity index 68% rename from src/main/java/com/grabfood/client/model/OrderCampaignsInner.java rename to src/main/java/com/grabfood/client/model/OrderCampaign.java index bd68baa..f031755 100644 --- a/src/main/java/com/grabfood/client/model/OrderCampaignsInner.java +++ b/src/main/java/com/grabfood/client/model/OrderCampaign.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.FreeItem; +import com.grabfood.client.model.OrderFreeItem; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,10 +53,10 @@ import com.grabfood.client.JSON; /** - * OrderCampaignsInner + * OrderCampaign */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class OrderCampaignsInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class OrderCampaign { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -83,7 +82,9 @@ public enum LevelEnum { DELIVERY_FEE("delivery_fee"), - BUNDLE("bundle"); + BUNDLE("bundle"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -106,7 +107,7 @@ public static LevelEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -143,13 +144,15 @@ public enum TypeEnum { DELIVERY("delivery"), - FREEITEM("freeItem"), + FREE_ITEM("freeItem"), + + BUNDLE_SAME_NET("bundleSameNet"), - BUNDLESAMENET("bundleSameNet"), + BUNDLE_SAME_PERCENTAGE("bundleSamePercentage"), - BUNDLESAMEPERCENTAGE("bundleSamePercentage"), + BUNDLE_SAME_FIX_PRICE("bundleSameFixPrice"), - BUNDLESAMEFIXPRICE("bundleSameFixPrice"); + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -172,7 +175,7 @@ public static TypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -217,7 +220,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public enum DeductedPartEnum { BASKET_AMOUNT("basket_amount"), - DELIVERY_FEE("delivery_fee"); + DELIVERY_FEE("delivery_fee"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -240,7 +245,7 @@ public static DeductedPartEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -272,20 +277,20 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_FREE_ITEM = "freeItem"; @SerializedName(SERIALIZED_NAME_FREE_ITEM) - private FreeItem freeItem; + private OrderFreeItem freeItem; - public OrderCampaignsInner() { + public OrderCampaign() { } - public OrderCampaignsInner id(String id) { + public OrderCampaign id(String id) { this.id = id; return this; } - /** + /** * The campaign's ID returned by GrabFood upon campaign creation. * @return id - **/ + */ @javax.annotation.Nullable public String getId() { return id; @@ -296,15 +301,15 @@ public void setId(String id) { } - public OrderCampaignsInner name(String name) { + public OrderCampaign name(String name) { this.name = name; return this; } - /** + /** * The name of the campaign. This campaign name has been automatically generated by Grab for display in the customer app. * @return name - **/ + */ @javax.annotation.Nullable public String getName() { return name; @@ -315,15 +320,15 @@ public void setName(String name) { } - public OrderCampaignsInner campaignNameForMex(String campaignNameForMex) { + public OrderCampaign campaignNameForMex(String campaignNameForMex) { this.campaignNameForMex = campaignNameForMex; return this; } - /** + /** * The campaign name provided by the merchant in [Create Campaign](#tag/create-campaign). Whitelist required, reach out to your integration manager. * @return campaignNameForMex - **/ + */ @javax.annotation.Nullable public String getCampaignNameForMex() { return campaignNameForMex; @@ -334,15 +339,15 @@ public void setCampaignNameForMex(String campaignNameForMex) { } - public OrderCampaignsInner level(LevelEnum level) { + public OrderCampaign level(LevelEnum level) { this.level = level; return this; } - /** + /** * The campaign level. * @return level - **/ + */ @javax.annotation.Nullable public LevelEnum getLevel() { return level; @@ -353,15 +358,15 @@ public void setLevel(LevelEnum level) { } - public OrderCampaignsInner type(TypeEnum type) { + public OrderCampaign type(TypeEnum type) { this.type = type; return this; } - /** + /** * The type of campaign. * @return type - **/ + */ @javax.annotation.Nullable public TypeEnum getType() { return type; @@ -372,15 +377,15 @@ public void setType(TypeEnum type) { } - public OrderCampaignsInner usageCount(Integer usageCount) { + public OrderCampaign usageCount(Integer usageCount) { this.usageCount = usageCount; return this; } - /** + /** * The campaign redemption count in this order. * @return usageCount - **/ + */ @javax.annotation.Nullable public Integer getUsageCount() { return usageCount; @@ -391,15 +396,15 @@ public void setUsageCount(Integer usageCount) { } - public OrderCampaignsInner mexFundedRatio(Integer mexFundedRatio) { + public OrderCampaign mexFundedRatio(Integer mexFundedRatio) { this.mexFundedRatio = mexFundedRatio; return this; } - /** + /** * The ratio funded by the merchant in percentage. * @return mexFundedRatio - **/ + */ @javax.annotation.Nullable public Integer getMexFundedRatio() { return mexFundedRatio; @@ -410,15 +415,15 @@ public void setMexFundedRatio(Integer mexFundedRatio) { } - public OrderCampaignsInner deductedAmount(Integer deductedAmount) { + public OrderCampaign deductedAmount(Integer deductedAmount) { this.deductedAmount = deductedAmount; return this; } - /** + /** * The deducted amount in minor unit format. `Item price(tax inclusive) * 20% discount | 2375*0.2` * @return deductedAmount - **/ + */ @javax.annotation.Nullable public Integer getDeductedAmount() { return deductedAmount; @@ -429,15 +434,15 @@ public void setDeductedAmount(Integer deductedAmount) { } - public OrderCampaignsInner deductedPart(DeductedPartEnum deductedPart) { + public OrderCampaign deductedPart(DeductedPartEnum deductedPart) { this.deductedPart = deductedPart; return this; } - /** + /** * The part that the campaign is applied. * @return deductedPart - **/ + */ @javax.annotation.Nullable public DeductedPartEnum getDeductedPart() { return deductedPart; @@ -448,12 +453,12 @@ public void setDeductedPart(DeductedPartEnum deductedPart) { } - public OrderCampaignsInner appliedItemIDs(List appliedItemIDs) { + public OrderCampaign appliedItemIDs(List appliedItemIDs) { this.appliedItemIDs = appliedItemIDs; return this; } - public OrderCampaignsInner addAppliedItemIDsItem(String appliedItemIDsItem) { + public OrderCampaign addAppliedItemIDsItem(String appliedItemIDsItem) { if (this.appliedItemIDs == null) { this.appliedItemIDs = new ArrayList<>(); } @@ -461,10 +466,10 @@ public OrderCampaignsInner addAppliedItemIDsItem(String appliedItemIDsItem) { return this; } - /** + /** * An array of item IDs that get discount under this campaign. `null` if no item applied in this campaign. * @return appliedItemIDs - **/ + */ @javax.annotation.Nullable public List getAppliedItemIDs() { return appliedItemIDs; @@ -475,24 +480,68 @@ public void setAppliedItemIDs(List appliedItemIDs) { } - public OrderCampaignsInner freeItem(FreeItem freeItem) { + public OrderCampaign freeItem(OrderFreeItem freeItem) { this.freeItem = freeItem; return this; } - /** + /** * Get freeItem * @return freeItem - **/ + */ @javax.annotation.Nullable - public FreeItem getFreeItem() { + public OrderFreeItem getFreeItem() { return freeItem; } - public void setFreeItem(FreeItem freeItem) { + public void setFreeItem(OrderFreeItem freeItem) { this.freeItem = freeItem; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderCampaign instance itself + */ + public OrderCampaign putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -503,18 +552,19 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - OrderCampaignsInner orderCampaignsInner = (OrderCampaignsInner) o; - return Objects.equals(this.id, orderCampaignsInner.id) && - Objects.equals(this.name, orderCampaignsInner.name) && - Objects.equals(this.campaignNameForMex, orderCampaignsInner.campaignNameForMex) && - Objects.equals(this.level, orderCampaignsInner.level) && - Objects.equals(this.type, orderCampaignsInner.type) && - Objects.equals(this.usageCount, orderCampaignsInner.usageCount) && - Objects.equals(this.mexFundedRatio, orderCampaignsInner.mexFundedRatio) && - Objects.equals(this.deductedAmount, orderCampaignsInner.deductedAmount) && - Objects.equals(this.deductedPart, orderCampaignsInner.deductedPart) && - Objects.equals(this.appliedItemIDs, orderCampaignsInner.appliedItemIDs) && - Objects.equals(this.freeItem, orderCampaignsInner.freeItem); + OrderCampaign orderCampaign = (OrderCampaign) o; + return Objects.equals(this.id, orderCampaign.id) && + Objects.equals(this.name, orderCampaign.name) && + Objects.equals(this.campaignNameForMex, orderCampaign.campaignNameForMex) && + Objects.equals(this.level, orderCampaign.level) && + Objects.equals(this.type, orderCampaign.type) && + Objects.equals(this.usageCount, orderCampaign.usageCount) && + Objects.equals(this.mexFundedRatio, orderCampaign.mexFundedRatio) && + Objects.equals(this.deductedAmount, orderCampaign.deductedAmount) && + Objects.equals(this.deductedPart, orderCampaign.deductedPart) && + Objects.equals(this.appliedItemIDs, orderCampaign.appliedItemIDs) && + Objects.equals(this.freeItem, orderCampaign.freeItem)&& + Objects.equals(this.additionalProperties, orderCampaign.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -523,7 +573,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(id, name, campaignNameForMex, level, type, usageCount, mexFundedRatio, deductedAmount, deductedPart, appliedItemIDs, freeItem); + return Objects.hash(id, name, campaignNameForMex, level, type, usageCount, mexFundedRatio, deductedAmount, deductedPart, appliedItemIDs, freeItem, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -536,7 +586,7 @@ private static int hashCodeNullable(JsonNullable a) { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class OrderCampaignsInner {\n"); + sb.append("class OrderCampaign {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" campaignNameForMex: ").append(toIndentedString(campaignNameForMex)).append("\n"); @@ -548,6 +598,7 @@ public String toString() { sb.append(" deductedPart: ").append(toIndentedString(deductedPart)).append("\n"); sb.append(" appliedItemIDs: ").append(toIndentedString(appliedItemIDs)).append("\n"); sb.append(" freeItem: ").append(toIndentedString(freeItem)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -586,24 +637,16 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OrderCampaignsInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderCampaign + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!OrderCampaignsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in OrderCampaignsInner is not found in the empty JSON string", OrderCampaignsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OrderCampaignsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrderCampaignsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!OrderCampaign.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OrderCampaign is not found in the empty JSON string", OrderCampaign.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -643,7 +686,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // validate the optional field `freeItem` if (jsonObj.get("freeItem") != null && !jsonObj.get("freeItem").isJsonNull()) { - FreeItem.validateJsonElement(jsonObj.get("freeItem")); + OrderFreeItem.validateJsonElement(jsonObj.get("freeItem")); } } @@ -651,47 +694,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!OrderCampaignsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'OrderCampaignsInner' and its subtypes + if (!OrderCampaign.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OrderCampaign' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(OrderCampaignsInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OrderCampaign.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, OrderCampaignsInner value) throws IOException { + public void write(JsonWriter out, OrderCampaign value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public OrderCampaignsInner read(JsonReader in) throws IOException { + public OrderCampaign read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderCampaign instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OrderCampaignsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of OrderCampaignsInner - * @throws IOException if the JSON string is invalid with respect to OrderCampaignsInner - */ - public static OrderCampaignsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, OrderCampaignsInner.class); + /** + * Create an instance of OrderCampaign given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderCampaign + * @throws IOException if the JSON string is invalid with respect to OrderCampaign + */ + public static OrderCampaign fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OrderCampaign.class); } - /** - * Convert an instance of OrderCampaignsInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderCampaign to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OrderDeliveryRequest.java b/src/main/java/com/grabfood/client/model/OrderDeliveryRequest.java index b6b8af7..e7c0f77 100644 --- a/src/main/java/com/grabfood/client/model/OrderDeliveryRequest.java +++ b/src/main/java/com/grabfood/client/model/OrderDeliveryRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request marks an order as delivered on GrabFood. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class OrderDeliveryRequest { public static final String SERIALIZED_NAME_ORDER_I_D = "orderID"; @SerializedName(SERIALIZED_NAME_ORDER_I_D) @@ -65,9 +64,11 @@ public class OrderDeliveryRequest { public enum FromStateEnum { ACCEPTED("Accepted"), - FINDDRIVER("FindDriver"), + FIND_DRIVER("FindDriver"), - COLLECTED("Collected"); + COLLECTED("Collected"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -90,7 +91,7 @@ public static FromStateEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -121,11 +122,13 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti */ @JsonAdapter(ToStateEnum.Adapter.class) public enum ToStateEnum { - FINDDRIVER("FindDriver"), + FIND_DRIVER("FindDriver"), COLLECTED("Collected"), - DELIVERED("Delivered"); + DELIVERED("Delivered"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -148,7 +151,7 @@ public static ToStateEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -182,10 +185,10 @@ public OrderDeliveryRequest orderID(String orderID) { return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -201,10 +204,10 @@ public OrderDeliveryRequest fromState(FromStateEnum fromState) { return this; } - /** + /** * Specify the order's initial state. * @return fromState - **/ + */ @javax.annotation.Nonnull public FromStateEnum getFromState() { return fromState; @@ -220,10 +223,10 @@ public OrderDeliveryRequest toState(ToStateEnum toState) { return this; } - /** + /** * Specify the order's new state. * @return toState - **/ + */ @javax.annotation.Nonnull public ToStateEnum getToState() { return toState; @@ -233,6 +236,50 @@ public void setToState(ToStateEnum toState) { this.toState = toState; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderDeliveryRequest instance itself + */ + public OrderDeliveryRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -246,12 +293,13 @@ public boolean equals(Object o) { OrderDeliveryRequest orderDeliveryRequest = (OrderDeliveryRequest) o; return Objects.equals(this.orderID, orderDeliveryRequest.orderID) && Objects.equals(this.fromState, orderDeliveryRequest.fromState) && - Objects.equals(this.toState, orderDeliveryRequest.toState); + Objects.equals(this.toState, orderDeliveryRequest.toState)&& + Objects.equals(this.additionalProperties, orderDeliveryRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(orderID, fromState, toState); + return Objects.hash(orderID, fromState, toState, additionalProperties); } @Override @@ -261,6 +309,7 @@ public String toString() { sb.append(" orderID: ").append(toIndentedString(orderID)).append("\n"); sb.append(" fromState: ").append(toIndentedString(fromState)).append("\n"); sb.append(" toState: ").append(toIndentedString(toState)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,12 +343,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("toState"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OrderDeliveryRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderDeliveryRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!OrderDeliveryRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -307,14 +356,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OrderDeliveryRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrderDeliveryRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : OrderDeliveryRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -352,6 +393,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, OrderDeliveryRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -359,29 +422,50 @@ public void write(JsonWriter out, OrderDeliveryRequest value) throws IOException public OrderDeliveryRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderDeliveryRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OrderDeliveryRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of OrderDeliveryRequest - * @throws IOException if the JSON string is invalid with respect to OrderDeliveryRequest - */ + /** + * Create an instance of OrderDeliveryRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderDeliveryRequest + * @throws IOException if the JSON string is invalid with respect to OrderDeliveryRequest + */ public static OrderDeliveryRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, OrderDeliveryRequest.class); } - /** - * Convert an instance of OrderDeliveryRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderDeliveryRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/FeatureFlags.java b/src/main/java/com/grabfood/client/model/OrderFeatureFlags.java similarity index 58% rename from src/main/java/com/grabfood/client/model/FeatureFlags.java rename to src/main/java/com/grabfood/client/model/OrderFeatureFlags.java index f45d88c..8c1348b 100644 --- a/src/main/java/com/grabfood/client/model/FeatureFlags.java +++ b/src/main/java/com/grabfood/client/model/OrderFeatureFlags.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,8 +51,8 @@ /** * The featureFlag JSON object containing an order's feature related information. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class FeatureFlags { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class OrderFeatureFlags { /** * The acceptance type for the order. Refer to FAQs for more details about [orderAcceptedType](#section/Order/How-do-I-identify-if-a-particular-order-is-auto-or-manual-acceptance). */ @@ -61,7 +60,9 @@ public class FeatureFlags { public enum OrderAcceptedTypeEnum { AUTO("AUTO"), - MANUAL("MANUAL"); + MANUAL("MANUAL"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -84,7 +85,7 @@ public static OrderAcceptedTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -115,13 +116,15 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti */ @JsonAdapter(OrderTypeEnum.Adapter.class) public enum OrderTypeEnum { - TAKEAWAY("TakeAway"), + TAKE_AWAY("TakeAway"), + + DELIVERED_BY_GRAB("DeliveredByGrab"), - DELIVEREDBYGRAB("DeliveredByGrab"), + DELIVERED_BY_RESTAURANT("DeliveredByRestaurant"), - DELIVEREDBYRESTAURANT("DeliveredByRestaurant"), + DINE_IN("DineIn"), - DINEIN("DineIn"); + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -144,7 +147,7 @@ public static OrderTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -174,18 +177,18 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_IS_MEX_EDIT_ORDER) private Boolean isMexEditOrder; - public FeatureFlags() { + public OrderFeatureFlags() { } - public FeatureFlags orderAcceptedType(OrderAcceptedTypeEnum orderAcceptedType) { + public OrderFeatureFlags orderAcceptedType(OrderAcceptedTypeEnum orderAcceptedType) { this.orderAcceptedType = orderAcceptedType; return this; } - /** + /** * The acceptance type for the order. Refer to FAQs for more details about [orderAcceptedType](#section/Order/How-do-I-identify-if-a-particular-order-is-auto-or-manual-acceptance). * @return orderAcceptedType - **/ + */ @javax.annotation.Nonnull public OrderAcceptedTypeEnum getOrderAcceptedType() { return orderAcceptedType; @@ -196,15 +199,15 @@ public void setOrderAcceptedType(OrderAcceptedTypeEnum orderAcceptedType) { } - public FeatureFlags orderType(OrderTypeEnum orderType) { + public OrderFeatureFlags orderType(OrderTypeEnum orderType) { this.orderType = orderType; return this; } - /** + /** * The type of order. * @return orderType - **/ + */ @javax.annotation.Nonnull public OrderTypeEnum getOrderType() { return orderType; @@ -215,15 +218,15 @@ public void setOrderType(OrderTypeEnum orderType) { } - public FeatureFlags isMexEditOrder(Boolean isMexEditOrder) { + public OrderFeatureFlags isMexEditOrder(Boolean isMexEditOrder) { this.isMexEditOrder = isMexEditOrder; return this; } - /** + /** * A boolean value that indicates if the order is edited. * @return isMexEditOrder - **/ + */ @javax.annotation.Nullable public Boolean getIsMexEditOrder() { return isMexEditOrder; @@ -233,6 +236,50 @@ public void setIsMexEditOrder(Boolean isMexEditOrder) { this.isMexEditOrder = isMexEditOrder; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderFeatureFlags instance itself + */ + public OrderFeatureFlags putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -243,24 +290,26 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - FeatureFlags featureFlags = (FeatureFlags) o; - return Objects.equals(this.orderAcceptedType, featureFlags.orderAcceptedType) && - Objects.equals(this.orderType, featureFlags.orderType) && - Objects.equals(this.isMexEditOrder, featureFlags.isMexEditOrder); + OrderFeatureFlags orderFeatureFlags = (OrderFeatureFlags) o; + return Objects.equals(this.orderAcceptedType, orderFeatureFlags.orderAcceptedType) && + Objects.equals(this.orderType, orderFeatureFlags.orderType) && + Objects.equals(this.isMexEditOrder, orderFeatureFlags.isMexEditOrder)&& + Objects.equals(this.additionalProperties, orderFeatureFlags.additionalProperties); } @Override public int hashCode() { - return Objects.hash(orderAcceptedType, orderType, isMexEditOrder); + return Objects.hash(orderAcceptedType, orderType, isMexEditOrder, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class FeatureFlags {\n"); + sb.append("class OrderFeatureFlags {\n"); sb.append(" orderAcceptedType: ").append(toIndentedString(orderAcceptedType)).append("\n"); sb.append(" orderType: ").append(toIndentedString(orderType)).append("\n"); sb.append(" isMexEditOrder: ").append(toIndentedString(isMexEditOrder)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -293,29 +342,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("orderType"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to FeatureFlags - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderFeatureFlags + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!FeatureFlags.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in FeatureFlags is not found in the empty JSON string", FeatureFlags.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FeatureFlags.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FeatureFlags` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!OrderFeatureFlags.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OrderFeatureFlags is not found in the empty JSON string", OrderFeatureFlags.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : FeatureFlags.openapiRequiredFields) { + for (String requiredField : OrderFeatureFlags.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -337,47 +378,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!FeatureFlags.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'FeatureFlags' and its subtypes + if (!OrderFeatureFlags.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OrderFeatureFlags' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(FeatureFlags.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OrderFeatureFlags.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, FeatureFlags value) throws IOException { + public void write(JsonWriter out, OrderFeatureFlags value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public FeatureFlags read(JsonReader in) throws IOException { + public OrderFeatureFlags read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderFeatureFlags instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of FeatureFlags given an JSON string - * - * @param jsonString JSON string - * @return An instance of FeatureFlags - * @throws IOException if the JSON string is invalid with respect to FeatureFlags - */ - public static FeatureFlags fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, FeatureFlags.class); + /** + * Create an instance of OrderFeatureFlags given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderFeatureFlags + * @throws IOException if the JSON string is invalid with respect to OrderFeatureFlags + */ + public static OrderFeatureFlags fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OrderFeatureFlags.class); } - /** - * Convert an instance of FeatureFlags to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderFeatureFlags to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OrderFreeItem.java b/src/main/java/com/grabfood/client/model/OrderFreeItem.java new file mode 100644 index 0000000..62ffbd8 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/OrderFreeItem.java @@ -0,0 +1,370 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * Free item information for `freeItem` campaign. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class OrderFreeItem { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_QUANTITY = "quantity"; + @SerializedName(SERIALIZED_NAME_QUANTITY) + private Integer quantity; + + public static final String SERIALIZED_NAME_PRICE = "price"; + @SerializedName(SERIALIZED_NAME_PRICE) + private Integer price; + + public OrderFreeItem() { + } + + public OrderFreeItem id(String id) { + this.id = id; + return this; + } + + /** + * The item's ID + * @return id + */ + @javax.annotation.Nullable + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public OrderFreeItem name(String name) { + this.name = name; + return this; + } + + /** + * The name of the item. + * @return name + */ + @javax.annotation.Nullable + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + public OrderFreeItem quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * The item's quantity. Maximum is **1**. + * @return quantity + */ + @javax.annotation.Nullable + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + + public OrderFreeItem price(Integer price) { + this.price = price; + return this; + } + + /** + * The item's price in minor unit format. + * @return price + */ + @javax.annotation.Nullable + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderFreeItem instance itself + */ + public OrderFreeItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OrderFreeItem orderFreeItem = (OrderFreeItem) o; + return Objects.equals(this.id, orderFreeItem.id) && + Objects.equals(this.name, orderFreeItem.name) && + Objects.equals(this.quantity, orderFreeItem.quantity) && + Objects.equals(this.price, orderFreeItem.price)&& + Objects.equals(this.additionalProperties, orderFreeItem.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, quantity, price, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OrderFreeItem {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("name"); + openapiFields.add("quantity"); + openapiFields.add("price"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderFreeItem + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OrderFreeItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OrderFreeItem is not found in the empty JSON string", OrderFreeItem.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OrderFreeItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OrderFreeItem' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OrderFreeItem.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OrderFreeItem value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public OrderFreeItem read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderFreeItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OrderFreeItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderFreeItem + * @throws IOException if the JSON string is invalid with respect to OrderFreeItem + */ + public static OrderFreeItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OrderFreeItem.class); + } + + /** + * Convert an instance of OrderFreeItem to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/OrderItemsInner.java b/src/main/java/com/grabfood/client/model/OrderItem.java similarity index 61% rename from src/main/java/com/grabfood/client/model/OrderItemsInner.java rename to src/main/java/com/grabfood/client/model/OrderItem.java index 65199d0..734d867 100644 --- a/src/main/java/com/grabfood/client/model/OrderItemsInner.java +++ b/src/main/java/com/grabfood/client/model/OrderItem.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.OrderModifiersInner; +import com.grabfood.client.model.OrderItemModifier; import com.grabfood.client.model.OutOfStockInstruction; import java.io.IOException; import java.util.ArrayList; @@ -45,7 +45,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,10 +54,10 @@ import com.grabfood.client.JSON; /** - * OrderItemsInner + * OrderItem */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class OrderItemsInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class OrderItem { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -89,20 +88,20 @@ public class OrderItemsInner { public static final String SERIALIZED_NAME_MODIFIERS = "modifiers"; @SerializedName(SERIALIZED_NAME_MODIFIERS) - private List modifiers = new ArrayList<>(); + private List modifiers = new ArrayList<>(); - public OrderItemsInner() { + public OrderItem() { } - public OrderItemsInner id(String id) { + public OrderItem id(String id) { this.id = id; return this; } - /** + /** * The item's ExternalID in the partner system. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -113,15 +112,15 @@ public void setId(String id) { } - public OrderItemsInner grabItemID(String grabItemID) { + public OrderItem grabItemID(String grabItemID) { this.grabItemID = grabItemID; return this; } - /** + /** * The item's ID in Grab system. Partner can use this field in the `EditOrder` endpoint. * @return grabItemID - **/ + */ @javax.annotation.Nonnull public String getGrabItemID() { return grabItemID; @@ -132,15 +131,15 @@ public void setGrabItemID(String grabItemID) { } - public OrderItemsInner quantity(Integer quantity) { + public OrderItem quantity(Integer quantity) { this.quantity = quantity; return this; } - /** + /** * The number of the item ordered. * @return quantity - **/ + */ @javax.annotation.Nonnull public Integer getQuantity() { return quantity; @@ -151,15 +150,15 @@ public void setQuantity(Integer quantity) { } - public OrderItemsInner price(Integer price) { + public OrderItem price(Integer price) { this.price = price; return this; } - /** + /** * The price (tax-inclusive) in minor format for 1 item and modifiers under it. `Item price(tax inclusive) + Modifier price(tax inclusive) | (2241*1.06)+(165*1.06)=2550`. * @return price - **/ + */ @javax.annotation.Nonnull public Integer getPrice() { return price; @@ -170,15 +169,15 @@ public void setPrice(Integer price) { } - public OrderItemsInner tax(Integer tax) { + public OrderItem tax(Integer tax) { this.tax = tax; return this; } - /** + /** * Tax in minor format for 1 item and all modifiers under it. `0` if tax configuration is absent. `Item tax + Modifier tax | (2241*0.06)+(165*0.06)=144`. Refer to FAQs for more details about [tax](#section/Order/How-is-tax-calculated). * @return tax - **/ + */ @javax.annotation.Nullable public Integer getTax() { return tax; @@ -189,15 +188,15 @@ public void setTax(Integer tax) { } - public OrderItemsInner specifications(String specifications) { + public OrderItem specifications(String specifications) { this.specifications = specifications; return this; } - /** + /** * An extra note for the merchant. `Blank` if no note from consumer. * @return specifications - **/ + */ @javax.annotation.Nullable public String getSpecifications() { return specifications; @@ -208,15 +207,15 @@ public void setSpecifications(String specifications) { } - public OrderItemsInner outOfStockInstruction(OutOfStockInstruction outOfStockInstruction) { + public OrderItem outOfStockInstruction(OutOfStockInstruction outOfStockInstruction) { this.outOfStockInstruction = outOfStockInstruction; return this; } - /** + /** * Get outOfStockInstruction * @return outOfStockInstruction - **/ + */ @javax.annotation.Nullable public OutOfStockInstruction getOutOfStockInstruction() { return outOfStockInstruction; @@ -227,12 +226,12 @@ public void setOutOfStockInstruction(OutOfStockInstruction outOfStockInstruction } - public OrderItemsInner modifiers(List modifiers) { + public OrderItem modifiers(List modifiers) { this.modifiers = modifiers; return this; } - public OrderItemsInner addModifiersItem(OrderModifiersInner modifiersItem) { + public OrderItem addModifiersItem(OrderItemModifier modifiersItem) { if (this.modifiers == null) { this.modifiers = new ArrayList<>(); } @@ -240,19 +239,63 @@ public OrderItemsInner addModifiersItem(OrderModifiersInner modifiersItem) { return this; } - /** + /** * An array of JSON objects modifiers. Read [this](#categories) for more information. * @return modifiers - **/ + */ @javax.annotation.Nullable - public List getModifiers() { + public List getModifiers() { return modifiers; } - public void setModifiers(List modifiers) { + public void setModifiers(List modifiers) { this.modifiers = modifiers; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderItem instance itself + */ + public OrderItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -263,15 +306,16 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - OrderItemsInner orderItemsInner = (OrderItemsInner) o; - return Objects.equals(this.id, orderItemsInner.id) && - Objects.equals(this.grabItemID, orderItemsInner.grabItemID) && - Objects.equals(this.quantity, orderItemsInner.quantity) && - Objects.equals(this.price, orderItemsInner.price) && - Objects.equals(this.tax, orderItemsInner.tax) && - Objects.equals(this.specifications, orderItemsInner.specifications) && - Objects.equals(this.outOfStockInstruction, orderItemsInner.outOfStockInstruction) && - Objects.equals(this.modifiers, orderItemsInner.modifiers); + OrderItem orderItem = (OrderItem) o; + return Objects.equals(this.id, orderItem.id) && + Objects.equals(this.grabItemID, orderItem.grabItemID) && + Objects.equals(this.quantity, orderItem.quantity) && + Objects.equals(this.price, orderItem.price) && + Objects.equals(this.tax, orderItem.tax) && + Objects.equals(this.specifications, orderItem.specifications) && + Objects.equals(this.outOfStockInstruction, orderItem.outOfStockInstruction) && + Objects.equals(this.modifiers, orderItem.modifiers)&& + Objects.equals(this.additionalProperties, orderItem.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -280,7 +324,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(id, grabItemID, quantity, price, tax, specifications, outOfStockInstruction, modifiers); + return Objects.hash(id, grabItemID, quantity, price, tax, specifications, outOfStockInstruction, modifiers, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -293,7 +337,7 @@ private static int hashCodeNullable(JsonNullable a) { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class OrderItemsInner {\n"); + sb.append("class OrderItem {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" grabItemID: ").append(toIndentedString(grabItemID)).append("\n"); sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); @@ -302,6 +346,7 @@ public String toString() { sb.append(" specifications: ").append(toIndentedString(specifications)).append("\n"); sb.append(" outOfStockInstruction: ").append(toIndentedString(outOfStockInstruction)).append("\n"); sb.append(" modifiers: ").append(toIndentedString(modifiers)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -341,29 +386,21 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("price"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OrderItemsInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderItem + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!OrderItemsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in OrderItemsInner is not found in the empty JSON string", OrderItemsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OrderItemsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrderItemsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!OrderItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OrderItem is not found in the empty JSON string", OrderItem.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : OrderItemsInner.openapiRequiredFields) { + for (String requiredField : OrderItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -392,7 +429,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `modifiers` (array) for (int i = 0; i < jsonArraymodifiers.size(); i++) { - OrderModifiersInner.validateJsonElement(jsonArraymodifiers.get(i)); + OrderItemModifier.validateJsonElement(jsonArraymodifiers.get(i)); }; } } @@ -402,47 +439,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!OrderItemsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'OrderItemsInner' and its subtypes + if (!OrderItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OrderItem' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(OrderItemsInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OrderItem.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, OrderItemsInner value) throws IOException { + public void write(JsonWriter out, OrderItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public OrderItemsInner read(JsonReader in) throws IOException { + public OrderItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OrderItemsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of OrderItemsInner - * @throws IOException if the JSON string is invalid with respect to OrderItemsInner - */ - public static OrderItemsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, OrderItemsInner.class); + /** + * Create an instance of OrderItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderItem + * @throws IOException if the JSON string is invalid with respect to OrderItem + */ + public static OrderItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OrderItem.class); } - /** - * Convert an instance of OrderItemsInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderItem to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OrderModifiersInner.java b/src/main/java/com/grabfood/client/model/OrderItemModifier.java similarity index 52% rename from src/main/java/com/grabfood/client/model/OrderModifiersInner.java rename to src/main/java/com/grabfood/client/model/OrderItemModifier.java index 91abd78..e5f3357 100644 --- a/src/main/java/com/grabfood/client/model/OrderModifiersInner.java +++ b/src/main/java/com/grabfood/client/model/OrderItemModifier.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -50,10 +49,10 @@ import com.grabfood.client.JSON; /** - * OrderModifiersInner + * OrderItemModifier */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class OrderModifiersInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class OrderItemModifier { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) private String id; @@ -71,7 +70,9 @@ public class OrderModifiersInner { */ @JsonAdapter(QuantityEnum.Adapter.class) public enum QuantityEnum { - NUMBER_1(1); + NUMBER_1(1), + + NUMBER_unknown_default_open_api(11184809); private Integer value; @@ -94,7 +95,7 @@ public static QuantityEnum fromValue(Integer value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return NUMBER_unknown_default_open_api; } public static class Adapter extends TypeAdapter { @@ -120,18 +121,18 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_QUANTITY) private QuantityEnum quantity; - public OrderModifiersInner() { + public OrderItemModifier() { } - public OrderModifiersInner id(String id) { + public OrderItemModifier id(String id) { this.id = id; return this; } - /** + /** * The modifier's ID that is on the partner's system. * @return id - **/ + */ @javax.annotation.Nullable public String getId() { return id; @@ -142,15 +143,15 @@ public void setId(String id) { } - public OrderModifiersInner price(Integer price) { + public OrderItemModifier price(Integer price) { this.price = price; return this; } - /** + /** * The modifier's price (tax-inclusive) in minor format. `round(165 * (1 + 0.06)) = 175`. * @return price - **/ + */ @javax.annotation.Nullable public Integer getPrice() { return price; @@ -161,15 +162,15 @@ public void setPrice(Integer price) { } - public OrderModifiersInner tax(Integer tax) { + public OrderItemModifier tax(Integer tax) { this.tax = tax; return this; } - /** + /** * Tax in minor format for 1 modifier. `165*0.06=10`. Refer to FAQs for more details about [tax](#section/Order/How-is-tax-calculated). * @return tax - **/ + */ @javax.annotation.Nullable public Integer getTax() { return tax; @@ -180,15 +181,15 @@ public void setTax(Integer tax) { } - public OrderModifiersInner quantity(QuantityEnum quantity) { + public OrderItemModifier quantity(QuantityEnum quantity) { this.quantity = quantity; return this; } - /** + /** * The number of modifiers present. The value is always 1. * @return quantity - **/ + */ @javax.annotation.Nullable public QuantityEnum getQuantity() { return quantity; @@ -198,6 +199,50 @@ public void setQuantity(QuantityEnum quantity) { this.quantity = quantity; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderItemModifier instance itself + */ + public OrderItemModifier putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -208,26 +253,28 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - OrderModifiersInner orderModifiersInner = (OrderModifiersInner) o; - return Objects.equals(this.id, orderModifiersInner.id) && - Objects.equals(this.price, orderModifiersInner.price) && - Objects.equals(this.tax, orderModifiersInner.tax) && - Objects.equals(this.quantity, orderModifiersInner.quantity); + OrderItemModifier orderItemModifier = (OrderItemModifier) o; + return Objects.equals(this.id, orderItemModifier.id) && + Objects.equals(this.price, orderItemModifier.price) && + Objects.equals(this.tax, orderItemModifier.tax) && + Objects.equals(this.quantity, orderItemModifier.quantity)&& + Objects.equals(this.additionalProperties, orderItemModifier.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, price, tax, quantity); + return Objects.hash(id, price, tax, quantity, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class OrderModifiersInner {\n"); + sb.append("class OrderItemModifier {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" price: ").append(toIndentedString(price)).append("\n"); sb.append(" tax: ").append(toIndentedString(tax)).append("\n"); sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -259,24 +306,16 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OrderModifiersInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderItemModifier + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!OrderModifiersInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in OrderModifiersInner is not found in the empty JSON string", OrderModifiersInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OrderModifiersInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrderModifiersInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!OrderItemModifier.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OrderItemModifier is not found in the empty JSON string", OrderItemModifier.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -293,47 +332,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!OrderModifiersInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'OrderModifiersInner' and its subtypes + if (!OrderItemModifier.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OrderItemModifier' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(OrderModifiersInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OrderItemModifier.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, OrderModifiersInner value) throws IOException { + public void write(JsonWriter out, OrderItemModifier value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public OrderModifiersInner read(JsonReader in) throws IOException { + public OrderItemModifier read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderItemModifier instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OrderModifiersInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of OrderModifiersInner - * @throws IOException if the JSON string is invalid with respect to OrderModifiersInner - */ - public static OrderModifiersInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, OrderModifiersInner.class); + /** + * Create an instance of OrderItemModifier given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderItemModifier + * @throws IOException if the JSON string is invalid with respect to OrderItemModifier + */ + public static OrderItemModifier fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OrderItemModifier.class); } - /** - * Convert an instance of OrderModifiersInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderItemModifier to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OrderPrice.java b/src/main/java/com/grabfood/client/model/OrderPrice.java index ee6e363..833c7d7 100644 --- a/src/main/java/com/grabfood/client/model/OrderPrice.java +++ b/src/main/java/com/grabfood/client/model/OrderPrice.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * A JSON object containing order's price in the minor unit format. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class OrderPrice { public static final String SERIALIZED_NAME_SUBTOTAL = "subtotal"; @SerializedName(SERIALIZED_NAME_SUBTOTAL) @@ -94,10 +93,10 @@ public OrderPrice subtotal(Integer subtotal) { return this; } - /** + /** * Total item and modifier price (tax-inclusive) in the minor unit. `Sum of all (Item price * quantity) | 2550*1=2550`. * @return subtotal - **/ + */ @javax.annotation.Nonnull public Integer getSubtotal() { return subtotal; @@ -113,10 +112,10 @@ public OrderPrice tax(Integer tax) { return this; } - /** + /** * GrabFood's tax in the minor unit. `(subtotal-merchantFundPromo)* Tax /(1+Tax) | (2550-475)*0.06/1.06=117`. Refer to FAQs for more details about [tax](#section/Order/How-is-tax-calculated). * @return tax - **/ + */ @javax.annotation.Nullable public Integer getTax() { return tax; @@ -132,10 +131,10 @@ public OrderPrice merchantChargeFee(Integer merchantChargeFee) { return this; } - /** + /** * Any additional fee charged by merchant, which is 100% paid out to the merchant. Eg. Takeaway, packaging costs, dine-in charge. * @return merchantChargeFee - **/ + */ @javax.annotation.Nullable public Integer getMerchantChargeFee() { return merchantChargeFee; @@ -151,10 +150,10 @@ public OrderPrice grabFundPromo(Integer grabFundPromo) { return this; } - /** + /** * GrabFood's promo fund in the minor unit. Calculated based on funded ratio. * @return grabFundPromo - **/ + */ @javax.annotation.Nullable public Integer getGrabFundPromo() { return grabFundPromo; @@ -170,10 +169,10 @@ public OrderPrice merchantFundPromo(Integer merchantFundPromo) { return this; } - /** + /** * The merchant's promo fund in the minor unit. Calculated based on funded ratio. * @return merchantFundPromo - **/ + */ @javax.annotation.Nullable public Integer getMerchantFundPromo() { return merchantFundPromo; @@ -189,10 +188,10 @@ public OrderPrice basketPromo(Integer basketPromo) { return this; } - /** + /** * The total amount promo applied to the basket items only (item level/order level) in the minor unit. Delivery fee is excluded. `(grabFundPromo + merchantFundPromo) | 300 + 475 = 775` * @return basketPromo - **/ + */ @javax.annotation.Nullable public Integer getBasketPromo() { return basketPromo; @@ -208,10 +207,10 @@ public OrderPrice deliveryFee(Integer deliveryFee) { return this; } - /** + /** * The delivery fee in the minor unit. * @return deliveryFee - **/ + */ @javax.annotation.Nullable public Integer getDeliveryFee() { return deliveryFee; @@ -227,10 +226,10 @@ public OrderPrice eaterPayment(Integer eaterPayment) { return this; } - /** + /** * The total amount consumer paid in the minor unit. `(subtotal + deliveryFee) - (sum of all promo) | (2550+400)-775=2175` * @return eaterPayment - **/ + */ @javax.annotation.Nonnull public Integer getEaterPayment() { return eaterPayment; @@ -240,6 +239,50 @@ public void setEaterPayment(Integer eaterPayment) { this.eaterPayment = eaterPayment; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderPrice instance itself + */ + public OrderPrice putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -258,12 +301,13 @@ public boolean equals(Object o) { Objects.equals(this.merchantFundPromo, orderPrice.merchantFundPromo) && Objects.equals(this.basketPromo, orderPrice.basketPromo) && Objects.equals(this.deliveryFee, orderPrice.deliveryFee) && - Objects.equals(this.eaterPayment, orderPrice.eaterPayment); + Objects.equals(this.eaterPayment, orderPrice.eaterPayment)&& + Objects.equals(this.additionalProperties, orderPrice.additionalProperties); } @Override public int hashCode() { - return Objects.hash(subtotal, tax, merchantChargeFee, grabFundPromo, merchantFundPromo, basketPromo, deliveryFee, eaterPayment); + return Objects.hash(subtotal, tax, merchantChargeFee, grabFundPromo, merchantFundPromo, basketPromo, deliveryFee, eaterPayment, additionalProperties); } @Override @@ -278,6 +322,7 @@ public String toString() { sb.append(" basketPromo: ").append(toIndentedString(basketPromo)).append("\n"); sb.append(" deliveryFee: ").append(toIndentedString(deliveryFee)).append("\n"); sb.append(" eaterPayment: ").append(toIndentedString(eaterPayment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -315,12 +360,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("eaterPayment"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OrderPrice - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderPrice + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!OrderPrice.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -328,14 +373,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OrderPrice.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrderPrice` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : OrderPrice.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -360,6 +397,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, OrderPrice value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -367,29 +426,50 @@ public void write(JsonWriter out, OrderPrice value) throws IOException { public OrderPrice read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderPrice instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OrderPrice given an JSON string - * - * @param jsonString JSON string - * @return An instance of OrderPrice - * @throws IOException if the JSON string is invalid with respect to OrderPrice - */ + /** + * Create an instance of OrderPrice given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderPrice + * @throws IOException if the JSON string is invalid with respect to OrderPrice + */ public static OrderPrice fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, OrderPrice.class); } - /** - * Convert an instance of OrderPrice to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderPrice to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/PromosInner.java b/src/main/java/com/grabfood/client/model/OrderPromo.java similarity index 57% rename from src/main/java/com/grabfood/client/model/PromosInner.java rename to src/main/java/com/grabfood/client/model/OrderPromo.java index a44df81..715a24f 100644 --- a/src/main/java/com/grabfood/client/model/PromosInner.java +++ b/src/main/java/com/grabfood/client/model/OrderPromo.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -50,10 +49,10 @@ import com.grabfood.client.JSON; /** - * PromosInner + * OrderPromo */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class PromosInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class OrderPromo { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) private String code; @@ -86,18 +85,18 @@ public class PromosInner { @SerializedName(SERIALIZED_NAME_PROMO_AMOUNT_IN_MIN) private Integer promoAmountInMin; - public PromosInner() { + public OrderPromo() { } - public PromosInner code(String code) { + public OrderPromo code(String code) { this.code = code; return this; } - /** + /** * Promo code applied in the order. * @return code - **/ + */ @javax.annotation.Nullable public String getCode() { return code; @@ -108,15 +107,15 @@ public void setCode(String code) { } - public PromosInner description(String description) { + public OrderPromo description(String description) { this.description = description; return this; } - /** + /** * Promo description. * @return description - **/ + */ @javax.annotation.Nullable public String getDescription() { return description; @@ -127,15 +126,15 @@ public void setDescription(String description) { } - public PromosInner name(String name) { + public OrderPromo name(String name) { this.name = name; return this; } - /** + /** * Name of the promotion. * @return name - **/ + */ @javax.annotation.Nullable public String getName() { return name; @@ -146,15 +145,15 @@ public void setName(String name) { } - public PromosInner promoAmount(Integer promoAmount) { + public OrderPromo promoAmount(Integer promoAmount) { this.promoAmount = promoAmount; return this; } - /** + /** * Promo amount applied in the order, in local currency. This amount is rounded into whole number. * @return promoAmount - **/ + */ @javax.annotation.Nullable public Integer getPromoAmount() { return promoAmount; @@ -165,15 +164,15 @@ public void setPromoAmount(Integer promoAmount) { } - public PromosInner mexFundedRatio(Integer mexFundedRatio) { + public OrderPromo mexFundedRatio(Integer mexFundedRatio) { this.mexFundedRatio = mexFundedRatio; return this; } - /** + /** * The merchant's funded ratio of the promo in percentage. * @return mexFundedRatio - **/ + */ @javax.annotation.Nullable public Integer getMexFundedRatio() { return mexFundedRatio; @@ -184,15 +183,15 @@ public void setMexFundedRatio(Integer mexFundedRatio) { } - public PromosInner mexFundedAmount(Integer mexFundedAmount) { + public OrderPromo mexFundedAmount(Integer mexFundedAmount) { this.mexFundedAmount = mexFundedAmount; return this; } - /** + /** * The merchant's promo fund in the minor unit. Calculated based on merchant funded ratio. * @return mexFundedAmount - **/ + */ @javax.annotation.Nullable public Integer getMexFundedAmount() { return mexFundedAmount; @@ -203,15 +202,15 @@ public void setMexFundedAmount(Integer mexFundedAmount) { } - public PromosInner targetedPrice(Integer targetedPrice) { + public OrderPromo targetedPrice(Integer targetedPrice) { this.targetedPrice = targetedPrice; return this; } - /** + /** * The subtotal of the order basket in minor unit. * @return targetedPrice - **/ + */ @javax.annotation.Nullable public Integer getTargetedPrice() { return targetedPrice; @@ -222,15 +221,15 @@ public void setTargetedPrice(Integer targetedPrice) { } - public PromosInner promoAmountInMin(Integer promoAmountInMin) { + public OrderPromo promoAmountInMin(Integer promoAmountInMin) { this.promoAmountInMin = promoAmountInMin; return this; } - /** + /** * Promo amount applied in the order in minor unit. * @return promoAmountInMin - **/ + */ @javax.annotation.Nullable public Integer getPromoAmountInMin() { return promoAmountInMin; @@ -240,6 +239,50 @@ public void setPromoAmountInMin(Integer promoAmountInMin) { this.promoAmountInMin = promoAmountInMin; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderPromo instance itself + */ + public OrderPromo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -250,26 +293,27 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - PromosInner promosInner = (PromosInner) o; - return Objects.equals(this.code, promosInner.code) && - Objects.equals(this.description, promosInner.description) && - Objects.equals(this.name, promosInner.name) && - Objects.equals(this.promoAmount, promosInner.promoAmount) && - Objects.equals(this.mexFundedRatio, promosInner.mexFundedRatio) && - Objects.equals(this.mexFundedAmount, promosInner.mexFundedAmount) && - Objects.equals(this.targetedPrice, promosInner.targetedPrice) && - Objects.equals(this.promoAmountInMin, promosInner.promoAmountInMin); + OrderPromo orderPromo = (OrderPromo) o; + return Objects.equals(this.code, orderPromo.code) && + Objects.equals(this.description, orderPromo.description) && + Objects.equals(this.name, orderPromo.name) && + Objects.equals(this.promoAmount, orderPromo.promoAmount) && + Objects.equals(this.mexFundedRatio, orderPromo.mexFundedRatio) && + Objects.equals(this.mexFundedAmount, orderPromo.mexFundedAmount) && + Objects.equals(this.targetedPrice, orderPromo.targetedPrice) && + Objects.equals(this.promoAmountInMin, orderPromo.promoAmountInMin)&& + Objects.equals(this.additionalProperties, orderPromo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(code, description, name, promoAmount, mexFundedRatio, mexFundedAmount, targetedPrice, promoAmountInMin); + return Objects.hash(code, description, name, promoAmount, mexFundedRatio, mexFundedAmount, targetedPrice, promoAmountInMin, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class PromosInner {\n"); + sb.append("class OrderPromo {\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); @@ -278,6 +322,7 @@ public String toString() { sb.append(" mexFundedAmount: ").append(toIndentedString(mexFundedAmount)).append("\n"); sb.append(" targetedPrice: ").append(toIndentedString(targetedPrice)).append("\n"); sb.append(" promoAmountInMin: ").append(toIndentedString(promoAmountInMin)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -313,24 +358,16 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to PromosInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderPromo + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!PromosInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in PromosInner is not found in the empty JSON string", PromosInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PromosInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PromosInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!OrderPromo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OrderPromo is not found in the empty JSON string", OrderPromo.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -349,47 +386,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!PromosInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'PromosInner' and its subtypes + if (!OrderPromo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OrderPromo' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(PromosInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OrderPromo.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, PromosInner value) throws IOException { + public void write(JsonWriter out, OrderPromo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public PromosInner read(JsonReader in) throws IOException { + public OrderPromo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderPromo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of PromosInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of PromosInner - * @throws IOException if the JSON string is invalid with respect to PromosInner - */ - public static PromosInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, PromosInner.class); + /** + * Create an instance of OrderPromo given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderPromo + * @throws IOException if the JSON string is invalid with respect to OrderPromo + */ + public static OrderPromo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OrderPromo.class); } - /** - * Convert an instance of PromosInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderPromo to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OrderReadyEstimation.java b/src/main/java/com/grabfood/client/model/OrderReadyEstimation.java index 95cf5fb..b531e62 100644 --- a/src/main/java/com/grabfood/client/model/OrderReadyEstimation.java +++ b/src/main/java/com/grabfood/client/model/OrderReadyEstimation.java @@ -42,7 +42,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,7 +53,7 @@ /** * Information related to the order ready time estimation. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class OrderReadyEstimation { public static final String SERIALIZED_NAME_ALLOW_CHANGE = "allowChange"; @SerializedName(SERIALIZED_NAME_ALLOW_CHANGE) @@ -80,10 +79,10 @@ public OrderReadyEstimation allowChange(Boolean allowChange) { return this; } - /** + /** * A boolean value indicating if the order ready time can be changed. * @return allowChange - **/ + */ @javax.annotation.Nonnull public Boolean getAllowChange() { return allowChange; @@ -99,10 +98,10 @@ public OrderReadyEstimation estimatedOrderReadyTime(OffsetDateTime estimatedOrde return this; } - /** + /** * The order ready time for this order estimated by GrabFood, based on ISO_8601/RFC3339. * @return estimatedOrderReadyTime - **/ + */ @javax.annotation.Nonnull public OffsetDateTime getEstimatedOrderReadyTime() { return estimatedOrderReadyTime; @@ -118,10 +117,10 @@ public OrderReadyEstimation maxOrderReadyTime(OffsetDateTime maxOrderReadyTime) return this; } - /** + /** * The max allowed order ready time for this order, based on ISO_8601/RFC3339. * @return maxOrderReadyTime - **/ + */ @javax.annotation.Nonnull public OffsetDateTime getMaxOrderReadyTime() { return maxOrderReadyTime; @@ -137,10 +136,10 @@ public OrderReadyEstimation newOrderReadyTime(OffsetDateTime newOrderReadyTime) return this; } - /** + /** * The new order ready time for this order. Only present after a new order ready time is set (default will be null), based on ISO_8601/RFC3339. * @return newOrderReadyTime - **/ + */ @javax.annotation.Nullable public OffsetDateTime getNewOrderReadyTime() { return newOrderReadyTime; @@ -150,6 +149,50 @@ public void setNewOrderReadyTime(OffsetDateTime newOrderReadyTime) { this.newOrderReadyTime = newOrderReadyTime; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderReadyEstimation instance itself + */ + public OrderReadyEstimation putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -164,7 +207,8 @@ public boolean equals(Object o) { return Objects.equals(this.allowChange, orderReadyEstimation.allowChange) && Objects.equals(this.estimatedOrderReadyTime, orderReadyEstimation.estimatedOrderReadyTime) && Objects.equals(this.maxOrderReadyTime, orderReadyEstimation.maxOrderReadyTime) && - Objects.equals(this.newOrderReadyTime, orderReadyEstimation.newOrderReadyTime); + Objects.equals(this.newOrderReadyTime, orderReadyEstimation.newOrderReadyTime)&& + Objects.equals(this.additionalProperties, orderReadyEstimation.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -173,7 +217,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(allowChange, estimatedOrderReadyTime, maxOrderReadyTime, newOrderReadyTime); + return Objects.hash(allowChange, estimatedOrderReadyTime, maxOrderReadyTime, newOrderReadyTime, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -191,6 +235,7 @@ public String toString() { sb.append(" estimatedOrderReadyTime: ").append(toIndentedString(estimatedOrderReadyTime)).append("\n"); sb.append(" maxOrderReadyTime: ").append(toIndentedString(maxOrderReadyTime)).append("\n"); sb.append(" newOrderReadyTime: ").append(toIndentedString(newOrderReadyTime)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -225,12 +270,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("maxOrderReadyTime"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OrderReadyEstimation - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderReadyEstimation + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!OrderReadyEstimation.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -238,14 +283,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OrderReadyEstimation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrderReadyEstimation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : OrderReadyEstimation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -270,6 +307,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, OrderReadyEstimation value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -277,29 +336,50 @@ public void write(JsonWriter out, OrderReadyEstimation value) throws IOException public OrderReadyEstimation read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderReadyEstimation instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OrderReadyEstimation given an JSON string - * - * @param jsonString JSON string - * @return An instance of OrderReadyEstimation - * @throws IOException if the JSON string is invalid with respect to OrderReadyEstimation - */ + /** + * Create an instance of OrderReadyEstimation given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderReadyEstimation + * @throws IOException if the JSON string is invalid with respect to OrderReadyEstimation + */ public static OrderReadyEstimation fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, OrderReadyEstimation.class); } - /** - * Convert an instance of OrderReadyEstimation to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderReadyEstimation to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OrderStateRequest.java b/src/main/java/com/grabfood/client/model/OrderStateRequest.java index 348a0b2..3438751 100644 --- a/src/main/java/com/grabfood/client/model/OrderStateRequest.java +++ b/src/main/java/com/grabfood/client/model/OrderStateRequest.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * This request pushes the state of an order on GrabFood. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class OrderStateRequest { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -80,7 +79,9 @@ public enum StateEnum { FAILED("FAILED"), - CANCELLED("CANCELLED"); + CANCELLED("CANCELLED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -103,7 +104,7 @@ public static StateEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -149,10 +150,10 @@ public OrderStateRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -168,10 +169,10 @@ public OrderStateRequest orderID(String orderID) { return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -187,10 +188,10 @@ public OrderStateRequest state(StateEnum state) { return this; } - /** + /** * The current order state. For takeaway orders, only `DELIVERED` and `CANCELLED` states are pushed. * @return state - **/ + */ @javax.annotation.Nonnull public StateEnum getState() { return state; @@ -206,10 +207,10 @@ public OrderStateRequest driverETA(Integer driverETA) { return this; } - /** + /** * The driver's estimated of arrival (ETA) in seconds when the state is `DRIVER_ALLOCATED`. * @return driverETA - **/ + */ @javax.annotation.Nullable public Integer getDriverETA() { return driverETA; @@ -225,10 +226,10 @@ public OrderStateRequest code(String code) { return this; } - /** + /** * The current order's sub-state. This is in free text so you should only use for reference. Grab may use this for troubleshooting. If you want some analysis, kindly use `state` instead. * @return code - **/ + */ @javax.annotation.Nullable public String getCode() { return code; @@ -244,10 +245,10 @@ public OrderStateRequest message(String message) { return this; } - /** + /** * Additional information to explain the current order state. May be system status or human entered message. * @return message - **/ + */ @javax.annotation.Nullable public String getMessage() { return message; @@ -257,6 +258,50 @@ public void setMessage(String message) { this.message = message; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OrderStateRequest instance itself + */ + public OrderStateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -273,7 +318,8 @@ public boolean equals(Object o) { Objects.equals(this.state, orderStateRequest.state) && Objects.equals(this.driverETA, orderStateRequest.driverETA) && Objects.equals(this.code, orderStateRequest.code) && - Objects.equals(this.message, orderStateRequest.message); + Objects.equals(this.message, orderStateRequest.message)&& + Objects.equals(this.additionalProperties, orderStateRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -282,7 +328,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(merchantID, orderID, state, driverETA, code, message); + return Objects.hash(merchantID, orderID, state, driverETA, code, message, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -302,6 +348,7 @@ public String toString() { sb.append(" driverETA: ").append(toIndentedString(driverETA)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -338,12 +385,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("state"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OrderStateRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrderStateRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!OrderStateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -351,14 +398,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OrderStateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrderStateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : OrderStateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -400,6 +439,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, OrderStateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -407,29 +468,50 @@ public void write(JsonWriter out, OrderStateRequest value) throws IOException { public OrderStateRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OrderStateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OrderStateRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of OrderStateRequest - * @throws IOException if the JSON string is invalid with respect to OrderStateRequest - */ + /** + * Create an instance of OrderStateRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrderStateRequest + * @throws IOException if the JSON string is invalid with respect to OrderStateRequest + */ public static OrderStateRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, OrderStateRequest.class); } - /** - * Convert an instance of OrderStateRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OrderStateRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/OutOfStockInstruction.java b/src/main/java/com/grabfood/client/model/OutOfStockInstruction.java index 35eae6b..6e0a7e9 100644 --- a/src/main/java/com/grabfood/client/model/OutOfStockInstruction.java +++ b/src/main/java/com/grabfood/client/model/OutOfStockInstruction.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * An JSON object that indicates the instructions to be taken by the merchant when the item is out of stock. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class OutOfStockInstruction { public static final String SERIALIZED_NAME_TITLE = "title"; @SerializedName(SERIALIZED_NAME_TITLE) @@ -69,7 +68,9 @@ public enum InstructionTypeEnum { SPECIFIC_ITEM("SPECIFIC_ITEM"), - CONTACT("CONTACT"); + CONTACT("CONTACT"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -92,7 +93,7 @@ public static InstructionTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -134,10 +135,10 @@ public OutOfStockInstruction title(String title) { return this; } - /** + /** * The short instruction message. * @return title - **/ + */ @javax.annotation.Nullable public String getTitle() { return title; @@ -153,10 +154,10 @@ public OutOfStockInstruction instructionType(InstructionTypeEnum instructionType return this; } - /** + /** * Type of out-of-stock instruction chosen by customer. `CONTACT` is disabled by default, kindly reach out to your integration manager if you wish to receive this instruction. * @return instructionType - **/ + */ @javax.annotation.Nullable public InstructionTypeEnum getInstructionType() { return instructionType; @@ -172,10 +173,10 @@ public OutOfStockInstruction replacementItemID(String replacementItemID) { return this; } - /** + /** * The preferred item's ID in the partner system. Only applicable when the instructionType is `SPECIFIC_ITEM`. * @return replacementItemID - **/ + */ @javax.annotation.Nullable public String getReplacementItemID() { return replacementItemID; @@ -191,10 +192,10 @@ public OutOfStockInstruction replacementGrabItemID(String replacementGrabItemID) return this; } - /** + /** * The preferred item's ID in the Grab system. Only applicable when the instructionType is `SPECIFIC_ITEM`. * @return replacementGrabItemID - **/ + */ @javax.annotation.Nullable public String getReplacementGrabItemID() { return replacementGrabItemID; @@ -204,6 +205,50 @@ public void setReplacementGrabItemID(String replacementGrabItemID) { this.replacementGrabItemID = replacementGrabItemID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the OutOfStockInstruction instance itself + */ + public OutOfStockInstruction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -218,12 +263,13 @@ public boolean equals(Object o) { return Objects.equals(this.title, outOfStockInstruction.title) && Objects.equals(this.instructionType, outOfStockInstruction.instructionType) && Objects.equals(this.replacementItemID, outOfStockInstruction.replacementItemID) && - Objects.equals(this.replacementGrabItemID, outOfStockInstruction.replacementGrabItemID); + Objects.equals(this.replacementGrabItemID, outOfStockInstruction.replacementGrabItemID)&& + Objects.equals(this.additionalProperties, outOfStockInstruction.additionalProperties); } @Override public int hashCode() { - return Objects.hash(title, instructionType, replacementItemID, replacementGrabItemID); + return Objects.hash(title, instructionType, replacementItemID, replacementGrabItemID, additionalProperties); } @Override @@ -234,6 +280,7 @@ public String toString() { sb.append(" instructionType: ").append(toIndentedString(instructionType)).append("\n"); sb.append(" replacementItemID: ").append(toIndentedString(replacementItemID)).append("\n"); sb.append(" replacementGrabItemID: ").append(toIndentedString(replacementGrabItemID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -265,26 +312,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to OutOfStockInstruction - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OutOfStockInstruction + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!OutOfStockInstruction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in OutOfStockInstruction is not found in the empty JSON string", OutOfStockInstruction.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OutOfStockInstruction.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OutOfStockInstruction` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); @@ -319,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, OutOfStockInstruction value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -326,29 +387,50 @@ public void write(JsonWriter out, OutOfStockInstruction value) throws IOExceptio public OutOfStockInstruction read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + OutOfStockInstruction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of OutOfStockInstruction given an JSON string - * - * @param jsonString JSON string - * @return An instance of OutOfStockInstruction - * @throws IOException if the JSON string is invalid with respect to OutOfStockInstruction - */ + /** + * Create an instance of OutOfStockInstruction given an JSON string + * + * @param jsonString JSON string + * @return An instance of OutOfStockInstruction + * @throws IOException if the JSON string is invalid with respect to OutOfStockInstruction + */ public static OutOfStockInstruction fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, OutOfStockInstruction.class); } - /** - * Convert an instance of OutOfStockInstruction to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of OutOfStockInstruction to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/PartnerOauthRequest.java b/src/main/java/com/grabfood/client/model/PartnerOauthRequest.java index 60a1bef..89d6b0e 100644 --- a/src/main/java/com/grabfood/client/model/PartnerOauthRequest.java +++ b/src/main/java/com/grabfood/client/model/PartnerOauthRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * Information about GrabFood getting an OAuth access token from partners. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class PartnerOauthRequest { public static final String SERIALIZED_NAME_CLIENT_ID = "client_id"; @SerializedName(SERIALIZED_NAME_CLIENT_ID) @@ -78,10 +77,10 @@ public PartnerOauthRequest clientId(String clientId) { return this; } - /** + /** * The client identifier issued to obtain the OAuth access token. * @return clientId - **/ + */ @javax.annotation.Nonnull public String getClientId() { return clientId; @@ -97,10 +96,10 @@ public PartnerOauthRequest clientSecret(String clientSecret) { return this; } - /** + /** * The client secret issued to obtain the OAuth access token. * @return clientSecret - **/ + */ @javax.annotation.Nonnull public String getClientSecret() { return clientSecret; @@ -116,10 +115,10 @@ public PartnerOauthRequest grantType(String grantType) { return this; } - /** + /** * Refers to the way an application gets OAuth access token. * @return grantType - **/ + */ @javax.annotation.Nonnull public String getGrantType() { return grantType; @@ -135,10 +134,10 @@ public PartnerOauthRequest scope(String scope) { return this; } - /** + /** * A space delimited list of partner scopes. * @return scope - **/ + */ @javax.annotation.Nullable public String getScope() { return scope; @@ -148,6 +147,50 @@ public void setScope(String scope) { this.scope = scope; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PartnerOauthRequest instance itself + */ + public PartnerOauthRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.clientId, partnerOauthRequest.clientId) && Objects.equals(this.clientSecret, partnerOauthRequest.clientSecret) && Objects.equals(this.grantType, partnerOauthRequest.grantType) && - Objects.equals(this.scope, partnerOauthRequest.scope); + Objects.equals(this.scope, partnerOauthRequest.scope)&& + Objects.equals(this.additionalProperties, partnerOauthRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(clientId, clientSecret, grantType, scope); + return Objects.hash(clientId, clientSecret, grantType, scope, additionalProperties); } @Override @@ -178,6 +222,7 @@ public String toString() { sb.append(" clientSecret: ").append(toIndentedString(clientSecret)).append("\n"); sb.append(" grantType: ").append(toIndentedString(grantType)).append("\n"); sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -212,12 +257,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("grant_type"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to PartnerOauthRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PartnerOauthRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PartnerOauthRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -225,14 +270,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PartnerOauthRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartnerOauthRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PartnerOauthRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -269,6 +306,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PartnerOauthRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -276,29 +335,50 @@ public void write(JsonWriter out, PartnerOauthRequest value) throws IOException public PartnerOauthRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PartnerOauthRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of PartnerOauthRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of PartnerOauthRequest - * @throws IOException if the JSON string is invalid with respect to PartnerOauthRequest - */ + /** + * Create an instance of PartnerOauthRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartnerOauthRequest + * @throws IOException if the JSON string is invalid with respect to PartnerOauthRequest + */ public static PartnerOauthRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, PartnerOauthRequest.class); } - /** - * Convert an instance of PartnerOauthRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of PartnerOauthRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/PartnerOauthResponse.java b/src/main/java/com/grabfood/client/model/PartnerOauthResponse.java index 2fdaddd..81d37a4 100644 --- a/src/main/java/com/grabfood/client/model/PartnerOauthResponse.java +++ b/src/main/java/com/grabfood/client/model/PartnerOauthResponse.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * PartnerOauthResponse */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class PartnerOauthResponse { public static final String SERIALIZED_NAME_ACCESS_TOKEN = "access_token"; @SerializedName(SERIALIZED_NAME_ACCESS_TOKEN) @@ -63,7 +62,9 @@ public class PartnerOauthResponse { */ @JsonAdapter(TokenTypeEnum.Adapter.class) public enum TokenTypeEnum { - BEARER("Bearer"); + BEARER("Bearer"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -86,7 +87,7 @@ public static TokenTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -124,10 +125,10 @@ public PartnerOauthResponse accessToken(String accessToken) { return this; } - /** + /** * The OAuth 2.0 access token issued by the partner. * @return accessToken - **/ + */ @javax.annotation.Nullable public String getAccessToken() { return accessToken; @@ -143,10 +144,10 @@ public PartnerOauthResponse tokenType(TokenTypeEnum tokenType) { return this; } - /** + /** * The type of token issued which is case insensitive. * @return tokenType - **/ + */ @javax.annotation.Nullable public TokenTypeEnum getTokenType() { return tokenType; @@ -162,10 +163,10 @@ public PartnerOauthResponse expiresIn(Integer expiresIn) { return this; } - /** + /** * The access token lifespan in seconds. * @return expiresIn - **/ + */ @javax.annotation.Nullable public Integer getExpiresIn() { return expiresIn; @@ -175,6 +176,50 @@ public void setExpiresIn(Integer expiresIn) { this.expiresIn = expiresIn; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PartnerOauthResponse instance itself + */ + public PartnerOauthResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -188,12 +233,13 @@ public boolean equals(Object o) { PartnerOauthResponse partnerOauthResponse = (PartnerOauthResponse) o; return Objects.equals(this.accessToken, partnerOauthResponse.accessToken) && Objects.equals(this.tokenType, partnerOauthResponse.tokenType) && - Objects.equals(this.expiresIn, partnerOauthResponse.expiresIn); + Objects.equals(this.expiresIn, partnerOauthResponse.expiresIn)&& + Objects.equals(this.additionalProperties, partnerOauthResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(accessToken, tokenType, expiresIn); + return Objects.hash(accessToken, tokenType, expiresIn, additionalProperties); } @Override @@ -203,6 +249,7 @@ public String toString() { sb.append(" accessToken: ").append(toIndentedString(accessToken)).append("\n"); sb.append(" tokenType: ").append(toIndentedString(tokenType)).append("\n"); sb.append(" expiresIn: ").append(toIndentedString(expiresIn)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -233,26 +280,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to PartnerOauthResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PartnerOauthResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PartnerOauthResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in PartnerOauthResponse is not found in the empty JSON string", PartnerOauthResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PartnerOauthResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartnerOauthResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("access_token") != null && !jsonObj.get("access_token").isJsonNull()) && !jsonObj.get("access_token").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `access_token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("access_token").toString())); @@ -281,6 +320,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PartnerOauthResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -288,29 +349,50 @@ public void write(JsonWriter out, PartnerOauthResponse value) throws IOException public PartnerOauthResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PartnerOauthResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of PartnerOauthResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of PartnerOauthResponse - * @throws IOException if the JSON string is invalid with respect to PartnerOauthResponse - */ + /** + * Create an instance of PartnerOauthResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartnerOauthResponse + * @throws IOException if the JSON string is invalid with respect to PartnerOauthResponse + */ public static PartnerOauthResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, PartnerOauthResponse.class); } - /** - * Convert an instance of PartnerOauthResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of PartnerOauthResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/PauseStoreRequest.java b/src/main/java/com/grabfood/client/model/PauseStoreRequest.java index 96cdcc6..0b28d75 100644 --- a/src/main/java/com/grabfood/client/model/PauseStoreRequest.java +++ b/src/main/java/com/grabfood/client/model/PauseStoreRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request pauses a store temporarily for (30 minutes/1 hour/24 hours) or unpauses a store on GrabFood. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class PauseStoreRequest { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -71,7 +70,9 @@ public enum DurationEnum { _1H("1h"), - _24H("24h"); + _24H("24h"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -94,7 +95,7 @@ public static DurationEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -128,10 +129,10 @@ public PauseStoreRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -147,10 +148,10 @@ public PauseStoreRequest isPause(Boolean isPause) { return this; } - /** + /** * Boolean value to pause or unpause store. * @return isPause - **/ + */ @javax.annotation.Nonnull public Boolean getIsPause() { return isPause; @@ -166,10 +167,10 @@ public PauseStoreRequest duration(DurationEnum duration) { return this; } - /** + /** * The duration to pause the store. Only required when `isPause=true`. * @return duration - **/ + */ @javax.annotation.Nullable public DurationEnum getDuration() { return duration; @@ -179,6 +180,50 @@ public void setDuration(DurationEnum duration) { this.duration = duration; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PauseStoreRequest instance itself + */ + public PauseStoreRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -192,12 +237,13 @@ public boolean equals(Object o) { PauseStoreRequest pauseStoreRequest = (PauseStoreRequest) o; return Objects.equals(this.merchantID, pauseStoreRequest.merchantID) && Objects.equals(this.isPause, pauseStoreRequest.isPause) && - Objects.equals(this.duration, pauseStoreRequest.duration); + Objects.equals(this.duration, pauseStoreRequest.duration)&& + Objects.equals(this.additionalProperties, pauseStoreRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(merchantID, isPause, duration); + return Objects.hash(merchantID, isPause, duration, additionalProperties); } @Override @@ -207,6 +253,7 @@ public String toString() { sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); sb.append(" isPause: ").append(toIndentedString(isPause)).append("\n"); sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -239,12 +286,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("isPause"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to PauseStoreRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PauseStoreRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!PauseStoreRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -252,14 +299,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PauseStoreRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PauseStoreRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PauseStoreRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -294,6 +333,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PauseStoreRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -301,29 +362,50 @@ public void write(JsonWriter out, PauseStoreRequest value) throws IOException { public PauseStoreRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PauseStoreRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of PauseStoreRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of PauseStoreRequest - * @throws IOException if the JSON string is invalid with respect to PauseStoreRequest - */ + /** + * Create an instance of PauseStoreRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of PauseStoreRequest + * @throws IOException if the JSON string is invalid with respect to PauseStoreRequest + */ public static PauseStoreRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, PauseStoreRequest.class); } - /** - * Convert an instance of PauseStoreRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of PauseStoreRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Purchasability.java b/src/main/java/com/grabfood/client/model/Purchasability.java index a9e8f84..07ee0a4 100644 --- a/src/main/java/com/grabfood/client/model/Purchasability.java +++ b/src/main/java/com/grabfood/client/model/Purchasability.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. Refer [Service Based Menu](#section/Service-Based-Menu). */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class Purchasability { public static final String SERIALIZED_NAME_DELIVERY_ON_DEMAND_GRAB_APP = "Delivery_OnDemand_GrabApp"; @SerializedName(SERIALIZED_NAME_DELIVERY_ON_DEMAND_GRAB_APP) @@ -90,10 +89,10 @@ public Purchasability deliveryOnDemandGrabApp(Boolean deliveryOnDemandGrabApp) { return this; } - /** + /** * Get deliveryOnDemandGrabApp * @return deliveryOnDemandGrabApp - **/ + */ @javax.annotation.Nullable public Boolean getDeliveryOnDemandGrabApp() { return deliveryOnDemandGrabApp; @@ -109,10 +108,10 @@ public Purchasability deliveryScheduledGrabApp(Boolean deliveryScheduledGrabApp) return this; } - /** + /** * Get deliveryScheduledGrabApp * @return deliveryScheduledGrabApp - **/ + */ @javax.annotation.Nullable public Boolean getDeliveryScheduledGrabApp() { return deliveryScheduledGrabApp; @@ -128,10 +127,10 @@ public Purchasability selfPickUpOnDemandGrabApp(Boolean selfPickUpOnDemandGrabAp return this; } - /** + /** * Get selfPickUpOnDemandGrabApp * @return selfPickUpOnDemandGrabApp - **/ + */ @javax.annotation.Nullable public Boolean getSelfPickUpOnDemandGrabApp() { return selfPickUpOnDemandGrabApp; @@ -147,10 +146,10 @@ public Purchasability dineInOnDemandGrabApp(Boolean dineInOnDemandGrabApp) { return this; } - /** + /** * Get dineInOnDemandGrabApp * @return dineInOnDemandGrabApp - **/ + */ @javax.annotation.Nullable public Boolean getDineInOnDemandGrabApp() { return dineInOnDemandGrabApp; @@ -166,10 +165,10 @@ public Purchasability deliveryOnDemandStoreFront(Boolean deliveryOnDemandStoreFr return this; } - /** + /** * Get deliveryOnDemandStoreFront * @return deliveryOnDemandStoreFront - **/ + */ @javax.annotation.Nullable public Boolean getDeliveryOnDemandStoreFront() { return deliveryOnDemandStoreFront; @@ -185,10 +184,10 @@ public Purchasability deliveryScheduledStoreFront(Boolean deliveryScheduledStore return this; } - /** + /** * Get deliveryScheduledStoreFront * @return deliveryScheduledStoreFront - **/ + */ @javax.annotation.Nullable public Boolean getDeliveryScheduledStoreFront() { return deliveryScheduledStoreFront; @@ -204,10 +203,10 @@ public Purchasability selfPickUpOnDemandStoreFront(Boolean selfPickUpOnDemandSto return this; } - /** + /** * Get selfPickUpOnDemandStoreFront * @return selfPickUpOnDemandStoreFront - **/ + */ @javax.annotation.Nullable public Boolean getSelfPickUpOnDemandStoreFront() { return selfPickUpOnDemandStoreFront; @@ -217,6 +216,50 @@ public void setSelfPickUpOnDemandStoreFront(Boolean selfPickUpOnDemandStoreFront this.selfPickUpOnDemandStoreFront = selfPickUpOnDemandStoreFront; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Purchasability instance itself + */ + public Purchasability putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -234,12 +277,13 @@ public boolean equals(Object o) { Objects.equals(this.dineInOnDemandGrabApp, purchasability.dineInOnDemandGrabApp) && Objects.equals(this.deliveryOnDemandStoreFront, purchasability.deliveryOnDemandStoreFront) && Objects.equals(this.deliveryScheduledStoreFront, purchasability.deliveryScheduledStoreFront) && - Objects.equals(this.selfPickUpOnDemandStoreFront, purchasability.selfPickUpOnDemandStoreFront); + Objects.equals(this.selfPickUpOnDemandStoreFront, purchasability.selfPickUpOnDemandStoreFront)&& + Objects.equals(this.additionalProperties, purchasability.additionalProperties); } @Override public int hashCode() { - return Objects.hash(deliveryOnDemandGrabApp, deliveryScheduledGrabApp, selfPickUpOnDemandGrabApp, dineInOnDemandGrabApp, deliveryOnDemandStoreFront, deliveryScheduledStoreFront, selfPickUpOnDemandStoreFront); + return Objects.hash(deliveryOnDemandGrabApp, deliveryScheduledGrabApp, selfPickUpOnDemandGrabApp, dineInOnDemandGrabApp, deliveryOnDemandStoreFront, deliveryScheduledStoreFront, selfPickUpOnDemandStoreFront, additionalProperties); } @Override @@ -253,6 +297,7 @@ public String toString() { sb.append(" deliveryOnDemandStoreFront: ").append(toIndentedString(deliveryOnDemandStoreFront)).append("\n"); sb.append(" deliveryScheduledStoreFront: ").append(toIndentedString(deliveryScheduledStoreFront)).append("\n"); sb.append(" selfPickUpOnDemandStoreFront: ").append(toIndentedString(selfPickUpOnDemandStoreFront)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -287,26 +332,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Purchasability - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Purchasability + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Purchasability.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in Purchasability is not found in the empty JSON string", Purchasability.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Purchasability.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Purchasability` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -325,6 +362,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Purchasability value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -332,29 +391,50 @@ public void write(JsonWriter out, Purchasability value) throws IOException { public Purchasability read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Purchasability instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Purchasability given an JSON string - * - * @param jsonString JSON string - * @return An instance of Purchasability - * @throws IOException if the JSON string is invalid with respect to Purchasability - */ + /** + * Create an instance of Purchasability given an JSON string + * + * @param jsonString JSON string + * @return An instance of Purchasability + * @throws IOException if the JSON string is invalid with respect to Purchasability + */ public static Purchasability fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, Purchasability.class); } - /** - * Convert an instance of Purchasability to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of Purchasability to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Quotas.java b/src/main/java/com/grabfood/client/model/Quotas.java deleted file mode 100644 index 02c8fdd..0000000 --- a/src/main/java/com/grabfood/client/model/Quotas.java +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * The quotas/limits for a particular campaign. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class Quotas { - public static final String SERIALIZED_NAME_TOTAL_COUNT = "totalCount"; - @SerializedName(SERIALIZED_NAME_TOTAL_COUNT) - private Integer totalCount; - - public static final String SERIALIZED_NAME_TOTAL_COUNT_PER_USER = "totalCountPerUser"; - @SerializedName(SERIALIZED_NAME_TOTAL_COUNT_PER_USER) - private Integer totalCountPerUser; - - public Quotas() { - } - - public Quotas totalCount(Integer totalCount) { - this.totalCount = totalCount; - return this; - } - - /** - * The maximum number of redemptions. Default is unlimited if unspecified. - * @return totalCount - **/ - @javax.annotation.Nullable - public Integer getTotalCount() { - return totalCount; - } - - public void setTotalCount(Integer totalCount) { - this.totalCount = totalCount; - } - - - public Quotas totalCountPerUser(Integer totalCountPerUser) { - this.totalCountPerUser = totalCountPerUser; - return this; - } - - /** - * The maximum number of redemptions per user. Default is unlimited if unspecified. - * @return totalCountPerUser - **/ - @javax.annotation.Nullable - public Integer getTotalCountPerUser() { - return totalCountPerUser; - } - - public void setTotalCountPerUser(Integer totalCountPerUser) { - this.totalCountPerUser = totalCountPerUser; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Quotas quotas = (Quotas) o; - return Objects.equals(this.totalCount, quotas.totalCount) && - Objects.equals(this.totalCountPerUser, quotas.totalCountPerUser); - } - - @Override - public int hashCode() { - return Objects.hash(totalCount, totalCountPerUser); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Quotas {\n"); - sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); - sb.append(" totalCountPerUser: ").append(toIndentedString(totalCountPerUser)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("totalCount"); - openapiFields.add("totalCountPerUser"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Quotas - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!Quotas.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in Quotas is not found in the empty JSON string", Quotas.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Quotas.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Quotas` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Quotas.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Quotas' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Quotas.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Quotas value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Quotas read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of Quotas given an JSON string - * - * @param jsonString JSON string - * @return An instance of Quotas - * @throws IOException if the JSON string is invalid with respect to Quotas - */ - public static Quotas fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Quotas.class); - } - - /** - * Convert an instance of Quotas to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/Receiver.java b/src/main/java/com/grabfood/client/model/Receiver.java index 9e4d57c..98962a7 100644 --- a/src/main/java/com/grabfood/client/model/Receiver.java +++ b/src/main/java/com/grabfood/client/model/Receiver.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * A JSON object containing the receiver information. Currently only for orders that are delivered by the restaurant. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class Receiver { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) @@ -75,10 +74,10 @@ public Receiver name(String name) { return this; } - /** + /** * The name of the receiver. * @return name - **/ + */ @javax.annotation.Nullable public String getName() { return name; @@ -94,10 +93,10 @@ public Receiver phones(String phones) { return this; } - /** + /** * The receiver's phone number. * @return phones - **/ + */ @javax.annotation.Nullable public String getPhones() { return phones; @@ -113,10 +112,10 @@ public Receiver address(Address address) { return this; } - /** + /** * Get address * @return address - **/ + */ @javax.annotation.Nullable public Address getAddress() { return address; @@ -126,6 +125,50 @@ public void setAddress(Address address) { this.address = address; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Receiver instance itself + */ + public Receiver putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -139,12 +182,13 @@ public boolean equals(Object o) { Receiver receiver = (Receiver) o; return Objects.equals(this.name, receiver.name) && Objects.equals(this.phones, receiver.phones) && - Objects.equals(this.address, receiver.address); + Objects.equals(this.address, receiver.address)&& + Objects.equals(this.additionalProperties, receiver.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, phones, address); + return Objects.hash(name, phones, address, additionalProperties); } @Override @@ -154,6 +198,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" phones: ").append(toIndentedString(phones)).append("\n"); sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -184,26 +229,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Receiver - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Receiver + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Receiver.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in Receiver is not found in the empty JSON string", Receiver.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Receiver.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Receiver` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -232,6 +269,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Receiver value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -239,29 +298,50 @@ public void write(JsonWriter out, Receiver value) throws IOException { public Receiver read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Receiver instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Receiver given an JSON string - * - * @param jsonString JSON string - * @return An instance of Receiver - * @throws IOException if the JSON string is invalid with respect to Receiver - */ + /** + * Create an instance of Receiver given an JSON string + * + * @param jsonString JSON string + * @return An instance of Receiver + * @throws IOException if the JSON string is invalid with respect to Receiver + */ public static Receiver fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, Receiver.class); } - /** - * Convert an instance of Receiver to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of Receiver to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/RedeemDineInVoucherRequest.java b/src/main/java/com/grabfood/client/model/RedeemDineInVoucherRequest.java index aa6749d..919b0a5 100644 --- a/src/main/java/com/grabfood/client/model/RedeemDineInVoucherRequest.java +++ b/src/main/java/com/grabfood/client/model/RedeemDineInVoucherRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * Dine in voucher redemption */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class RedeemDineInVoucherRequest { public static final String SERIALIZED_NAME_CERTIFICATE_I_D = "certificateID"; @SerializedName(SERIALIZED_NAME_CERTIFICATE_I_D) @@ -70,10 +69,10 @@ public RedeemDineInVoucherRequest certificateID(String certificateID) { return this; } - /** + /** * This certificateID is decoded from scanning the QR code, and 1:1 mapping with `voucherCode`. * @return certificateID - **/ + */ @javax.annotation.Nonnull public String getCertificateID() { return certificateID; @@ -89,10 +88,10 @@ public RedeemDineInVoucherRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -102,6 +101,50 @@ public void setMerchantID(String merchantID) { this.merchantID = merchantID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RedeemDineInVoucherRequest instance itself + */ + public RedeemDineInVoucherRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +157,13 @@ public boolean equals(Object o) { } RedeemDineInVoucherRequest redeemDineInVoucherRequest = (RedeemDineInVoucherRequest) o; return Objects.equals(this.certificateID, redeemDineInVoucherRequest.certificateID) && - Objects.equals(this.merchantID, redeemDineInVoucherRequest.merchantID); + Objects.equals(this.merchantID, redeemDineInVoucherRequest.merchantID)&& + Objects.equals(this.additionalProperties, redeemDineInVoucherRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(certificateID, merchantID); + return Objects.hash(certificateID, merchantID, additionalProperties); } @Override @@ -128,6 +172,7 @@ public String toString() { sb.append("class RedeemDineInVoucherRequest {\n"); sb.append(" certificateID: ").append(toIndentedString(certificateID)).append("\n"); sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -159,12 +204,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("merchantID"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to RedeemDineInVoucherRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RedeemDineInVoucherRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RedeemDineInVoucherRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -172,14 +217,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RedeemDineInVoucherRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RedeemDineInVoucherRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RedeemDineInVoucherRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -210,6 +247,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RedeemDineInVoucherRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -217,29 +276,50 @@ public void write(JsonWriter out, RedeemDineInVoucherRequest value) throws IOExc public RedeemDineInVoucherRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RedeemDineInVoucherRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of RedeemDineInVoucherRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of RedeemDineInVoucherRequest - * @throws IOException if the JSON string is invalid with respect to RedeemDineInVoucherRequest - */ + /** + * Create an instance of RedeemDineInVoucherRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of RedeemDineInVoucherRequest + * @throws IOException if the JSON string is invalid with respect to RedeemDineInVoucherRequest + */ public static RedeemDineInVoucherRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, RedeemDineInVoucherRequest.class); } - /** - * Convert an instance of RedeemDineInVoucherRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of RedeemDineInVoucherRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/RedeemDineInVoucherResponse.java b/src/main/java/com/grabfood/client/model/RedeemDineInVoucherResponse.java index b78b966..9bd7a56 100644 --- a/src/main/java/com/grabfood/client/model/RedeemDineInVoucherResponse.java +++ b/src/main/java/com/grabfood/client/model/RedeemDineInVoucherResponse.java @@ -42,7 +42,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,7 +53,7 @@ /** * */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class RedeemDineInVoucherResponse { public static final String SERIALIZED_NAME_CERTIFICATE_I_D = "certificateID"; @SerializedName(SERIALIZED_NAME_CERTIFICATE_I_D) @@ -88,10 +87,10 @@ public RedeemDineInVoucherResponse certificateID(String certificateID) { return this; } - /** + /** * This certificateID is decoded from scanning the QR code, and 1:1 mapping with `voucherCode`. * @return certificateID - **/ + */ @javax.annotation.Nullable public String getCertificateID() { return certificateID; @@ -107,10 +106,10 @@ public RedeemDineInVoucherResponse voucherCode(String voucherCode) { return this; } - /** + /** * A short code for the dine-in voucher purchased by the user. * @return voucherCode - **/ + */ @javax.annotation.Nullable public String getVoucherCode() { return voucherCode; @@ -126,10 +125,10 @@ public RedeemDineInVoucherResponse voucher(Voucher voucher) { return this; } - /** + /** * Get voucher * @return voucher - **/ + */ @javax.annotation.Nullable public Voucher getVoucher() { return voucher; @@ -145,10 +144,10 @@ public RedeemDineInVoucherResponse redeemResult(RedeemResult redeemResult) { return this; } - /** + /** * Get redeemResult * @return redeemResult - **/ + */ @javax.annotation.Nullable public RedeemResult getRedeemResult() { return redeemResult; @@ -164,10 +163,10 @@ public RedeemDineInVoucherResponse merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -183,10 +182,10 @@ public RedeemDineInVoucherResponse campaignID(String campaignID) { return this; } - /** + /** * The dine-in voucher campaign's ID in GrabFood's database. * @return campaignID - **/ + */ @javax.annotation.Nullable public String getCampaignID() { return campaignID; @@ -196,6 +195,50 @@ public void setCampaignID(String campaignID) { this.campaignID = campaignID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RedeemDineInVoucherResponse instance itself + */ + public RedeemDineInVoucherResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -212,12 +255,13 @@ public boolean equals(Object o) { Objects.equals(this.voucher, redeemDineInVoucherResponse.voucher) && Objects.equals(this.redeemResult, redeemDineInVoucherResponse.redeemResult) && Objects.equals(this.merchantID, redeemDineInVoucherResponse.merchantID) && - Objects.equals(this.campaignID, redeemDineInVoucherResponse.campaignID); + Objects.equals(this.campaignID, redeemDineInVoucherResponse.campaignID)&& + Objects.equals(this.additionalProperties, redeemDineInVoucherResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(certificateID, voucherCode, voucher, redeemResult, merchantID, campaignID); + return Objects.hash(certificateID, voucherCode, voucher, redeemResult, merchantID, campaignID, additionalProperties); } @Override @@ -230,6 +274,7 @@ public String toString() { sb.append(" redeemResult: ").append(toIndentedString(redeemResult)).append("\n"); sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); sb.append(" campaignID: ").append(toIndentedString(campaignID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -263,26 +308,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to RedeemDineInVoucherResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RedeemDineInVoucherResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RedeemDineInVoucherResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in RedeemDineInVoucherResponse is not found in the empty JSON string", RedeemDineInVoucherResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RedeemDineInVoucherResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RedeemDineInVoucherResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("certificateID") != null && !jsonObj.get("certificateID").isJsonNull()) && !jsonObj.get("certificateID").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `certificateID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("certificateID").toString())); @@ -321,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RedeemDineInVoucherResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -328,29 +387,50 @@ public void write(JsonWriter out, RedeemDineInVoucherResponse value) throws IOEx public RedeemDineInVoucherResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RedeemDineInVoucherResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of RedeemDineInVoucherResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of RedeemDineInVoucherResponse - * @throws IOException if the JSON string is invalid with respect to RedeemDineInVoucherResponse - */ + /** + * Create an instance of RedeemDineInVoucherResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of RedeemDineInVoucherResponse + * @throws IOException if the JSON string is invalid with respect to RedeemDineInVoucherResponse + */ public static RedeemDineInVoucherResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, RedeemDineInVoucherResponse.class); } - /** - * Convert an instance of RedeemDineInVoucherResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of RedeemDineInVoucherResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/RedeemDineinVoucher500Response.java b/src/main/java/com/grabfood/client/model/RedeemDineinVoucher500Response.java deleted file mode 100644 index 0c7cd5c..0000000 --- a/src/main/java/com/grabfood/client/model/RedeemDineinVoucher500Response.java +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * RedeemDineinVoucher500Response - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class RedeemDineinVoucher500Response { - public static final String SERIALIZED_NAME_TARGET = "target"; - @SerializedName(SERIALIZED_NAME_TARGET) - private String target; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public RedeemDineinVoucher500Response() { - } - - public RedeemDineinVoucher500Response target(String target) { - this.target = target; - return this; - } - - /** - * The target of error. - * @return target - **/ - @javax.annotation.Nullable - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - - public RedeemDineinVoucher500Response reason(String reason) { - this.reason = reason; - return this; - } - - /** - * The type of error. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public RedeemDineinVoucher500Response message(String message) { - this.message = message; - return this; - } - - /** - * The details of the error. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RedeemDineinVoucher500Response redeemDineinVoucher500Response = (RedeemDineinVoucher500Response) o; - return Objects.equals(this.target, redeemDineinVoucher500Response.target) && - Objects.equals(this.reason, redeemDineinVoucher500Response.reason) && - Objects.equals(this.message, redeemDineinVoucher500Response.message); - } - - @Override - public int hashCode() { - return Objects.hash(target, reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class RedeemDineinVoucher500Response {\n"); - sb.append(" target: ").append(toIndentedString(target)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("target"); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to RedeemDineinVoucher500Response - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!RedeemDineinVoucher500Response.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in RedeemDineinVoucher500Response is not found in the empty JSON string", RedeemDineinVoucher500Response.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RedeemDineinVoucher500Response.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RedeemDineinVoucher500Response` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("target") != null && !jsonObj.get("target").isJsonNull()) && !jsonObj.get("target").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `target` to be a primitive type in the JSON string but got `%s`", jsonObj.get("target").toString())); - } - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!RedeemDineinVoucher500Response.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'RedeemDineinVoucher500Response' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(RedeemDineinVoucher500Response.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, RedeemDineinVoucher500Response value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public RedeemDineinVoucher500Response read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of RedeemDineinVoucher500Response given an JSON string - * - * @param jsonString JSON string - * @return An instance of RedeemDineinVoucher500Response - * @throws IOException if the JSON string is invalid with respect to RedeemDineinVoucher500Response - */ - public static RedeemDineinVoucher500Response fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, RedeemDineinVoucher500Response.class); - } - - /** - * Convert an instance of RedeemDineinVoucher500Response to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/RedeemResult.java b/src/main/java/com/grabfood/client/model/RedeemResult.java index 2a4592e..dfdaf34 100644 --- a/src/main/java/com/grabfood/client/model/RedeemResult.java +++ b/src/main/java/com/grabfood/client/model/RedeemResult.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * A JSON object containing dine-in voucher details. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class RedeemResult { public static final String SERIALIZED_NAME_SUCCESS = "success"; @SerializedName(SERIALIZED_NAME_SUCCESS) @@ -73,7 +72,9 @@ public enum CodeEnum { INVALID_ID("INVALID_ID"), - EMPTY(""); + EMPTY(""), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -96,7 +97,7 @@ public static CodeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -130,10 +131,10 @@ public RedeemResult success(Boolean success) { return this; } - /** + /** * To indicate whether the dine-in voucher redemption succeeded. * @return success - **/ + */ @javax.annotation.Nullable public Boolean getSuccess() { return success; @@ -149,10 +150,10 @@ public RedeemResult code(CodeEnum code) { return this; } - /** + /** * The code for the reason of failed redemption. Empty if the `success` is true. * `VOUCHER_REDEEMED` - The voucher has already been redeemed. * `INVALID_STATE` - The current status of voucher is EXPIRED or REFUNDED. * `REDEEM_FAILED` - Internal service error. * `INVALID_MERCHANT` - Voucher not applicable for this merchant. * `INVALID_ID` - Invalid certificateID. * @return code - **/ + */ @javax.annotation.Nullable public CodeEnum getCode() { return code; @@ -162,6 +163,50 @@ public void setCode(CodeEnum code) { this.code = code; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RedeemResult instance itself + */ + public RedeemResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -174,12 +219,13 @@ public boolean equals(Object o) { } RedeemResult redeemResult = (RedeemResult) o; return Objects.equals(this.success, redeemResult.success) && - Objects.equals(this.code, redeemResult.code); + Objects.equals(this.code, redeemResult.code)&& + Objects.equals(this.additionalProperties, redeemResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(success, code); + return Objects.hash(success, code, additionalProperties); } @Override @@ -188,6 +234,7 @@ public String toString() { sb.append("class RedeemResult {\n"); sb.append(" success: ").append(toIndentedString(success)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -217,26 +264,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to RedeemResult - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RedeemResult + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RedeemResult.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in RedeemResult is not found in the empty JSON string", RedeemResult.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RedeemResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RedeemResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("code") != null && !jsonObj.get("code").isJsonNull()) && !jsonObj.get("code").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); @@ -262,6 +301,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RedeemResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -269,29 +330,50 @@ public void write(JsonWriter out, RedeemResult value) throws IOException { public RedeemResult read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RedeemResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of RedeemResult given an JSON string - * - * @param jsonString JSON string - * @return An instance of RedeemResult - * @throws IOException if the JSON string is invalid with respect to RedeemResult - */ + /** + * Create an instance of RedeemResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of RedeemResult + * @throws IOException if the JSON string is invalid with respect to RedeemResult + */ public static RedeemResult fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, RedeemResult.class); } - /** - * Convert an instance of RedeemResult to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of RedeemResult to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/RegisterMembershipNativeRequest.java b/src/main/java/com/grabfood/client/model/RegisterMembershipNativeRequest.java index 7ff2773..e1b94eb 100644 --- a/src/main/java/com/grabfood/client/model/RegisterMembershipNativeRequest.java +++ b/src/main/java/com/grabfood/client/model/RegisterMembershipNativeRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request submits membership registration request to partner. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class RegisterMembershipNativeRequest { public static final String SERIALIZED_NAME_GRAB_I_D = "grabID"; @SerializedName(SERIALIZED_NAME_GRAB_I_D) @@ -78,10 +77,10 @@ public RegisterMembershipNativeRequest grabID(String grabID) { return this; } - /** + /** * The id used to identify an unique grab user. * @return grabID - **/ + */ @javax.annotation.Nonnull public String getGrabID() { return grabID; @@ -97,10 +96,10 @@ public RegisterMembershipNativeRequest phoneNumber(String phoneNumber) { return this; } - /** + /** * Grab user's phone number for registration. * @return phoneNumber - **/ + */ @javax.annotation.Nullable public String getPhoneNumber() { return phoneNumber; @@ -116,10 +115,10 @@ public RegisterMembershipNativeRequest name(String name) { return this; } - /** + /** * Grab user's name for registration. * @return name - **/ + */ @javax.annotation.Nullable public String getName() { return name; @@ -135,10 +134,10 @@ public RegisterMembershipNativeRequest email(String email) { return this; } - /** + /** * Grab user's email address for registration. * @return email - **/ + */ @javax.annotation.Nullable public String getEmail() { return email; @@ -148,6 +147,50 @@ public void setEmail(String email) { this.email = email; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RegisterMembershipNativeRequest instance itself + */ + public RegisterMembershipNativeRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +205,13 @@ public boolean equals(Object o) { return Objects.equals(this.grabID, registerMembershipNativeRequest.grabID) && Objects.equals(this.phoneNumber, registerMembershipNativeRequest.phoneNumber) && Objects.equals(this.name, registerMembershipNativeRequest.name) && - Objects.equals(this.email, registerMembershipNativeRequest.email); + Objects.equals(this.email, registerMembershipNativeRequest.email)&& + Objects.equals(this.additionalProperties, registerMembershipNativeRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(grabID, phoneNumber, name, email); + return Objects.hash(grabID, phoneNumber, name, email, additionalProperties); } @Override @@ -178,6 +222,7 @@ public String toString() { sb.append(" phoneNumber: ").append(toIndentedString(phoneNumber)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -210,12 +255,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("grabID"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to RegisterMembershipNativeRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RegisterMembershipNativeRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RegisterMembershipNativeRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -223,14 +268,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RegisterMembershipNativeRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RegisterMembershipNativeRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RegisterMembershipNativeRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -267,6 +304,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RegisterMembershipNativeRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -274,29 +333,50 @@ public void write(JsonWriter out, RegisterMembershipNativeRequest value) throws public RegisterMembershipNativeRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RegisterMembershipNativeRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of RegisterMembershipNativeRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of RegisterMembershipNativeRequest - * @throws IOException if the JSON string is invalid with respect to RegisterMembershipNativeRequest - */ + /** + * Create an instance of RegisterMembershipNativeRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of RegisterMembershipNativeRequest + * @throws IOException if the JSON string is invalid with respect to RegisterMembershipNativeRequest + */ public static RegisterMembershipNativeRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, RegisterMembershipNativeRequest.class); } - /** - * Convert an instance of RegisterMembershipNativeRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of RegisterMembershipNativeRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/RegisterMembershipNativeResponse.java b/src/main/java/com/grabfood/client/model/RegisterMembershipNativeResponse.java index de03194..449ba1e 100644 --- a/src/main/java/com/grabfood/client/model/RegisterMembershipNativeResponse.java +++ b/src/main/java/com/grabfood/client/model/RegisterMembershipNativeResponse.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This response returns membershipID after membership binding is successful. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class RegisterMembershipNativeResponse { public static final String SERIALIZED_NAME_MEMBER_I_D = "memberID"; @SerializedName(SERIALIZED_NAME_MEMBER_I_D) @@ -66,10 +65,10 @@ public RegisterMembershipNativeResponse memberID(String memberID) { return this; } - /** + /** * The unique member ID on the partner's database. * @return memberID - **/ + */ @javax.annotation.Nonnull public String getMemberID() { return memberID; @@ -79,6 +78,50 @@ public void setMemberID(String memberID) { this.memberID = memberID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RegisterMembershipNativeResponse instance itself + */ + public RegisterMembershipNativeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } RegisterMembershipNativeResponse registerMembershipNativeResponse = (RegisterMembershipNativeResponse) o; - return Objects.equals(this.memberID, registerMembershipNativeResponse.memberID); + return Objects.equals(this.memberID, registerMembershipNativeResponse.memberID)&& + Objects.equals(this.additionalProperties, registerMembershipNativeResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(memberID); + return Objects.hash(memberID, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class RegisterMembershipNativeResponse {\n"); sb.append(" memberID: ").append(toIndentedString(memberID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -132,12 +177,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("memberID"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to RegisterMembershipNativeResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RegisterMembershipNativeResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RegisterMembershipNativeResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -145,14 +190,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RegisterMembershipNativeResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RegisterMembershipNativeResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RegisterMembershipNativeResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -180,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RegisterMembershipNativeResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -187,29 +246,50 @@ public void write(JsonWriter out, RegisterMembershipNativeResponse value) throws public RegisterMembershipNativeResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RegisterMembershipNativeResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of RegisterMembershipNativeResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of RegisterMembershipNativeResponse - * @throws IOException if the JSON string is invalid with respect to RegisterMembershipNativeResponse - */ + /** + * Create an instance of RegisterMembershipNativeResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of RegisterMembershipNativeResponse + * @throws IOException if the JSON string is invalid with respect to RegisterMembershipNativeResponse + */ public static RegisterMembershipNativeResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, RegisterMembershipNativeResponse.class); } - /** - * Convert an instance of RegisterMembershipNativeResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of RegisterMembershipNativeResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/RewardItem.java b/src/main/java/com/grabfood/client/model/RewardItem.java new file mode 100644 index 0000000..49af0be --- /dev/null +++ b/src/main/java/com/grabfood/client/model/RewardItem.java @@ -0,0 +1,315 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * RewardItem + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class RewardItem { + public static final String SERIALIZED_NAME_ITEM_I_D = "itemID"; + @SerializedName(SERIALIZED_NAME_ITEM_I_D) + private String itemID; + + public static final String SERIALIZED_NAME_QUANTITY = "quantity"; + @SerializedName(SERIALIZED_NAME_QUANTITY) + private Integer quantity; + + public RewardItem() { + } + + public RewardItem itemID(String itemID) { + this.itemID = itemID; + return this; + } + + /** + * The item's ID in partner system. + * @return itemID + */ + @javax.annotation.Nullable + public String getItemID() { + return itemID; + } + + public void setItemID(String itemID) { + this.itemID = itemID; + } + + + public RewardItem quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * The item's quantity. + * @return quantity + */ + @javax.annotation.Nullable + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RewardItem instance itself + */ + public RewardItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RewardItem rewardItem = (RewardItem) o; + return Objects.equals(this.itemID, rewardItem.itemID) && + Objects.equals(this.quantity, rewardItem.quantity)&& + Objects.equals(this.additionalProperties, rewardItem.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(itemID, quantity, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RewardItem {\n"); + sb.append(" itemID: ").append(toIndentedString(itemID)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("itemID"); + openapiFields.add("quantity"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RewardItem + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RewardItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RewardItem is not found in the empty JSON string", RewardItem.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("itemID") != null && !jsonObj.get("itemID").isJsonNull()) && !jsonObj.get("itemID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `itemID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("itemID").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RewardItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RewardItem' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RewardItem.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RewardItem value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RewardItem read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RewardItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RewardItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of RewardItem + * @throws IOException if the JSON string is invalid with respect to RewardItem + */ + public static RewardItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RewardItem.class); + } + + /** + * Convert an instance of RewardItem to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/SellingTimesInner.java b/src/main/java/com/grabfood/client/model/SellingTime.java similarity index 55% rename from src/main/java/com/grabfood/client/model/SellingTimesInner.java rename to src/main/java/com/grabfood/client/model/SellingTime.java index 1efdb3e..fe86c02 100644 --- a/src/main/java/com/grabfood/client/model/SellingTimesInner.java +++ b/src/main/java/com/grabfood/client/model/SellingTime.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -51,10 +50,10 @@ import com.grabfood.client.JSON; /** - * SellingTimesInner + * SellingTime */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SellingTimesInner { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class SellingTime { public static final String SERIALIZED_NAME_START_TIME = "startTime"; @SerializedName(SERIALIZED_NAME_START_TIME) private String startTime; @@ -75,18 +74,18 @@ public class SellingTimesInner { @SerializedName(SERIALIZED_NAME_SERVICE_HOURS) private ServiceHours serviceHours; - public SellingTimesInner() { + public SellingTime() { } - public SellingTimesInner startTime(String startTime) { + public SellingTime startTime(String startTime) { this.startTime = startTime; return this; } - /** + /** * The selling time group start time in date & time format. * @return startTime - **/ + */ @javax.annotation.Nullable public String getStartTime() { return startTime; @@ -97,15 +96,15 @@ public void setStartTime(String startTime) { } - public SellingTimesInner endTime(String endTime) { + public SellingTime endTime(String endTime) { this.endTime = endTime; return this; } - /** + /** * The selling time group end time in date & time format. * @return endTime - **/ + */ @javax.annotation.Nullable public String getEndTime() { return endTime; @@ -116,15 +115,15 @@ public void setEndTime(String endTime) { } - public SellingTimesInner id(String id) { + public SellingTime id(String id) { this.id = id; return this; } - /** + /** * The selling time's ID on the partner system. This ID should be unique with length min 1 and max 64. * @return id - **/ + */ @javax.annotation.Nullable public String getId() { return id; @@ -135,15 +134,15 @@ public void setId(String id) { } - public SellingTimesInner name(String name) { + public SellingTime name(String name) { this.name = name; return this; } - /** + /** * The name of the selling time. * @return name - **/ + */ @javax.annotation.Nullable public String getName() { return name; @@ -154,15 +153,15 @@ public void setName(String name) { } - public SellingTimesInner serviceHours(ServiceHours serviceHours) { + public SellingTime serviceHours(ServiceHours serviceHours) { this.serviceHours = serviceHours; return this; } - /** + /** * Get serviceHours * @return serviceHours - **/ + */ @javax.annotation.Nullable public ServiceHours getServiceHours() { return serviceHours; @@ -172,6 +171,50 @@ public void setServiceHours(ServiceHours serviceHours) { this.serviceHours = serviceHours; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SellingTime instance itself + */ + public SellingTime putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -182,28 +225,30 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - SellingTimesInner sellingTimesInner = (SellingTimesInner) o; - return Objects.equals(this.startTime, sellingTimesInner.startTime) && - Objects.equals(this.endTime, sellingTimesInner.endTime) && - Objects.equals(this.id, sellingTimesInner.id) && - Objects.equals(this.name, sellingTimesInner.name) && - Objects.equals(this.serviceHours, sellingTimesInner.serviceHours); + SellingTime sellingTime = (SellingTime) o; + return Objects.equals(this.startTime, sellingTime.startTime) && + Objects.equals(this.endTime, sellingTime.endTime) && + Objects.equals(this.id, sellingTime.id) && + Objects.equals(this.name, sellingTime.name) && + Objects.equals(this.serviceHours, sellingTime.serviceHours)&& + Objects.equals(this.additionalProperties, sellingTime.additionalProperties); } @Override public int hashCode() { - return Objects.hash(startTime, endTime, id, name, serviceHours); + return Objects.hash(startTime, endTime, id, name, serviceHours, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class SellingTimesInner {\n"); + sb.append("class SellingTime {\n"); sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" serviceHours: ").append(toIndentedString(serviceHours)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -236,24 +281,16 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SellingTimesInner - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SellingTime + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!SellingTimesInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SellingTimesInner is not found in the empty JSON string", SellingTimesInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SellingTimesInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SellingTimesInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!SellingTime.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in SellingTime is not found in the empty JSON string", SellingTime.openapiRequiredFields.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); @@ -279,47 +316,90 @@ public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!SellingTimesInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SellingTimesInner' and its subtypes + if (!SellingTime.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SellingTime' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SellingTimesInner.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SellingTime.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, SellingTimesInner value) throws IOException { + public void write(JsonWriter out, SellingTime value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public SellingTimesInner read(JsonReader in) throws IOException { + public SellingTime read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SellingTime instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of SellingTimesInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of SellingTimesInner - * @throws IOException if the JSON string is invalid with respect to SellingTimesInner - */ - public static SellingTimesInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SellingTimesInner.class); + /** + * Create an instance of SellingTime given an JSON string + * + * @param jsonString JSON string + * @return An instance of SellingTime + * @throws IOException if the JSON string is invalid with respect to SellingTime + */ + public static SellingTime fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SellingTime.class); } - /** - * Convert an instance of SellingTimesInner to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of SellingTime to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/DayHours.java b/src/main/java/com/grabfood/client/model/ServiceHour.java similarity index 50% rename from src/main/java/com/grabfood/client/model/DayHours.java rename to src/main/java/com/grabfood/client/model/ServiceHour.java index 0676637..ec663d8 100644 --- a/src/main/java/com/grabfood/client/model/DayHours.java +++ b/src/main/java/com/grabfood/client/model/ServiceHour.java @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,20 +52,22 @@ import com.grabfood.client.JSON; /** - * A JSON object serviceHours for each day. + * A JSON object serviceHour for each day. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class DayHours { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class ServiceHour { /** * The period type for when the outlet is open. - OpenPeriod = open only in given periods - OpenAllDay = open 24 hours - CloseAllDay = closed 24 hours */ @JsonAdapter(OpenPeriodTypeEnum.Adapter.class) public enum OpenPeriodTypeEnum { - OPENPERIOD("OpenPeriod"), + OPEN_PERIOD("OpenPeriod"), - OPENALLDAY("OpenAllDay"), + OPEN_ALL_DAY("OpenAllDay"), - CLOSEALLDAY("CloseAllDay"); + CLOSE_ALL_DAY("CloseAllDay"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -89,7 +90,7 @@ public static OpenPeriodTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -119,18 +120,18 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @SerializedName(SERIALIZED_NAME_PERIODS) private List periods = new ArrayList<>(); - public DayHours() { + public ServiceHour() { } - public DayHours openPeriodType(OpenPeriodTypeEnum openPeriodType) { + public ServiceHour openPeriodType(OpenPeriodTypeEnum openPeriodType) { this.openPeriodType = openPeriodType; return this; } - /** + /** * The period type for when the outlet is open. - OpenPeriod = open only in given periods - OpenAllDay = open 24 hours - CloseAllDay = closed 24 hours * @return openPeriodType - **/ + */ @javax.annotation.Nonnull public OpenPeriodTypeEnum getOpenPeriodType() { return openPeriodType; @@ -141,12 +142,12 @@ public void setOpenPeriodType(OpenPeriodTypeEnum openPeriodType) { } - public DayHours periods(List periods) { + public ServiceHour periods(List periods) { this.periods = periods; return this; } - public DayHours addPeriodsItem(OpenPeriod periodsItem) { + public ServiceHour addPeriodsItem(OpenPeriod periodsItem) { if (this.periods == null) { this.periods = new ArrayList<>(); } @@ -154,11 +155,11 @@ public DayHours addPeriodsItem(OpenPeriod periodsItem) { return this; } - /** + /** * An array of open periods. Only required when `openPeriodType` is **OpenPeriod** * @return periods - **/ - @javax.annotation.Nonnull + */ + @javax.annotation.Nullable public List getPeriods() { return periods; } @@ -167,6 +168,50 @@ public void setPeriods(List periods) { this.periods = periods; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ServiceHour instance itself + */ + public ServiceHour putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -177,22 +222,24 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - DayHours dayHours = (DayHours) o; - return Objects.equals(this.openPeriodType, dayHours.openPeriodType) && - Objects.equals(this.periods, dayHours.periods); + ServiceHour serviceHour = (ServiceHour) o; + return Objects.equals(this.openPeriodType, serviceHour.openPeriodType) && + Objects.equals(this.periods, serviceHour.periods)&& + Objects.equals(this.additionalProperties, serviceHour.additionalProperties); } @Override public int hashCode() { - return Objects.hash(openPeriodType, periods); + return Objects.hash(openPeriodType, periods, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class DayHours {\n"); + sb.append("class ServiceHour {\n"); sb.append(" openPeriodType: ").append(toIndentedString(openPeriodType)).append("\n"); sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -221,32 +268,23 @@ private String toIndentedString(Object o) { // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); openapiRequiredFields.add("openPeriodType"); - openapiRequiredFields.add("periods"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to DayHours - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ServiceHour + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { - if (!DayHours.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in DayHours is not found in the empty JSON string", DayHours.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DayHours.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DayHours` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + if (!ServiceHour.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ServiceHour is not found in the empty JSON string", ServiceHour.openapiRequiredFields.toString())); } } // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : DayHours.openapiRequiredFields) { + for (String requiredField : ServiceHour.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } @@ -257,63 +295,110 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // validate the required field `openPeriodType` OpenPeriodTypeEnum.validateJsonElement(jsonObj.get("openPeriodType")); - // ensure the json data is an array - if (!jsonObj.get("periods").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); + if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { + JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); + if (jsonArrayperiods != null) { + // ensure the json data is an array + if (!jsonObj.get("periods").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); + } + + // validate the optional field `periods` (array) + for (int i = 0; i < jsonArrayperiods.size(); i++) { + OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); + }; + } } - - JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); - // validate the required field `periods` (array) - for (int i = 0; i < jsonArrayperiods.size(); i++) { - OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); - }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { - if (!DayHours.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'DayHours' and its subtypes + if (!ServiceHour.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ServiceHour' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(DayHours.class)); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ServiceHour.class)); - return (TypeAdapter) new TypeAdapter() { + return (TypeAdapter) new TypeAdapter() { @Override - public void write(JsonWriter out, DayHours value) throws IOException { + public void write(JsonWriter out, ServiceHour value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @Override - public DayHours read(JsonReader in) throws IOException { + public ServiceHour read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ServiceHour instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of DayHours given an JSON string - * - * @param jsonString JSON string - * @return An instance of DayHours - * @throws IOException if the JSON string is invalid with respect to DayHours - */ - public static DayHours fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, DayHours.class); + /** + * Create an instance of ServiceHour given an JSON string + * + * @param jsonString JSON string + * @return An instance of ServiceHour + * @throws IOException if the JSON string is invalid with respect to ServiceHour + */ + public static ServiceHour fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ServiceHour.class); } - /** - * Convert an instance of DayHours to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of ServiceHour to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/ServiceHours.java b/src/main/java/com/grabfood/client/model/ServiceHours.java index dcfe6a5..1dbed1f 100644 --- a/src/main/java/com/grabfood/client/model/ServiceHours.java +++ b/src/main/java/com/grabfood/client/model/ServiceHours.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.DayHours; +import com.grabfood.client.model.ServiceHour; import java.io.IOException; import java.util.Arrays; @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,171 +52,215 @@ /** * A JSON object with serviceHours for each day of the week. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class ServiceHours { public static final String SERIALIZED_NAME_MON = "mon"; @SerializedName(SERIALIZED_NAME_MON) - private DayHours mon; + private ServiceHour mon; public static final String SERIALIZED_NAME_TUE = "tue"; @SerializedName(SERIALIZED_NAME_TUE) - private DayHours tue; + private ServiceHour tue; public static final String SERIALIZED_NAME_WED = "wed"; @SerializedName(SERIALIZED_NAME_WED) - private DayHours wed; + private ServiceHour wed; public static final String SERIALIZED_NAME_THU = "thu"; @SerializedName(SERIALIZED_NAME_THU) - private DayHours thu; + private ServiceHour thu; public static final String SERIALIZED_NAME_FRI = "fri"; @SerializedName(SERIALIZED_NAME_FRI) - private DayHours fri; + private ServiceHour fri; public static final String SERIALIZED_NAME_SAT = "sat"; @SerializedName(SERIALIZED_NAME_SAT) - private DayHours sat; + private ServiceHour sat; public static final String SERIALIZED_NAME_SUN = "sun"; @SerializedName(SERIALIZED_NAME_SUN) - private DayHours sun; + private ServiceHour sun; public ServiceHours() { } - public ServiceHours mon(DayHours mon) { + public ServiceHours mon(ServiceHour mon) { this.mon = mon; return this; } - /** + /** * Get mon * @return mon - **/ + */ @javax.annotation.Nonnull - public DayHours getMon() { + public ServiceHour getMon() { return mon; } - public void setMon(DayHours mon) { + public void setMon(ServiceHour mon) { this.mon = mon; } - public ServiceHours tue(DayHours tue) { + public ServiceHours tue(ServiceHour tue) { this.tue = tue; return this; } - /** + /** * Get tue * @return tue - **/ + */ @javax.annotation.Nonnull - public DayHours getTue() { + public ServiceHour getTue() { return tue; } - public void setTue(DayHours tue) { + public void setTue(ServiceHour tue) { this.tue = tue; } - public ServiceHours wed(DayHours wed) { + public ServiceHours wed(ServiceHour wed) { this.wed = wed; return this; } - /** + /** * Get wed * @return wed - **/ + */ @javax.annotation.Nonnull - public DayHours getWed() { + public ServiceHour getWed() { return wed; } - public void setWed(DayHours wed) { + public void setWed(ServiceHour wed) { this.wed = wed; } - public ServiceHours thu(DayHours thu) { + public ServiceHours thu(ServiceHour thu) { this.thu = thu; return this; } - /** + /** * Get thu * @return thu - **/ + */ @javax.annotation.Nonnull - public DayHours getThu() { + public ServiceHour getThu() { return thu; } - public void setThu(DayHours thu) { + public void setThu(ServiceHour thu) { this.thu = thu; } - public ServiceHours fri(DayHours fri) { + public ServiceHours fri(ServiceHour fri) { this.fri = fri; return this; } - /** + /** * Get fri * @return fri - **/ + */ @javax.annotation.Nonnull - public DayHours getFri() { + public ServiceHour getFri() { return fri; } - public void setFri(DayHours fri) { + public void setFri(ServiceHour fri) { this.fri = fri; } - public ServiceHours sat(DayHours sat) { + public ServiceHours sat(ServiceHour sat) { this.sat = sat; return this; } - /** + /** * Get sat * @return sat - **/ + */ @javax.annotation.Nonnull - public DayHours getSat() { + public ServiceHour getSat() { return sat; } - public void setSat(DayHours sat) { + public void setSat(ServiceHour sat) { this.sat = sat; } - public ServiceHours sun(DayHours sun) { + public ServiceHours sun(ServiceHour sun) { this.sun = sun; return this; } - /** + /** * Get sun * @return sun - **/ + */ @javax.annotation.Nonnull - public DayHours getSun() { + public ServiceHour getSun() { return sun; } - public void setSun(DayHours sun) { + public void setSun(ServiceHour sun) { this.sun = sun; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ServiceHours instance itself + */ + public ServiceHours putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -235,12 +278,13 @@ public boolean equals(Object o) { Objects.equals(this.thu, serviceHours.thu) && Objects.equals(this.fri, serviceHours.fri) && Objects.equals(this.sat, serviceHours.sat) && - Objects.equals(this.sun, serviceHours.sun); + Objects.equals(this.sun, serviceHours.sun)&& + Objects.equals(this.additionalProperties, serviceHours.additionalProperties); } @Override public int hashCode() { - return Objects.hash(mon, tue, wed, thu, fri, sat, sun); + return Objects.hash(mon, tue, wed, thu, fri, sat, sun, additionalProperties); } @Override @@ -254,6 +298,7 @@ public String toString() { sb.append(" fri: ").append(toIndentedString(fri)).append("\n"); sb.append(" sat: ").append(toIndentedString(sat)).append("\n"); sb.append(" sun: ").append(toIndentedString(sun)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -295,12 +340,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("sun"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ServiceHours - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ServiceHours + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!ServiceHours.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -308,14 +353,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ServiceHours.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ServiceHours` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ServiceHours.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -324,19 +361,19 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the required field `mon` - DayHours.validateJsonElement(jsonObj.get("mon")); + ServiceHour.validateJsonElement(jsonObj.get("mon")); // validate the required field `tue` - DayHours.validateJsonElement(jsonObj.get("tue")); + ServiceHour.validateJsonElement(jsonObj.get("tue")); // validate the required field `wed` - DayHours.validateJsonElement(jsonObj.get("wed")); + ServiceHour.validateJsonElement(jsonObj.get("wed")); // validate the required field `thu` - DayHours.validateJsonElement(jsonObj.get("thu")); + ServiceHour.validateJsonElement(jsonObj.get("thu")); // validate the required field `fri` - DayHours.validateJsonElement(jsonObj.get("fri")); + ServiceHour.validateJsonElement(jsonObj.get("fri")); // validate the required field `sat` - DayHours.validateJsonElement(jsonObj.get("sat")); + ServiceHour.validateJsonElement(jsonObj.get("sat")); // validate the required field `sun` - DayHours.validateJsonElement(jsonObj.get("sun")); + ServiceHour.validateJsonElement(jsonObj.get("sun")); } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -354,6 +391,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ServiceHours value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -361,29 +420,50 @@ public void write(JsonWriter out, ServiceHours value) throws IOException { public ServiceHours read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ServiceHours instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of ServiceHours given an JSON string - * - * @param jsonString JSON string - * @return An instance of ServiceHours - * @throws IOException if the JSON string is invalid with respect to ServiceHours - */ + /** + * Create an instance of ServiceHours given an JSON string + * + * @param jsonString JSON string + * @return An instance of ServiceHours + * @throws IOException if the JSON string is invalid with respect to ServiceHours + */ public static ServiceHours fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, ServiceHours.class); } - /** - * Convert an instance of ServiceHours to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of ServiceHours to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/SpecialOpeningHour.java b/src/main/java/com/grabfood/client/model/SpecialOpeningHour.java index 31684f9..086fa49 100644 --- a/src/main/java/com/grabfood/client/model/SpecialOpeningHour.java +++ b/src/main/java/com/grabfood/client/model/SpecialOpeningHour.java @@ -42,7 +42,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -54,7 +53,7 @@ /** * SpecialOpeningHour */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class SpecialOpeningHour { public static final String SERIALIZED_NAME_START_DATE = "startDate"; @SerializedName(SERIALIZED_NAME_START_DATE) @@ -80,10 +79,10 @@ public SpecialOpeningHour startDate(String startDate) { return this; } - /** + /** * The start date of store special opening hours. * @return startDate - **/ + */ @javax.annotation.Nullable public String getStartDate() { return startDate; @@ -99,10 +98,10 @@ public SpecialOpeningHour endDate(String endDate) { return this; } - /** + /** * The end date of store special opening hours. * @return endDate - **/ + */ @javax.annotation.Nullable public String getEndDate() { return endDate; @@ -118,10 +117,10 @@ public SpecialOpeningHour metadata(SpecialOpeningHourMetadata metadata) { return this; } - /** + /** * Get metadata * @return metadata - **/ + */ @javax.annotation.Nullable public SpecialOpeningHourMetadata getMetadata() { return metadata; @@ -137,10 +136,10 @@ public SpecialOpeningHour openingHours(SpecialOpeningHourOpeningHours openingHou return this; } - /** + /** * Get openingHours * @return openingHours - **/ + */ @javax.annotation.Nullable public SpecialOpeningHourOpeningHours getOpeningHours() { return openingHours; @@ -150,6 +149,50 @@ public void setOpeningHours(SpecialOpeningHourOpeningHours openingHours) { this.openingHours = openingHours; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SpecialOpeningHour instance itself + */ + public SpecialOpeningHour putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -164,12 +207,13 @@ public boolean equals(Object o) { return Objects.equals(this.startDate, specialOpeningHour.startDate) && Objects.equals(this.endDate, specialOpeningHour.endDate) && Objects.equals(this.metadata, specialOpeningHour.metadata) && - Objects.equals(this.openingHours, specialOpeningHour.openingHours); + Objects.equals(this.openingHours, specialOpeningHour.openingHours)&& + Objects.equals(this.additionalProperties, specialOpeningHour.additionalProperties); } @Override public int hashCode() { - return Objects.hash(startDate, endDate, metadata, openingHours); + return Objects.hash(startDate, endDate, metadata, openingHours, additionalProperties); } @Override @@ -180,6 +224,7 @@ public String toString() { sb.append(" endDate: ").append(toIndentedString(endDate)).append("\n"); sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); sb.append(" openingHours: ").append(toIndentedString(openingHours)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -211,26 +256,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SpecialOpeningHour - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SpecialOpeningHour + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SpecialOpeningHour.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in SpecialOpeningHour is not found in the empty JSON string", SpecialOpeningHour.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SpecialOpeningHour.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialOpeningHour` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("startDate") != null && !jsonObj.get("startDate").isJsonNull()) && !jsonObj.get("startDate").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `startDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("startDate").toString())); @@ -263,6 +300,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SpecialOpeningHour value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -270,29 +329,50 @@ public void write(JsonWriter out, SpecialOpeningHour value) throws IOException { public SpecialOpeningHour read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SpecialOpeningHour instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of SpecialOpeningHour given an JSON string - * - * @param jsonString JSON string - * @return An instance of SpecialOpeningHour - * @throws IOException if the JSON string is invalid with respect to SpecialOpeningHour - */ + /** + * Create an instance of SpecialOpeningHour given an JSON string + * + * @param jsonString JSON string + * @return An instance of SpecialOpeningHour + * @throws IOException if the JSON string is invalid with respect to SpecialOpeningHour + */ public static SpecialOpeningHour fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, SpecialOpeningHour.class); } - /** - * Convert an instance of SpecialOpeningHour to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of SpecialOpeningHour to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/SpecialOpeningHourMetadata.java b/src/main/java/com/grabfood/client/model/SpecialOpeningHourMetadata.java index 1137947..e524451 100644 --- a/src/main/java/com/grabfood/client/model/SpecialOpeningHourMetadata.java +++ b/src/main/java/com/grabfood/client/model/SpecialOpeningHourMetadata.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * Contains special opening hour info. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class SpecialOpeningHourMetadata { public static final String SERIALIZED_NAME_DESCRIPTION = "description"; @SerializedName(SERIALIZED_NAME_DESCRIPTION) @@ -66,10 +65,10 @@ public SpecialOpeningHourMetadata description(String description) { return this; } - /** + /** * Description of the special opening hour. * @return description - **/ + */ @javax.annotation.Nullable public String getDescription() { return description; @@ -79,6 +78,50 @@ public void setDescription(String description) { this.description = description; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SpecialOpeningHourMetadata instance itself + */ + public SpecialOpeningHourMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } SpecialOpeningHourMetadata specialOpeningHourMetadata = (SpecialOpeningHourMetadata) o; - return Objects.equals(this.description, specialOpeningHourMetadata.description); + return Objects.equals(this.description, specialOpeningHourMetadata.description)&& + Objects.equals(this.additionalProperties, specialOpeningHourMetadata.additionalProperties); } @Override public int hashCode() { - return Objects.hash(description); + return Objects.hash(description, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class SpecialOpeningHourMetadata {\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -131,26 +176,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SpecialOpeningHourMetadata - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SpecialOpeningHourMetadata + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SpecialOpeningHourMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in SpecialOpeningHourMetadata is not found in the empty JSON string", SpecialOpeningHourMetadata.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SpecialOpeningHourMetadata.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialOpeningHourMetadata` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); @@ -172,6 +209,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SpecialOpeningHourMetadata value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -179,29 +238,50 @@ public void write(JsonWriter out, SpecialOpeningHourMetadata value) throws IOExc public SpecialOpeningHourMetadata read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SpecialOpeningHourMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of SpecialOpeningHourMetadata given an JSON string - * - * @param jsonString JSON string - * @return An instance of SpecialOpeningHourMetadata - * @throws IOException if the JSON string is invalid with respect to SpecialOpeningHourMetadata - */ + /** + * Create an instance of SpecialOpeningHourMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of SpecialOpeningHourMetadata + * @throws IOException if the JSON string is invalid with respect to SpecialOpeningHourMetadata + */ public static SpecialOpeningHourMetadata fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, SpecialOpeningHourMetadata.class); } - /** - * Convert an instance of SpecialOpeningHourMetadata to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of SpecialOpeningHourMetadata to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/SpecialOpeningHourOpeningHours.java b/src/main/java/com/grabfood/client/model/SpecialOpeningHourOpeningHours.java index fb442e4..5586ac7 100644 --- a/src/main/java/com/grabfood/client/model/SpecialOpeningHourOpeningHours.java +++ b/src/main/java/com/grabfood/client/model/SpecialOpeningHourOpeningHours.java @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * Store special opening hour period. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class SpecialOpeningHourOpeningHours { /** * The period type for when the outlet is open. @@ -64,9 +63,11 @@ public class SpecialOpeningHourOpeningHours { public enum OpenPeriodTypeEnum { PERIOD("Period"), - OPENALLDAY("OpenAllDay"), + OPEN_ALL_DAY("OpenAllDay"), - CLOSEDALLDAY("ClosedAllDay"); + CLOSED_ALL_DAY("ClosedAllDay"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -89,7 +90,7 @@ public static OpenPeriodTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -127,10 +128,10 @@ public SpecialOpeningHourOpeningHours openPeriodType(OpenPeriodTypeEnum openPeri return this; } - /** + /** * The period type for when the outlet is open. * @return openPeriodType - **/ + */ @javax.annotation.Nullable public OpenPeriodTypeEnum getOpenPeriodType() { return openPeriodType; @@ -154,10 +155,10 @@ public SpecialOpeningHourOpeningHours addPeriodsItem(OpenPeriod periodsItem) { return this; } - /** + /** * An array of open periods. Maximum of 3 periods. * @return periods - **/ + */ @javax.annotation.Nullable public List getPeriods() { return periods; @@ -167,6 +168,50 @@ public void setPeriods(List periods) { this.periods = periods; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SpecialOpeningHourOpeningHours instance itself + */ + public SpecialOpeningHourOpeningHours putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -179,12 +224,13 @@ public boolean equals(Object o) { } SpecialOpeningHourOpeningHours specialOpeningHourOpeningHours = (SpecialOpeningHourOpeningHours) o; return Objects.equals(this.openPeriodType, specialOpeningHourOpeningHours.openPeriodType) && - Objects.equals(this.periods, specialOpeningHourOpeningHours.periods); + Objects.equals(this.periods, specialOpeningHourOpeningHours.periods)&& + Objects.equals(this.additionalProperties, specialOpeningHourOpeningHours.additionalProperties); } @Override public int hashCode() { - return Objects.hash(openPeriodType, periods); + return Objects.hash(openPeriodType, periods, additionalProperties); } @Override @@ -193,6 +239,7 @@ public String toString() { sb.append("class SpecialOpeningHourOpeningHours {\n"); sb.append(" openPeriodType: ").append(toIndentedString(openPeriodType)).append("\n"); sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -222,26 +269,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SpecialOpeningHourOpeningHours - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SpecialOpeningHourOpeningHours + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SpecialOpeningHourOpeningHours.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in SpecialOpeningHourOpeningHours is not found in the empty JSON string", SpecialOpeningHourOpeningHours.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SpecialOpeningHourOpeningHours.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialOpeningHourOpeningHours` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("openPeriodType") != null && !jsonObj.get("openPeriodType").isJsonNull()) && !jsonObj.get("openPeriodType").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `openPeriodType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("openPeriodType").toString())); @@ -281,6 +320,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SpecialOpeningHourOpeningHours value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -288,29 +349,50 @@ public void write(JsonWriter out, SpecialOpeningHourOpeningHours value) throws I public SpecialOpeningHourOpeningHours read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SpecialOpeningHourOpeningHours instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of SpecialOpeningHourOpeningHours given an JSON string - * - * @param jsonString JSON string - * @return An instance of SpecialOpeningHourOpeningHours - * @throws IOException if the JSON string is invalid with respect to SpecialOpeningHourOpeningHours - */ + /** + * Create an instance of SpecialOpeningHourOpeningHours given an JSON string + * + * @param jsonString JSON string + * @return An instance of SpecialOpeningHourOpeningHours + * @throws IOException if the JSON string is invalid with respect to SpecialOpeningHourOpeningHours + */ public static SpecialOpeningHourOpeningHours fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, SpecialOpeningHourOpeningHours.class); } - /** - * Convert an instance of SpecialOpeningHourOpeningHours to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of SpecialOpeningHourOpeningHours to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/StoreHour.java b/src/main/java/com/grabfood/client/model/StoreHour.java index 3b25079..f33d722 100644 --- a/src/main/java/com/grabfood/client/model/StoreHour.java +++ b/src/main/java/com/grabfood/client/model/StoreHour.java @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * A JSON object that describes the store hour for each day. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class StoreHour { public static final String SERIALIZED_NAME_MON = "mon"; @SerializedName(SERIALIZED_NAME_MON) @@ -101,10 +100,10 @@ public StoreHour addMonItem(OpenPeriod monItem) { return this; } - /** + /** * An array of open periods. Maximum of 3 periods. Blank indicates store close. * @return mon - **/ + */ @javax.annotation.Nonnull public List getMon() { return mon; @@ -128,10 +127,10 @@ public StoreHour addTueItem(OpenPeriod tueItem) { return this; } - /** + /** * An array of open periods. Maximum of 3 periods. Blank indicates store close. * @return tue - **/ + */ @javax.annotation.Nonnull public List getTue() { return tue; @@ -155,10 +154,10 @@ public StoreHour addWedItem(OpenPeriod wedItem) { return this; } - /** + /** * An array of open periods. Maximum of 3 periods. Blank indicates store close. * @return wed - **/ + */ @javax.annotation.Nonnull public List getWed() { return wed; @@ -182,10 +181,10 @@ public StoreHour addThuItem(OpenPeriod thuItem) { return this; } - /** + /** * An array of open periods. Maximum of 3 periods. Blank indicates store close. * @return thu - **/ + */ @javax.annotation.Nonnull public List getThu() { return thu; @@ -209,10 +208,10 @@ public StoreHour addFriItem(OpenPeriod friItem) { return this; } - /** + /** * An array of open periods. Maximum of 3 periods. Blank indicates store close. * @return fri - **/ + */ @javax.annotation.Nonnull public List getFri() { return fri; @@ -236,10 +235,10 @@ public StoreHour addSatItem(OpenPeriod satItem) { return this; } - /** + /** * An array of open periods. Maximum of 3 periods. Blank indicates store close. * @return sat - **/ + */ @javax.annotation.Nonnull public List getSat() { return sat; @@ -263,10 +262,10 @@ public StoreHour addSunItem(OpenPeriod sunItem) { return this; } - /** + /** * An array of open periods. Maximum of 3 periods. Blank indicates store close. * @return sun - **/ + */ @javax.annotation.Nonnull public List getSun() { return sun; @@ -276,6 +275,50 @@ public void setSun(List sun) { this.sun = sun; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the StoreHour instance itself + */ + public StoreHour putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -293,12 +336,13 @@ public boolean equals(Object o) { Objects.equals(this.thu, storeHour.thu) && Objects.equals(this.fri, storeHour.fri) && Objects.equals(this.sat, storeHour.sat) && - Objects.equals(this.sun, storeHour.sun); + Objects.equals(this.sun, storeHour.sun)&& + Objects.equals(this.additionalProperties, storeHour.additionalProperties); } @Override public int hashCode() { - return Objects.hash(mon, tue, wed, thu, fri, sat, sun); + return Objects.hash(mon, tue, wed, thu, fri, sat, sun, additionalProperties); } @Override @@ -312,6 +356,7 @@ public String toString() { sb.append(" fri: ").append(toIndentedString(fri)).append("\n"); sb.append(" sat: ").append(toIndentedString(sat)).append("\n"); sb.append(" sun: ").append(toIndentedString(sun)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -353,12 +398,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("sun"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to StoreHour - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to StoreHour + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StoreHour.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -366,14 +411,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StoreHour.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `StoreHour` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StoreHour.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -468,6 +505,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StoreHour value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -475,29 +534,50 @@ public void write(JsonWriter out, StoreHour value) throws IOException { public StoreHour read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + StoreHour instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of StoreHour given an JSON string - * - * @param jsonString JSON string - * @return An instance of StoreHour - * @throws IOException if the JSON string is invalid with respect to StoreHour - */ + /** + * Create an instance of StoreHour given an JSON string + * + * @param jsonString JSON string + * @return An instance of StoreHour + * @throws IOException if the JSON string is invalid with respect to StoreHour + */ public static StoreHour fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, StoreHour.class); } - /** - * Convert an instance of StoreHour to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of StoreHour to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/StoreHourResponse.java b/src/main/java/com/grabfood/client/model/StoreHourResponse.java index f7df9b2..45ffc48 100644 --- a/src/main/java/com/grabfood/client/model/StoreHourResponse.java +++ b/src/main/java/com/grabfood/client/model/StoreHourResponse.java @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -56,7 +55,7 @@ /** * Object contain store hour info */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class StoreHourResponse { public static final String SERIALIZED_NAME_DINE_IN_HOUR = "dineInHour"; @SerializedName(SERIALIZED_NAME_DINE_IN_HOUR) @@ -78,10 +77,10 @@ public StoreHourResponse dineInHour(StoreHour dineInHour) { return this; } - /** + /** * Get dineInHour * @return dineInHour - **/ + */ @javax.annotation.Nullable public StoreHour getDineInHour() { return dineInHour; @@ -97,10 +96,10 @@ public StoreHourResponse openingHour(StoreHour openingHour) { return this; } - /** + /** * Get openingHour * @return openingHour - **/ + */ @javax.annotation.Nullable public StoreHour getOpeningHour() { return openingHour; @@ -124,10 +123,10 @@ public StoreHourResponse addSpecialOpeningHoursItem(SpecialOpeningHour specialOp return this; } - /** + /** * The store's special opening hours. * @return specialOpeningHours - **/ + */ @javax.annotation.Nullable public List getSpecialOpeningHours() { return specialOpeningHours; @@ -137,6 +136,50 @@ public void setSpecialOpeningHours(List specialOpeningHours) this.specialOpeningHours = specialOpeningHours; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the StoreHourResponse instance itself + */ + public StoreHourResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -150,12 +193,13 @@ public boolean equals(Object o) { StoreHourResponse storeHourResponse = (StoreHourResponse) o; return Objects.equals(this.dineInHour, storeHourResponse.dineInHour) && Objects.equals(this.openingHour, storeHourResponse.openingHour) && - Objects.equals(this.specialOpeningHours, storeHourResponse.specialOpeningHours); + Objects.equals(this.specialOpeningHours, storeHourResponse.specialOpeningHours)&& + Objects.equals(this.additionalProperties, storeHourResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dineInHour, openingHour, specialOpeningHours); + return Objects.hash(dineInHour, openingHour, specialOpeningHours, additionalProperties); } @Override @@ -165,6 +209,7 @@ public String toString() { sb.append(" dineInHour: ").append(toIndentedString(dineInHour)).append("\n"); sb.append(" openingHour: ").append(toIndentedString(openingHour)).append("\n"); sb.append(" specialOpeningHours: ").append(toIndentedString(specialOpeningHours)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -195,26 +240,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to StoreHourResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to StoreHourResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StoreHourResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in StoreHourResponse is not found in the empty JSON string", StoreHourResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StoreHourResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `StoreHourResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `dineInHour` if (jsonObj.get("dineInHour") != null && !jsonObj.get("dineInHour").isJsonNull()) { @@ -255,6 +292,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StoreHourResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -262,29 +321,50 @@ public void write(JsonWriter out, StoreHourResponse value) throws IOException { public StoreHourResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + StoreHourResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of StoreHourResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of StoreHourResponse - * @throws IOException if the JSON string is invalid with respect to StoreHourResponse - */ + /** + * Create an instance of StoreHourResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of StoreHourResponse + * @throws IOException if the JSON string is invalid with respect to StoreHourResponse + */ public static StoreHourResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, StoreHourResponse.class); } - /** - * Convert an instance of StoreHourResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of StoreHourResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/StoreHourStatusError.java b/src/main/java/com/grabfood/client/model/StoreHourStatusError.java deleted file mode 100644 index 758d53f..0000000 --- a/src/main/java/com/grabfood/client/model/StoreHourStatusError.java +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * Example error returned for invalid request - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class StoreHourStatusError { - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public StoreHourStatusError() { - } - - public StoreHourStatusError reason(String reason) { - this.reason = reason; - return this; - } - - /** - * Reason of invalid request. - * @return reason - **/ - @javax.annotation.Nullable - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - - public StoreHourStatusError message(String message) { - this.message = message; - return this; - } - - /** - * Readable error message. - * @return message - **/ - @javax.annotation.Nullable - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - StoreHourStatusError storeHourStatusError = (StoreHourStatusError) o; - return Objects.equals(this.reason, storeHourStatusError.reason) && - Objects.equals(this.message, storeHourStatusError.message); - } - - @Override - public int hashCode() { - return Objects.hash(reason, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class StoreHourStatusError {\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("reason"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to StoreHourStatusError - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!StoreHourStatusError.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in StoreHourStatusError is not found in the empty JSON string", StoreHourStatusError.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StoreHourStatusError.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `StoreHourStatusError` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("reason") != null && !jsonObj.get("reason").isJsonNull()) && !jsonObj.get("reason").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `reason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reason").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!StoreHourStatusError.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'StoreHourStatusError' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(StoreHourStatusError.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, StoreHourStatusError value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public StoreHourStatusError read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of StoreHourStatusError given an JSON string - * - * @param jsonString JSON string - * @return An instance of StoreHourStatusError - * @throws IOException if the JSON string is invalid with respect to StoreHourStatusError - */ - public static StoreHourStatusError fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, StoreHourStatusError.class); - } - - /** - * Convert an instance of StoreHourStatusError to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/StoreStatusResponse.java b/src/main/java/com/grabfood/client/model/StoreStatusResponse.java index 035e66a..a9b160c 100644 --- a/src/main/java/com/grabfood/client/model/StoreStatusResponse.java +++ b/src/main/java/com/grabfood/client/model/StoreStatusResponse.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * Object contains store status info */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class StoreStatusResponse { /** * The code of store close reason. Blank indicates store is currently open. @@ -77,7 +76,9 @@ public enum CloseReasonEnum { PARSE_DATA_FAIL("parse_data_fail"), - EMPTY(""); + EMPTY(""), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -100,7 +101,7 @@ public static CloseReasonEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -142,10 +143,10 @@ public StoreStatusResponse closeReason(CloseReasonEnum closeReason) { return this; } - /** + /** * The code of store close reason. Blank indicates store is currently open. * @return closeReason - **/ + */ @javax.annotation.Nonnull public CloseReasonEnum getCloseReason() { return closeReason; @@ -161,10 +162,10 @@ public StoreStatusResponse isInSpecialOpeningHourRange(Boolean isInSpecialOpenin return this; } - /** + /** * Indicate whether the store is in special opening hour range. * @return isInSpecialOpeningHourRange - **/ + */ @javax.annotation.Nonnull public Boolean getIsInSpecialOpeningHourRange() { return isInSpecialOpeningHourRange; @@ -180,10 +181,10 @@ public StoreStatusResponse isOpen(Boolean isOpen) { return this; } - /** + /** * Indicate whether the store is open. * @return isOpen - **/ + */ @javax.annotation.Nonnull public Boolean getIsOpen() { return isOpen; @@ -193,6 +194,50 @@ public void setIsOpen(Boolean isOpen) { this.isOpen = isOpen; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the StoreStatusResponse instance itself + */ + public StoreStatusResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -206,12 +251,13 @@ public boolean equals(Object o) { StoreStatusResponse storeStatusResponse = (StoreStatusResponse) o; return Objects.equals(this.closeReason, storeStatusResponse.closeReason) && Objects.equals(this.isInSpecialOpeningHourRange, storeStatusResponse.isInSpecialOpeningHourRange) && - Objects.equals(this.isOpen, storeStatusResponse.isOpen); + Objects.equals(this.isOpen, storeStatusResponse.isOpen)&& + Objects.equals(this.additionalProperties, storeStatusResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(closeReason, isInSpecialOpeningHourRange, isOpen); + return Objects.hash(closeReason, isInSpecialOpeningHourRange, isOpen, additionalProperties); } @Override @@ -221,6 +267,7 @@ public String toString() { sb.append(" closeReason: ").append(toIndentedString(closeReason)).append("\n"); sb.append(" isInSpecialOpeningHourRange: ").append(toIndentedString(isInSpecialOpeningHourRange)).append("\n"); sb.append(" isOpen: ").append(toIndentedString(isOpen)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -254,12 +301,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("isOpen"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to StoreStatusResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to StoreStatusResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!StoreStatusResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -267,14 +314,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StoreStatusResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `StoreStatusResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StoreStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -304,6 +343,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StoreStatusResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -311,29 +372,50 @@ public void write(JsonWriter out, StoreStatusResponse value) throws IOException public StoreStatusResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + StoreStatusResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of StoreStatusResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of StoreStatusResponse - * @throws IOException if the JSON string is invalid with respect to StoreStatusResponse - */ + /** + * Create an instance of StoreStatusResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of StoreStatusResponse + * @throws IOException if the JSON string is invalid with respect to StoreStatusResponse + */ public static StoreStatusResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, StoreStatusResponse.class); } - /** - * Convert an instance of StoreStatusResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of StoreStatusResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/SubmitOrderRequest.java b/src/main/java/com/grabfood/client/model/SubmitOrderRequest.java index 3bce43f..aff8f66 100644 --- a/src/main/java/com/grabfood/client/model/SubmitOrderRequest.java +++ b/src/main/java/com/grabfood/client/model/SubmitOrderRequest.java @@ -24,12 +24,12 @@ import com.google.gson.stream.JsonWriter; import com.grabfood.client.model.Currency; import com.grabfood.client.model.DineIn; -import com.grabfood.client.model.FeatureFlags; -import com.grabfood.client.model.OrderCampaignsInner; -import com.grabfood.client.model.OrderItemsInner; +import com.grabfood.client.model.OrderCampaign; +import com.grabfood.client.model.OrderFeatureFlags; +import com.grabfood.client.model.OrderItem; import com.grabfood.client.model.OrderPrice; +import com.grabfood.client.model.OrderPromo; import com.grabfood.client.model.OrderReadyEstimation; -import com.grabfood.client.model.PromosInner; import com.grabfood.client.model.Receiver; import java.io.IOException; import java.time.OffsetDateTime; @@ -53,7 +53,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -65,7 +64,7 @@ /** * A JSON object containing the order information. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class SubmitOrderRequest { public static final String SERIALIZED_NAME_ORDER_I_D = "orderID"; @SerializedName(SERIALIZED_NAME_ORDER_I_D) @@ -90,7 +89,9 @@ public class SubmitOrderRequest { public enum PaymentTypeEnum { CASH("CASH"), - CASHLESS("CASHLESS"); + CASHLESS("CASHLESS"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -113,7 +114,7 @@ public static PaymentTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -145,7 +146,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_ORDER_TIME = "orderTime"; @SerializedName(SERIALIZED_NAME_ORDER_TIME) - private OffsetDateTime orderTime; + private String orderTime; public static final String SERIALIZED_NAME_SUBMIT_TIME = "submitTime"; @SerializedName(SERIALIZED_NAME_SUBMIT_TIME) @@ -157,7 +158,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_SCHEDULED_TIME = "scheduledTime"; @SerializedName(SERIALIZED_NAME_SCHEDULED_TIME) - private OffsetDateTime scheduledTime; + private String scheduledTime; public static final String SERIALIZED_NAME_ORDER_STATE = "orderState"; @SerializedName(SERIALIZED_NAME_ORDER_STATE) @@ -169,19 +170,19 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_FEATURE_FLAGS = "featureFlags"; @SerializedName(SERIALIZED_NAME_FEATURE_FLAGS) - private FeatureFlags featureFlags; + private OrderFeatureFlags featureFlags; public static final String SERIALIZED_NAME_ITEMS = "items"; @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); + private List items = new ArrayList<>(); public static final String SERIALIZED_NAME_CAMPAIGNS = "campaigns"; @SerializedName(SERIALIZED_NAME_CAMPAIGNS) - private List campaigns; + private List campaigns; public static final String SERIALIZED_NAME_PROMOS = "promos"; @SerializedName(SERIALIZED_NAME_PROMOS) - private List promos = new ArrayList<>(); + private List promos = new ArrayList<>(); public static final String SERIALIZED_NAME_PRICE = "price"; @SerializedName(SERIALIZED_NAME_PRICE) @@ -211,10 +212,10 @@ public SubmitOrderRequest orderID(String orderID) { return this; } - /** + /** * The order's ID that is returned from GrabFood. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return orderID - **/ + */ @javax.annotation.Nonnull public String getOrderID() { return orderID; @@ -230,10 +231,10 @@ public SubmitOrderRequest shortOrderNumber(String shortOrderNumber) { return this; } - /** + /** * The GrabFood short order number. This is unique for each merchant per day. Refer to FAQs for more details about [orderID and shortOrderNumber](#section/Order/What's-the-difference-between-orderID-and-shortOrderNumber). * @return shortOrderNumber - **/ + */ @javax.annotation.Nonnull public String getShortOrderNumber() { return shortOrderNumber; @@ -249,10 +250,10 @@ public SubmitOrderRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -268,10 +269,10 @@ public SubmitOrderRequest partnerMerchantID(String partnerMerchantID) { return this; } - /** + /** * The merchant's ID that is on the partner's database. * @return partnerMerchantID - **/ + */ @javax.annotation.Nullable public String getPartnerMerchantID() { return partnerMerchantID; @@ -287,10 +288,10 @@ public SubmitOrderRequest paymentType(PaymentTypeEnum paymentType) { return this; } - /** + /** * The payment method used. Refer to FAQs for more details about [paymentType](#section/Order/Does-the-paymentType-affect-partners). * @return paymentType - **/ + */ @javax.annotation.Nonnull public PaymentTypeEnum getPaymentType() { return paymentType; @@ -306,10 +307,10 @@ public SubmitOrderRequest cutlery(Boolean cutlery) { return this; } - /** + /** * The boolean value to indicate whether cutlery are needed or not. Refer to FAQs for more details about [cutlery](#section/Order/What-do-the-true-or-false-values-mean-for-cutlery). * @return cutlery - **/ + */ @javax.annotation.Nonnull public Boolean getCutlery() { return cutlery; @@ -320,21 +321,21 @@ public void setCutlery(Boolean cutlery) { } - public SubmitOrderRequest orderTime(OffsetDateTime orderTime) { + public SubmitOrderRequest orderTime(String orderTime) { this.orderTime = orderTime; return this; } - /** + /** * The UTC time that a consumer places the order, based on ISO_8601/RFC3339. * @return orderTime - **/ + */ @javax.annotation.Nonnull - public OffsetDateTime getOrderTime() { + public String getOrderTime() { return orderTime; } - public void setOrderTime(OffsetDateTime orderTime) { + public void setOrderTime(String orderTime) { this.orderTime = orderTime; } @@ -344,10 +345,10 @@ public SubmitOrderRequest submitTime(OffsetDateTime submitTime) { return this; } - /** + /** * The order submit time, based on ISO_8601/RFC3339. Only present in the [List Orders](#tag/list-order) response. * @return submitTime - **/ + */ @javax.annotation.Nullable public OffsetDateTime getSubmitTime() { return submitTime; @@ -363,10 +364,10 @@ public SubmitOrderRequest completeTime(OffsetDateTime completeTime) { return this; } - /** + /** * The order complete time, based on ISO_8601/RFC3339. Only present in the [List Orders](#tag/list-order) response. * @return completeTime - **/ + */ @javax.annotation.Nullable public OffsetDateTime getCompleteTime() { return completeTime; @@ -377,21 +378,21 @@ public void setCompleteTime(OffsetDateTime completeTime) { } - public SubmitOrderRequest scheduledTime(OffsetDateTime scheduledTime) { + public SubmitOrderRequest scheduledTime(String scheduledTime) { this.scheduledTime = scheduledTime; return this; } - /** + /** * The order scheduled time, based on ISO_8601/RFC3339. Empty for non-scheduled orders. * @return scheduledTime - **/ + */ @javax.annotation.Nullable - public OffsetDateTime getScheduledTime() { + public String getScheduledTime() { return scheduledTime; } - public void setScheduledTime(OffsetDateTime scheduledTime) { + public void setScheduledTime(String scheduledTime) { this.scheduledTime = scheduledTime; } @@ -401,10 +402,10 @@ public SubmitOrderRequest orderState(String orderState) { return this; } - /** + /** * The state of the order. Only present in the [List Orders](#tag/list-order) response. Refer to [Order States](#section/Order-states). * @return orderState - **/ + */ @javax.annotation.Nullable public String getOrderState() { return orderState; @@ -420,10 +421,10 @@ public SubmitOrderRequest currency(Currency currency) { return this; } - /** + /** * Get currency * @return currency - **/ + */ @javax.annotation.Nonnull public Currency getCurrency() { return currency; @@ -434,31 +435,31 @@ public void setCurrency(Currency currency) { } - public SubmitOrderRequest featureFlags(FeatureFlags featureFlags) { + public SubmitOrderRequest featureFlags(OrderFeatureFlags featureFlags) { this.featureFlags = featureFlags; return this; } - /** + /** * Get featureFlags * @return featureFlags - **/ + */ @javax.annotation.Nonnull - public FeatureFlags getFeatureFlags() { + public OrderFeatureFlags getFeatureFlags() { return featureFlags; } - public void setFeatureFlags(FeatureFlags featureFlags) { + public void setFeatureFlags(OrderFeatureFlags featureFlags) { this.featureFlags = featureFlags; } - public SubmitOrderRequest items(List items) { + public SubmitOrderRequest items(List items) { this.items = items; return this; } - public SubmitOrderRequest addItemsItem(OrderItemsInner itemsItem) { + public SubmitOrderRequest addItemsItem(OrderItem itemsItem) { if (this.items == null) { this.items = new ArrayList<>(); } @@ -466,26 +467,26 @@ public SubmitOrderRequest addItemsItem(OrderItemsInner itemsItem) { return this; } - /** + /** * The items in an array of JSON Object. Refer to [Items](#items) for more information. * @return items - **/ + */ @javax.annotation.Nonnull - public List getItems() { + public List getItems() { return items; } - public void setItems(List items) { + public void setItems(List items) { this.items = items; } - public SubmitOrderRequest campaigns(List campaigns) { + public SubmitOrderRequest campaigns(List campaigns) { this.campaigns = campaigns; return this; } - public SubmitOrderRequest addCampaignsItem(OrderCampaignsInner campaignsItem) { + public SubmitOrderRequest addCampaignsItem(OrderCampaign campaignsItem) { if (this.campaigns == null) { this.campaigns = new ArrayList<>(); } @@ -493,26 +494,26 @@ public SubmitOrderRequest addCampaignsItem(OrderCampaignsInner campaignsItem) { return this; } - /** + /** * The campaigns that are applicable for the order.`null` when there is no campaign applied. * @return campaigns - **/ + */ @javax.annotation.Nullable - public List getCampaigns() { + public List getCampaigns() { return campaigns; } - public void setCampaigns(List campaigns) { + public void setCampaigns(List campaigns) { this.campaigns = campaigns; } - public SubmitOrderRequest promos(List promos) { + public SubmitOrderRequest promos(List promos) { this.promos = promos; return this; } - public SubmitOrderRequest addPromosItem(PromosInner promosItem) { + public SubmitOrderRequest addPromosItem(OrderPromo promosItem) { if (this.promos == null) { this.promos = new ArrayList<>(); } @@ -520,16 +521,16 @@ public SubmitOrderRequest addPromosItem(PromosInner promosItem) { return this; } - /** + /** * An array of promotion objects. Only promotions that are funded by merchants will be sent. * @return promos - **/ + */ @javax.annotation.Nullable - public List getPromos() { + public List getPromos() { return promos; } - public void setPromos(List promos) { + public void setPromos(List promos) { this.promos = promos; } @@ -539,10 +540,10 @@ public SubmitOrderRequest price(OrderPrice price) { return this; } - /** + /** * Get price * @return price - **/ + */ @javax.annotation.Nonnull public OrderPrice getPrice() { return price; @@ -558,10 +559,10 @@ public SubmitOrderRequest dineIn(DineIn dineIn) { return this; } - /** + /** * Get dineIn * @return dineIn - **/ + */ @javax.annotation.Nullable public DineIn getDineIn() { return dineIn; @@ -577,10 +578,10 @@ public SubmitOrderRequest receiver(Receiver receiver) { return this; } - /** + /** * Get receiver * @return receiver - **/ + */ @javax.annotation.Nullable public Receiver getReceiver() { return receiver; @@ -596,10 +597,10 @@ public SubmitOrderRequest orderReadyEstimation(OrderReadyEstimation orderReadyEs return this; } - /** + /** * Get orderReadyEstimation * @return orderReadyEstimation - **/ + */ @javax.annotation.Nullable public OrderReadyEstimation getOrderReadyEstimation() { return orderReadyEstimation; @@ -615,10 +616,10 @@ public SubmitOrderRequest membershipID(String membershipID) { return this; } - /** + /** * Membership ID for loyalty project. Only present for loyalty program partners. * @return membershipID - **/ + */ @javax.annotation.Nullable public String getMembershipID() { return membershipID; @@ -628,6 +629,50 @@ public void setMembershipID(String membershipID) { this.membershipID = membershipID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SubmitOrderRequest instance itself + */ + public SubmitOrderRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -659,7 +704,8 @@ public boolean equals(Object o) { Objects.equals(this.dineIn, submitOrderRequest.dineIn) && Objects.equals(this.receiver, submitOrderRequest.receiver) && Objects.equals(this.orderReadyEstimation, submitOrderRequest.orderReadyEstimation) && - Objects.equals(this.membershipID, submitOrderRequest.membershipID); + Objects.equals(this.membershipID, submitOrderRequest.membershipID)&& + Objects.equals(this.additionalProperties, submitOrderRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -668,7 +714,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(orderID, shortOrderNumber, merchantID, partnerMerchantID, paymentType, cutlery, orderTime, submitTime, completeTime, scheduledTime, orderState, currency, featureFlags, items, campaigns, promos, price, dineIn, receiver, orderReadyEstimation, membershipID); + return Objects.hash(orderID, shortOrderNumber, merchantID, partnerMerchantID, paymentType, cutlery, orderTime, submitTime, completeTime, scheduledTime, orderState, currency, featureFlags, items, campaigns, promos, price, dineIn, receiver, orderReadyEstimation, membershipID, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -703,6 +749,7 @@ public String toString() { sb.append(" receiver: ").append(toIndentedString(receiver)).append("\n"); sb.append(" orderReadyEstimation: ").append(toIndentedString(orderReadyEstimation)).append("\n"); sb.append(" membershipID: ").append(toIndentedString(membershipID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -761,12 +808,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("price"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SubmitOrderRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SubmitOrderRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!SubmitOrderRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -774,14 +821,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SubmitOrderRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SubmitOrderRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SubmitOrderRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -806,13 +845,19 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // validate the required field `paymentType` PaymentTypeEnum.validateJsonElement(jsonObj.get("paymentType")); + if (!jsonObj.get("orderTime").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `orderTime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orderTime").toString())); + } + if ((jsonObj.get("scheduledTime") != null && !jsonObj.get("scheduledTime").isJsonNull()) && !jsonObj.get("scheduledTime").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `scheduledTime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("scheduledTime").toString())); + } if ((jsonObj.get("orderState") != null && !jsonObj.get("orderState").isJsonNull()) && !jsonObj.get("orderState").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `orderState` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orderState").toString())); } // validate the required field `currency` Currency.validateJsonElement(jsonObj.get("currency")); // validate the required field `featureFlags` - FeatureFlags.validateJsonElement(jsonObj.get("featureFlags")); + OrderFeatureFlags.validateJsonElement(jsonObj.get("featureFlags")); // ensure the json data is an array if (!jsonObj.get("items").isJsonArray()) { throw new IllegalArgumentException(String.format("Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); @@ -821,7 +866,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); // validate the required field `items` (array) for (int i = 0; i < jsonArrayitems.size(); i++) { - OrderItemsInner.validateJsonElement(jsonArrayitems.get(i)); + OrderItem.validateJsonElement(jsonArrayitems.get(i)); }; if (jsonObj.get("campaigns") != null && !jsonObj.get("campaigns").isJsonNull()) { JsonArray jsonArraycampaigns = jsonObj.getAsJsonArray("campaigns"); @@ -833,7 +878,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `campaigns` (array) for (int i = 0; i < jsonArraycampaigns.size(); i++) { - OrderCampaignsInner.validateJsonElement(jsonArraycampaigns.get(i)); + OrderCampaign.validateJsonElement(jsonArraycampaigns.get(i)); }; } } @@ -847,7 +892,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `promos` (array) for (int i = 0; i < jsonArraypromos.size(); i++) { - PromosInner.validateJsonElement(jsonArraypromos.get(i)); + OrderPromo.validateJsonElement(jsonArraypromos.get(i)); }; } } @@ -885,6 +930,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SubmitOrderRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -892,29 +959,50 @@ public void write(JsonWriter out, SubmitOrderRequest value) throws IOException { public SubmitOrderRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SubmitOrderRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of SubmitOrderRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of SubmitOrderRequest - * @throws IOException if the JSON string is invalid with respect to SubmitOrderRequest - */ + /** + * Create an instance of SubmitOrderRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of SubmitOrderRequest + * @throws IOException if the JSON string is invalid with respect to SubmitOrderRequest + */ public static SubmitOrderRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, SubmitOrderRequest.class); } - /** - * Convert an instance of SubmitOrderRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of SubmitOrderRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/SyncFail.java b/src/main/java/com/grabfood/client/model/SyncFail.java deleted file mode 100644 index 6abe6be..0000000 --- a/src/main/java/com/grabfood/client/model/SyncFail.java +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.SyncFailCategoriesInner; -import com.grabfood.client.model.SyncFailServiceHours; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * SyncFail - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SyncFail { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private String id; - - public static final String SERIALIZED_NAME_ERRORS = "errors"; - @SerializedName(SERIALIZED_NAME_ERRORS) - private List errors = new ArrayList<>(); - - public static final String SERIALIZED_NAME_SERVICE_HOURS = "serviceHours"; - @SerializedName(SERIALIZED_NAME_SERVICE_HOURS) - private SyncFailServiceHours serviceHours; - - public static final String SERIALIZED_NAME_CATEGORIES = "categories"; - @SerializedName(SERIALIZED_NAME_CATEGORIES) - private List categories = new ArrayList<>(); - - public SyncFail() { - } - - public SyncFail id(String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @javax.annotation.Nullable - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - - public SyncFail errors(List errors) { - this.errors = errors; - return this; - } - - public SyncFail addErrorsItem(String errorsItem) { - if (this.errors == null) { - this.errors = new ArrayList<>(); - } - this.errors.add(errorsItem); - return this; - } - - /** - * An array of strings of error message. - * @return errors - **/ - @javax.annotation.Nullable - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } - - - public SyncFail serviceHours(SyncFailServiceHours serviceHours) { - this.serviceHours = serviceHours; - return this; - } - - /** - * Get serviceHours - * @return serviceHours - **/ - @javax.annotation.Nullable - public SyncFailServiceHours getServiceHours() { - return serviceHours; - } - - public void setServiceHours(SyncFailServiceHours serviceHours) { - this.serviceHours = serviceHours; - } - - - public SyncFail categories(List categories) { - this.categories = categories; - return this; - } - - public SyncFail addCategoriesItem(SyncFailCategoriesInner categoriesItem) { - if (this.categories == null) { - this.categories = new ArrayList<>(); - } - this.categories.add(categoriesItem); - return this; - } - - /** - * Get categories - * @return categories - **/ - @javax.annotation.Nullable - public List getCategories() { - return categories; - } - - public void setCategories(List categories) { - this.categories = categories; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SyncFail syncFail = (SyncFail) o; - return Objects.equals(this.id, syncFail.id) && - Objects.equals(this.errors, syncFail.errors) && - Objects.equals(this.serviceHours, syncFail.serviceHours) && - Objects.equals(this.categories, syncFail.categories); - } - - @Override - public int hashCode() { - return Objects.hash(id, errors, serviceHours, categories); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SyncFail {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); - sb.append(" serviceHours: ").append(toIndentedString(serviceHours)).append("\n"); - sb.append(" categories: ").append(toIndentedString(categories)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("id"); - openapiFields.add("errors"); - openapiFields.add("serviceHours"); - openapiFields.add("categories"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SyncFail - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!SyncFail.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SyncFail is not found in the empty JSON string", SyncFail.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SyncFail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SyncFail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // ensure the optional json data is an array if present - if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); - } - // validate the optional field `serviceHours` - if (jsonObj.get("serviceHours") != null && !jsonObj.get("serviceHours").isJsonNull()) { - SyncFailServiceHours.validateJsonElement(jsonObj.get("serviceHours")); - } - if (jsonObj.get("categories") != null && !jsonObj.get("categories").isJsonNull()) { - JsonArray jsonArraycategories = jsonObj.getAsJsonArray("categories"); - if (jsonArraycategories != null) { - // ensure the json data is an array - if (!jsonObj.get("categories").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `categories` to be an array in the JSON string but got `%s`", jsonObj.get("categories").toString())); - } - - // validate the optional field `categories` (array) - for (int i = 0; i < jsonArraycategories.size(); i++) { - SyncFailCategoriesInner.validateJsonElement(jsonArraycategories.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SyncFail.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SyncFail' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SyncFail.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SyncFail value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public SyncFail read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of SyncFail given an JSON string - * - * @param jsonString JSON string - * @return An instance of SyncFail - * @throws IOException if the JSON string is invalid with respect to SyncFail - */ - public static SyncFail fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SyncFail.class); - } - - /** - * Convert an instance of SyncFail to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/SyncFailCategoriesInner.java b/src/main/java/com/grabfood/client/model/SyncFailCategoriesInner.java deleted file mode 100644 index 593ed83..0000000 --- a/src/main/java/com/grabfood/client/model/SyncFailCategoriesInner.java +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.SyncFailCategoryItemsInner; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * SyncFailCategoriesInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SyncFailCategoriesInner { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private String id; - - public static final String SERIALIZED_NAME_ERRORS = "errors"; - @SerializedName(SERIALIZED_NAME_ERRORS) - private List errors = new ArrayList<>(); - - public static final String SERIALIZED_NAME_ITEMS = "items"; - @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); - - public SyncFailCategoriesInner() { - } - - public SyncFailCategoriesInner id(String id) { - this.id = id; - return this; - } - - /** - * The category's ID that is on the partner system. This ID should be unique with a min length of 1 and max of 64. - * @return id - **/ - @javax.annotation.Nullable - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - - public SyncFailCategoriesInner errors(List errors) { - this.errors = errors; - return this; - } - - public SyncFailCategoriesInner addErrorsItem(String errorsItem) { - if (this.errors == null) { - this.errors = new ArrayList<>(); - } - this.errors.add(errorsItem); - return this; - } - - /** - * An array of strings of error message. - * @return errors - **/ - @javax.annotation.Nullable - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } - - - public SyncFailCategoriesInner items(List items) { - this.items = items; - return this; - } - - public SyncFailCategoriesInner addItemsItem(SyncFailCategoryItemsInner itemsItem) { - if (this.items == null) { - this.items = new ArrayList<>(); - } - this.items.add(itemsItem); - return this; - } - - /** - * An array of item JSON objects. Max 300 allowed per category. Refer to [Items](#items) for more information. - * @return items - **/ - @javax.annotation.Nullable - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SyncFailCategoriesInner syncFailCategoriesInner = (SyncFailCategoriesInner) o; - return Objects.equals(this.id, syncFailCategoriesInner.id) && - Objects.equals(this.errors, syncFailCategoriesInner.errors) && - Objects.equals(this.items, syncFailCategoriesInner.items); - } - - @Override - public int hashCode() { - return Objects.hash(id, errors, items); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SyncFailCategoriesInner {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); - sb.append(" items: ").append(toIndentedString(items)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("id"); - openapiFields.add("errors"); - openapiFields.add("items"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SyncFailCategoriesInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!SyncFailCategoriesInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SyncFailCategoriesInner is not found in the empty JSON string", SyncFailCategoriesInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SyncFailCategoriesInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SyncFailCategoriesInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // ensure the optional json data is an array if present - if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); - } - if (jsonObj.get("items") != null && !jsonObj.get("items").isJsonNull()) { - JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); - if (jsonArrayitems != null) { - // ensure the json data is an array - if (!jsonObj.get("items").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); - } - - // validate the optional field `items` (array) - for (int i = 0; i < jsonArrayitems.size(); i++) { - SyncFailCategoryItemsInner.validateJsonElement(jsonArrayitems.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SyncFailCategoriesInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SyncFailCategoriesInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SyncFailCategoriesInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SyncFailCategoriesInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public SyncFailCategoriesInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of SyncFailCategoriesInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of SyncFailCategoriesInner - * @throws IOException if the JSON string is invalid with respect to SyncFailCategoriesInner - */ - public static SyncFailCategoriesInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SyncFailCategoriesInner.class); - } - - /** - * Convert an instance of SyncFailCategoriesInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInner.java b/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInner.java deleted file mode 100644 index 24ced80..0000000 --- a/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInner.java +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.SyncFailCategoryItemsInnerModifierGroupsInner; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * SyncFailCategoryItemsInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SyncFailCategoryItemsInner { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private String id; - - public static final String SERIALIZED_NAME_ERRORS = "errors"; - @SerializedName(SERIALIZED_NAME_ERRORS) - private List errors = new ArrayList<>(); - - public static final String SERIALIZED_NAME_MODIFIER_GROUPS = "modifierGroups"; - @SerializedName(SERIALIZED_NAME_MODIFIER_GROUPS) - private List modifierGroups = new ArrayList<>(); - - public SyncFailCategoryItemsInner() { - } - - public SyncFailCategoryItemsInner id(String id) { - this.id = id; - return this; - } - - /** - * The item's ID in the partner system. - * @return id - **/ - @javax.annotation.Nullable - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - - public SyncFailCategoryItemsInner errors(List errors) { - this.errors = errors; - return this; - } - - public SyncFailCategoryItemsInner addErrorsItem(String errorsItem) { - if (this.errors == null) { - this.errors = new ArrayList<>(); - } - this.errors.add(errorsItem); - return this; - } - - /** - * An array of strings of error message. - * @return errors - **/ - @javax.annotation.Nullable - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } - - - public SyncFailCategoryItemsInner modifierGroups(List modifierGroups) { - this.modifierGroups = modifierGroups; - return this; - } - - public SyncFailCategoryItemsInner addModifierGroupsItem(SyncFailCategoryItemsInnerModifierGroupsInner modifierGroupsItem) { - if (this.modifierGroups == null) { - this.modifierGroups = new ArrayList<>(); - } - this.modifierGroups.add(modifierGroupsItem); - return this; - } - - /** - * Get modifierGroups - * @return modifierGroups - **/ - @javax.annotation.Nullable - public List getModifierGroups() { - return modifierGroups; - } - - public void setModifierGroups(List modifierGroups) { - this.modifierGroups = modifierGroups; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SyncFailCategoryItemsInner syncFailCategoryItemsInner = (SyncFailCategoryItemsInner) o; - return Objects.equals(this.id, syncFailCategoryItemsInner.id) && - Objects.equals(this.errors, syncFailCategoryItemsInner.errors) && - Objects.equals(this.modifierGroups, syncFailCategoryItemsInner.modifierGroups); - } - - @Override - public int hashCode() { - return Objects.hash(id, errors, modifierGroups); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SyncFailCategoryItemsInner {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); - sb.append(" modifierGroups: ").append(toIndentedString(modifierGroups)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("id"); - openapiFields.add("errors"); - openapiFields.add("modifierGroups"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SyncFailCategoryItemsInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!SyncFailCategoryItemsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SyncFailCategoryItemsInner is not found in the empty JSON string", SyncFailCategoryItemsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SyncFailCategoryItemsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SyncFailCategoryItemsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // ensure the optional json data is an array if present - if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); - } - if (jsonObj.get("modifierGroups") != null && !jsonObj.get("modifierGroups").isJsonNull()) { - JsonArray jsonArraymodifierGroups = jsonObj.getAsJsonArray("modifierGroups"); - if (jsonArraymodifierGroups != null) { - // ensure the json data is an array - if (!jsonObj.get("modifierGroups").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `modifierGroups` to be an array in the JSON string but got `%s`", jsonObj.get("modifierGroups").toString())); - } - - // validate the optional field `modifierGroups` (array) - for (int i = 0; i < jsonArraymodifierGroups.size(); i++) { - SyncFailCategoryItemsInnerModifierGroupsInner.validateJsonElement(jsonArraymodifierGroups.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SyncFailCategoryItemsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SyncFailCategoryItemsInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SyncFailCategoryItemsInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SyncFailCategoryItemsInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public SyncFailCategoryItemsInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of SyncFailCategoryItemsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of SyncFailCategoryItemsInner - * @throws IOException if the JSON string is invalid with respect to SyncFailCategoryItemsInner - */ - public static SyncFailCategoryItemsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SyncFailCategoryItemsInner.class); - } - - /** - * Convert an instance of SyncFailCategoryItemsInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInnerModifierGroupsInner.java b/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInnerModifierGroupsInner.java deleted file mode 100644 index 03a8eb6..0000000 --- a/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInnerModifierGroupsInner.java +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * SyncFailCategoryItemsInnerModifierGroupsInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SyncFailCategoryItemsInnerModifierGroupsInner { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private String id; - - public static final String SERIALIZED_NAME_ERRORS = "errors"; - @SerializedName(SERIALIZED_NAME_ERRORS) - private List errors = new ArrayList<>(); - - public static final String SERIALIZED_NAME_MODIFIERS = "modifiers"; - @SerializedName(SERIALIZED_NAME_MODIFIERS) - private List modifiers = new ArrayList<>(); - - public SyncFailCategoryItemsInnerModifierGroupsInner() { - } - - public SyncFailCategoryItemsInnerModifierGroupsInner id(String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @javax.annotation.Nullable - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - - public SyncFailCategoryItemsInnerModifierGroupsInner errors(List errors) { - this.errors = errors; - return this; - } - - public SyncFailCategoryItemsInnerModifierGroupsInner addErrorsItem(String errorsItem) { - if (this.errors == null) { - this.errors = new ArrayList<>(); - } - this.errors.add(errorsItem); - return this; - } - - /** - * An array of strings of error message. - * @return errors - **/ - @javax.annotation.Nullable - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } - - - public SyncFailCategoryItemsInnerModifierGroupsInner modifiers(List modifiers) { - this.modifiers = modifiers; - return this; - } - - public SyncFailCategoryItemsInnerModifierGroupsInner addModifiersItem(SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner modifiersItem) { - if (this.modifiers == null) { - this.modifiers = new ArrayList<>(); - } - this.modifiers.add(modifiersItem); - return this; - } - - /** - * Get modifiers - * @return modifiers - **/ - @javax.annotation.Nullable - public List getModifiers() { - return modifiers; - } - - public void setModifiers(List modifiers) { - this.modifiers = modifiers; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SyncFailCategoryItemsInnerModifierGroupsInner syncFailCategoryItemsInnerModifierGroupsInner = (SyncFailCategoryItemsInnerModifierGroupsInner) o; - return Objects.equals(this.id, syncFailCategoryItemsInnerModifierGroupsInner.id) && - Objects.equals(this.errors, syncFailCategoryItemsInnerModifierGroupsInner.errors) && - Objects.equals(this.modifiers, syncFailCategoryItemsInnerModifierGroupsInner.modifiers); - } - - @Override - public int hashCode() { - return Objects.hash(id, errors, modifiers); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SyncFailCategoryItemsInnerModifierGroupsInner {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); - sb.append(" modifiers: ").append(toIndentedString(modifiers)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("id"); - openapiFields.add("errors"); - openapiFields.add("modifiers"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SyncFailCategoryItemsInnerModifierGroupsInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!SyncFailCategoryItemsInnerModifierGroupsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SyncFailCategoryItemsInnerModifierGroupsInner is not found in the empty JSON string", SyncFailCategoryItemsInnerModifierGroupsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SyncFailCategoryItemsInnerModifierGroupsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SyncFailCategoryItemsInnerModifierGroupsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // ensure the optional json data is an array if present - if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); - } - if (jsonObj.get("modifiers") != null && !jsonObj.get("modifiers").isJsonNull()) { - JsonArray jsonArraymodifiers = jsonObj.getAsJsonArray("modifiers"); - if (jsonArraymodifiers != null) { - // ensure the json data is an array - if (!jsonObj.get("modifiers").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `modifiers` to be an array in the JSON string but got `%s`", jsonObj.get("modifiers").toString())); - } - - // validate the optional field `modifiers` (array) - for (int i = 0; i < jsonArraymodifiers.size(); i++) { - SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.validateJsonElement(jsonArraymodifiers.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SyncFailCategoryItemsInnerModifierGroupsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SyncFailCategoryItemsInnerModifierGroupsInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SyncFailCategoryItemsInnerModifierGroupsInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SyncFailCategoryItemsInnerModifierGroupsInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public SyncFailCategoryItemsInnerModifierGroupsInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of SyncFailCategoryItemsInnerModifierGroupsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of SyncFailCategoryItemsInnerModifierGroupsInner - * @throws IOException if the JSON string is invalid with respect to SyncFailCategoryItemsInnerModifierGroupsInner - */ - public static SyncFailCategoryItemsInnerModifierGroupsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SyncFailCategoryItemsInnerModifierGroupsInner.class); - } - - /** - * Convert an instance of SyncFailCategoryItemsInnerModifierGroupsInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.java b/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.java deleted file mode 100644 index 621f525..0000000 --- a/src/main/java/com/grabfood/client/model/SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.java +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private String id; - - public static final String SERIALIZED_NAME_ERRORS = "errors"; - @SerializedName(SERIALIZED_NAME_ERRORS) - private List errors = new ArrayList<>(); - - public SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner() { - } - - public SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner id(String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @javax.annotation.Nullable - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - - public SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner errors(List errors) { - this.errors = errors; - return this; - } - - public SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner addErrorsItem(String errorsItem) { - if (this.errors == null) { - this.errors = new ArrayList<>(); - } - this.errors.add(errorsItem); - return this; - } - - /** - * An array of strings of error message. - * @return errors - **/ - @javax.annotation.Nullable - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner syncFailCategoryItemsInnerModifierGroupsInnerModifiersInner = (SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner) o; - return Objects.equals(this.id, syncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.id) && - Objects.equals(this.errors, syncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.errors); - } - - @Override - public int hashCode() { - return Objects.hash(id, errors); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("id"); - openapiFields.add("errors"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner is not found in the empty JSON string", SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); - } - // ensure the optional json data is an array if present - if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner - * @throws IOException if the JSON string is invalid with respect to SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner - */ - public static SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner.class); - } - - /** - * Convert an instance of SyncFailCategoryItemsInnerModifierGroupsInnerModifiersInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/SyncFailServiceHours.java b/src/main/java/com/grabfood/client/model/SyncFailServiceHours.java deleted file mode 100644 index 6958ce0..0000000 --- a/src/main/java/com/grabfood/client/model/SyncFailServiceHours.java +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * SyncFailServiceHours - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class SyncFailServiceHours { - public static final String SERIALIZED_NAME_ERRORS = "errors"; - @SerializedName(SERIALIZED_NAME_ERRORS) - private List errors = new ArrayList<>(); - - public SyncFailServiceHours() { - } - - public SyncFailServiceHours errors(List errors) { - this.errors = errors; - return this; - } - - public SyncFailServiceHours addErrorsItem(String errorsItem) { - if (this.errors == null) { - this.errors = new ArrayList<>(); - } - this.errors.add(errorsItem); - return this; - } - - /** - * An array of strings of error message. - * @return errors - **/ - @javax.annotation.Nullable - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SyncFailServiceHours syncFailServiceHours = (SyncFailServiceHours) o; - return Objects.equals(this.errors, syncFailServiceHours.errors); - } - - @Override - public int hashCode() { - return Objects.hash(errors); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SyncFailServiceHours {\n"); - sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("errors"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SyncFailServiceHours - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!SyncFailServiceHours.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in SyncFailServiceHours is not found in the empty JSON string", SyncFailServiceHours.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SyncFailServiceHours.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SyncFailServiceHours` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull() && !jsonObj.get("errors").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SyncFailServiceHours.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SyncFailServiceHours' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(SyncFailServiceHours.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SyncFailServiceHours value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public SyncFailServiceHours read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of SyncFailServiceHours given an JSON string - * - * @param jsonString JSON string - * @return An instance of SyncFailServiceHours - * @throws IOException if the JSON string is invalid with respect to SyncFailServiceHours - */ - public static SyncFailServiceHours fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SyncFailServiceHours.class); - } - - /** - * Convert an instance of SyncFailServiceHours to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/UnbindMembershipNativeRequest.java b/src/main/java/com/grabfood/client/model/UnbindMembershipNativeRequest.java index 7113504..784dc6c 100644 --- a/src/main/java/com/grabfood/client/model/UnbindMembershipNativeRequest.java +++ b/src/main/java/com/grabfood/client/model/UnbindMembershipNativeRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request submits membership unbind request to partner. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UnbindMembershipNativeRequest { public static final String SERIALIZED_NAME_MEMBER_I_D = "memberID"; @SerializedName(SERIALIZED_NAME_MEMBER_I_D) @@ -66,10 +65,10 @@ public UnbindMembershipNativeRequest memberID(String memberID) { return this; } - /** + /** * The unique member ID on the partner's database. * @return memberID - **/ + */ @javax.annotation.Nonnull public String getMemberID() { return memberID; @@ -79,6 +78,50 @@ public void setMemberID(String memberID) { this.memberID = memberID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UnbindMembershipNativeRequest instance itself + */ + public UnbindMembershipNativeRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } UnbindMembershipNativeRequest unbindMembershipNativeRequest = (UnbindMembershipNativeRequest) o; - return Objects.equals(this.memberID, unbindMembershipNativeRequest.memberID); + return Objects.equals(this.memberID, unbindMembershipNativeRequest.memberID)&& + Objects.equals(this.additionalProperties, unbindMembershipNativeRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(memberID); + return Objects.hash(memberID, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UnbindMembershipNativeRequest {\n"); sb.append(" memberID: ").append(toIndentedString(memberID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -132,12 +177,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("memberID"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UnbindMembershipNativeRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UnbindMembershipNativeRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UnbindMembershipNativeRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -145,14 +190,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UnbindMembershipNativeRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UnbindMembershipNativeRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UnbindMembershipNativeRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -180,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UnbindMembershipNativeRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -187,29 +246,50 @@ public void write(JsonWriter out, UnbindMembershipNativeRequest value) throws IO public UnbindMembershipNativeRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UnbindMembershipNativeRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UnbindMembershipNativeRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of UnbindMembershipNativeRequest - * @throws IOException if the JSON string is invalid with respect to UnbindMembershipNativeRequest - */ + /** + * Create an instance of UnbindMembershipNativeRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UnbindMembershipNativeRequest + * @throws IOException if the JSON string is invalid with respect to UnbindMembershipNativeRequest + */ public static UnbindMembershipNativeRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UnbindMembershipNativeRequest.class); } - /** - * Convert an instance of UnbindMembershipNativeRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UnbindMembershipNativeRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UnlinkMembershipWebviewRequest.java b/src/main/java/com/grabfood/client/model/UnlinkMembershipWebviewRequest.java index 68de316..a452f2f 100644 --- a/src/main/java/com/grabfood/client/model/UnlinkMembershipWebviewRequest.java +++ b/src/main/java/com/grabfood/client/model/UnlinkMembershipWebviewRequest.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * This request submits membership unbind request to partner. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UnlinkMembershipWebviewRequest { public static final String SERIALIZED_NAME_MEMBER_I_D = "memberID"; @SerializedName(SERIALIZED_NAME_MEMBER_I_D) @@ -66,10 +65,10 @@ public UnlinkMembershipWebviewRequest memberID(String memberID) { return this; } - /** + /** * The unique member ID on the partner's database. * @return memberID - **/ + */ @javax.annotation.Nonnull public String getMemberID() { return memberID; @@ -79,6 +78,50 @@ public void setMemberID(String memberID) { this.memberID = memberID; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UnlinkMembershipWebviewRequest instance itself + */ + public UnlinkMembershipWebviewRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } UnlinkMembershipWebviewRequest unlinkMembershipWebviewRequest = (UnlinkMembershipWebviewRequest) o; - return Objects.equals(this.memberID, unlinkMembershipWebviewRequest.memberID); + return Objects.equals(this.memberID, unlinkMembershipWebviewRequest.memberID)&& + Objects.equals(this.additionalProperties, unlinkMembershipWebviewRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(memberID); + return Objects.hash(memberID, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UnlinkMembershipWebviewRequest {\n"); sb.append(" memberID: ").append(toIndentedString(memberID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -132,12 +177,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("memberID"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UnlinkMembershipWebviewRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UnlinkMembershipWebviewRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UnlinkMembershipWebviewRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -145,14 +190,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UnlinkMembershipWebviewRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UnlinkMembershipWebviewRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UnlinkMembershipWebviewRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -180,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UnlinkMembershipWebviewRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -187,29 +246,50 @@ public void write(JsonWriter out, UnlinkMembershipWebviewRequest value) throws I public UnlinkMembershipWebviewRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UnlinkMembershipWebviewRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UnlinkMembershipWebviewRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of UnlinkMembershipWebviewRequest - * @throws IOException if the JSON string is invalid with respect to UnlinkMembershipWebviewRequest - */ + /** + * Create an instance of UnlinkMembershipWebviewRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UnlinkMembershipWebviewRequest + * @throws IOException if the JSON string is invalid with respect to UnlinkMembershipWebviewRequest + */ public static UnlinkMembershipWebviewRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UnlinkMembershipWebviewRequest.class); } - /** - * Convert an instance of UnlinkMembershipWebviewRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UnlinkMembershipWebviewRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateAdvancedPricing.java b/src/main/java/com/grabfood/client/model/UpdateAdvancedPricing.java new file mode 100644 index 0000000..f4cfcc6 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/UpdateAdvancedPricing.java @@ -0,0 +1,383 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * UpdateAdvancedPricing + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class UpdateAdvancedPricing { + /** + * Available service type. + */ + @JsonAdapter(KeyEnum.Adapter.class) + public enum KeyEnum { + DELIVERY_ON_DEMAND_GRAB_APP("Delivery_OnDemand_GrabApp"), + + DELIVERY_SCHEDULED_GRAB_APP("Delivery_Scheduled_GrabApp"), + + SELF_PICK_UP_ON_DEMAND_GRAB_APP("SelfPickUp_OnDemand_GrabApp"), + + DINE_IN_ON_DEMAND_GRAB_APP("DineIn_OnDemand_GrabApp"), + + DELIVERY_ON_DEMAND_STORE_FRONT("Delivery_OnDemand_StoreFront"), + + DELIVERY_SCHEDULED_STORE_FRONT("Delivery_Scheduled_StoreFront"), + + SELF_PICK_UP_ON_DEMAND_STORE_FRONT("SelfPickUp_OnDemand_StoreFront"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KeyEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KeyEnum fromValue(String value) { + for (KeyEnum b : KeyEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KeyEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KeyEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KeyEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KeyEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KEY = "key"; + @SerializedName(SERIALIZED_NAME_KEY) + private KeyEnum key; + + public static final String SERIALIZED_NAME_PRICE = "price"; + @SerializedName(SERIALIZED_NAME_PRICE) + private Integer price; + + public UpdateAdvancedPricing() { + } + + public UpdateAdvancedPricing key(KeyEnum key) { + this.key = key; + return this; + } + + /** + * Available service type. + * @return key + */ + @javax.annotation.Nullable + public KeyEnum getKey() { + return key; + } + + public void setKey(KeyEnum key) { + this.key = key; + } + + + public UpdateAdvancedPricing price(Integer price) { + this.price = price; + return this; + } + + /** + * Price in minor unit. + * @return price + */ + @javax.annotation.Nullable + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateAdvancedPricing instance itself + */ + public UpdateAdvancedPricing putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateAdvancedPricing updateAdvancedPricing = (UpdateAdvancedPricing) o; + return Objects.equals(this.key, updateAdvancedPricing.key) && + Objects.equals(this.price, updateAdvancedPricing.price)&& + Objects.equals(this.additionalProperties, updateAdvancedPricing.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(key, price, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateAdvancedPricing {\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("key"); + openapiFields.add("price"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateAdvancedPricing + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateAdvancedPricing.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateAdvancedPricing is not found in the empty JSON string", UpdateAdvancedPricing.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) && !jsonObj.get("key").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); + } + // validate the optional field `key` + if (jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) { + KeyEnum.validateJsonElement(jsonObj.get("key")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateAdvancedPricing.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateAdvancedPricing' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateAdvancedPricing.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateAdvancedPricing value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public UpdateAdvancedPricing read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateAdvancedPricing instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateAdvancedPricing given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateAdvancedPricing + * @throws IOException if the JSON string is invalid with respect to UpdateAdvancedPricing + */ + public static UpdateAdvancedPricing fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateAdvancedPricing.class); + } + + /** + * Convert an instance of UpdateAdvancedPricing to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/UpdateCampaignRequest.java b/src/main/java/com/grabfood/client/model/UpdateCampaignRequest.java index be8315c..bd1f780 100644 --- a/src/main/java/com/grabfood/client/model/UpdateCampaignRequest.java +++ b/src/main/java/com/grabfood/client/model/UpdateCampaignRequest.java @@ -22,9 +22,9 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.Conditions; -import com.grabfood.client.model.Discount; -import com.grabfood.client.model.Quotas; +import com.grabfood.client.model.CampaignConditions; +import com.grabfood.client.model.CampaignDiscount; +import com.grabfood.client.model.CampaignQuotas; import java.io.IOException; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * This request updates a campaign for your GrabFood store. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateCampaignRequest { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -67,15 +66,15 @@ public class UpdateCampaignRequest { public static final String SERIALIZED_NAME_QUOTAS = "quotas"; @SerializedName(SERIALIZED_NAME_QUOTAS) - private Quotas quotas; + private CampaignQuotas quotas; public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; @SerializedName(SERIALIZED_NAME_CONDITIONS) - private Conditions conditions; + private CampaignConditions conditions; public static final String SERIALIZED_NAME_DISCOUNT = "discount"; @SerializedName(SERIALIZED_NAME_DISCOUNT) - private Discount discount; + private CampaignDiscount discount; public static final String SERIALIZED_NAME_CUSTOM_TAG = "customTag"; @SerializedName(SERIALIZED_NAME_CUSTOM_TAG) @@ -89,10 +88,10 @@ public UpdateCampaignRequest merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nullable public String getMerchantID() { return merchantID; @@ -108,10 +107,10 @@ public UpdateCampaignRequest name(String name) { return this; } - /** + /** * The campaign's name. * @return name - **/ + */ @javax.annotation.Nullable public String getName() { return name; @@ -122,59 +121,59 @@ public void setName(String name) { } - public UpdateCampaignRequest quotas(Quotas quotas) { + public UpdateCampaignRequest quotas(CampaignQuotas quotas) { this.quotas = quotas; return this; } - /** + /** * Get quotas * @return quotas - **/ + */ @javax.annotation.Nullable - public Quotas getQuotas() { + public CampaignQuotas getQuotas() { return quotas; } - public void setQuotas(Quotas quotas) { + public void setQuotas(CampaignQuotas quotas) { this.quotas = quotas; } - public UpdateCampaignRequest conditions(Conditions conditions) { + public UpdateCampaignRequest conditions(CampaignConditions conditions) { this.conditions = conditions; return this; } - /** + /** * Get conditions * @return conditions - **/ + */ @javax.annotation.Nullable - public Conditions getConditions() { + public CampaignConditions getConditions() { return conditions; } - public void setConditions(Conditions conditions) { + public void setConditions(CampaignConditions conditions) { this.conditions = conditions; } - public UpdateCampaignRequest discount(Discount discount) { + public UpdateCampaignRequest discount(CampaignDiscount discount) { this.discount = discount; return this; } - /** + /** * Get discount * @return discount - **/ + */ @javax.annotation.Nullable - public Discount getDiscount() { + public CampaignDiscount getDiscount() { return discount; } - public void setDiscount(Discount discount) { + public void setDiscount(CampaignDiscount discount) { this.discount = discount; } @@ -184,10 +183,10 @@ public UpdateCampaignRequest customTag(String customTag) { return this; } - /** + /** * Specify the tag for custom bundle offer campaign. Only whitelisted partner is supported as of now. * @return customTag - **/ + */ @javax.annotation.Nullable public String getCustomTag() { return customTag; @@ -197,6 +196,50 @@ public void setCustomTag(String customTag) { this.customTag = customTag; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateCampaignRequest instance itself + */ + public UpdateCampaignRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -213,12 +256,13 @@ public boolean equals(Object o) { Objects.equals(this.quotas, updateCampaignRequest.quotas) && Objects.equals(this.conditions, updateCampaignRequest.conditions) && Objects.equals(this.discount, updateCampaignRequest.discount) && - Objects.equals(this.customTag, updateCampaignRequest.customTag); + Objects.equals(this.customTag, updateCampaignRequest.customTag)&& + Objects.equals(this.additionalProperties, updateCampaignRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(merchantID, name, quotas, conditions, discount, customTag); + return Objects.hash(merchantID, name, quotas, conditions, discount, customTag, additionalProperties); } @Override @@ -231,6 +275,7 @@ public String toString() { sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); sb.append(" discount: ").append(toIndentedString(discount)).append("\n"); sb.append(" customTag: ").append(toIndentedString(customTag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -264,26 +309,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateCampaignRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateCampaignRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateCampaignRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateCampaignRequest is not found in the empty JSON string", UpdateCampaignRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateCampaignRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateCampaignRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("merchantID") != null && !jsonObj.get("merchantID").isJsonNull()) && !jsonObj.get("merchantID").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `merchantID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("merchantID").toString())); @@ -293,15 +330,15 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } // validate the optional field `quotas` if (jsonObj.get("quotas") != null && !jsonObj.get("quotas").isJsonNull()) { - Quotas.validateJsonElement(jsonObj.get("quotas")); + CampaignQuotas.validateJsonElement(jsonObj.get("quotas")); } // validate the optional field `conditions` if (jsonObj.get("conditions") != null && !jsonObj.get("conditions").isJsonNull()) { - Conditions.validateJsonElement(jsonObj.get("conditions")); + CampaignConditions.validateJsonElement(jsonObj.get("conditions")); } // validate the optional field `discount` if (jsonObj.get("discount") != null && !jsonObj.get("discount").isJsonNull()) { - Discount.validateJsonElement(jsonObj.get("discount")); + CampaignDiscount.validateJsonElement(jsonObj.get("discount")); } if ((jsonObj.get("customTag") != null && !jsonObj.get("customTag").isJsonNull()) && !jsonObj.get("customTag").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `customTag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("customTag").toString())); @@ -323,6 +360,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateCampaignRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -330,29 +389,50 @@ public void write(JsonWriter out, UpdateCampaignRequest value) throws IOExceptio public UpdateCampaignRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateCampaignRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateCampaignRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateCampaignRequest - * @throws IOException if the JSON string is invalid with respect to UpdateCampaignRequest - */ + /** + * Create an instance of UpdateCampaignRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateCampaignRequest + * @throws IOException if the JSON string is invalid with respect to UpdateCampaignRequest + */ public static UpdateCampaignRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateCampaignRequest.class); } - /** - * Convert an instance of UpdateCampaignRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateCampaignRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateDeliveryHourRequest.java b/src/main/java/com/grabfood/client/model/UpdateDeliveryHourRequest.java index 0c5d8e7..2cf90da 100644 --- a/src/main/java/com/grabfood/client/model/UpdateDeliveryHourRequest.java +++ b/src/main/java/com/grabfood/client/model/UpdateDeliveryHourRequest.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * Object contains store delivery hours. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateDeliveryHourRequest { public static final String SERIALIZED_NAME_OPENING_HOUR = "openingHour"; @SerializedName(SERIALIZED_NAME_OPENING_HOUR) @@ -71,10 +70,10 @@ public UpdateDeliveryHourRequest openingHour(StoreHour openingHour) { return this; } - /** + /** * Get openingHour * @return openingHour - **/ + */ @javax.annotation.Nonnull public StoreHour getOpeningHour() { return openingHour; @@ -90,10 +89,10 @@ public UpdateDeliveryHourRequest force(Boolean force) { return this; } - /** + /** * To enable force update store delivery hours. Error will be returned if set to false while there is ongoing order. * @return force - **/ + */ @javax.annotation.Nonnull public Boolean getForce() { return force; @@ -103,6 +102,50 @@ public void setForce(Boolean force) { this.force = force; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateDeliveryHourRequest instance itself + */ + public UpdateDeliveryHourRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -115,12 +158,13 @@ public boolean equals(Object o) { } UpdateDeliveryHourRequest updateDeliveryHourRequest = (UpdateDeliveryHourRequest) o; return Objects.equals(this.openingHour, updateDeliveryHourRequest.openingHour) && - Objects.equals(this.force, updateDeliveryHourRequest.force); + Objects.equals(this.force, updateDeliveryHourRequest.force)&& + Objects.equals(this.additionalProperties, updateDeliveryHourRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(openingHour, force); + return Objects.hash(openingHour, force, additionalProperties); } @Override @@ -129,6 +173,7 @@ public String toString() { sb.append("class UpdateDeliveryHourRequest {\n"); sb.append(" openingHour: ").append(toIndentedString(openingHour)).append("\n"); sb.append(" force: ").append(toIndentedString(force)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -160,12 +205,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("force"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateDeliveryHourRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateDeliveryHourRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateDeliveryHourRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -173,14 +218,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateDeliveryHourRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateDeliveryHourRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateDeliveryHourRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -207,6 +244,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateDeliveryHourRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -214,29 +273,50 @@ public void write(JsonWriter out, UpdateDeliveryHourRequest value) throws IOExce public UpdateDeliveryHourRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateDeliveryHourRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateDeliveryHourRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateDeliveryHourRequest - * @throws IOException if the JSON string is invalid with respect to UpdateDeliveryHourRequest - */ + /** + * Create an instance of UpdateDeliveryHourRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateDeliveryHourRequest + * @throws IOException if the JSON string is invalid with respect to UpdateDeliveryHourRequest + */ public static UpdateDeliveryHourRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateDeliveryHourRequest.class); } - /** - * Convert an instance of UpdateDeliveryHourRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateDeliveryHourRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateDeliveryHourResponse.java b/src/main/java/com/grabfood/client/model/UpdateDeliveryHourResponse.java index f2f5dba..c0a243f 100644 --- a/src/main/java/com/grabfood/client/model/UpdateDeliveryHourResponse.java +++ b/src/main/java/com/grabfood/client/model/UpdateDeliveryHourResponse.java @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,20 +54,22 @@ /** * Object contain update store delivery hour response */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateDeliveryHourResponse { /** * Gets or Sets errorReasons */ @JsonAdapter(ErrorReasonsEnum.Adapter.class) public enum ErrorReasonsEnum { - CLOSINGHOURSINEFFECTIVE("ClosingHoursIneffective"), + CLOSING_HOURS_INEFFECTIVE("ClosingHoursIneffective"), - FORCEUPDATED("ForceUpdated"), + FORCE_UPDATED("ForceUpdated"), - PENDINGSCHEDULEDORDERS("PendingScheduledOrders"), + PENDING_SCHEDULED_ORDERS("PendingScheduledOrders"), - PENDINGORDERS("PendingOrders"); + PENDING_ORDERS("PendingOrders"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -91,7 +92,7 @@ public static ErrorReasonsEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -145,10 +146,10 @@ public UpdateDeliveryHourResponse addErrorReasonsItem(ErrorReasonsEnum errorReas return this; } - /** + /** * Error message when updating store delivery hour. `null` indicates no error. * @return errorReasons - **/ + */ @javax.annotation.Nullable public List getErrorReasons() { return errorReasons; @@ -164,10 +165,10 @@ public UpdateDeliveryHourResponse orderCount(Integer orderCount) { return this; } - /** + /** * Total active order for the day. * @return orderCount - **/ + */ @javax.annotation.Nonnull public Integer getOrderCount() { return orderCount; @@ -183,10 +184,10 @@ public UpdateDeliveryHourResponse scheduledOrderCount(Integer scheduledOrderCoun return this; } - /** + /** * Total scheduled order during store close period. * @return scheduledOrderCount - **/ + */ @javax.annotation.Nonnull public Integer getScheduledOrderCount() { return scheduledOrderCount; @@ -202,10 +203,10 @@ public UpdateDeliveryHourResponse closeImmediately(Boolean closeImmediately) { return this; } - /** + /** * Indicate the store status after updating delivery hours. * @return closeImmediately - **/ + */ @javax.annotation.Nonnull public Boolean getCloseImmediately() { return closeImmediately; @@ -215,6 +216,50 @@ public void setCloseImmediately(Boolean closeImmediately) { this.closeImmediately = closeImmediately; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateDeliveryHourResponse instance itself + */ + public UpdateDeliveryHourResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -229,7 +274,8 @@ public boolean equals(Object o) { return Objects.equals(this.errorReasons, updateDeliveryHourResponse.errorReasons) && Objects.equals(this.orderCount, updateDeliveryHourResponse.orderCount) && Objects.equals(this.scheduledOrderCount, updateDeliveryHourResponse.scheduledOrderCount) && - Objects.equals(this.closeImmediately, updateDeliveryHourResponse.closeImmediately); + Objects.equals(this.closeImmediately, updateDeliveryHourResponse.closeImmediately)&& + Objects.equals(this.additionalProperties, updateDeliveryHourResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -238,7 +284,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(errorReasons, orderCount, scheduledOrderCount, closeImmediately); + return Objects.hash(errorReasons, orderCount, scheduledOrderCount, closeImmediately, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -256,6 +302,7 @@ public String toString() { sb.append(" orderCount: ").append(toIndentedString(orderCount)).append("\n"); sb.append(" scheduledOrderCount: ").append(toIndentedString(scheduledOrderCount)).append("\n"); sb.append(" closeImmediately: ").append(toIndentedString(closeImmediately)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -290,12 +337,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("closeImmediately"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateDeliveryHourResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateDeliveryHourResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateDeliveryHourResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -303,14 +350,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateDeliveryHourResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateDeliveryHourResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateDeliveryHourResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -339,6 +378,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateDeliveryHourResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,29 +407,50 @@ public void write(JsonWriter out, UpdateDeliveryHourResponse value) throws IOExc public UpdateDeliveryHourResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateDeliveryHourResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateDeliveryHourResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateDeliveryHourResponse - * @throws IOException if the JSON string is invalid with respect to UpdateDeliveryHourResponse - */ + /** + * Create an instance of UpdateDeliveryHourResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateDeliveryHourResponse + * @throws IOException if the JSON string is invalid with respect to UpdateDeliveryHourResponse + */ public static UpdateDeliveryHourResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateDeliveryHourResponse.class); } - /** - * Convert an instance of UpdateDeliveryHourResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateDeliveryHourResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateDineInHourRequest.java b/src/main/java/com/grabfood/client/model/UpdateDineInHourRequest.java index b493f88..81652a4 100644 --- a/src/main/java/com/grabfood/client/model/UpdateDineInHourRequest.java +++ b/src/main/java/com/grabfood/client/model/UpdateDineInHourRequest.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * Object contains store dine-in hours. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateDineInHourRequest { public static final String SERIALIZED_NAME_DINE_IN_HOUR = "dineInHour"; @SerializedName(SERIALIZED_NAME_DINE_IN_HOUR) @@ -67,10 +66,10 @@ public UpdateDineInHourRequest dineInHour(StoreHour dineInHour) { return this; } - /** + /** * Get dineInHour * @return dineInHour - **/ + */ @javax.annotation.Nonnull public StoreHour getDineInHour() { return dineInHour; @@ -80,6 +79,50 @@ public void setDineInHour(StoreHour dineInHour) { this.dineInHour = dineInHour; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateDineInHourRequest instance itself + */ + public UpdateDineInHourRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -91,12 +134,13 @@ public boolean equals(Object o) { return false; } UpdateDineInHourRequest updateDineInHourRequest = (UpdateDineInHourRequest) o; - return Objects.equals(this.dineInHour, updateDineInHourRequest.dineInHour); + return Objects.equals(this.dineInHour, updateDineInHourRequest.dineInHour)&& + Objects.equals(this.additionalProperties, updateDineInHourRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dineInHour); + return Objects.hash(dineInHour, additionalProperties); } @Override @@ -104,6 +148,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpdateDineInHourRequest {\n"); sb.append(" dineInHour: ").append(toIndentedString(dineInHour)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -133,12 +178,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("dineInHour"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateDineInHourRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateDineInHourRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateDineInHourRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -146,14 +191,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateDineInHourRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateDineInHourRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateDineInHourRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -180,6 +217,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateDineInHourRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -187,29 +246,50 @@ public void write(JsonWriter out, UpdateDineInHourRequest value) throws IOExcept public UpdateDineInHourRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateDineInHourRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateDineInHourRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateDineInHourRequest - * @throws IOException if the JSON string is invalid with respect to UpdateDineInHourRequest - */ + /** + * Create an instance of UpdateDineInHourRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateDineInHourRequest + * @throws IOException if the JSON string is invalid with respect to UpdateDineInHourRequest + */ public static UpdateDineInHourRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateDineInHourRequest.class); } - /** - * Convert an instance of UpdateDineInHourRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateDineInHourRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateDineInHourResponse.java b/src/main/java/com/grabfood/client/model/UpdateDineInHourResponse.java index 0473f12..e6b6551 100644 --- a/src/main/java/com/grabfood/client/model/UpdateDineInHourResponse.java +++ b/src/main/java/com/grabfood/client/model/UpdateDineInHourResponse.java @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * Object contain update store dine-in hour response */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateDineInHourResponse { public static final String SERIALIZED_NAME_ERROR_REASONS = "errorReasons"; @SerializedName(SERIALIZED_NAME_ERROR_REASONS) @@ -77,10 +76,10 @@ public UpdateDineInHourResponse addErrorReasonsItem(String errorReasonsItem) { return this; } - /** + /** * Error message when updating store dine-in hour. `null` indicates no error. * @return errorReasons - **/ + */ @javax.annotation.Nullable public List getErrorReasons() { return errorReasons; @@ -90,6 +89,50 @@ public void setErrorReasons(List errorReasons) { this.errorReasons = errorReasons; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateDineInHourResponse instance itself + */ + public UpdateDineInHourResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -101,7 +144,8 @@ public boolean equals(Object o) { return false; } UpdateDineInHourResponse updateDineInHourResponse = (UpdateDineInHourResponse) o; - return Objects.equals(this.errorReasons, updateDineInHourResponse.errorReasons); + return Objects.equals(this.errorReasons, updateDineInHourResponse.errorReasons)&& + Objects.equals(this.additionalProperties, updateDineInHourResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -110,7 +154,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(errorReasons); + return Objects.hash(errorReasons, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -125,6 +169,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpdateDineInHourResponse {\n"); sb.append(" errorReasons: ").append(toIndentedString(errorReasons)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -153,26 +198,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateDineInHourResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateDineInHourResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateDineInHourResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateDineInHourResponse is not found in the empty JSON string", UpdateDineInHourResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateDineInHourResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateDineInHourResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("errorReasons") != null && !jsonObj.get("errorReasons").isJsonNull() && !jsonObj.get("errorReasons").isJsonArray()) { @@ -195,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateDineInHourResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -202,29 +261,50 @@ public void write(JsonWriter out, UpdateDineInHourResponse value) throws IOExcep public UpdateDineInHourResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateDineInHourResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateDineInHourResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateDineInHourResponse - * @throws IOException if the JSON string is invalid with respect to UpdateDineInHourResponse - */ + /** + * Create an instance of UpdateDineInHourResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateDineInHourResponse + * @throws IOException if the JSON string is invalid with respect to UpdateDineInHourResponse + */ public static UpdateDineInHourResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateDineInHourResponse.class); } - /** - * Convert an instance of UpdateDineInHourResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateDineInHourResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateMenuItem.java b/src/main/java/com/grabfood/client/model/UpdateMenuItem.java index b4692c6..b420649 100644 --- a/src/main/java/com/grabfood/client/model/UpdateMenuItem.java +++ b/src/main/java/com/grabfood/client/model/UpdateMenuItem.java @@ -22,8 +22,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.UpdateMenuItemAdvancedPricingsInner; -import com.grabfood.client.model.UpdateMenuItemPurchasabilitiesInner; +import com.grabfood.client.model.UpdateAdvancedPricing; +import com.grabfood.client.model.UpdatePurchasability; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +44,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -56,7 +55,7 @@ /** * Information about the GrabFood client updating their food menu. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateMenuItem { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -67,7 +66,9 @@ public class UpdateMenuItem { */ @JsonAdapter(FieldEnum.Adapter.class) public enum FieldEnum { - ITEM("ITEM"); + ITEM("ITEM"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -90,7 +91,7 @@ public static FieldEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -133,7 +134,9 @@ public enum AvailableStatusEnum { UNAVAILABLE("UNAVAILABLE"), - UNAVAILABLETODAY("UNAVAILABLETODAY"); + UNAVAILABLETODAY("UNAVAILABLETODAY"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -156,7 +159,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -188,11 +191,11 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_ADVANCED_PRICINGS = "advancedPricings"; @SerializedName(SERIALIZED_NAME_ADVANCED_PRICINGS) - private List advancedPricings = new ArrayList<>(); + private List advancedPricings = new ArrayList<>(); public static final String SERIALIZED_NAME_PURCHASABILITIES = "purchasabilities"; @SerializedName(SERIALIZED_NAME_PURCHASABILITIES) - private List purchasabilities = new ArrayList<>(); + private List purchasabilities = new ArrayList<>(); public UpdateMenuItem() { } @@ -202,10 +205,10 @@ public UpdateMenuItem merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -221,10 +224,10 @@ public UpdateMenuItem field(FieldEnum field) { return this; } - /** + /** * The record type that you want to update. * @return field - **/ + */ @javax.annotation.Nonnull public FieldEnum getField() { return field; @@ -240,10 +243,10 @@ public UpdateMenuItem id(String id) { return this; } - /** + /** * The record's ID on the partner system. For example, the item id in case type is ITEM. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -259,10 +262,10 @@ public UpdateMenuItem price(Integer price) { return this; } - /** + /** * The record's price in minor unit format. * @return price - **/ + */ @javax.annotation.Nullable public Integer getPrice() { return price; @@ -278,10 +281,10 @@ public UpdateMenuItem availableStatus(AvailableStatusEnum availableStatus) { return this; } - /** + /** * The record's availableStatus. Note: In order to set an item as \"UNAVAILABLE\", it is required to update both the `availableStatus` and `maxStock` fields, whereby the `maxStock` value should be set to 0. * @return availableStatus - **/ + */ @javax.annotation.Nullable public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -297,10 +300,10 @@ public UpdateMenuItem maxStock(Integer maxStock) { return this; } - /** + /** * Available stocks under inventory for this item. Auto reduce when there is order placed for this item. Note: It is necessary to set `maxStock` to 0 if the `availableStatus` of the item is \"UNAVAILABLE\". Item will be set to \"AVAILABLE\" if `maxStock` > 0. * @return maxStock - **/ + */ @javax.annotation.Nullable public Integer getMaxStock() { return maxStock; @@ -311,12 +314,12 @@ public void setMaxStock(Integer maxStock) { } - public UpdateMenuItem advancedPricings(List advancedPricings) { + public UpdateMenuItem advancedPricings(List advancedPricings) { this.advancedPricings = advancedPricings; return this; } - public UpdateMenuItem addAdvancedPricingsItem(UpdateMenuItemAdvancedPricingsInner advancedPricingsItem) { + public UpdateMenuItem addAdvancedPricingsItem(UpdateAdvancedPricing advancedPricingsItem) { if (this.advancedPricings == null) { this.advancedPricings = new ArrayList<>(); } @@ -324,26 +327,26 @@ public UpdateMenuItem addAdvancedPricingsItem(UpdateMenuItemAdvancedPricingsInne return this; } - /** + /** * Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. * @return advancedPricings - **/ + */ @javax.annotation.Nullable - public List getAdvancedPricings() { + public List getAdvancedPricings() { return advancedPricings; } - public void setAdvancedPricings(List advancedPricings) { + public void setAdvancedPricings(List advancedPricings) { this.advancedPricings = advancedPricings; } - public UpdateMenuItem purchasabilities(List purchasabilities) { + public UpdateMenuItem purchasabilities(List purchasabilities) { this.purchasabilities = purchasabilities; return this; } - public UpdateMenuItem addPurchasabilitiesItem(UpdateMenuItemPurchasabilitiesInner purchasabilitiesItem) { + public UpdateMenuItem addPurchasabilitiesItem(UpdatePurchasability purchasabilitiesItem) { if (this.purchasabilities == null) { this.purchasabilities = new ArrayList<>(); } @@ -351,19 +354,63 @@ public UpdateMenuItem addPurchasabilitiesItem(UpdateMenuItemPurchasabilitiesInne return this; } - /** + /** * Purchasability is set to true by default for all service type, unless it is explicitly set to false. Modifier will reuse it’s item’s purchasability. * @return purchasabilities - **/ + */ @javax.annotation.Nullable - public List getPurchasabilities() { + public List getPurchasabilities() { return purchasabilities; } - public void setPurchasabilities(List purchasabilities) { + public void setPurchasabilities(List purchasabilities) { this.purchasabilities = purchasabilities; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateMenuItem instance itself + */ + public UpdateMenuItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -382,12 +429,13 @@ public boolean equals(Object o) { Objects.equals(this.availableStatus, updateMenuItem.availableStatus) && Objects.equals(this.maxStock, updateMenuItem.maxStock) && Objects.equals(this.advancedPricings, updateMenuItem.advancedPricings) && - Objects.equals(this.purchasabilities, updateMenuItem.purchasabilities); + Objects.equals(this.purchasabilities, updateMenuItem.purchasabilities)&& + Objects.equals(this.additionalProperties, updateMenuItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(merchantID, field, id, price, availableStatus, maxStock, advancedPricings, purchasabilities); + return Objects.hash(merchantID, field, id, price, availableStatus, maxStock, advancedPricings, purchasabilities, additionalProperties); } @Override @@ -402,6 +450,7 @@ public String toString() { sb.append(" maxStock: ").append(toIndentedString(maxStock)).append("\n"); sb.append(" advancedPricings: ").append(toIndentedString(advancedPricings)).append("\n"); sb.append(" purchasabilities: ").append(toIndentedString(purchasabilities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -440,12 +489,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("id"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateMenuItem - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateMenuItem + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateMenuItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -453,14 +502,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateMenuItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateMenuItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateMenuItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -496,7 +537,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `advancedPricings` (array) for (int i = 0; i < jsonArrayadvancedPricings.size(); i++) { - UpdateMenuItemAdvancedPricingsInner.validateJsonElement(jsonArrayadvancedPricings.get(i)); + UpdateAdvancedPricing.validateJsonElement(jsonArrayadvancedPricings.get(i)); }; } } @@ -510,7 +551,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `purchasabilities` (array) for (int i = 0; i < jsonArraypurchasabilities.size(); i++) { - UpdateMenuItemPurchasabilitiesInner.validateJsonElement(jsonArraypurchasabilities.get(i)); + UpdatePurchasability.validateJsonElement(jsonArraypurchasabilities.get(i)); }; } } @@ -531,6 +572,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateMenuItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -538,29 +601,50 @@ public void write(JsonWriter out, UpdateMenuItem value) throws IOException { public UpdateMenuItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateMenuItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateMenuItem given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateMenuItem - * @throws IOException if the JSON string is invalid with respect to UpdateMenuItem - */ + /** + * Create an instance of UpdateMenuItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateMenuItem + * @throws IOException if the JSON string is invalid with respect to UpdateMenuItem + */ public static UpdateMenuItem fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateMenuItem.class); } - /** - * Convert an instance of UpdateMenuItem to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateMenuItem to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateMenuItemAdvancedPricingsInner.java b/src/main/java/com/grabfood/client/model/UpdateMenuItemAdvancedPricingsInner.java deleted file mode 100644 index a1078f2..0000000 --- a/src/main/java/com/grabfood/client/model/UpdateMenuItemAdvancedPricingsInner.java +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * UpdateMenuItemAdvancedPricingsInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class UpdateMenuItemAdvancedPricingsInner { - /** - * Available service type. - */ - @JsonAdapter(KeyEnum.Adapter.class) - public enum KeyEnum { - DELIVERY_ONDEMAND_GRABAPP("Delivery_OnDemand_GrabApp"), - - DELIVERY_SCHEDULED_GRABAPP("Delivery_Scheduled_GrabApp"), - - SELFPICKUP_ONDEMAND_GRABAPP("SelfPickUp_OnDemand_GrabApp"), - - DINEIN_ONDEMAND_GRABAPP("DineIn_OnDemand_GrabApp"), - - DELIVERY_ONDEMAND_STOREFRONT("Delivery_OnDemand_StoreFront"), - - DELIVERY_SCHEDULED_STOREFRONT("Delivery_Scheduled_StoreFront"), - - SELFPICKUP_ONDEMAND_STOREFRONT("SelfPickUp_OnDemand_StoreFront"); - - private String value; - - KeyEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static KeyEnum fromValue(String value) { - for (KeyEnum b : KeyEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final KeyEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public KeyEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return KeyEnum.fromValue(value); - } - } - - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - String value = jsonElement.getAsString(); - KeyEnum.fromValue(value); - } - } - - public static final String SERIALIZED_NAME_KEY = "key"; - @SerializedName(SERIALIZED_NAME_KEY) - private KeyEnum key; - - public static final String SERIALIZED_NAME_PRICE = "price"; - @SerializedName(SERIALIZED_NAME_PRICE) - private Integer price; - - public UpdateMenuItemAdvancedPricingsInner() { - } - - public UpdateMenuItemAdvancedPricingsInner key(KeyEnum key) { - this.key = key; - return this; - } - - /** - * Available service type. - * @return key - **/ - @javax.annotation.Nullable - public KeyEnum getKey() { - return key; - } - - public void setKey(KeyEnum key) { - this.key = key; - } - - - public UpdateMenuItemAdvancedPricingsInner price(Integer price) { - this.price = price; - return this; - } - - /** - * Price in minor unit. - * @return price - **/ - @javax.annotation.Nullable - public Integer getPrice() { - return price; - } - - public void setPrice(Integer price) { - this.price = price; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - UpdateMenuItemAdvancedPricingsInner updateMenuItemAdvancedPricingsInner = (UpdateMenuItemAdvancedPricingsInner) o; - return Objects.equals(this.key, updateMenuItemAdvancedPricingsInner.key) && - Objects.equals(this.price, updateMenuItemAdvancedPricingsInner.price); - } - - @Override - public int hashCode() { - return Objects.hash(key, price); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class UpdateMenuItemAdvancedPricingsInner {\n"); - sb.append(" key: ").append(toIndentedString(key)).append("\n"); - sb.append(" price: ").append(toIndentedString(price)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("key"); - openapiFields.add("price"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateMenuItemAdvancedPricingsInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!UpdateMenuItemAdvancedPricingsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateMenuItemAdvancedPricingsInner is not found in the empty JSON string", UpdateMenuItemAdvancedPricingsInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateMenuItemAdvancedPricingsInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateMenuItemAdvancedPricingsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) && !jsonObj.get("key").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); - } - // validate the optional field `key` - if (jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) { - KeyEnum.validateJsonElement(jsonObj.get("key")); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!UpdateMenuItemAdvancedPricingsInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'UpdateMenuItemAdvancedPricingsInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(UpdateMenuItemAdvancedPricingsInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, UpdateMenuItemAdvancedPricingsInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public UpdateMenuItemAdvancedPricingsInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of UpdateMenuItemAdvancedPricingsInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateMenuItemAdvancedPricingsInner - * @throws IOException if the JSON string is invalid with respect to UpdateMenuItemAdvancedPricingsInner - */ - public static UpdateMenuItemAdvancedPricingsInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, UpdateMenuItemAdvancedPricingsInner.class); - } - - /** - * Convert an instance of UpdateMenuItemAdvancedPricingsInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/UpdateMenuItemPurchasabilitiesInner.java b/src/main/java/com/grabfood/client/model/UpdateMenuItemPurchasabilitiesInner.java deleted file mode 100644 index 6ea39a5..0000000 --- a/src/main/java/com/grabfood/client/model/UpdateMenuItemPurchasabilitiesInner.java +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * UpdateMenuItemPurchasabilitiesInner - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class UpdateMenuItemPurchasabilitiesInner { - /** - * Available service type. - */ - @JsonAdapter(KeyEnum.Adapter.class) - public enum KeyEnum { - DELIVERY_ONDEMAND_GRABAPP("Delivery_OnDemand_GrabApp"), - - DELIVERY_SCHEDULED_GRABAPP("Delivery_Scheduled_GrabApp"), - - SELFPICKUP_ONDEMAND_GRABAPP("SelfPickUp_OnDemand_GrabApp"), - - DINEIN_ONDEMAND_GRABAPP("DineIn_OnDemand_GrabApp"), - - DELIVERY_ONDEMAND_STOREFRONT("Delivery_OnDemand_StoreFront"), - - DELIVERY_SCHEDULED_STOREFRONT("Delivery_Scheduled_StoreFront"), - - SELFPICKUP_ONDEMAND_STOREFRONT("SelfPickUp_OnDemand_StoreFront"); - - private String value; - - KeyEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static KeyEnum fromValue(String value) { - for (KeyEnum b : KeyEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final KeyEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public KeyEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return KeyEnum.fromValue(value); - } - } - - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - String value = jsonElement.getAsString(); - KeyEnum.fromValue(value); - } - } - - public static final String SERIALIZED_NAME_KEY = "key"; - @SerializedName(SERIALIZED_NAME_KEY) - private KeyEnum key; - - public static final String SERIALIZED_NAME_PURCHASABLE = "purchasable"; - @SerializedName(SERIALIZED_NAME_PURCHASABLE) - private Boolean purchasable; - - public UpdateMenuItemPurchasabilitiesInner() { - } - - public UpdateMenuItemPurchasabilitiesInner key(KeyEnum key) { - this.key = key; - return this; - } - - /** - * Available service type. - * @return key - **/ - @javax.annotation.Nullable - public KeyEnum getKey() { - return key; - } - - public void setKey(KeyEnum key) { - this.key = key; - } - - - public UpdateMenuItemPurchasabilitiesInner purchasable(Boolean purchasable) { - this.purchasable = purchasable; - return this; - } - - /** - * Get purchasable - * @return purchasable - **/ - @javax.annotation.Nullable - public Boolean getPurchasable() { - return purchasable; - } - - public void setPurchasable(Boolean purchasable) { - this.purchasable = purchasable; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - UpdateMenuItemPurchasabilitiesInner updateMenuItemPurchasabilitiesInner = (UpdateMenuItemPurchasabilitiesInner) o; - return Objects.equals(this.key, updateMenuItemPurchasabilitiesInner.key) && - Objects.equals(this.purchasable, updateMenuItemPurchasabilitiesInner.purchasable); - } - - @Override - public int hashCode() { - return Objects.hash(key, purchasable); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class UpdateMenuItemPurchasabilitiesInner {\n"); - sb.append(" key: ").append(toIndentedString(key)).append("\n"); - sb.append(" purchasable: ").append(toIndentedString(purchasable)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("key"); - openapiFields.add("purchasable"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateMenuItemPurchasabilitiesInner - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!UpdateMenuItemPurchasabilitiesInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateMenuItemPurchasabilitiesInner is not found in the empty JSON string", UpdateMenuItemPurchasabilitiesInner.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateMenuItemPurchasabilitiesInner.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateMenuItemPurchasabilitiesInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) && !jsonObj.get("key").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); - } - // validate the optional field `key` - if (jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) { - KeyEnum.validateJsonElement(jsonObj.get("key")); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!UpdateMenuItemPurchasabilitiesInner.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'UpdateMenuItemPurchasabilitiesInner' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(UpdateMenuItemPurchasabilitiesInner.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, UpdateMenuItemPurchasabilitiesInner value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public UpdateMenuItemPurchasabilitiesInner read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of UpdateMenuItemPurchasabilitiesInner given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateMenuItemPurchasabilitiesInner - * @throws IOException if the JSON string is invalid with respect to UpdateMenuItemPurchasabilitiesInner - */ - public static UpdateMenuItemPurchasabilitiesInner fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, UpdateMenuItemPurchasabilitiesInner.class); - } - - /** - * Convert an instance of UpdateMenuItemPurchasabilitiesInner to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/UpdateMenuModifier.java b/src/main/java/com/grabfood/client/model/UpdateMenuModifier.java index c88cc8f..de55783 100644 --- a/src/main/java/com/grabfood/client/model/UpdateMenuModifier.java +++ b/src/main/java/com/grabfood/client/model/UpdateMenuModifier.java @@ -22,7 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.UpdateMenuItemAdvancedPricingsInner; +import com.grabfood.client.model.UpdateAdvancedPricing; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * Information about the GrabFood client updating their food menu. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateMenuModifier { public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) @@ -66,7 +65,9 @@ public class UpdateMenuModifier { */ @JsonAdapter(FieldEnum.Adapter.class) public enum FieldEnum { - MODIFIER("MODIFIER"); + MODIFIER("MODIFIER"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -89,7 +90,7 @@ public static FieldEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -136,7 +137,9 @@ public enum AvailableStatusEnum { UNAVAILABLE("UNAVAILABLE"), - UNAVAILABLETODAY("UNAVAILABLETODAY"); + UNAVAILABLETODAY("UNAVAILABLETODAY"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -159,7 +162,7 @@ public static AvailableStatusEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -191,7 +194,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti public static final String SERIALIZED_NAME_ADVANCED_PRICINGS = "advancedPricings"; @SerializedName(SERIALIZED_NAME_ADVANCED_PRICINGS) - private List advancedPricings = new ArrayList<>(); + private List advancedPricings = new ArrayList<>(); public UpdateMenuModifier() { } @@ -201,10 +204,10 @@ public UpdateMenuModifier merchantID(String merchantID) { return this; } - /** + /** * The merchant's ID that is in GrabFood's database. * @return merchantID - **/ + */ @javax.annotation.Nonnull public String getMerchantID() { return merchantID; @@ -220,10 +223,10 @@ public UpdateMenuModifier field(FieldEnum field) { return this; } - /** + /** * The record type that you want to update. * @return field - **/ + */ @javax.annotation.Nonnull public FieldEnum getField() { return field; @@ -239,10 +242,10 @@ public UpdateMenuModifier id(String id) { return this; } - /** + /** * The record's ID on the partner system. For example, the modifier id in case type is MODIFIER. * @return id - **/ + */ @javax.annotation.Nonnull public String getId() { return id; @@ -258,10 +261,10 @@ public UpdateMenuModifier price(Integer price) { return this; } - /** + /** * The record's price in minor unit format. * @return price - **/ + */ @javax.annotation.Nullable public Integer getPrice() { return price; @@ -277,10 +280,10 @@ public UpdateMenuModifier name(String name) { return this; } - /** + /** * **Only required when updating modifiers.** The record's name. Used as identifier to locate the correct record. * @return name - **/ + */ @javax.annotation.Nonnull public String getName() { return name; @@ -296,10 +299,10 @@ public UpdateMenuModifier availableStatus(AvailableStatusEnum availableStatus) { return this; } - /** + /** * The record's availableStatus. * @return availableStatus - **/ + */ @javax.annotation.Nullable public AvailableStatusEnum getAvailableStatus() { return availableStatus; @@ -315,10 +318,10 @@ public UpdateMenuModifier isFree(Boolean isFree) { return this; } - /** + /** * Allows the modifier's price to be explicitly set as zero. Possible values are as follows: * `isFree` && `price == 0` sets the modifier's price to zero. * `isFree` && `price > 0` returns an error message that \"price cannot be set to > 0, if modifier is free”. * `!isFree` && `price > 0` sets the modifier's price to the defined price. * `!isFree` && `price == 0` does not update the modifier's price and reuses the existing price. * @return isFree - **/ + */ @javax.annotation.Nullable public Boolean getIsFree() { return isFree; @@ -329,12 +332,12 @@ public void setIsFree(Boolean isFree) { } - public UpdateMenuModifier advancedPricings(List advancedPricings) { + public UpdateMenuModifier advancedPricings(List advancedPricings) { this.advancedPricings = advancedPricings; return this; } - public UpdateMenuModifier addAdvancedPricingsItem(UpdateMenuItemAdvancedPricingsInner advancedPricingsItem) { + public UpdateMenuModifier addAdvancedPricingsItem(UpdateAdvancedPricing advancedPricingsItem) { if (this.advancedPricings == null) { this.advancedPricings = new ArrayList<>(); } @@ -342,19 +345,63 @@ public UpdateMenuModifier addAdvancedPricingsItem(UpdateMenuItemAdvancedPricings return this; } - /** + /** * Price configuration (in minor unit) for different service, order type and channel combination. If a service type does not have a specified price, it will utilize the default price of the item. * @return advancedPricings - **/ + */ @javax.annotation.Nullable - public List getAdvancedPricings() { + public List getAdvancedPricings() { return advancedPricings; } - public void setAdvancedPricings(List advancedPricings) { + public void setAdvancedPricings(List advancedPricings) { this.advancedPricings = advancedPricings; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateMenuModifier instance itself + */ + public UpdateMenuModifier putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -373,12 +420,13 @@ public boolean equals(Object o) { Objects.equals(this.name, updateMenuModifier.name) && Objects.equals(this.availableStatus, updateMenuModifier.availableStatus) && Objects.equals(this.isFree, updateMenuModifier.isFree) && - Objects.equals(this.advancedPricings, updateMenuModifier.advancedPricings); + Objects.equals(this.advancedPricings, updateMenuModifier.advancedPricings)&& + Objects.equals(this.additionalProperties, updateMenuModifier.additionalProperties); } @Override public int hashCode() { - return Objects.hash(merchantID, field, id, price, name, availableStatus, isFree, advancedPricings); + return Objects.hash(merchantID, field, id, price, name, availableStatus, isFree, advancedPricings, additionalProperties); } @Override @@ -393,6 +441,7 @@ public String toString() { sb.append(" availableStatus: ").append(toIndentedString(availableStatus)).append("\n"); sb.append(" isFree: ").append(toIndentedString(isFree)).append("\n"); sb.append(" advancedPricings: ").append(toIndentedString(advancedPricings)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -432,12 +481,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("name"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateMenuModifier - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateMenuModifier + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateMenuModifier.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -445,14 +494,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateMenuModifier.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateMenuModifier` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateMenuModifier.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -491,7 +532,7 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti // validate the optional field `advancedPricings` (array) for (int i = 0; i < jsonArrayadvancedPricings.size(); i++) { - UpdateMenuItemAdvancedPricingsInner.validateJsonElement(jsonArrayadvancedPricings.get(i)); + UpdateAdvancedPricing.validateJsonElement(jsonArrayadvancedPricings.get(i)); }; } } @@ -512,6 +553,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateMenuModifier value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -519,29 +582,50 @@ public void write(JsonWriter out, UpdateMenuModifier value) throws IOException { public UpdateMenuModifier read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateMenuModifier instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateMenuModifier given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateMenuModifier - * @throws IOException if the JSON string is invalid with respect to UpdateMenuModifier - */ + /** + * Create an instance of UpdateMenuModifier given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateMenuModifier + * @throws IOException if the JSON string is invalid with respect to UpdateMenuModifier + */ public static UpdateMenuModifier fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateMenuModifier.class); } - /** - * Convert an instance of UpdateMenuModifier to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateMenuModifier to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateMenuNotiRequest.java b/src/main/java/com/grabfood/client/model/UpdateMenuNotiRequest.java deleted file mode 100644 index 15f73b0..0000000 --- a/src/main/java/com/grabfood/client/model/UpdateMenuNotiRequest.java +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * This request notifies GrabFood about the partner's updated food menu. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class UpdateMenuNotiRequest { - public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; - @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) - private String merchantID; - - public UpdateMenuNotiRequest() { - } - - public UpdateMenuNotiRequest merchantID(String merchantID) { - this.merchantID = merchantID; - return this; - } - - /** - * The merchant's ID that is in GrabFood's database. - * @return merchantID - **/ - @javax.annotation.Nonnull - public String getMerchantID() { - return merchantID; - } - - public void setMerchantID(String merchantID) { - this.merchantID = merchantID; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - UpdateMenuNotiRequest updateMenuNotiRequest = (UpdateMenuNotiRequest) o; - return Objects.equals(this.merchantID, updateMenuNotiRequest.merchantID); - } - - @Override - public int hashCode() { - return Objects.hash(merchantID); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class UpdateMenuNotiRequest {\n"); - sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("merchantID"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - openapiRequiredFields.add("merchantID"); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateMenuNotiRequest - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!UpdateMenuNotiRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateMenuNotiRequest is not found in the empty JSON string", UpdateMenuNotiRequest.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateMenuNotiRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateMenuNotiRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : UpdateMenuNotiRequest.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (!jsonObj.get("merchantID").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `merchantID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("merchantID").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!UpdateMenuNotiRequest.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'UpdateMenuNotiRequest' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(UpdateMenuNotiRequest.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, UpdateMenuNotiRequest value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public UpdateMenuNotiRequest read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of UpdateMenuNotiRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateMenuNotiRequest - * @throws IOException if the JSON string is invalid with respect to UpdateMenuNotiRequest - */ - public static UpdateMenuNotiRequest fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, UpdateMenuNotiRequest.class); - } - - /** - * Convert an instance of UpdateMenuNotiRequest to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/UpdateMenuNotifRequest.java b/src/main/java/com/grabfood/client/model/UpdateMenuNotifRequest.java new file mode 100644 index 0000000..2675337 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/UpdateMenuNotifRequest.java @@ -0,0 +1,297 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * This request notifies GrabFood about the partner's updated food menu. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class UpdateMenuNotifRequest { + public static final String SERIALIZED_NAME_MERCHANT_I_D = "merchantID"; + @SerializedName(SERIALIZED_NAME_MERCHANT_I_D) + private String merchantID; + + public UpdateMenuNotifRequest() { + } + + public UpdateMenuNotifRequest merchantID(String merchantID) { + this.merchantID = merchantID; + return this; + } + + /** + * The merchant's ID that is in GrabFood's database. + * @return merchantID + */ + @javax.annotation.Nonnull + public String getMerchantID() { + return merchantID; + } + + public void setMerchantID(String merchantID) { + this.merchantID = merchantID; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateMenuNotifRequest instance itself + */ + public UpdateMenuNotifRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateMenuNotifRequest updateMenuNotifRequest = (UpdateMenuNotifRequest) o; + return Objects.equals(this.merchantID, updateMenuNotifRequest.merchantID)&& + Objects.equals(this.additionalProperties, updateMenuNotifRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(merchantID, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateMenuNotifRequest {\n"); + sb.append(" merchantID: ").append(toIndentedString(merchantID)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("merchantID"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("merchantID"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateMenuNotifRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateMenuNotifRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateMenuNotifRequest is not found in the empty JSON string", UpdateMenuNotifRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateMenuNotifRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("merchantID").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `merchantID` to be a primitive type in the JSON string but got `%s`", jsonObj.get("merchantID").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateMenuNotifRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateMenuNotifRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdateMenuNotifRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateMenuNotifRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public UpdateMenuNotifRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateMenuNotifRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateMenuNotifRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateMenuNotifRequest + * @throws IOException if the JSON string is invalid with respect to UpdateMenuNotifRequest + */ + public static UpdateMenuNotifRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateMenuNotifRequest.class); + } + + /** + * Convert an instance of UpdateMenuNotifRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/UpdateMenuRequest.java b/src/main/java/com/grabfood/client/model/UpdateMenuRequest.java index 9bdae08..0f1b3cf 100644 --- a/src/main/java/com/grabfood/client/model/UpdateMenuRequest.java +++ b/src/main/java/com/grabfood/client/model/UpdateMenuRequest.java @@ -22,10 +22,10 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.grabfood.client.model.UpdateAdvancedPricing; import com.grabfood.client.model.UpdateMenuItem; -import com.grabfood.client.model.UpdateMenuItemAdvancedPricingsInner; -import com.grabfood.client.model.UpdateMenuItemPurchasabilitiesInner; import com.grabfood.client.model.UpdateMenuModifier; +import com.grabfood.client.model.UpdatePurchasability; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -66,7 +66,7 @@ import com.grabfood.client.JSON; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateMenuRequest extends AbstractOpenApiSchema { private static final Logger log = Logger.getLogger(UpdateMenuRequest.class.getName()); diff --git a/src/main/java/com/grabfood/client/model/UpdatePurchasability.java b/src/main/java/com/grabfood/client/model/UpdatePurchasability.java new file mode 100644 index 0000000..63e3a6d --- /dev/null +++ b/src/main/java/com/grabfood/client/model/UpdatePurchasability.java @@ -0,0 +1,383 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * UpdatePurchasability + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class UpdatePurchasability { + /** + * Available service type. + */ + @JsonAdapter(KeyEnum.Adapter.class) + public enum KeyEnum { + DELIVERY_ON_DEMAND_GRAB_APP("Delivery_OnDemand_GrabApp"), + + DELIVERY_SCHEDULED_GRAB_APP("Delivery_Scheduled_GrabApp"), + + SELF_PICK_UP_ON_DEMAND_GRAB_APP("SelfPickUp_OnDemand_GrabApp"), + + DINE_IN_ON_DEMAND_GRAB_APP("DineIn_OnDemand_GrabApp"), + + DELIVERY_ON_DEMAND_STORE_FRONT("Delivery_OnDemand_StoreFront"), + + DELIVERY_SCHEDULED_STORE_FRONT("Delivery_Scheduled_StoreFront"), + + SELF_PICK_UP_ON_DEMAND_STORE_FRONT("SelfPickUp_OnDemand_StoreFront"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + KeyEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static KeyEnum fromValue(String value) { + for (KeyEnum b : KeyEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final KeyEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public KeyEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return KeyEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KeyEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_KEY = "key"; + @SerializedName(SERIALIZED_NAME_KEY) + private KeyEnum key; + + public static final String SERIALIZED_NAME_PURCHASABLE = "purchasable"; + @SerializedName(SERIALIZED_NAME_PURCHASABLE) + private Boolean purchasable; + + public UpdatePurchasability() { + } + + public UpdatePurchasability key(KeyEnum key) { + this.key = key; + return this; + } + + /** + * Available service type. + * @return key + */ + @javax.annotation.Nullable + public KeyEnum getKey() { + return key; + } + + public void setKey(KeyEnum key) { + this.key = key; + } + + + public UpdatePurchasability purchasable(Boolean purchasable) { + this.purchasable = purchasable; + return this; + } + + /** + * Get purchasable + * @return purchasable + */ + @javax.annotation.Nullable + public Boolean getPurchasable() { + return purchasable; + } + + public void setPurchasable(Boolean purchasable) { + this.purchasable = purchasable; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdatePurchasability instance itself + */ + public UpdatePurchasability putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdatePurchasability updatePurchasability = (UpdatePurchasability) o; + return Objects.equals(this.key, updatePurchasability.key) && + Objects.equals(this.purchasable, updatePurchasability.purchasable)&& + Objects.equals(this.additionalProperties, updatePurchasability.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(key, purchasable, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatePurchasability {\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" purchasable: ").append(toIndentedString(purchasable)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("key"); + openapiFields.add("purchasable"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdatePurchasability + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdatePurchasability.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in UpdatePurchasability is not found in the empty JSON string", UpdatePurchasability.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) && !jsonObj.get("key").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString())); + } + // validate the optional field `key` + if (jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) { + KeyEnum.validateJsonElement(jsonObj.get("key")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdatePurchasability.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdatePurchasability' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(UpdatePurchasability.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdatePurchasability value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public UpdatePurchasability read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdatePurchasability instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of UpdatePurchasability given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdatePurchasability + * @throws IOException if the JSON string is invalid with respect to UpdatePurchasability + */ + public static UpdatePurchasability fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdatePurchasability.class); + } + + /** + * Convert an instance of UpdatePurchasability to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/UpdateSpecialHourRequest.java b/src/main/java/com/grabfood/client/model/UpdateSpecialHourRequest.java index 765c204..5f6c583 100644 --- a/src/main/java/com/grabfood/client/model/UpdateSpecialHourRequest.java +++ b/src/main/java/com/grabfood/client/model/UpdateSpecialHourRequest.java @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,7 +54,7 @@ /** * Object contains store special hours. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateSpecialHourRequest { public static final String SERIALIZED_NAME_SPECIAL_OPENING_HOURS = "specialOpeningHours"; @SerializedName(SERIALIZED_NAME_SPECIAL_OPENING_HOURS) @@ -77,11 +76,11 @@ public UpdateSpecialHourRequest addSpecialOpeningHoursItem(SpecialOpeningHour sp return this; } - /** + /** * An array of objects contain store special hours. Max. 3 array elements. * @return specialOpeningHours - **/ - @javax.annotation.Nullable + */ + @javax.annotation.Nonnull public List getSpecialOpeningHours() { return specialOpeningHours; } @@ -90,6 +89,50 @@ public void setSpecialOpeningHours(List specialOpeningHours) this.specialOpeningHours = specialOpeningHours; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateSpecialHourRequest instance itself + */ + public UpdateSpecialHourRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -101,12 +144,13 @@ public boolean equals(Object o) { return false; } UpdateSpecialHourRequest updateSpecialHourRequest = (UpdateSpecialHourRequest) o; - return Objects.equals(this.specialOpeningHours, updateSpecialHourRequest.specialOpeningHours); + return Objects.equals(this.specialOpeningHours, updateSpecialHourRequest.specialOpeningHours)&& + Objects.equals(this.additionalProperties, updateSpecialHourRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(specialOpeningHours); + return Objects.hash(specialOpeningHours, additionalProperties); } @Override @@ -114,6 +158,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpdateSpecialHourRequest {\n"); sb.append(" specialOpeningHours: ").append(toIndentedString(specialOpeningHours)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -140,14 +185,15 @@ private String toIndentedString(Object o) { // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("specialOpeningHours"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateSpecialHourRequest - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateSpecialHourRequest + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateSpecialHourRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -155,28 +201,23 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateSpecialHourRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSpecialHourRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : UpdateSpecialHourRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("specialOpeningHours") != null && !jsonObj.get("specialOpeningHours").isJsonNull()) { - JsonArray jsonArrayspecialOpeningHours = jsonObj.getAsJsonArray("specialOpeningHours"); - if (jsonArrayspecialOpeningHours != null) { - // ensure the json data is an array - if (!jsonObj.get("specialOpeningHours").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `specialOpeningHours` to be an array in the JSON string but got `%s`", jsonObj.get("specialOpeningHours").toString())); - } - - // validate the optional field `specialOpeningHours` (array) - for (int i = 0; i < jsonArrayspecialOpeningHours.size(); i++) { - SpecialOpeningHour.validateJsonElement(jsonArrayspecialOpeningHours.get(i)); - }; - } + // ensure the json data is an array + if (!jsonObj.get("specialOpeningHours").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `specialOpeningHours` to be an array in the JSON string but got `%s`", jsonObj.get("specialOpeningHours").toString())); } + + JsonArray jsonArrayspecialOpeningHours = jsonObj.getAsJsonArray("specialOpeningHours"); + // validate the required field `specialOpeningHours` (array) + for (int i = 0; i < jsonArrayspecialOpeningHours.size(); i++) { + SpecialOpeningHour.validateJsonElement(jsonArrayspecialOpeningHours.get(i)); + }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -194,6 +235,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateSpecialHourRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,29 +264,50 @@ public void write(JsonWriter out, UpdateSpecialHourRequest value) throws IOExcep public UpdateSpecialHourRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateSpecialHourRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateSpecialHourRequest given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateSpecialHourRequest - * @throws IOException if the JSON string is invalid with respect to UpdateSpecialHourRequest - */ + /** + * Create an instance of UpdateSpecialHourRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSpecialHourRequest + * @throws IOException if the JSON string is invalid with respect to UpdateSpecialHourRequest + */ public static UpdateSpecialHourRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateSpecialHourRequest.class); } - /** - * Convert an instance of UpdateSpecialHourRequest to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateSpecialHourRequest to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/UpdateSpecialHourResponse.java b/src/main/java/com/grabfood/client/model/UpdateSpecialHourResponse.java index 6bea1e4..693df7e 100644 --- a/src/main/java/com/grabfood/client/model/UpdateSpecialHourResponse.java +++ b/src/main/java/com/grabfood/client/model/UpdateSpecialHourResponse.java @@ -43,7 +43,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -55,14 +54,16 @@ /** * Object contain update store special hour response */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class UpdateSpecialHourResponse { /** * Gets or Sets errorReasons */ @JsonAdapter(ErrorReasonsEnum.Adapter.class) public enum ErrorReasonsEnum { - PENDINGORDERS("PendingOrders"); + PENDING_ORDERS("PendingOrders"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -85,7 +86,7 @@ public static ErrorReasonsEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -139,10 +140,10 @@ public UpdateSpecialHourResponse addErrorReasonsItem(ErrorReasonsEnum errorReaso return this; } - /** + /** * Error message when updating store delivery hour. `null` indicates no error. * @return errorReasons - **/ + */ @javax.annotation.Nullable public List getErrorReasons() { return errorReasons; @@ -158,10 +159,10 @@ public UpdateSpecialHourResponse orderCount(Integer orderCount) { return this; } - /** + /** * Total active order for the day. * @return orderCount - **/ + */ @javax.annotation.Nonnull public Integer getOrderCount() { return orderCount; @@ -177,10 +178,10 @@ public UpdateSpecialHourResponse scheduledOrderCount(Integer scheduledOrderCount return this; } - /** + /** * Total scheduled order during store close period. * @return scheduledOrderCount - **/ + */ @javax.annotation.Nonnull public Integer getScheduledOrderCount() { return scheduledOrderCount; @@ -196,10 +197,10 @@ public UpdateSpecialHourResponse closeImmediately(Boolean closeImmediately) { return this; } - /** + /** * Indicate the store status after updating special hours. * @return closeImmediately - **/ + */ @javax.annotation.Nonnull public Boolean getCloseImmediately() { return closeImmediately; @@ -209,6 +210,50 @@ public void setCloseImmediately(Boolean closeImmediately) { this.closeImmediately = closeImmediately; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateSpecialHourResponse instance itself + */ + public UpdateSpecialHourResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -223,7 +268,8 @@ public boolean equals(Object o) { return Objects.equals(this.errorReasons, updateSpecialHourResponse.errorReasons) && Objects.equals(this.orderCount, updateSpecialHourResponse.orderCount) && Objects.equals(this.scheduledOrderCount, updateSpecialHourResponse.scheduledOrderCount) && - Objects.equals(this.closeImmediately, updateSpecialHourResponse.closeImmediately); + Objects.equals(this.closeImmediately, updateSpecialHourResponse.closeImmediately)&& + Objects.equals(this.additionalProperties, updateSpecialHourResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -232,7 +278,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(errorReasons, orderCount, scheduledOrderCount, closeImmediately); + return Objects.hash(errorReasons, orderCount, scheduledOrderCount, closeImmediately, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -250,6 +296,7 @@ public String toString() { sb.append(" orderCount: ").append(toIndentedString(orderCount)).append("\n"); sb.append(" scheduledOrderCount: ").append(toIndentedString(scheduledOrderCount)).append("\n"); sb.append(" closeImmediately: ").append(toIndentedString(closeImmediately)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -284,12 +331,12 @@ private String toIndentedString(Object o) { openapiRequiredFields.add("closeImmediately"); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to UpdateSpecialHourResponse - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateSpecialHourResponse + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!UpdateSpecialHourResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null @@ -297,14 +344,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateSpecialHourResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UpdateSpecialHourResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateSpecialHourResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -333,6 +372,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateSpecialHourResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -340,29 +401,50 @@ public void write(JsonWriter out, UpdateSpecialHourResponse value) throws IOExce public UpdateSpecialHourResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateSpecialHourResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of UpdateSpecialHourResponse given an JSON string - * - * @param jsonString JSON string - * @return An instance of UpdateSpecialHourResponse - * @throws IOException if the JSON string is invalid with respect to UpdateSpecialHourResponse - */ + /** + * Create an instance of UpdateSpecialHourResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSpecialHourResponse + * @throws IOException if the JSON string is invalid with respect to UpdateSpecialHourResponse + */ public static UpdateSpecialHourResponse fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, UpdateSpecialHourResponse.class); } - /** - * Convert an instance of UpdateSpecialHourResponse to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of UpdateSpecialHourResponse to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/Voucher.java b/src/main/java/com/grabfood/client/model/Voucher.java index 8f857b9..ffc3ddc 100644 --- a/src/main/java/com/grabfood/client/model/Voucher.java +++ b/src/main/java/com/grabfood/client/model/Voucher.java @@ -41,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +52,7 @@ /** * A JSON object containing dine-in voucher details. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class Voucher { public static final String SERIALIZED_NAME_TITLE = "title"; @SerializedName(SERIALIZED_NAME_TITLE) @@ -78,7 +77,9 @@ public class Voucher { public enum VoucherTypeEnum { CASH("CASH"), - ITEM("ITEM"); + ITEM("ITEM"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -101,7 +102,7 @@ public static VoucherTypeEnum fromValue(String value) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return UNKNOWN_DEFAULT_OPEN_API; } public static class Adapter extends TypeAdapter { @@ -135,10 +136,10 @@ public Voucher title(String title) { return this; } - /** + /** * The title of the voucher. * @return title - **/ + */ @javax.annotation.Nullable public String getTitle() { return title; @@ -154,10 +155,10 @@ public Voucher discountedPrice(String discountedPrice) { return this; } - /** + /** * The amount paid after discount is applied in local currency. * @return discountedPrice - **/ + */ @javax.annotation.Nullable public String getDiscountedPrice() { return discountedPrice; @@ -173,10 +174,10 @@ public Voucher originalPrice(String originalPrice) { return this; } - /** + /** * The original amount before discount is applied in local currency. * @return originalPrice - **/ + */ @javax.annotation.Nullable public String getOriginalPrice() { return originalPrice; @@ -192,10 +193,10 @@ public Voucher descriptionInfo(VoucherDescriptionInfo descriptionInfo) { return this; } - /** + /** * Get descriptionInfo * @return descriptionInfo - **/ + */ @javax.annotation.Nullable public VoucherDescriptionInfo getDescriptionInfo() { return descriptionInfo; @@ -211,10 +212,10 @@ public Voucher voucherType(VoucherTypeEnum voucherType) { return this; } - /** + /** * The type of the dine-in voucher. * @return voucherType - **/ + */ @javax.annotation.Nullable public VoucherTypeEnum getVoucherType() { return voucherType; @@ -224,6 +225,50 @@ public void setVoucherType(VoucherTypeEnum voucherType) { this.voucherType = voucherType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Voucher instance itself + */ + public Voucher putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -239,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.discountedPrice, voucher.discountedPrice) && Objects.equals(this.originalPrice, voucher.originalPrice) && Objects.equals(this.descriptionInfo, voucher.descriptionInfo) && - Objects.equals(this.voucherType, voucher.voucherType); + Objects.equals(this.voucherType, voucher.voucherType)&& + Objects.equals(this.additionalProperties, voucher.additionalProperties); } @Override public int hashCode() { - return Objects.hash(title, discountedPrice, originalPrice, descriptionInfo, voucherType); + return Objects.hash(title, discountedPrice, originalPrice, descriptionInfo, voucherType, additionalProperties); } @Override @@ -256,6 +302,7 @@ public String toString() { sb.append(" originalPrice: ").append(toIndentedString(originalPrice)).append("\n"); sb.append(" descriptionInfo: ").append(toIndentedString(descriptionInfo)).append("\n"); sb.append(" voucherType: ").append(toIndentedString(voucherType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -288,26 +335,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to Voucher - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Voucher + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Voucher.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in Voucher is not found in the empty JSON string", Voucher.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Voucher.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Voucher` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); @@ -346,6 +385,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Voucher value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -353,29 +414,50 @@ public void write(JsonWriter out, Voucher value) throws IOException { public Voucher read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Voucher instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of Voucher given an JSON string - * - * @param jsonString JSON string - * @return An instance of Voucher - * @throws IOException if the JSON string is invalid with respect to Voucher - */ + /** + * Create an instance of Voucher given an JSON string + * + * @param jsonString JSON string + * @return An instance of Voucher + * @throws IOException if the JSON string is invalid with respect to Voucher + */ public static Voucher fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, Voucher.class); } - /** - * Convert an instance of Voucher to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of Voucher to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/VoucherDescriptionInfo.java b/src/main/java/com/grabfood/client/model/VoucherDescriptionInfo.java index 66004e2..08eaad8 100644 --- a/src/main/java/com/grabfood/client/model/VoucherDescriptionInfo.java +++ b/src/main/java/com/grabfood/client/model/VoucherDescriptionInfo.java @@ -40,7 +40,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -52,7 +51,7 @@ /** * A JSON object containing dine-in voucher's description information. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class VoucherDescriptionInfo { public static final String SERIALIZED_NAME_TEXT = "text"; @SerializedName(SERIALIZED_NAME_TEXT) @@ -66,10 +65,10 @@ public VoucherDescriptionInfo text(String text) { return this; } - /** + /** * The description of the dine-in voucher. * @return text - **/ + */ @javax.annotation.Nullable public String getText() { return text; @@ -79,6 +78,50 @@ public void setText(String text) { this.text = text; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the VoucherDescriptionInfo instance itself + */ + public VoucherDescriptionInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +133,13 @@ public boolean equals(Object o) { return false; } VoucherDescriptionInfo voucherDescriptionInfo = (VoucherDescriptionInfo) o; - return Objects.equals(this.text, voucherDescriptionInfo.text); + return Objects.equals(this.text, voucherDescriptionInfo.text)&& + Objects.equals(this.additionalProperties, voucherDescriptionInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(text); + return Objects.hash(text, additionalProperties); } @Override @@ -103,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class VoucherDescriptionInfo {\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -131,26 +176,18 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to VoucherDescriptionInfo - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to VoucherDescriptionInfo + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!VoucherDescriptionInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in VoucherDescriptionInfo is not found in the empty JSON string", VoucherDescriptionInfo.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!VoucherDescriptionInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `VoucherDescriptionInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("text") != null && !jsonObj.get("text").isJsonNull()) && !jsonObj.get("text").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); @@ -172,6 +209,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, VoucherDescriptionInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -179,29 +238,50 @@ public void write(JsonWriter out, VoucherDescriptionInfo value) throws IOExcepti public VoucherDescriptionInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VoucherDescriptionInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of VoucherDescriptionInfo given an JSON string - * - * @param jsonString JSON string - * @return An instance of VoucherDescriptionInfo - * @throws IOException if the JSON string is invalid with respect to VoucherDescriptionInfo - */ + /** + * Create an instance of VoucherDescriptionInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of VoucherDescriptionInfo + * @throws IOException if the JSON string is invalid with respect to VoucherDescriptionInfo + */ public static VoucherDescriptionInfo fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, VoucherDescriptionInfo.class); } - /** - * Convert an instance of VoucherDescriptionInfo to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of VoucherDescriptionInfo to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/WorkingHour.java b/src/main/java/com/grabfood/client/model/WorkingHour.java index d12cbb8..264df8d 100644 --- a/src/main/java/com/grabfood/client/model/WorkingHour.java +++ b/src/main/java/com/grabfood/client/model/WorkingHour.java @@ -22,13 +22,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.WorkingHourFri; -import com.grabfood.client.model.WorkingHourMon; -import com.grabfood.client.model.WorkingHourSat; -import com.grabfood.client.model.WorkingHourSun; -import com.grabfood.client.model.WorkingHourThu; -import com.grabfood.client.model.WorkingHourTue; -import com.grabfood.client.model.WorkingHourWed; +import com.grabfood.client.model.WorkingHourDay; import java.io.IOException; import java.util.Arrays; @@ -47,7 +41,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -59,171 +52,215 @@ /** * A JSON object that describes the workingHour for each day. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") public class WorkingHour { public static final String SERIALIZED_NAME_SUN = "sun"; @SerializedName(SERIALIZED_NAME_SUN) - private WorkingHourSun sun; + private WorkingHourDay sun; public static final String SERIALIZED_NAME_MON = "mon"; @SerializedName(SERIALIZED_NAME_MON) - private WorkingHourMon mon; + private WorkingHourDay mon; public static final String SERIALIZED_NAME_TUE = "tue"; @SerializedName(SERIALIZED_NAME_TUE) - private WorkingHourTue tue; + private WorkingHourDay tue; public static final String SERIALIZED_NAME_WED = "wed"; @SerializedName(SERIALIZED_NAME_WED) - private WorkingHourWed wed; + private WorkingHourDay wed; public static final String SERIALIZED_NAME_THU = "thu"; @SerializedName(SERIALIZED_NAME_THU) - private WorkingHourThu thu; + private WorkingHourDay thu; public static final String SERIALIZED_NAME_FRI = "fri"; @SerializedName(SERIALIZED_NAME_FRI) - private WorkingHourFri fri; + private WorkingHourDay fri; public static final String SERIALIZED_NAME_SAT = "sat"; @SerializedName(SERIALIZED_NAME_SAT) - private WorkingHourSat sat; + private WorkingHourDay sat; public WorkingHour() { } - public WorkingHour sun(WorkingHourSun sun) { + public WorkingHour sun(WorkingHourDay sun) { this.sun = sun; return this; } - /** + /** * Get sun * @return sun - **/ + */ @javax.annotation.Nullable - public WorkingHourSun getSun() { + public WorkingHourDay getSun() { return sun; } - public void setSun(WorkingHourSun sun) { + public void setSun(WorkingHourDay sun) { this.sun = sun; } - public WorkingHour mon(WorkingHourMon mon) { + public WorkingHour mon(WorkingHourDay mon) { this.mon = mon; return this; } - /** + /** * Get mon * @return mon - **/ + */ @javax.annotation.Nullable - public WorkingHourMon getMon() { + public WorkingHourDay getMon() { return mon; } - public void setMon(WorkingHourMon mon) { + public void setMon(WorkingHourDay mon) { this.mon = mon; } - public WorkingHour tue(WorkingHourTue tue) { + public WorkingHour tue(WorkingHourDay tue) { this.tue = tue; return this; } - /** + /** * Get tue * @return tue - **/ + */ @javax.annotation.Nullable - public WorkingHourTue getTue() { + public WorkingHourDay getTue() { return tue; } - public void setTue(WorkingHourTue tue) { + public void setTue(WorkingHourDay tue) { this.tue = tue; } - public WorkingHour wed(WorkingHourWed wed) { + public WorkingHour wed(WorkingHourDay wed) { this.wed = wed; return this; } - /** + /** * Get wed * @return wed - **/ + */ @javax.annotation.Nullable - public WorkingHourWed getWed() { + public WorkingHourDay getWed() { return wed; } - public void setWed(WorkingHourWed wed) { + public void setWed(WorkingHourDay wed) { this.wed = wed; } - public WorkingHour thu(WorkingHourThu thu) { + public WorkingHour thu(WorkingHourDay thu) { this.thu = thu; return this; } - /** + /** * Get thu * @return thu - **/ + */ @javax.annotation.Nullable - public WorkingHourThu getThu() { + public WorkingHourDay getThu() { return thu; } - public void setThu(WorkingHourThu thu) { + public void setThu(WorkingHourDay thu) { this.thu = thu; } - public WorkingHour fri(WorkingHourFri fri) { + public WorkingHour fri(WorkingHourDay fri) { this.fri = fri; return this; } - /** + /** * Get fri * @return fri - **/ + */ @javax.annotation.Nullable - public WorkingHourFri getFri() { + public WorkingHourDay getFri() { return fri; } - public void setFri(WorkingHourFri fri) { + public void setFri(WorkingHourDay fri) { this.fri = fri; } - public WorkingHour sat(WorkingHourSat sat) { + public WorkingHour sat(WorkingHourDay sat) { this.sat = sat; return this; } - /** + /** * Get sat * @return sat - **/ + */ @javax.annotation.Nullable - public WorkingHourSat getSat() { + public WorkingHourDay getSat() { return sat; } - public void setSat(WorkingHourSat sat) { + public void setSat(WorkingHourDay sat) { this.sat = sat; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the WorkingHour instance itself + */ + public WorkingHour putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -241,12 +278,13 @@ public boolean equals(Object o) { Objects.equals(this.wed, workingHour.wed) && Objects.equals(this.thu, workingHour.thu) && Objects.equals(this.fri, workingHour.fri) && - Objects.equals(this.sat, workingHour.sat); + Objects.equals(this.sat, workingHour.sat)&& + Objects.equals(this.additionalProperties, workingHour.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sun, mon, tue, wed, thu, fri, sat); + return Objects.hash(sun, mon, tue, wed, thu, fri, sat, additionalProperties); } @Override @@ -260,6 +298,7 @@ public String toString() { sb.append(" thu: ").append(toIndentedString(thu)).append("\n"); sb.append(" fri: ").append(toIndentedString(fri)).append("\n"); sb.append(" sat: ").append(toIndentedString(sat)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,54 +333,46 @@ private String toIndentedString(Object o) { openapiRequiredFields = new HashSet(); } - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to WorkingHour - */ + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to WorkingHour + */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!WorkingHour.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHour is not found in the empty JSON string", WorkingHour.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkingHour.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WorkingHour` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `sun` if (jsonObj.get("sun") != null && !jsonObj.get("sun").isJsonNull()) { - WorkingHourSun.validateJsonElement(jsonObj.get("sun")); + WorkingHourDay.validateJsonElement(jsonObj.get("sun")); } // validate the optional field `mon` if (jsonObj.get("mon") != null && !jsonObj.get("mon").isJsonNull()) { - WorkingHourMon.validateJsonElement(jsonObj.get("mon")); + WorkingHourDay.validateJsonElement(jsonObj.get("mon")); } // validate the optional field `tue` if (jsonObj.get("tue") != null && !jsonObj.get("tue").isJsonNull()) { - WorkingHourTue.validateJsonElement(jsonObj.get("tue")); + WorkingHourDay.validateJsonElement(jsonObj.get("tue")); } // validate the optional field `wed` if (jsonObj.get("wed") != null && !jsonObj.get("wed").isJsonNull()) { - WorkingHourWed.validateJsonElement(jsonObj.get("wed")); + WorkingHourDay.validateJsonElement(jsonObj.get("wed")); } // validate the optional field `thu` if (jsonObj.get("thu") != null && !jsonObj.get("thu").isJsonNull()) { - WorkingHourThu.validateJsonElement(jsonObj.get("thu")); + WorkingHourDay.validateJsonElement(jsonObj.get("thu")); } // validate the optional field `fri` if (jsonObj.get("fri") != null && !jsonObj.get("fri").isJsonNull()) { - WorkingHourFri.validateJsonElement(jsonObj.get("fri")); + WorkingHourDay.validateJsonElement(jsonObj.get("fri")); } // validate the optional field `sat` if (jsonObj.get("sat") != null && !jsonObj.get("sat").isJsonNull()) { - WorkingHourSat.validateJsonElement(jsonObj.get("sat")); + WorkingHourDay.validateJsonElement(jsonObj.get("sat")); } } @@ -360,6 +391,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, WorkingHour value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -367,29 +420,50 @@ public void write(JsonWriter out, WorkingHour value) throws IOException { public WorkingHour read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WorkingHour instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); } } - /** - * Create an instance of WorkingHour given an JSON string - * - * @param jsonString JSON string - * @return An instance of WorkingHour - * @throws IOException if the JSON string is invalid with respect to WorkingHour - */ + /** + * Create an instance of WorkingHour given an JSON string + * + * @param jsonString JSON string + * @return An instance of WorkingHour + * @throws IOException if the JSON string is invalid with respect to WorkingHour + */ public static WorkingHour fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, WorkingHour.class); } - /** - * Convert an instance of WorkingHour to an JSON string - * - * @return JSON string - */ + /** + * Convert an instance of WorkingHour to an JSON string + * + * @return JSON string + */ public String toJson() { return JSON.getGson().toJson(this); } diff --git a/src/main/java/com/grabfood/client/model/WorkingHourDay.java b/src/main/java/com/grabfood/client/model/WorkingHourDay.java new file mode 100644 index 0000000..e9f40b2 --- /dev/null +++ b/src/main/java/com/grabfood/client/model/WorkingHourDay.java @@ -0,0 +1,323 @@ +// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. +// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file + +/* + * GrabFood + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.1.3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.grabfood.client.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.grabfood.client.model.OpenPeriod; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.grabfood.client.JSON; + +/** + * A JSON object for workingHour for a day. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0") +public class WorkingHourDay { + public static final String SERIALIZED_NAME_PERIODS = "periods"; + @SerializedName(SERIALIZED_NAME_PERIODS) + private List periods; + + public WorkingHourDay() { + } + + public WorkingHourDay periods(List periods) { + this.periods = periods; + return this; + } + + public WorkingHourDay addPeriodsItem(OpenPeriod periodsItem) { + if (this.periods == null) { + this.periods = new ArrayList<>(); + } + this.periods.add(periodsItem); + return this; + } + + /** + * An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. + * @return periods + */ + @javax.annotation.Nullable + public List getPeriods() { + return periods; + } + + public void setPeriods(List periods) { + this.periods = periods; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the WorkingHourDay instance itself + */ + public WorkingHourDay putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WorkingHourDay workingHourDay = (WorkingHourDay) o; + return Objects.equals(this.periods, workingHourDay.periods)&& + Objects.equals(this.additionalProperties, workingHourDay.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(periods, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WorkingHourDay {\n"); + sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("periods"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to WorkingHourDay + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WorkingHourDay.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHourDay is not found in the empty JSON string", WorkingHourDay.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { + JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); + if (jsonArrayperiods != null) { + // ensure the json data is an array + if (!jsonObj.get("periods").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); + } + + // validate the optional field `periods` (array) + for (int i = 0; i < jsonArrayperiods.size(); i++) { + OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WorkingHourDay.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WorkingHourDay' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WorkingHourDay.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WorkingHourDay value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WorkingHourDay read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WorkingHourDay instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of WorkingHourDay given an JSON string + * + * @param jsonString JSON string + * @return An instance of WorkingHourDay + * @throws IOException if the JSON string is invalid with respect to WorkingHourDay + */ + public static WorkingHourDay fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WorkingHourDay.class); + } + + /** + * Convert an instance of WorkingHourDay to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/grabfood/client/model/WorkingHourFri.java b/src/main/java/com/grabfood/client/model/WorkingHourFri.java deleted file mode 100644 index 14763f4..0000000 --- a/src/main/java/com/grabfood/client/model/WorkingHourFri.java +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.OpenPeriod; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * A JSON object for workingHour for Friday. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class WorkingHourFri { - public static final String SERIALIZED_NAME_PERIODS = "periods"; - @SerializedName(SERIALIZED_NAME_PERIODS) - private List periods; - - public WorkingHourFri() { - } - - public WorkingHourFri periods(List periods) { - this.periods = periods; - return this; - } - - public WorkingHourFri addPeriodsItem(OpenPeriod periodsItem) { - if (this.periods == null) { - this.periods = new ArrayList<>(); - } - this.periods.add(periodsItem); - return this; - } - - /** - * An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. - * @return periods - **/ - @javax.annotation.Nullable - public List getPeriods() { - return periods; - } - - public void setPeriods(List periods) { - this.periods = periods; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkingHourFri workingHourFri = (WorkingHourFri) o; - return Objects.equals(this.periods, workingHourFri.periods); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(periods); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkingHourFri {\n"); - sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("periods"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to WorkingHourFri - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!WorkingHourFri.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHourFri is not found in the empty JSON string", WorkingHourFri.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkingHourFri.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WorkingHourFri` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { - JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); - if (jsonArrayperiods != null) { - // ensure the json data is an array - if (!jsonObj.get("periods").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); - } - - // validate the optional field `periods` (array) - for (int i = 0; i < jsonArrayperiods.size(); i++) { - OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!WorkingHourFri.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'WorkingHourFri' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(WorkingHourFri.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, WorkingHourFri value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public WorkingHourFri read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of WorkingHourFri given an JSON string - * - * @param jsonString JSON string - * @return An instance of WorkingHourFri - * @throws IOException if the JSON string is invalid with respect to WorkingHourFri - */ - public static WorkingHourFri fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, WorkingHourFri.class); - } - - /** - * Convert an instance of WorkingHourFri to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/WorkingHourMon.java b/src/main/java/com/grabfood/client/model/WorkingHourMon.java deleted file mode 100644 index 20654da..0000000 --- a/src/main/java/com/grabfood/client/model/WorkingHourMon.java +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.OpenPeriod; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * A JSON object for workingHour for Monday. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class WorkingHourMon { - public static final String SERIALIZED_NAME_PERIODS = "periods"; - @SerializedName(SERIALIZED_NAME_PERIODS) - private List periods; - - public WorkingHourMon() { - } - - public WorkingHourMon periods(List periods) { - this.periods = periods; - return this; - } - - public WorkingHourMon addPeriodsItem(OpenPeriod periodsItem) { - if (this.periods == null) { - this.periods = new ArrayList<>(); - } - this.periods.add(periodsItem); - return this; - } - - /** - * An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. - * @return periods - **/ - @javax.annotation.Nullable - public List getPeriods() { - return periods; - } - - public void setPeriods(List periods) { - this.periods = periods; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkingHourMon workingHourMon = (WorkingHourMon) o; - return Objects.equals(this.periods, workingHourMon.periods); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(periods); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkingHourMon {\n"); - sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("periods"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to WorkingHourMon - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!WorkingHourMon.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHourMon is not found in the empty JSON string", WorkingHourMon.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkingHourMon.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WorkingHourMon` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { - JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); - if (jsonArrayperiods != null) { - // ensure the json data is an array - if (!jsonObj.get("periods").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); - } - - // validate the optional field `periods` (array) - for (int i = 0; i < jsonArrayperiods.size(); i++) { - OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!WorkingHourMon.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'WorkingHourMon' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(WorkingHourMon.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, WorkingHourMon value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public WorkingHourMon read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of WorkingHourMon given an JSON string - * - * @param jsonString JSON string - * @return An instance of WorkingHourMon - * @throws IOException if the JSON string is invalid with respect to WorkingHourMon - */ - public static WorkingHourMon fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, WorkingHourMon.class); - } - - /** - * Convert an instance of WorkingHourMon to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/WorkingHourSat.java b/src/main/java/com/grabfood/client/model/WorkingHourSat.java deleted file mode 100644 index dc2767b..0000000 --- a/src/main/java/com/grabfood/client/model/WorkingHourSat.java +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.OpenPeriod; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * A JSON object for workingHour for Saturday. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class WorkingHourSat { - public static final String SERIALIZED_NAME_PERIODS = "periods"; - @SerializedName(SERIALIZED_NAME_PERIODS) - private List periods; - - public WorkingHourSat() { - } - - public WorkingHourSat periods(List periods) { - this.periods = periods; - return this; - } - - public WorkingHourSat addPeriodsItem(OpenPeriod periodsItem) { - if (this.periods == null) { - this.periods = new ArrayList<>(); - } - this.periods.add(periodsItem); - return this; - } - - /** - * An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. - * @return periods - **/ - @javax.annotation.Nullable - public List getPeriods() { - return periods; - } - - public void setPeriods(List periods) { - this.periods = periods; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkingHourSat workingHourSat = (WorkingHourSat) o; - return Objects.equals(this.periods, workingHourSat.periods); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(periods); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkingHourSat {\n"); - sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("periods"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to WorkingHourSat - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!WorkingHourSat.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHourSat is not found in the empty JSON string", WorkingHourSat.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkingHourSat.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WorkingHourSat` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { - JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); - if (jsonArrayperiods != null) { - // ensure the json data is an array - if (!jsonObj.get("periods").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); - } - - // validate the optional field `periods` (array) - for (int i = 0; i < jsonArrayperiods.size(); i++) { - OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!WorkingHourSat.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'WorkingHourSat' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(WorkingHourSat.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, WorkingHourSat value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public WorkingHourSat read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of WorkingHourSat given an JSON string - * - * @param jsonString JSON string - * @return An instance of WorkingHourSat - * @throws IOException if the JSON string is invalid with respect to WorkingHourSat - */ - public static WorkingHourSat fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, WorkingHourSat.class); - } - - /** - * Convert an instance of WorkingHourSat to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/WorkingHourSun.java b/src/main/java/com/grabfood/client/model/WorkingHourSun.java deleted file mode 100644 index a187f55..0000000 --- a/src/main/java/com/grabfood/client/model/WorkingHourSun.java +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.OpenPeriod; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * A JSON object for workingHour for Sunday. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class WorkingHourSun { - public static final String SERIALIZED_NAME_PERIODS = "periods"; - @SerializedName(SERIALIZED_NAME_PERIODS) - private List periods; - - public WorkingHourSun() { - } - - public WorkingHourSun periods(List periods) { - this.periods = periods; - return this; - } - - public WorkingHourSun addPeriodsItem(OpenPeriod periodsItem) { - if (this.periods == null) { - this.periods = new ArrayList<>(); - } - this.periods.add(periodsItem); - return this; - } - - /** - * An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. - * @return periods - **/ - @javax.annotation.Nullable - public List getPeriods() { - return periods; - } - - public void setPeriods(List periods) { - this.periods = periods; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkingHourSun workingHourSun = (WorkingHourSun) o; - return Objects.equals(this.periods, workingHourSun.periods); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(periods); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkingHourSun {\n"); - sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("periods"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to WorkingHourSun - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!WorkingHourSun.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHourSun is not found in the empty JSON string", WorkingHourSun.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkingHourSun.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WorkingHourSun` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { - JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); - if (jsonArrayperiods != null) { - // ensure the json data is an array - if (!jsonObj.get("periods").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); - } - - // validate the optional field `periods` (array) - for (int i = 0; i < jsonArrayperiods.size(); i++) { - OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!WorkingHourSun.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'WorkingHourSun' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(WorkingHourSun.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, WorkingHourSun value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public WorkingHourSun read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of WorkingHourSun given an JSON string - * - * @param jsonString JSON string - * @return An instance of WorkingHourSun - * @throws IOException if the JSON string is invalid with respect to WorkingHourSun - */ - public static WorkingHourSun fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, WorkingHourSun.class); - } - - /** - * Convert an instance of WorkingHourSun to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/WorkingHourThu.java b/src/main/java/com/grabfood/client/model/WorkingHourThu.java deleted file mode 100644 index a8f52d4..0000000 --- a/src/main/java/com/grabfood/client/model/WorkingHourThu.java +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.OpenPeriod; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * A JSON object for workingHour for Thursday. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class WorkingHourThu { - public static final String SERIALIZED_NAME_PERIODS = "periods"; - @SerializedName(SERIALIZED_NAME_PERIODS) - private List periods; - - public WorkingHourThu() { - } - - public WorkingHourThu periods(List periods) { - this.periods = periods; - return this; - } - - public WorkingHourThu addPeriodsItem(OpenPeriod periodsItem) { - if (this.periods == null) { - this.periods = new ArrayList<>(); - } - this.periods.add(periodsItem); - return this; - } - - /** - * An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. - * @return periods - **/ - @javax.annotation.Nullable - public List getPeriods() { - return periods; - } - - public void setPeriods(List periods) { - this.periods = periods; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkingHourThu workingHourThu = (WorkingHourThu) o; - return Objects.equals(this.periods, workingHourThu.periods); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(periods); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkingHourThu {\n"); - sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("periods"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to WorkingHourThu - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!WorkingHourThu.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHourThu is not found in the empty JSON string", WorkingHourThu.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkingHourThu.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WorkingHourThu` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { - JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); - if (jsonArrayperiods != null) { - // ensure the json data is an array - if (!jsonObj.get("periods").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); - } - - // validate the optional field `periods` (array) - for (int i = 0; i < jsonArrayperiods.size(); i++) { - OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!WorkingHourThu.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'WorkingHourThu' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(WorkingHourThu.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, WorkingHourThu value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public WorkingHourThu read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of WorkingHourThu given an JSON string - * - * @param jsonString JSON string - * @return An instance of WorkingHourThu - * @throws IOException if the JSON string is invalid with respect to WorkingHourThu - */ - public static WorkingHourThu fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, WorkingHourThu.class); - } - - /** - * Convert an instance of WorkingHourThu to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/WorkingHourTue.java b/src/main/java/com/grabfood/client/model/WorkingHourTue.java deleted file mode 100644 index 55f279a..0000000 --- a/src/main/java/com/grabfood/client/model/WorkingHourTue.java +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.OpenPeriod; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * A JSON object for workingHour for Tuesday. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class WorkingHourTue { - public static final String SERIALIZED_NAME_PERIODS = "periods"; - @SerializedName(SERIALIZED_NAME_PERIODS) - private List periods; - - public WorkingHourTue() { - } - - public WorkingHourTue periods(List periods) { - this.periods = periods; - return this; - } - - public WorkingHourTue addPeriodsItem(OpenPeriod periodsItem) { - if (this.periods == null) { - this.periods = new ArrayList<>(); - } - this.periods.add(periodsItem); - return this; - } - - /** - * An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. - * @return periods - **/ - @javax.annotation.Nullable - public List getPeriods() { - return periods; - } - - public void setPeriods(List periods) { - this.periods = periods; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkingHourTue workingHourTue = (WorkingHourTue) o; - return Objects.equals(this.periods, workingHourTue.periods); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(periods); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkingHourTue {\n"); - sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("periods"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to WorkingHourTue - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!WorkingHourTue.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHourTue is not found in the empty JSON string", WorkingHourTue.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkingHourTue.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WorkingHourTue` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { - JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); - if (jsonArrayperiods != null) { - // ensure the json data is an array - if (!jsonObj.get("periods").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); - } - - // validate the optional field `periods` (array) - for (int i = 0; i < jsonArrayperiods.size(); i++) { - OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!WorkingHourTue.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'WorkingHourTue' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(WorkingHourTue.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, WorkingHourTue value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public WorkingHourTue read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of WorkingHourTue given an JSON string - * - * @param jsonString JSON string - * @return An instance of WorkingHourTue - * @throws IOException if the JSON string is invalid with respect to WorkingHourTue - */ - public static WorkingHourTue fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, WorkingHourTue.class); - } - - /** - * Convert an instance of WorkingHourTue to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/com/grabfood/client/model/WorkingHourWed.java b/src/main/java/com/grabfood/client/model/WorkingHourWed.java deleted file mode 100644 index d18b6a5..0000000 --- a/src/main/java/com/grabfood/client/model/WorkingHourWed.java +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2024 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved. -// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file - -/* - * GrabFood - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1.1.3 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package com.grabfood.client.model; - -import java.util.Objects; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.grabfood.client.model.OpenPeriod; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.openapitools.jackson.nullable.JsonNullable; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.grabfood.client.JSON; - -/** - * A JSON object for workingHour for Wednesday. - */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-09-10T06:13:57.715918Z[Etc/UTC]", comments = "Generator version: 7.6.0") -public class WorkingHourWed { - public static final String SERIALIZED_NAME_PERIODS = "periods"; - @SerializedName(SERIALIZED_NAME_PERIODS) - private List periods; - - public WorkingHourWed() { - } - - public WorkingHourWed periods(List periods) { - this.periods = periods; - return this; - } - - public WorkingHourWed addPeriodsItem(OpenPeriod periodsItem) { - if (this.periods == null) { - this.periods = new ArrayList<>(); - } - this.periods.add(periodsItem); - return this; - } - - /** - * An array of open periods. `null` in [ListCampaign](#tag/list-campaign) response if the campaign is available all day. - * @return periods - **/ - @javax.annotation.Nullable - public List getPeriods() { - return periods; - } - - public void setPeriods(List periods) { - this.periods = periods; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - WorkingHourWed workingHourWed = (WorkingHourWed) o; - return Objects.equals(this.periods, workingHourWed.periods); - } - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - } - - @Override - public int hashCode() { - return Objects.hash(periods); - } - - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class WorkingHourWed {\n"); - sb.append(" periods: ").append(toIndentedString(periods)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(); - openapiFields.add("periods"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to WorkingHourWed - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!WorkingHourWed.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException(String.format("The required field(s) %s in WorkingHourWed is not found in the empty JSON string", WorkingHourWed.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WorkingHourWed.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `WorkingHourWed` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - if (jsonObj.get("periods") != null && !jsonObj.get("periods").isJsonNull()) { - JsonArray jsonArrayperiods = jsonObj.getAsJsonArray("periods"); - if (jsonArrayperiods != null) { - // ensure the json data is an array - if (!jsonObj.get("periods").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `periods` to be an array in the JSON string but got `%s`", jsonObj.get("periods").toString())); - } - - // validate the optional field `periods` (array) - for (int i = 0; i < jsonArrayperiods.size(); i++) { - OpenPeriod.validateJsonElement(jsonArrayperiods.get(i)); - }; - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!WorkingHourWed.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'WorkingHourWed' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(WorkingHourWed.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, WorkingHourWed value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public WorkingHourWed read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); - } - - }.nullSafe(); - } - } - - /** - * Create an instance of WorkingHourWed given an JSON string - * - * @param jsonString JSON string - * @return An instance of WorkingHourWed - * @throws IOException if the JSON string is invalid with respect to WorkingHourWed - */ - public static WorkingHourWed fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, WorkingHourWed.class); - } - - /** - * Convert an instance of WorkingHourWed to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} -